Files
Investidor-V2/outputs/investmoz-audit-current-20261012/line02-access-readonly-20261015.php
T
nala c13f250b87
tests / ci (push) Canceled after 0s
versao compilada
2026-10-15 17:37:00 +02:00

18 lines
1.8 KiB
PHP

<?php
ini_set('zend.exception_ignore_args','1');putenv('STABILITY_QA_MODE=consumers');
$app=require dirname(__DIR__,2).'/storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742/tools/portal-stability-runtime.php';
$db=Illuminate\Support\Facades\DB::connection();
$target=(array)$db->selectOne('SELECT current_database() AS database,inet_server_port() AS port');
if($target!==['database'=>'stability_consumers_20261011_084534_test','port'=>55441])throw new RuntimeException('QA isolation required');
$stage=$argv[1]??'';if(!in_array($stage,['before','after'],true))throw new RuntimeException('stage required');
$db->beginTransaction();$db->statement('SET TRANSACTION READ ONLY');
try {
$a=app(App\Services\PortalProfileAccess::class);$u=App\Models\User::findOrFail(22);
$grants=$db->table('portal_role_assignments')->orderBy('id')->get();
$hashes=[];foreach($grants as $g)$hashes[$g->id]=hash('sha256',json_encode($g,JSON_THROW_ON_ERROR));
$roles=$db->table('portal_role_assignments')->where('user_id',22)->get(['id','role','organization_id','opportunity_types','revoked_at']);
$p=['at'=>gmdate('c'),'target'=>$target,'SQL_read_only'=>true,'QA22_grants'=>$roles,'all_grant_hashes'=>$hashes,'QA22_session_count'=>$db->table('sessions')->where('user_id',22)->count(),'QA22_can_edit15'=>$a->canEdit($u,App\Models\Opportunity::findOrFail(15)),'QA22_can_view30'=>$a->canView($u,App\Models\Opportunity::findOrFail(30)),'active_changes'=>0];
$path=__DIR__.'/line02-'.$stage.'-readonly-20261015.json';if(is_file($path))throw new RuntimeException('Preserve proof');
file_put_contents($path,json_encode($p,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR).PHP_EOL);echo json_encode($p,JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR).PHP_EOL;
}finally{$db->rollBack();}