Files
Investidor-V2/tools/portal-stability-services-qa.php
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

25 lines
2.2 KiB
PHP

<?php
// Prepare retained official exemplars and measure the real scanner; isolated files only.
use Illuminate\Support\Facades\DB;
use App\Services\Malware\MalwareScanner;
$root=dirname(__DIR__);$private=$root.'/storage/app/private/investmoz-v2/portal-audit';
$p=json_decode(file_get_contents($private.'/portal-stability-latest.json'),true,512,JSON_THROW_ON_ERROR);
putenv('STABILITY_QA_MODE=consumers');$app=require $p['source'].'/tools/portal-stability-runtime.php';
$directory=storage_path('app/private/investmoz-v2/portal-audit');$files=[];
foreach([1,2,3] as $level){foreach(['moz-adm'.$level.'-ine-20190607.geojson','moz-adm'.$level.'-ine-metadata.html'] as $name){
$from=$private.'/'.$name;$to=$directory.'/'.$name;copy($from,$to);
throw_unless(hash_file('sha256',$from)===hash_file('sha256',$to),RuntimeException::class,'Retained original differs.');
$files[$name]=['bytes'=>filesize($to),'sha256'=>hash_file('sha256',$to)];}}
$scanner=app(MalwareScanner::class);$health=$scanner->health();
if($health['signatures_at']!==null)$health['signatures_at']=$health['signatures_at']->format(DATE_ATOM);
$scans=[];
foreach([1,2,3] as $level){$name='moz-adm'.$level.'-ine-20190607.geojson';$f=$directory.'/'.$name;
$scan=$scanner->scan($f,filesize($f),storage_path('app/private'));
if($scan['signatures_at']!==null)$scan['signatures_at']=$scan['signatures_at']->format(DATE_ATOM);
$scans[]=['file'=>$name,'sha256'=>$files[$name]['sha256'],'scan'=>$scan];}
file_put_contents($directory.'/geometry-source-scans.json',json_encode(['captured_at'=>gmdate('c'),'files'=>$scans],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));
$proof=['at'=>gmdate('c'),'target'=>$p['consumer_environment']['target'],'retained_exemplars'=>$files,'ClamD_real'=>$health,
'scan_results'=>$scans,'active_writes'=>0,'official_acceptance_preserved'=>true,'main_QA_files_modified'=>false];
file_put_contents($private.'/portal-stability-services-qa.json',json_encode($proof,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));
echo json_encode(['target'=>$proof['target'],'ClamD_real'=>$health,'scan_results'=>array_map(fn($s)=>['file'=>$s['file'],'result'=>$s['scan']['result'],'reason'=>$s['scan']['reason_code']],$scans),'active_writes'=>0]).PHP_EOL;