Repository navigation
Description
At audited revision f04bc7a5729e26dc9c067b0d610e35cd51633435, a malformed independent image or nested index aborts planning for the entire archive, discarding healthy siblings before any layer is inspected. The result is conservatively incomplete, but loses supported evidence the tool promises to preserve.
The nested-index loop defers a nested document into pending, then validates its schema outside the per-descriptor exception handler. The Docker-save loop likewise raises directly for a missing layer or invalid image manifest. Because scan_archive obtains all plans before scanning any image, either exception prevents every valid plan from being processed. The existing sibling test covers unsupported OCI layer media types, which take a different exception path.
Safe reproduction: run python repro.py. The second case retains one fully valid synthetic OCI image containing Sharp 0.35.5 and appends a correctly hashed nested-index blob with schemaVersion=3. Observed: exit 2, images=[], and unsupported_index_schema_version. The third case retains a fully valid Docker-save entry and appends a second entry naming missing.tar; observed: exit 2, images=[], and missing_docker_layer. Both valid siblings are accepted when supplied alone by the repository fixtures. All work uses in-memory TAR construction and temporary local evidence files.
Expected: retain and process healthy siblings, record a separate incomplete entry for the rejected item, and keep overall exit 2. The OCI index specification explicitly supports nested indexes and per-manifest descriptors; this does not require treating an invalid child as a valid image. The README promises preservation of completed images and independent planning failures.
Remediation: isolate structural child-index and Docker image planning errors into per-item failure plans while preserving global resource budgets. Acceptance: both reproduction cases retain Sharp from the healthy sibling with its digest provenance, include a localized failed item, return exit 2, and behave identically with sibling order reversed. Truly global archive/index corruption may still stop inspection. No exact covering issue exists in supplied metadata; merged PR #1 does not cover this remaining behavior.
Self-contained synthetic reproduction
Save the following as repro.py beside the pinned repository's test_inventory.py, then run python repro.py. It uses existing local fixture helpers and never runs an image or contacts a registry.
import sys, io, json, hashlib, tarfile
from pathlib import Path
import test_inventory as t
case=t.InventoryTests()
base=t.oci_archive([t.tar_bytes([('app/package.json',t.package())])])
def unpack(raw):
with tarfile.open(fileobj=io.BytesIO(raw)) as f:
return {m.name:f.extractfile(m).read() for m in f if m.isfile()}
def blob(files,value):
raw=json.dumps(value).encode(); d='sha256:'+hashlib.sha256(raw).hexdigest();files['blobs/sha256/'+d[7:]]=raw
return dict(digest=d,size=len(raw),mediaType='application/vnd.oci.image.manifest.v1+json')
files=unpack(base); index=json.loads(files['index.json']); old=index['manifests'][0]; manifest=json.loads(files['blobs/sha256/'+old['digest'][7:]])
empty=b'{}';empty_hash=hashlib.sha256(empty).hexdigest();files['blobs/sha256/'+empty_hash]=empty
manifest['config']=dict(digest='sha256:'+empty_hash,size=2,mediaType='application/vnd.oci.empty.v1+json');manifest['artifactType']='application/vnd.example.attestation';index['manifests']=[blob(files,manifest)];files['index.json']=json.dumps(index).encode()
code,report,_=case.scan(t.tar_bytes(list(files.items())))
print(json.dumps(dict(case='artifact-treated-as-image',exit=code,complete=report['complete'],images=report['images'])))
files=unpack(base);index=json.loads(files['index.json']);nested=blob(files,dict(schemaVersion=3,manifests=[]));nested['mediaType']='application/vnd.oci.image.index.v1+json';index['manifests'].append(nested);files['index.json']=json.dumps(index).encode()
code,report,_=case.scan(t.tar_bytes(list(files.items())))
print(json.dumps(dict(case='nested-invalid-index-loses-sibling',exit=code,report=report)))
files=unpack(t.docker_archive([t.tar_bytes([('app/package.json',t.package())])]))
manifest=json.loads(files['manifest.json']);manifest.append(dict(Config='config.json',Layers=['missing.tar']));files['manifest.json']=json.dumps(manifest).encode()
code,report,_=case.scan(t.tar_bytes(list(files.items())))
print(json.dumps(dict(case='docker-missing-layer-loses-sibling',exit=code,report=report)))
Activity