28 lines
3.4 KiB
Python
28 lines
3.4 KiB
Python
from pathlib import Path
|
|
import json,hashlib,zipfile,shutil,re,datetime
|
|
root=Path('.').resolve();out=root/'outputs/investmoz-audit-current-20261012';review=out/'para-revisao';doc=root/'docs/investmoz/v2/auditoria-portal'
|
|
proof=json.loads((out/'final-integrity.json').read_text(encoding='utf-8'));assert proof['result']=='passed'
|
|
manifest=json.loads((out/'manifesto-correcoes-qa.json').read_text(encoding='utf-8'));manifest['bundle_manifest_sha256']=proof['checks']['bundle_unchanged']['manifest_sha256'];manifest['recompilation_required']=False
|
|
(out/'manifesto-correcoes-qa.json').write_text(json.dumps(manifest,ensure_ascii=False,indent=2),encoding='utf-8');shutil.copyfile(out/'manifesto-correcoes-qa.json',review/'manifesto-correcoes-qa.json')
|
|
for name in ['matriz-requisitos.csv','backlog-priorizado.csv','inventario-fontes.csv','correspondencias-cartograficas.md']:shutil.copyfile(doc/name,review/name)
|
|
for rel in ['app/Services/OpportunityContacts.php','config/inertia.php']:
|
|
dest=review/'correcoes-preparadas'/rel;dest.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(out/'correcoes-preparadas'/rel,dest)
|
|
for name in ['contact-normalization-http.json','contact-whitespace-before.json','contact-whitespace-after.json','devtools-isolation-http.json','C132-active-readonly.json','parameterized-http.json','response-field-coverage-http.json','reused-evidence-integrity.json','final-integrity.json','browser-availability.json','scanner-current-readonly.json','reconciliation-summary.json']:
|
|
d=review/'evidencias'/name;d.parent.mkdir(exist_ok=True);shutil.copyfile(out/name,d)
|
|
for name in ['proof-groups.json','module-counts.json']:shutil.copyfile(out/name,review/name)
|
|
files=sorted(p for p in review.rglob('*') if p.is_file() and p.name!='manifesto-revisao.json');forbidden=['QA-[a-f0-9]{32,}','otpauth://',r'(?:Cookie|X-XSRF-TOKEN):\s*[^\s<]{20,}']
|
|
for p in files:
|
|
s=p.read_text(encoding='utf-8-sig');assert not any(re.search(x,s,re.I) for x in forbidden),'Review excluded due to secret-shaped value'
|
|
assert p.name not in ['.env','onboarding-actors-local.json','profiles-v1-actors-private.json']
|
|
package={'at':datetime.datetime.now(datetime.timezone.utc).isoformat(),'purpose':'Snapshot de revisão; fontes canónicas continuam na matriz/backlog existentes','requirements':3401,'source_occurrences':7739,'new_ids':0,'active_changes':0,'QA_delta':manifest['delta_revision'],'visual_complete':False,'files':[{'name':p.relative_to(review).as_posix(),'bytes':p.stat().st_size,'sha256':hashlib.sha256(p.read_bytes()).hexdigest()} for p in files]}
|
|
(review/'manifesto-revisao.json').write_text(json.dumps(package,ensure_ascii=False,indent=2),encoding='utf-8')
|
|
zip_path=out/'investmoz-auditoria-revisao-20261012.zip'
|
|
with zipfile.ZipFile(zip_path,'w',zipfile.ZIP_DEFLATED,compresslevel=8) as z:
|
|
for p in sorted(review.rglob('*')):
|
|
if p.is_file():z.write(p,p.relative_to(review).as_posix())
|
|
with zipfile.ZipFile(zip_path) as z:
|
|
assert z.testzip() is None
|
|
for record in package['files']:assert hashlib.sha256(z.read(record['name'])).hexdigest()==record['sha256']
|
|
result={'result':'passed','file':zip_path.name,'bytes':zip_path.stat().st_size,'sha256':hashlib.sha256(zip_path.read_bytes()).hexdigest(),'entries':len(package['files'])+1,'secrets_or_private_binaries_included':False,'canonical_source_files_preserved':True}
|
|
(out/'delivery-package-proof.json').write_text(json.dumps(result,indent=2),encoding='utf-8');print(json.dumps(result))
|