Verify frozen export using canonical Path ordering and separate delivery source identity

This commit is contained in:
huncode committed 2026-10-26 19:34:55 +03:00
1 parent 78274fbe09
commit 38f223e5af
1 file changed
+2 -2
+2 -2
View File
@@ -62,7 +62,7 @@ def tar_rows(stream,expected,extract=None):
data=archive.extractfile(member).read();row=dict(path=name,sha256=sha(data),bytes=len(data));require(row==expected[name],'File mismatch: '+name);result.append(row)
if extract:
dest=extract/name;dest.parent.mkdir(parents=True,exist_ok=True);dest.write_bytes(data)
require(seen==set(expected),'Missing export files');return sorted(result,key=lambda r:r['path'])
require(seen==set(expected),'Missing export files');return sorted(result,key=lambda r:PurePosixPath(r['path']))
def pack(args):
report=json.loads(rooted(args.report).read_text());require(report['summary']['errors']==0 and report['summary']['technicalStatus']=='passed','Technical verification required')
out=ROOT/'web-front/out';rows=files(out);require(hash_manifest(rows)==report['exportManifestSha256'],'Export differs from checked candidate')
@@ -71,7 +71,7 @@ def pack(args):
for row in rows:
file=out/row['path'];info=tarfile.TarInfo(row['path']);info.size=row['bytes'];info.mode=0o644;info.mtime=0
with file.open('rb') as stream:tar.addfile(info,stream)
m=dict(schemaVersion=1,scope='reviewed-corpus-only',historicalRestorationComplete=False,publicationDecision='PENDING_FIVE_SCOPED_DECISIONS',sourceCommit=revision,appSourceManifestSha256=report['sourceManifestSha256'],appSourceFiles=report['sourceFiles'],deploymentSourceCommit=revision,deploymentFiles=[dict(path=f,sha256=sha(rooted(f).read_bytes())) for f in DEPLOY_FILES],exportManifestSha256=report['exportManifestSha256'],files=rows,archivePath=archive.relative_to(ROOT).as_posix(),archiveSha256=sha(archive.read_bytes()),roleApprovals=[],inventoryAtPack=report['summary']['inventoryItems'],unresolvedAtPack=report['summary']['unresolvedInventoryItems'])
m=dict(schemaVersion=1,scope='reviewed-corpus-only',historicalRestorationComplete=False,publicationDecision='PENDING_FIVE_SCOPED_DECISIONS',sourceCommit=revision,appSourceManifestSha256=report['sourceManifestSha256'],appSourceFiles=report['sourceFiles'],deploymentSourceCommit=subprocess.check_output(['git','rev-parse','HEAD'],cwd=ROOT,text=True).strip(),deploymentFiles=[dict(path=f,sha256=sha(rooted(f).read_bytes())) for f in DEPLOY_FILES],exportManifestSha256=report['exportManifestSha256'],files=rows,archivePath=archive.relative_to(ROOT).as_posix(),archiveSha256=sha(archive.read_bytes()),roleApprovals=[],inventoryAtPack=report['summary']['inventoryItems'],unresolvedAtPack=report['summary']['unresolvedInventoryItems'])
rooted(args.manifest).parent.mkdir(parents=True,exist_ok=True);rooted(args.manifest).write_text(json.dumps(m,ensure_ascii=False,indent=2)+'\n');print(json.dumps(dict(source=revision,export=m['exportManifestSha256'],archiveBytes=archive.stat().st_size,files=len(rows),publicationDecision=m['publicationDecision'])))
def verify(args):
m=checked_manifest(args.manifest,not args.prepare_only);archive=rooted(m['archivePath']);require(sha(archive.read_bytes())==m['archiveSha256'],'Archive SHA mismatch');expected={r['path']:r for r in m['files']};require(len(expected)==len(m['files']),'Duplicate manifest path')