29 lines
2.5 KiB
Python
29 lines
2.5 KiB
Python
from pathlib import Path
|
|
import hashlib,json,zipfile
|
|
|
|
out=Path(__file__).resolve().parent
|
|
root=out.parents[1]
|
|
dest=out/'para-revisao'
|
|
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
|
|
receipt=json.loads((dest/'RECIBO-INTEGRIDADE.json').read_text('utf-8'))
|
|
result={'date':'2026-10-18','candidate':receipt['candidate'],'scope':'Conferência local documental e de integridade; sem testes HTTP ou ligação a bases de dados'}
|
|
result['documents']={n:sha(dest/n)==v['sha256'] and (dest/n).stat().st_size==v['bytes'] for n,v in receipt['documents'].items()}
|
|
package=out/receipt['package']['name']
|
|
result['package_hash_and_size']=sha(package)==receipt['package']['sha256'] and package.stat().st_size==receipt['package']['bytes']
|
|
with zipfile.ZipFile(package) as z:
|
|
entries=json.loads(z.read('MANIFESTO-INTEGRIDADE.json'))['entries']
|
|
result['zip_crc_and_all_entries']=z.testzip() is None and set(z.namelist())==set(entries)|{'MANIFESTO-INTEGRIDADE.json'} and all(hashlib.sha256(z.read(n)).hexdigest()==v['sha256'] for n,v in entries.items())
|
|
manifest=json.loads(z.read('MANIFESTO-ENTREGA.json'))
|
|
result['candidate_sources']=all(hashlib.sha256(z.read('candidate/'+v['path'])).hexdigest()==v['candidate_sha256'] for v in manifest['sources'])
|
|
result['builds']={mode:all(hashlib.sha256(z.read(mode+'/public/build/'+n)).hexdigest()==h for n,h in manifest[key].items()) for mode,key in [('candidate','candidate_build'),('compatible','compatibility_build')]}
|
|
result['manifest_matches_review_copy']=z.read('MANIFESTO-ENTREGA.json')==(dest/'MANIFESTO-ENTREGA.json').read_bytes()
|
|
result['entries']=len(z.namelist())
|
|
result['living_documents']={key:{'matches_historical_receipt':sha(root/n)==receipt[key],'current_sha256':sha(root/n)} for key,n in [('matrix_sha256','docs/investmoz/v2/auditoria-portal/matriz-requisitos.csv'),('backlog_sha256','docs/investmoz/v2/auditoria-portal/backlog.md'),('manual_sha256','docs/investmoz/unification/traceability-and-manual.md')]}
|
|
base=json.loads((out/'ATIVO-ANTES.json').read_text('utf-8'))
|
|
result['runtime_and_protected_differences']=[n for n,h in {**base['files'],**base['protected']}.items() if not (root/n).is_file() or sha(root/n)!=h]
|
|
result['historical_reversal_evidence']={s:json.loads((out/f'REVERSAO-{s}-QA.json').read_text('utf-8')) for s in 'ABC'}
|
|
result['active_changes_performed']=False
|
|
result['user_annex_review_confirmed']=False
|
|
(out/'CONFERENCIA-20261018.json').write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n','utf-8')
|
|
print(json.dumps(result,ensure_ascii=False,indent=2))
|