Repository navigation
Description
What is the version of your ORAS CLI
v1.4.0 / main (oras-go v3.0.0)
What would you like to be added?
Part of #1791. Depends on #2359. This extends oras check beyond a single artifact, to its referrers and to whole OCI layouts. The two parts share little code and should be separate PRs, with whole layouts first because checking backups is the stronger use case.
Scope
- Whole OCI layout: when an OCI layout is given without a tag or digest, check everything in it, as a directory or a tar archive.
- Referrers:
--include-referrerschecks an artifact together with its referrers, and supports--distribution-specascpandbackupdo.
Evaluation
Feasible after #2359. Effort is large as a whole, or about two medium PRs. The change is additive, so the main risk is a wrong result: passing content that was not fully checked, or reporting a problem that is not there.
These behaviors were observed in scratch tests against oras-go v3.0.0.
Whole layout with oci.Verify:
| Scenario | Result | What oras check needs to do |
|---|---|---|
| Manifest with the wrong layer size in a descriptor | Clean; only digests are compared with paths | Also walk the manifests |
index.json types an image manifest as an index, layer missing |
Clean except for an unreferenced config | Also walk the manifests with the media type check from #2359 |
Corrupt or missing index.json, corrupt oci-layout |
Reported only in Layout |
Treat invalid structure as an error |
Interrupted write in ingest/ |
Reported in Layout with a ModTime |
Information only |
| Foreign layer absent | Reported in Missing |
Not an error; copies leave these layers out |
| Corrupt referrer manifest | In both Failed and Unverifiable |
Remove duplicates |
Referrer listed in index.json but missing |
Reported in Missing |
Error |
| Layout with no tags | All blobs in Unreferenced |
Information only |
Wrong path, or no blobs directory |
Returns an error | Return a clear error |
Referrers with oras.ExtendedVerifyGraphNodes:
| Scenario | Result | What oras check needs to do |
|---|---|---|
| Index as the only start node | A referrer of a child manifest is not found | Also look up referrers of the child manifests |
| Default predecessors on a layout | An unrelated index that contains the manifest is checked too | Only follow subject relationships |
Corrupt referrer manifest in an open layout, using registry.Referrers |
The whole walk stops without a report | Record the failure and continue |
| Corrupt referrer manifest, using default predecessors | The referrer fails and the artifact is not checked | Check the artifact on its own first |
| Artifact manifest missing, referrer intact | The artifact fails, but is reached only by a subject edge | Never downgrade a requested artifact to a warning |
In addition, oci.NewStorageFromFS, which #2359 uses for layouts, has no predecessor lookup, while oci.NewFromFS does not open a layout with a corrupt manifest.
Proposed implementation: whole layout
-
For a directory, run
oci.Verifyand useFailed,Unverifiable,LayoutandUnreferenced. -
Run the walk from Add
oras checkto verify the integrity of an artifact #2359 on every entry inindex.json. In tests this found the wrong size and did not report the foreign layer. Take missing content from this walk instead of fromMissing. -
Seed an
oras.VerifiedSetfrom the verified blobs, using their sizes on disk. In tests this avoided reading layers twice and still found the size mismatch. -
Remove duplicates by digest and combine the results:
Source Proposed result Failed, and failures from the walkError, classified as in Add oras checkto verify the integrity of an artifact #2359Layoutwith a zeroModTimeError, invalid structure Layoutwith aModTimeInformation, leftover of an interrupted write UnverifiableUnable to check, non-zero exit UnreferencedInformation The error that marks leftovers is not exported, so
ModTimeis the only way to tell the two kinds ofLayoutfinding apart.Unreferenceduses the garbage collection rule and is only reliable when nothing is writing to the layout. -
For a tar archive, run only the walk, using
oci.NewStorageFromTarand readingindex.jsonfrom the archive. In tests this found corrupt, missing and wrong-size layers. It needs no extraction and no change in oras-go, but does not find unreferenced blobs or stray files. The output should say so.
Proposed implementation: referrers
- Check the requested artifact first with the walk from Add
oras checkto verify the integrity of an artifact #2359, so that its result does not depend on the referrers. The absent subject rule in Addoras checkto verify the integrity of an artifact #2359 must exclude every requested artifact, not only the root of the current walk. - Find referrers of the artifact, and of the child manifests of an index, with a loop that tracks visited digests and records failures per node.
graph.RecursiveFindReferrerstracks visited digests but stops at the first error. - Treat the referrer list as untrusted: limit the depth and count, tolerate cycles, and confirm that the
subjectof each referrer matches. - Run
VerifyGraphon each referrer and share theVerifiedSet. - For a layout, find referrers by reading the manifests listed in
index.json, and record the ones that cannot be read. - Drop phantom referrers as
prepareCopyOptionincmd/oras/root/cp.godoes (cp -r fails with 'MANIFEST_UNKNOWN' #2148). - Print how many referrers were found.
Design decisions to confirm
- Syntax for a whole layout. Proposal: omit the reference with
--oci-layout.--oci-layout-pathtakes the reference as its only argument, so it would need to accept no arguments. - Referrers cannot be listed. Proposal: unable to check, with a non-zero exit.
- Limits for the depth and number of referrers.
Unverifiablealso covers stray files. Proposal: do not try to tell them apart for now.
Known limitations
- A layout cannot show that a referrer was never copied. A backup made without referrers passes. The check confirms that everything listed in the layout is present and intact.
- Finding no referrers in a registry does not prove that there are none.
Tests
- Unit, layout: each row in the layout table; intact layout; duplicate findings; intact, corrupt, missing and wrong-size content in a tar.
- Unit, referrers: referrers of a manifest, of an index and of its children; corrupt referrer with an intact artifact; corrupt and missing artifact with an intact referrer; unrelated index; phantom referrers; cyclic referrers; listing failure; subject that does not match; depth and count limits.
- E2E:
--include-referrerswith the Referrers API and with the referrers tag schema; directory and tar output oforas backup, with and without referrers; layout with a corrupt manifest.
Related code
cmd/oras/root/cp.go:prepareCopyOption, with tests for cp -r fails with 'MANIFEST_UNKNOWN' #2148 incp_test.gointernal/graph/graph.go:FindPredecessors,RecursiveFindReferrerscmd/oras/root/backup.go:countReferrers;cmd/oras/root/restore.go: directory and tar inputcmd/oras/internal/option/target.go:parseOCILayoutReference;remote.go:EnableDistributionSpecFlaginternal/io/tar_utils.go:IsTarFile- oras-go v3.0.0:
extendedverify.go,registry/repository.go,content/oci/verify.go,content/oci/verify_layout.go,content/oci/readonlystorage.go
Why is this needed for ORAS?
Air-gapped and disaster recovery workflows need to know that a backup is intact, including the signatures, SBOMs and attestations in it, before it is restored.
Are you willing to submit PRs to contribute to this feature?
- Yes, I am willing to implement it.
Activity
Detoy commentedon Nov 28, 2026
I'd like to take the referrers part (
--include-referrers), now that whole layouts are in through #2372.Plan, following the proposal above:
subjectmust name the node it was listed for. An index's own children listed as its referrers are dropped as phantoms (cp -r fails with 'MANIFEST_UNKNOWN' #2148); any other mismatch is reported as invalid.VerifyGraph, sharing oneVerifiedSet. The subject edge back to a node that was already checked is not walked again.index.json; ones that cannot be read are reported.--distribution-specworks as incpandbackup, and the summary says how many referrers were found.On the open decisions, unless you'd rather have something else: referrers that cannot be listed are "Unable to check" with a non-zero exit, and the limits are a depth of 16 and 4096 referrers, either of which ends the referrer walk as "Unable to check" rather than passing. Stray files stay under
Unverifiableas proposed. Whole-layout checks keep their current behaviour, so--include-referrersneeds a reference.