## Summary - move the Laravel application into `apps/platform` and keep the repository root for orchestration, docs, and tooling - update the local command model, Sail/Docker wiring, runtime paths, and ignore rules around the new platform location - add relocation quickstart/contracts plus focused smoke coverage for bootstrap, command model, routes, and runtime behavior ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/PlatformRelocation` - integrated browser smoke validated `/up`, `/`, `/admin`, `/admin/choose-workspace`, and tenant route semantics for `200`, `403`, and `404` ## Remaining Rollout Checks - validate Dokploy build context and working-directory assumptions against the new `apps/platform` layout - confirm web, queue, and scheduler processes all start from the expected working directory in staging/production - verify no legacy volume mounts or asset-publish paths still point at the old root-level `public/` or `storage/` locations Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #213
86 lines
1.9 KiB
PHP
86 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Audit;
|
|
|
|
use App\Services\Intune\SecretClassificationService;
|
|
|
|
final class AuditContextSanitizer
|
|
{
|
|
private const REDACTED = '[REDACTED]';
|
|
|
|
/**
|
|
* @var array<int, string>
|
|
*/
|
|
private const DROPPED_FIELDS = [
|
|
'evidence_jsonb',
|
|
'raw_evidence',
|
|
'snapshot_payload',
|
|
];
|
|
|
|
private const MAX_ITEMS = 50;
|
|
|
|
private const MAX_STRING_LENGTH = 500;
|
|
|
|
public static function sanitize(mixed $value): mixed
|
|
{
|
|
if (is_array($value)) {
|
|
$sanitized = [];
|
|
$count = 0;
|
|
|
|
foreach ($value as $key => $item) {
|
|
$count++;
|
|
|
|
if ($count > self::MAX_ITEMS) {
|
|
$sanitized['truncated'] = true;
|
|
|
|
break;
|
|
}
|
|
|
|
if (is_string($key) && in_array($key, self::DROPPED_FIELDS, true)) {
|
|
continue;
|
|
}
|
|
|
|
if (is_string($key) && self::classifier()->protectsField('audit', $key)) {
|
|
$sanitized[$key] = self::REDACTED;
|
|
|
|
continue;
|
|
}
|
|
|
|
$sanitized[$key] = self::sanitize($item);
|
|
}
|
|
|
|
return $sanitized;
|
|
}
|
|
|
|
if (is_string($value)) {
|
|
return self::sanitizeString($value);
|
|
}
|
|
|
|
return $value;
|
|
}
|
|
|
|
private static function sanitizeString(string $value): string
|
|
{
|
|
$candidate = trim($value);
|
|
|
|
if ($candidate === '') {
|
|
return $value;
|
|
}
|
|
|
|
$sanitized = self::classifier()->sanitizeAuditString($value);
|
|
|
|
if (mb_strlen($sanitized) <= self::MAX_STRING_LENGTH) {
|
|
return $sanitized;
|
|
}
|
|
|
|
return mb_substr($sanitized, 0, self::MAX_STRING_LENGTH).' [truncated]';
|
|
}
|
|
|
|
private static function classifier(): SecretClassificationService
|
|
{
|
|
return app(SecretClassificationService::class);
|
|
}
|
|
}
|