@@ -8,7 +8,7 @@ use Illuminate\Support\Str;
|
||||
use LogicException;
|
||||
use RuntimeException;
|
||||
|
||||
/** Only new, individually tracked files in an owned QA workspace; never recursive deletion. */
|
||||
/** Only new, individually tracked files in private application storage. */
|
||||
final class PrivateAuditFiles
|
||||
{
|
||||
public readonly string $relative;
|
||||
@@ -24,12 +24,15 @@ final class PrivateAuditFiles
|
||||
public function __construct(User $actor)
|
||||
{
|
||||
$disk = Storage::disk('local');
|
||||
$boundary = realpath(base_path('storage/framework/testing'));
|
||||
$operational = app(StandaloneRuntime::class)->enabled();
|
||||
abort_if($operational && ! app(PrivateAuditAccess::class)->ready(), 503);
|
||||
$boundary = realpath($operational ? storage_path() : base_path('storage/framework/testing'));
|
||||
$storageRoot = realpath($disk->path(''));
|
||||
abort_unless($actor->id === auth()->id() && $actor->tenant_id !== null && $boundary !== false && $storageRoot !== false
|
||||
&& $this->within($storageRoot, $boundary), 503, 'A exportação requer armazenamento QA isolado.');
|
||||
$public = realpath(public_path());
|
||||
abort_if($public !== false && $this->within($storageRoot, $public), 503, 'O pacote de auditoria não pode usar armazenamento público.');
|
||||
&& $this->within($storageRoot, $boundary), 503, 'A exportação requer armazenamento privado da aplicação.');
|
||||
foreach ([realpath(public_path()), realpath(storage_path('app/public'))] as $public) {
|
||||
abort_if($public !== false && ($storageRoot === $public || $this->within($storageRoot, $public)), 503, 'O pacote de auditoria não pode usar armazenamento público.');
|
||||
}
|
||||
$this->relative = 'audit-exports/'.$actor->tenant_id.'/'.$actor->id.'/'.Str::uuid();
|
||||
$this->root = $disk->path($this->relative);
|
||||
$parent = $storageRoot;
|
||||
|
||||
Reference in New Issue
Block a user