Files
6a6e7b0bbf feat(artifacts): inventory OCI image layouts offline (#12470)
* feat(artifacts): inventory OCI image layouts offline

OCI image-layout directories (oci-layout, index.json, blobs/) arrive as evidence and previously required walking the JSON by hand.

This adds inspect_oci_image_layout / inspect-oci-image-layout for the directory form only. It reports layout version, nested indexes, image config facts, layers, and streamed SHA-256 (and SHA-512 when declared) verification of present referenced blobs. Env values stay omitted unless include_env_values is selected. Missing blobs, digest and size mismatches, unreferenced blobs, unknown media types, unsupported digest algorithms, and symlink blobs are findings. Layer contents are not decompressed.

* fix(oci): preserve whitespace in image config strings

Keep config facts such as WorkingDir exactly as written instead of
returning their trimmed form. Blank values still count as absent.

* fix(oci): read the platform os.version member

The OCI image index stores a platform version under the literal
"os.version" member, so Windows entries that share OS and architecture
keep the build that tells them apart.

* fix(oci): keep config Env values unless the caller omits them

Env values are bytes from the selected image, and AGENTS.md asks to
preserve local evidence without inferring secrecy from names. The
include_env_values control now defaults to true; false still leaves each
value null and keeps the names.

* fix(oci): report descriptors the parser cannot model

An index, layer or config descriptor without a string mediaType or digest
was dropped with no diagnostic, so an index of only malformed descriptors
read as an empty, fully covered index. Each such descriptor now records a
malformed_blob_json finding naming its position, what it lacks and any
digest it carries.

* fix(oci): walk nested indexes breadth-first

The index walk was depth-first with a visited set that ignored depth, so
an index shared between a nested path and the root was first visited too
deep, and what it reached within max_index_depth was never inventoried.
Indexes now queue breadth-first, so each is first reached at the
shallowest depth any path gives it.

* fix(oci): check every declared size of a shared blob

When several descriptors referenced one blob with different sizes,
remember kept only the first declaration, so a wrong later size was
never checked. Each referenced blob now keeps every distinct declared
size, and the file-size and hashed-byte checks run against each one.

* fix(oci): report partial coverage when referenced JSON is not read

A referenced index, manifest or config that was a symlink, or otherwise
could not be read, left its facts unexamined while coverage still read
complete. Any skipped referenced JSON read now makes coverage partial,
whatever finding explains it.

* fix(oci): report unsupported layer digests without calling them missing

A layer whose digest used an unsupported algorithm got no finding and
was recorded as a missing blob, even when its file existed, and coverage
could read complete. Every referenced digest with an unsupported
algorithm now records unsupported_digest_algorithm, its blob record
reflects the file at blobs/<algorithm>/<encoded>, and such a finding
makes coverage partial.

* fix(oci): keep the parse outcome when reader cleanup fails

The provider's finally replaced the parse result with a cleanup failure
that always claimed the parse completed, so a refusal, cancellation or
integrity failure and its layout snapshot were lost when closing the
reader also failed. The parse outcome is now captured first; a failed
parse stays the primary error, with its partial facts, and the cleanup
failure is attached to it.

* Address review feedback

* fix(oci): keep oci-layout snapshot on missing imageLayoutVersion

Build the oci-layout file snapshot before checking imageLayoutVersion and
attach it to the refusal, so a readable oci-layout without a version still
reports its sha256 and byte count.

* fix(oci): keep directory traversal coverage in layout reports

parseOciImageLayout iterated the directory reader without an onCoverage
sink, so names the reader skipped (for example non-UTF-8 names on Linux)
left the report claiming complete coverage with no limitation. Collect
the traversal coverage, carry its limitations into the report, and let
unknown or partial traversal coverage override the findings-based status.
A reader that reports nothing is treated as unknown.

* fix(oci): keep reader failures on referenced blobs

A referenced index, manifest or config read that failed in the reader,
for example a close failure after the JSON was fully read, was recorded
as malformed_blob_json and the call carried on. Only format failures
become findings now; reader failures reach the caller with their own
facts.

* fix(oci): budget decoded descriptors separately from directory entries

max_entries bounds the directory walk, but index, manifest and layer
descriptors also spent it, so many manifests sharing layers were refused
far inside the advertised directory budget. Decoded descriptors now spend
their own max_descriptors allowance (default 65536, maximum 1048576), and
a refusal names that allowance.

* fix(oci): keep the completed inventory when reader cleanup fails

When parsing finished but closing the directory reader failed, the
provider threw a cleanup failure built against a placeholder outcome and
the completed inventory was dropped. The cleanup failure now carries the
completed report as unretained Evidence in its partial observation, the
same way DesktopApplicationReader keeps its report. A provider test
covers that case and checks that a later close retries the failed
reader cleanup.

* fix(oci): keep reader omissions out of complete layout coverage

parseOciImageLayout took the directory reader's coverage but not its
omission callback, so a FIFO, socket or device node under blobs/ was
dropped from the blob inventory while the report still said complete.
Collect omissions other than the intentional skip of directories
outside blobs/, name the first one in a limitation, and report unknown
coverage when any were seen.

* refactor(oci): classify layout failures through classifyProviderFailure

The provider kept its own raw-error ladder in layoutFailure. Its OCI
decisions (unsupported root or symlink, parse limits with budget
recovery, format failures, reader failures) are now the recognise step
of a ProviderFailureDialect, with the io report as its unclassified
fallback, so typed failures pass through, cancelled reads use the shared
cancellation path, and a failed read's cleanup is bound by the shared
owner.

* fix(oci): match referenced blobs by resolved path

parseOciDigest accepts uppercase SHA-256 hex and resolves it to the
lowercase blob path, but the unreferenced-blob sweep keyed membership by
the descriptor's original spelling. A blob named that way was hashed as
referenced and also reported as unreferenced_blob with a second
referenced: false row. Track the resolved paths of referenced blobs and
skip them in the sweep.

* fix(oci): read shared configs once and budget expanded config facts

Each manifest reread and reparsed its config, and every image carried its
own copy of the facts, so many small manifests sharing a large config
could expand to far more memory than the per-file limits suggest before
the service checked the report.

Each config blob is now read and parsed once per layout and its facts are
reused. The config bytes behind each image spend a new max_config_bytes
allowance (default 64 MiB, maximum 512 MiB) before the image is added, so
a shared config counts once per image and an expansion past the budget
refuses the inspect and names that allowance.

* fix(oci): report blob sizes above 4 GiB

Descriptor, layer and blob sizes used the 32-bit count schema, so a
layout with a blob over 4 GiB produced a report the output schema
rejected, hiding its blob_oversize finding. Sizes now accept any
nonnegative safe integer; depth and coverage counts stay 32-bit.

* fix(oci): report a referenced layer that is not a regular file

A referenced layer whose blob path is a directory was recorded as kind
other with present false, but no finding was emitted. Layer blobs never
go through the referenced JSON reader, so coverage stayed complete even
though the layer was never verified. The layer now gets a missing_blob
finding, matching non-file indexes, manifests and configs, and coverage
is reported as partial.

* fix(oci): keep the oci-layout hash when a later budget refuses

A manifest or config past max_json_bytes, or a layout past
max_descriptors or max_config_bytes, threw a bare ParseFailureError
after oci-layout had been read and hashed. The provider only attaches
partial facts to OciImageLayoutRefusal, so that completed observation
was dropped.

The parser now rewraps any later ParseFailureError as an
OciImageLayoutRefusal carrying the oci-layout snapshot, so every
refusal after that point reports it as the partial observation.

* fix(oci): keep blobs unknown when the reference walk is truncated

When max_index_depth, an unreadable index or manifest, or a descriptor
that cannot be modeled stops the reference walk, blobs outside the
walked part were reported as unreferenced_blob. They may still be
reachable from what was not examined, so the parser now only asserts
unreferenced status after a complete walk and otherwise records a
limitation and leaves those blobs out of the inventory.

* fix(oci): report wrong-typed manifests and layers arrays

A non-array manifests member in index.json now refuses the layout and
keeps the oci-layout observation. A non-array manifests member in a
nested index, or a non-array layers member in a manifest, records a
malformed_blob_json finding and marks the reference graph truncated
instead of reading as an empty collection.

* fix(oci): report image configs whose root is not a JSON object

A config blob holding valid JSON such as [] or null fell back to empty
facts with no finding, so the report claimed complete coverage. Record a
malformed_blob_json finding for the config digest while keeping the
manifest and layer observations.

* fix(oci): decode only image config media types as JSON

A manifest whose config is application/octet-stream or another
non-image type no longer has its config run through the JSON decoder.
Valid binary config bytes produced a false malformed_blob_json finding,
and a config larger than max_json_bytes refused the whole inventory even
when it fit max_blob_bytes. Such configs now stay opaque references that
the blob pass hashes; the unknown_media_type finding is kept.

* fix(oci): bound JSON reads by the descriptor budget

The service checked json_bytes_read against one max_json_bytes document
per returned index and image plus two. A layout reads a manifest and a
config per image, and manifests or nested indexes that fail to parse are
read without appearing in the report, so valid layouts whose every
document fit max_json_bytes could be rejected after parsing.

Every nested index or manifest read is charged one descriptor and each
manifest reads at most one config, so bound the total by oci-layout,
index.json and two documents per allowed descriptor.

* fix(oci): count OCI 1.1 subject blobs as referenced

A manifest or index subject that names a blob present in the layout now
joins the referenced set, so the blob is hashed and is not reported as
unreferenced. A subject absent from the layout is allowed by the spec
and adds no finding. A subject that is not a descriptor is reported as
malformed and keeps unreferenced blobs unknown.

* fix(oci): keep caller selections in cleanup-recovered Evidence

When the reader fails to close after a completed inspection, the provider
keeps the inventory as partial Evidence built from the resolved input, so
its parameters named defaults the caller never chose and its Evidence ID
differed from the success path. Build both from one OCI Evidence helper
and have the service rebuild a recovered inventory from the caller's own
selections.

* fix(oci): keep blob rows when the reference graph walk is incomplete

When a nested index or manifest could not be read or exceeded
max_index_depth, every blob outside the walked part was dropped from the
report, losing its path, size and kind. List those blobs with a null
referenced status instead, and report unreferenced_blob only when the
whole graph was examined.

* fix(oci): report unknown media types on present subjects

A subject blob present in the layout now joins the referenced set, which
removed its unreferenced_blob finding. Index entries, layers and configs
also report an unfamiliar media type, but subjects skipped that check, so
an unknown subject format went unreported. A present subject with an
unknown media type now records unknown_media_type.

* perf(oci): index emitted blob findings instead of rescanning them

The blob inventory loop checked each referenced digest against the whole
findings array before recording missing_blob, symlink_blob, or
unsupported_digest_algorithm, which is quadratic for layouts with many
missing blobs. Index finding kind and digest in a set built once before
the loop so each check is constant time. Output is unchanged.

* fix(oci): report invalid descriptor sizes as malformed

An index entry, config, layer or subject descriptor whose required size
was missing, a string, negative or fractional became a null size, which
dropped it from size validation without any finding, so the report could
claim complete coverage. The descriptor still keeps its other facts, but
the defect is now recorded as malformed_blob_json on the owning blob.

* fix(oci): keep damaged config, subject and descriptor facts in the report

Image config parsing kept any string in rootfs.diff_ids, so a readable
config with diff_ids [""] produced output the schema rejects and the
service discarded the whole inventory as an AnalysisOutputError. Config
parsing now owns that boundary: diff_ids members that are not nonempty
strings, and empty ExposedPorts or Volumes keys, are omitted and reported
once per config blob as malformed_blob_json, and the manifest and layer
observations stay in the report.

Related gaps in the same walk:

- A present subject was hashed but never walked, so blobs it names were
  reported as unreferenced. A subject manifest now goes through
  walkManifest and a subject index joins the breadth-first index queue one
  level below its owner, within max_index_depth.
- A manifest with no config member reported complete coverage. A missing
  config is now treated like a malformed one.
- A symlinked referenced blob was not hashed but left coverage complete.
  symlink_blob now makes coverage partial.
- An unusable descriptor size was serialized into the finding message.
  It is now described by type and length, with short strings quoted.
- A reader failure after oci-layout was hashed dropped that observation.
  It is now attached when the reader did not attach its own.
- Annotation and label names allowed by OCI, including the empty key,
  failed the output schema. The name is now any string. The advertised
  compact output schema summary is unchanged.

* perf(oci): index declared sizes for shared blobs

Recording a distinct declared size scanned every earlier declaration for
the same blob, so many references to one blob with distinct sizes cost
quadratic work inside max_descriptors. ReferencedBlob now keeps a Set
beside declaredSizes for membership, and the array keeps declaration order
for verification.

* fix(oci): walk subject manifests from a queue

Finish each manifest before reading the one its local subject names, so a
long subject chain no longer keeps every parsed document alive at once.

* fix(oci): resolve unsupported-digest layer presence at its layout path

A layer stored at blobs/sha1/<hex> was reported present: false because
the layer lookup only resolved verifiable digests, while the blob
inventory reported the same file present. Use the grammar-based path
fallback for layer presence too.

* fix(oci): keep reference coverage uncertain for opaque index entries

An index entry with an unknown media type is not walked, so the blobs
it references are unknown. Mark the reference graph truncated so no
blob is reported unreferenced, and report coverage as partial whenever
the reference graph was not fully examined.

* fix(oci): walk digest aliases that differ only in hex casing once

Descriptors whose digests differ only in accepted hex casing resolve to
one blob, but the index queue, visited set and config cache were keyed
by the source spelling, so each alias reread and rewalked the whole
index. Key traversal by the resolved blob path while descriptors keep
their source spelling in the report.

* fix(oci): keep unparsed digest spellings out of accepted traversal keys

A descriptor spelled blobs/sha256/<hex> did not parse, so its traversal
key fell back to the raw text, which matched the blob path key of the
accepted sha256:<hex> digest. Listed first, it marked the manifest
visited and the valid descriptor was skipped. Prefix accepted and
unparsed keys separately.

* fix(oci): bound index entry text retained across indexes

Index entries keep their digests, media types, platforms and annotations
in the report, but no allowance covered that text across indexes, so many
nested indexes with large annotations could exhaust memory within every
other limit. Charge each retained entry to a new max_descriptor_bytes
budget (64 MiB default, 512 MiB maximum) before adding it.

* fix(oci): hash each blob file once across digest spellings

Digest spellings that differ only in accepted hex casing resolve to one
blob path, but the blob pass hashed the file once per spelling. Cache the
hash result, or its oversize refusal, by blob path so each file is read
once, while every spelling keeps its own row, size checks and digest
check.

* fix(oci): report non-object config and rootfs subobjects

A present config or rootfs value that is not a JSON object now records a
malformed_blob_json defect instead of being replaced by an empty object, so
coverage reports partial. Other image facts are kept. Regenerate the
inspect_oci_image_layout advertised-schema summary.

* fix(oci): check declared sizes for unsupported-digest blobs

A blob referenced by a valid but unsupported digest (for example sha1)
skipped the declared-size checks and left observed_size null, even
though the directory reader already captured the file size. Record
observed_size and emit size_mismatch for it, still without hashing.

* fix(oci): keep reader integrity failures that wrap a JSON parse failure

readJsonDocument unwrapped any ArtifactReaderFailure whose cause was a
ParseFailureError. When a malformed referenced blob changed during
inspection, DirectoryArtifactReader.inspectFile raised an "integrity"
failure carrying that ParseFailureError, and the unwrap turned it back
into a malformed_blob_json finding. Only unwrap the plain "io" transport
wrapper with no cleanup lease, so integrity, cancelled and limit
failures keep their reader facts.

* fix(oci): report malformed config leaf fields

A config with Env: "A=1" or Cmd: ["/bin/sh", false] used to come back
as env: [] or cmd: null with no finding, indistinguishable from an
image that declared neither. parseConfig now checks each present known
field (the top-level strings, User, Env, Entrypoint, Cmd, WorkingDir,
ExposedPorts, Volumes, Labels, StopSignal) and records
malformed_blob_json for a wrong type, keeping the other facts. Env
members that are not a named string and non-string label values are
omitted and counted. null stays an omitted declaration.

* fix(oci): allow json_bytes_read beyond 32 bits

coverage.json_bytes_read sums bytes across every JSON document read.
OciImageLayoutService bounds it by max_json_bytes * (2 + 2 *
max_descriptors), which at a 16 MiB per-document cap passes 0xffffffff
well within budget, so the uint schema made safeParse reject a completed
report as AnalysisOutputError. Give the counter a nonnegative safe-integer
schema; the other uint counters are unchanged.

* fix(oci): report malformed image history

A non-array history or a history member that is not an object was
silently dropped, so damaged build history looked the same as omitted
history. Report both as malformed_blob_json defects on the config blob
and keep the readable history records and other image facts.

* fix(oci): report damaged descriptor metadata and symlinked blob dirs

Descriptor platform and annotations that were present but malformed
(platform: [], a non-string platform field, annotations that are not an
object or hold non-string values) were normalized to null or [] with no
finding. Report each as a malformed_blob_json defect against the owning
document and keep the readable entries.

A symlink at blobs or blobs/<algorithm> is not followed, but nothing
recorded the skipped tree, so an empty index over a linked blob
directory reported an empty inventory with complete coverage. Record a
symlink_blob finding for the linked directory so coverage is partial.

* Address review feedback

* Address review feedback

* Address review feedback

* Bound repeated JSON member names in OCI findings

A long duplicate member name is now described by its length instead of
being copied into the finding message.

* fix(oci): keep the oci-layout hash when its JSON is malformed

The oci-layout file is now read and hashed first, and its observation is
recorded before decoding. An oci-layout with invalid UTF-8, invalid JSON
or a duplicate member is refused with its completed file identity.

* fix(oci): charge accepted descriptor text to max_descriptor_bytes

Accepted subject, config and layer descriptors keep their digest and
media type in image rows, the reference map, findings and blob rows, but
only index entries and rejected descriptors spent max_descriptor_bytes.
A layout with many manifests carrying long distinct layer digests could
retain unbounded text. Charge accepted descriptor text before retaining
it, once per referencing manifest or index.

* fix(oci): report presence defects for unsupported-digest blobs

A referenced blob with an unsupported digest algorithm whose layout path
is missing, a symlink, or not a regular file now gets the same
missing_blob or symlink_blob finding a supported digest gets, alongside
unsupported_digest_algorithm. Present files still only get the size
check and stay non-missing.

* perf(oci): drain index and manifest queues with a cursor

shift() relocates the remaining queue on every step, which makes draining
layouts with many index references quadratic. Walk both breadth-first
queues with an index cursor instead.

* fix(oci): keep blobs under a symlinked blob directory unexamined

When blobs or blobs/<algorithm> is a symlink, the reader lists the link
but never its children, so a referenced blob under it is absent from the
listing without being absent from the layout. One shared lookup now
tells listed, unexamined and confirmed-missing paths apart for the
reference walk, subjects, and both inventory branches. An unexamined
blob gets a symlink_blob finding naming the directory instead of
missing_blob, and an unexamined subject marks the reference graph
truncated.

* fix(oci): charge serialized config facts to max_config_bytes

The config allowance counted the config document's source bytes, but each
image carries the parsed facts, and a sparse history entry such as {}
expands into a record with four null fields. A small shared config with
thousands of empty history entries could pass the budget while the report
grew past the runtime's string limit. Each distinct config now charges the
exact compact JSON size of its facts, once per image that uses it.

* fix(oci): keep the oci-layout snapshot when its read fails to finalize

When the oci-layout read completes but closing its descriptor fails, or
cancellation arrives during the close, the reader rejects before the
parser records the layout hash. The reader keeps the completed bytes on
that failure, so the failure reached translation without the SHA-256 and
byte count it could have carried, unlike the same failure on index.json.
The parser now records the completed layout observation from that outcome
and rethrows the reader's failure unchanged, keeping its cleanup owner.

* fix(oci): keep reference status unknown under an unwalked present subject

A present subject with an unknown media type, or an index or manifest
subject whose digest algorithm is unsupported, is not read, so the blobs
it names were reported as unreferenced with complete coverage. Mark the
reference graph truncated in both cases so unmatched blobs keep an
unknown referenced status.

* fix(oci): keep a malformed index.json primary when its handle close fails

When index.json is malformed and closing its descriptor also fails, the
directory reader raises ArtifactFileCleanupFailure with reason io and keeps
the ParseFailureError as the physical outcome. The OCI dialect translated
the wrapper directly, so the malformed input surfaced as an I/O failure even
after the resource scope retried the close.

The dialect now supplies readCleanup: the shared classifier classifies the
failed outcome as primary, and the unresolved close is attached beside it
and bound to that read's exact cleanup lease. A cleanup-only read keeps its
previous projection.

* fix(oci): count a malformed blob's bytes in json_bytes_read

A referenced index, manifest or config that was read in full but failed
UTF-8, JSON or duplicate-member decoding became a malformed_blob_json
finding, yet its bytes never reached json_bytes_read, because the count
was added only after decoding succeeded.

The blob read now adds the byte count inside the completed read, before
decoding, so coverage reports every byte the parser examined.

* fix(oci): report a missing or non-directory-ancestor path as invalid input

A selected root that resolves to ENOENT or ENOTDIR is a bad path, not an
I/O failure. Classify it as an AnalysisInputError on `path` before the
generic reader translation; other root I/O keeps its execution failure.

* fix(oci): keep the layout hash when index.json close also fails

When malformed index.json also failed to close, readCleanup composed the
error from the classified parse failure, which carries no observation,
so the completed oci-layout hash was dropped. Carry the read's partial
observation onto the primary before composing.

The close-fault test now selects the index.json handle by file identity
(dev and inode) rather than the second close call, and asserts the
fault landed there and the oci-layout hash survived.

* fix(oci): report malformed subject digests and count examined entries

A subject whose digest is not a valid OCI digest has no layout path, so
the walk returned without a finding and kept claiming it could prove
which blobs nothing references. It now records a malformed_blob_json
finding on the owner and marks the reference graph truncated, the same
as any other subject descriptor it cannot model. An absent subject with
a well-formed digest stays finding-free.

coverage.entries_examined counted only the entries the reader yielded.
It now takes the reader's examinedEntries from onCoverage, which
includes names the reader examined but omitted, and falls back to the
yielded count when the reader does not report one. An omission that
rewrites the traversal coverage keeps that count.

* fix(oci): keep the root index out of the blob traversal namespace

The root index was walked and prequeued under the traversal key of its
SHA-256 digest, which is the key of the blob path blobs/sha256/<hex>.
When a damaged nested index named that digest and the blob file there
held different index JSON, the queue skipped the blob as already walked,
so its manifests, configs and layers were never read and were reported
as unreferenced under complete coverage.

index.json now walks under its own traversal identity. A descriptor that
names its digest reads and walks the blob stored at that path like any
other nested index.

* fix(oci): diagnose conflicting media types inside referenced JSON

A referenced manifest or nested index may repeat its media type in its
own optional mediaType member. The walk ignored that declaration, so a
document admitted as a manifest but declaring the index type, or an
unknown type, produced no finding.

Check a present declaration against the descriptor type the walk
admitted it under. An unknown declared type is reported as
unknown_media_type; a known but conflicting type or a non-string value
is reported as malformed_blob_json. The members are still read, so the
other readable facts are kept, and an omitted mediaType stays valid.
The root index.json is admitted under its own declaration and is not
checked against itself.

* fix(oci): charge unknown declared media types to max_descriptor_bytes

A referenced manifest or nested index whose own mediaType is an unknown
string is quoted in an unknown_media_type finding. That text was retained
without spending the descriptor text budget, so many hash-valid documents
with long declarations could grow findings well past max_descriptor_bytes.
Charge the escaped declaration before the finding is recorded.

* fix(oci): mark the reference graph incomplete on document-type conflicts

A referenced manifest or nested index whose own mediaType names another
document kind, or an unknown type, was diagnosed but its blobs were still
judged with a complete reference graph. The walker reads only the members
of the admitted kind, so members of the declared kind, such as an index's
manifests inside a document admitted as a manifest, were never followed
and the blobs they name were reported as unreferenced_blob.

Mark the reference graph truncated for an unknown declared type or one of
a different document kind, so unreached blobs keep an unknown referenced
status. The readable facts are still reported. A declaration of the same
kind, such as the Docker manifest type on an OCI manifest descriptor,
reads the same members and keeps unreferenced status definite.

* docs(oci): state that unsupported digest algorithms skip hashing

The guide said every present referenced blob gets a SHA-256. Blobs whose
digest uses an algorithm other than sha256 or sha512 are not hashed; their
row reports hashed: false with null sha256 and sha512. Document that and pin
the null hash fields in the sha1 layer test.

* fix(oci): check the root index.json mediaType against the index kind

The root index.json skipped declaration checking because no descriptor
names it, so its own mediaType chose the admitted type. A root that
declared the manifest type or an unknown type was still walked as an
index with a complete reference graph, and blobs named by members the
index walk never reads were reported as unreferenced_blob.

Admit the root as an index: an index declaration of either family
stands, and any other declaration is checked against the OCI index type
like a nested index, which diagnoses it and marks the graph incomplete.

Also document that unknown declared media types quoted in findings
spend max_descriptor_bytes.

* Address review feedback

* Address review feedback

* fix(oci): check each referencing media type against a revisited document

A manifest or nested index reached a second time was skipped before its
mediaType declaration was compared with the new descriptor type, so a
conflict was reported or not depending on descriptor order. Each document
now records its declaration on first decode, and every distinct media type
a later reference admits it under is checked against it.

* fix(oci): detach redacted Env names from their bindings

With include_env_values false, each retained Env name was a slice of the
whole NAME=value string, so a long value stayed alive while the config
fact budget charged only the name. Redacted names are now standalone
copies, and a heap regression test covers eight 0.9 MiB values.

* fix(oci): keep only string mediaType declarations for revisit checks

The revisit cache kept each decoded document's raw mediaType, so a layout
of many manifests with large object declarations held all of them for the
whole walk while no byte budget charged them. A non-string declaration is
rejected whatever it holds, so the cache now keeps null in its place and
still reports it as not a string on each new referencing media type.

* Address review feedback

* Address review feedback

* Address review feedback

* fix(oci): preserve layout evidence on malformed targets

* Address review feedback

* fix(oci): diagnose schema versions and charge annotation records

Indexes and manifests whose schemaVersion is omitted, not a number, or a
number other than 2 now get a malformed_blob_json finding and partial
coverage, while their entries, config and layers stay readable.

Index entry annotations now spend max_descriptor_bytes as each
{name, value} record is built, charged at its serialized size, so many
short or empty annotations can no longer retain far more than their text
was charged for.

* docs(oci): describe annotation record accounting for max_descriptor_bytes

* Address review feedback

* fix(oci): wire summary delivery, parameter budget limits, and single-pass annotation parsing

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Matt Van Horn <mvanhorn@MacBook-Pro-10.local>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-26 20:02:44 +00:00
..