14 lines
3.0 KiB
PHP
14 lines
3.0 KiB
PHP
<?php
|
|
ini_set('zend.exception_ignore_args','1');set_exception_handler(function(Throwable $e){fwrite(STDERR,$e::class.' '.basename($e->getFile()).':'.$e->getLine());exit(1);});
|
|
$root=dirname(__DIR__,2);require $root.'/vendor/autoload.php';$app=require $root.'/bootstrap/app.php';(new Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables)->bootstrap($app);(new Illuminate\Foundation\Bootstrap\LoadConfiguration)->bootstrap($app);
|
|
$c=config('database.connections.'.config('database.default'));if($c['driver']!=='pgsql'||!empty($c['url'])||(int)$c['port']!==5432||$c['database']!=='investemoz')throw new RuntimeException('Target differs');
|
|
$db=new PDO('pgsql:host='.$c['host'].';port=5432;dbname=investemoz',$c['username'],$c['password'],[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);$identity=$db->query('SELECT current_database() AS database,inet_server_port() AS port')->fetch(PDO::FETCH_ASSOC);if($identity['database']!=='investemoz'||(int)$identity['port']!==5432)throw new RuntimeException('Wrong identity');
|
|
$action='C132_anonymous_diagnostics_contained';$correlation='ead504de-19c1-4d84-9eca-d5649b8a456a';
|
|
$before=json_decode(file_get_contents(__DIR__.'/C132-preflight.json'),true,512,JSON_THROW_ON_ERROR);$after=json_decode(file_get_contents(__DIR__.'/C132-runtime-after.json'),true,512,JSON_THROW_ON_ERROR);
|
|
foreach(['key_fingerprint','flags','build_hash','C131_active_hash','session_cookie']as$k)if($before[$k]!==$after[$k])throw new RuntimeException('Out-of-scope change');
|
|
if($after['active_inertia_hash']!=='80c68e12bf6cb64e39931e2467b43909893cea3eb6d04c3c1e68bdcb1236dfb7')throw new RuntimeException('Not contained');
|
|
$existing=$db->prepare('SELECT id FROM audit_events WHERE source_system=? AND action=? AND correlation_id=?');$existing->execute(['C132-incident-response',$action,$correlation]);$id=$existing->fetchColumn();
|
|
if(!$id){$q=$db->prepare("INSERT INTO audit_events(source_system,entity_type,action,data_classification,actor_user_id,correlation_id,after_data) VALUES ('C132-incident-response','security_incident',?,'restricted',NULL,?,?::jsonb) RETURNING id");
|
|
$q->execute([$action,$correlation,json_encode(['case'=>'C132','authorization'=>'Explicit owner incident-response instruction in conversation','changed_file'=>'config/inertia.php','before_sha256'=>$before['active_inertia_hash'],'after_sha256'=>$after['active_inertia_hash'],'anonymous_index_and_real_detail_HTTP'=>404,'login_MFA_dashboard_manual_confirmed'=>true,'MFA_seed_rotation_user_ids'=>[14,15,16,17],'C131_included'=>false,'app_key_and_flags_unchanged'=>true,'incident_closed'=>false,'raw_sensitive_values_recorded'=>false],JSON_THROW_ON_ERROR)]);$id=$q->fetchColumn();}
|
|
$proof=['at'=>gmdate('c'),'target'=>$identity,'containment_audit_event_id'=>$id,'correlation_id'=>$correlation,'actor_user_id'=>null,'no_human_account_impersonated'=>true,'configuration_keys_flags_C131_bundle_cookie_preserved'=>true,'incident_closed'=>false];file_put_contents(__DIR__.'/C132-audit-record.json',json_encode($proof,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo json_encode($proof,JSON_THROW_ON_ERROR);
|