Files
Investidor-V2/outputs/investmoz-legado-setores-ativacao-20261015/check-private-scan.php
T
nala 6a76aac80f
tests / ci (push) Canceled after 0s
versao compilada 1
2026-10-16 09:17:28 +02:00

3 lines
2.1 KiB
PHP

<?php
ini_set('zend.exception_ignore_args','1');$root=dirname(__DIR__,2);require $root.'/vendor/autoload.php';$app=require $root.'/bootstrap/app.php';$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();$c=config('database.connections.'.config('database.default'));if($c['database']!=='investemoz'||(int)$c['port']!==5432)throw new RuntimeException('Destination guard');use Illuminate\Support\Facades\DB;use Illuminate\Support\Facades\Storage;DB::beginTransaction();DB::statement('SET TRANSACTION READ ONLY');try{$rows=DB::table('documents as d')->join('portal_resources as r','r.document_id','=','d.id')->whereIn('d.external_id',array_column(json_decode(file_get_contents($root.'/outputs/investmoz-legado-setores-lote20-QA-20261015/MANIFESTO-POR-RECURSO.json'),true)['resources'],'external_id'))->get(['r.title','r.source_url','r.version_label','r.source_reference','d.id','d.external_id','d.sha256','d.status','d.storage_key','d.data_classification','d.rights_status','d.malware_scan_status','d.malware_scanned_sha256','r.id as resource_id','r.published','r.metadata_version']);if($rows->count()!==20)throw new RuntimeException('Need exactly 20 originals');foreach($rows as$x){if($x->malware_scan_status!=='clean'||trim($x->sha256)!==$x->malware_scanned_sha256||$x->published||$x->data_classification!=='internal')throw new RuntimeException('Scan/private state mismatch');}$expected=array_column(json_decode(file_get_contents($root.'/outputs/investmoz-legado-setores-lote20-QA-20261015/MANIFESTO-POR-RECURSO.json'),true)['resources'],'sha256','external_id');foreach($rows as$x){if(trim($x->sha256)!==$expected[$x->external_id]||hash_file('sha256',Storage::disk('local')->path($x->storage_key))!==$expected[$x->external_id])throw new RuntimeException('Actual bytes mismatch');}$v=['at'=>gmdate('c'),'target'=>'investemoz:5432','SQL_read_only'=>true,'result'=>'20 exact clean originals, still private and unpublished','resources'=>$rows];file_put_contents(__DIR__.'/SCAN-PRIVATE-VERIFIED.json',json_encode($v,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo json_encode($v);}finally{DB::rollBack();}