@@ -3,6 +3,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\ScanDocumentForMalware;
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@@ -56,11 +57,26 @@ class ImportDocumentBatch extends Command
|
||||
|
||||
$apply = (bool) $this->option('apply');
|
||||
$actorId = $this->option('actor');
|
||||
if ($apply) {
|
||||
// CLI attribution is not an authenticated active installation. Rehearsals stay isolated.
|
||||
$target = DB::selectOne('SELECT current_database() AS database,inet_server_port() AS port');
|
||||
if (! app()->environment('testing') || ! str_ends_with($target->database, '_test') || (int) $target->port !== 55441
|
||||
|| config('database.connections.pgsql.host') !== '127.0.0.1' || config('database.connections.pgsql.url')) {
|
||||
$this->error('CLI apply is restricted to isolated QA. Active imports require the authenticated activation mechanism; --actor is attribution only.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
}
|
||||
if ($apply && (! is_numeric($actorId) || ! DB::table('users')->where('id', (int) $actorId)->exists())) {
|
||||
$this->error('Apply requires --actor=<existing-user-id>; no author identity will be fabricated.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
if ($apply && ! User::findOrFail((int) $actorId)->can('manage-portal')) {
|
||||
$this->error('QA import requires an authorized library manager; no permission is granted by naming an account.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
$disk = Storage::disk('local');
|
||||
$seenHashes = [];
|
||||
$seenExternalIds = [];
|
||||
|
||||
Reference in New Issue
Block a user