Files
Investidor-V2/outputs/investmoz-audit-current-20261012/C132-verify-deployment-guard.py
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

24 lines
2.4 KiB
Python

from pathlib import Path
import json,subprocess,hashlib,sys
from datetime import datetime,timezone
OUT=Path(__file__).resolve().parent;ROOT=OUT.parents[1]
sys.path.insert(0,str(ROOT/'tools'))
from portal_diagnostics_deployment_guard import assert_diagnostics_off
php='C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64/php.exe'
before={p:hashlib.sha256((ROOT/p).read_bytes()).hexdigest() for p in ['.env','config/inertia.php','app/Services/OpportunityContacts.php','public/build/manifest.json']}
safe=(ROOT/'config/inertia.php').read_bytes();checks={}
for label,payload,blocked in [('unchanged_destination',{},False),('safe_candidate',{'config/inertia.php':safe},False),('enabled_candidate',{'config/inertia.php':safe.replace(b"'enabled' => false",b"'enabled' => true",1)},True),('missing_explicit_setting',{'config/inertia.php':safe.replace(b"'devtools' => ['enabled' => false],",b'',1)},True)]:
actualBlocked=False
try:assert_diagnostics_off(ROOT,payload=payload)
except RuntimeError:actualBlocked=True
assert actualBlocked==blocked,label
checks[label]='passed'
selftest=subprocess.run([php,str(ROOT/'tools/portal-diagnostics-deployment-guard.php'),'--self-test'],capture_output=True,text=True,check=True)
checks.update(json.loads(selftest.stdout)['checks'])
assert before=={p:hashlib.sha256((ROOT/p).read_bytes()).hexdigest() for p in before}
proof={'at':datetime.now(timezone.utc).isoformat(),'case':'C132','result':'passed','checks':checks,'active_configuration_code_build_unchanged':True,'active_writes':0,'services_changed':False,'historical_deployments_not_repeated':True,
'wired_pre_post_helpers':['portal-owner-administration-release.py','portal-workflow-activation-stage.py','portal-stability-activation-stage.py','portal-country-activation-stage.ps1'],
'CI_guard_added_but_remote_CI_not_executed':True,'limitations':['Guard stops supported staging paths before unsafe candidate configuration. A deliberate manual bypass or unreviewed external deployment cannot be prevented by these scripts. HTTP list and real detail 404 remain mandatory post-deployment checks.'],
'source_hashes':{p:hashlib.sha256((ROOT/p).read_bytes()).hexdigest() for p in ['tools/portal-diagnostics-deployment-guard.php','tools/portal_diagnostics_deployment_guard.py','.github/workflows/tests.yml']},'C131_included':False}
(OUT/'C132-deployment-guard-proof.json').write_text(json.dumps(proof,indent=2),encoding='utf-8');print(json.dumps(proof))