fix(bundle): reject import of bundles whose manifest lists files missing from tarball#85
Conversation
…ing from tarball (vouchdev#80) import_check previously only verified that tar members listed in the manifest had matching hashes, but never checked the reverse: whether every manifest entry had a corresponding tar member. A bundle whose manifest.json referenced claims/c1.yaml but whose tarball contained only manifest.json would pass import_check with ok=True, and import_apply would silently write nothing — no exception, no audit event indicating data loss. Add the missing-member pass (mirroring the existing check in export_check) so that manifest entries without a matching tar member produce a "manifest lists missing file" issue. import_apply then refuses to import because check.issues is non-empty.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR addresses issue ChangesBundle Integrity Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
PR should target test branch |
7bb44c0 to
f558fd0
Compare
|
Fix conflict |
Problem
bundle.import_checkwalks two loops in series: one over manifestentries (to compute
new_files/conflicts/identical), and oneover tar members (to schema-validate and verify the per-member sha256).
Neither loop flags the case where
manifest.jsonlists a path that hasno corresponding tar member.
The symptom is the inverse of
hash mismatchand is just as silent:import_checkreturnsok=Truefor a bundle wheremanifest.jsonclaims
claims/c1.yamlexists, but the tarball contains noclaims/c1.yamlmember.import_applythen iterates tar members, never reaches themanifest-listed-but-missing path, and writes nothing for it. The
bundle.importaudit event records a clean success — but theresulting KB is missing artifacts the manifest promised.
export_checkalready catches this (it walks recorded paths and checkstar.getmember(path)). The same companion check was missing on theimport side — exactly the asymmetry that issue #74 was about, just for a
different attack/corruption shape (omission instead of substitution).
Fix
Add the missing-member pass to
import_checkinsrc/vouch/bundle.py,mirroring the existing pattern in
export_check:import_applythen refuses to import becausecheck.issuesisnon-empty, raising
RuntimeError("refusing to import: manifest lists missing file: ...").Tests
test_import_check_rejects_manifest_listing_missing_file— builds atarball with only
manifest.json(no content members), assertsimport_check.ok is Falsewith a"missing file"issue.test_import_apply_rejects_bundle_with_missing_manifest_file—asserts
import_applyraisesRuntimeErrormatching"missing file".Both pass. All existing bundle tests continue to pass.
Closes #80
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests