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

44 lines
2.6 KiB
PHP

<?php
ini_set('zend.exception_ignore_args', '1');
putenv('STABILITY_QA_MODE=consumers');
$diagnosticRoot = dirname(__DIR__, 2);
$app = require $diagnosticRoot.'/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.');
}
$db->beginTransaction();
$db->statement('SET TRANSACTION READ ONLY');
try {
$access = app(App\Services\PortalProfileAccess::class);
$record = App\Models\Opportunity::withTrashed()->findOrFail(33);
$actors = [];
foreach ([21,22,24,25] as $id) {
$actor = App\Models\User::findOrFail($id);
$actors[] = ['QA_account'=>$id, 'can_view'=>$access->canView($actor, $record),
'can_edit'=>$access->canEdit($actor, $record),
'promoter_record_scope'=>$access->promoterRecordScope($actor, $record),
'promoter_type_scope'=>$access->scoped($actor, 'promoter', $record->organization_id, $record->opportunity_category),
'represents'=>$access->represents($actor, $record->organization_id)];
}
$audits = $db->select("SELECT created_at,action,actor_user_id,
after_data->>'method' AS method,after_data->>'path' AS path,
after_data->>'status' AS http_status,after_data->>'action' AS attempted_action
FROM audit_events WHERE source_system='portal-profiles-v1'
AND ((action='request_denied' AND after_data->>'path'='minhas-oportunidades/33/edit')
OR (action='access_denied' AND after_data->>'record_id'='33'))
ORDER BY created_at DESC LIMIT 16");
$receipt = ['at'=>gmdate('c'), 'target'=>$target, 'SQL_read_only'=>true,
'reported_account_not_assumed'=>true, 'case'=>33, 'state'=>$access->state($record),
'version'=>$record->management_version, 'owner_QA_account'=>$record->owner_user_id,
'category'=>$record->opportunity_category, 'actors'=>$actors, 'recent_denials'=>$audits,
'QA_database_changes'=>0,'active_changes'=>0,'credentials_or_sessions_read'=>false];
$proof = __DIR__.'/case33-access-readonly-20261015.json';
if (is_file($proof)) { throw new RuntimeException('Preserve existing evidence.'); }
file_put_contents($proof, json_encode($receipt, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR).PHP_EOL);
echo json_encode($receipt, JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR).PHP_EOL;
} finally {
$db->rollBack();
}