Skip to content

Support referrers and whole OCI layouts in oras check #2360

Todo

Description

@TerryHowe

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-referrers checks an artifact together with its referrers, and supports --distribution-spec as cp and backup do.

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

  1. For a directory, run oci.Verify and use Failed, Unverifiable, Layout and Unreferenced.

  2. Run the walk from Add oras check to verify the integrity of an artifact #2359 on every entry in index.json. In tests this found the wrong size and did not report the foreign layer. Take missing content from this walk instead of from Missing.

  3. Seed an oras.VerifiedSet from the verified blobs, using their sizes on disk. In tests this avoided reading layers twice and still found the size mismatch.

  4. Remove duplicates by digest and combine the results:

    Source Proposed result
    Failed, and failures from the walk Error, classified as in Add oras check to verify the integrity of an artifact #2359
    Layout with a zero ModTime Error, invalid structure
    Layout with a ModTime Information, leftover of an interrupted write
    Unverifiable Unable to check, non-zero exit
    Unreferenced Information

    The error that marks leftovers is not exported, so ModTime is the only way to tell the two kinds of Layout finding apart. Unreferenced uses the garbage collection rule and is only reliable when nothing is writing to the layout.

  5. For a tar archive, run only the walk, using oci.NewStorageFromTar and reading index.json from 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

  1. Check the requested artifact first with the walk from Add oras check to verify the integrity of an artifact #2359, so that its result does not depend on the referrers. The absent subject rule in Add oras check to verify the integrity of an artifact #2359 must exclude every requested artifact, not only the root of the current walk.
  2. 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.RecursiveFindReferrers tracks visited digests but stops at the first error.
  3. Treat the referrer list as untrusted: limit the depth and count, tolerate cycles, and confirm that the subject of each referrer matches.
  4. Run VerifyGraph on each referrer and share the VerifiedSet.
  5. For a layout, find referrers by reading the manifests listed in index.json, and record the ones that cannot be read.
  6. Drop phantom referrers as prepareCopyOption in cmd/oras/root/cp.go does (cp -r fails with 'MANIFEST_UNKNOWN' #2148).
  7. Print how many referrers were found.

Design decisions to confirm

  • Syntax for a whole layout. Proposal: omit the reference with --oci-layout. --oci-layout-path takes 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.
  • Unverifiable also 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-referrers with the Referrers API and with the referrers tag schema; directory and tar output of oras 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 in cp_test.go
  • internal/graph/graph.go: FindPredecessors, RecursiveFindReferrers
  • cmd/oras/root/backup.go: countReferrers; cmd/oras/root/restore.go: directory and tar input
  • cmd/oras/internal/option/target.go: parseOCILayoutReference; remote.go: EnableDistributionSpecFlag
  • internal/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

  1. added
    enhancement
    on Nov 25, 2026
  2. added this to the v1.5.0 milestone on Nov 25, 2026
  3. added
    help wanted
    and removed
    help wanted
    on Nov 25, 2026
  4. Detoy commented on Nov 28, 2026

    @Detoy

    I'd like to take the referrers part (--include-referrers), now that whole layouts are in through #2372.

    Plan, following the proposal above:

    • Check the requested artifact first with the existing walk, unchanged, so its result does not depend on the referrers.
    • Then find referrers of the artifact and, for an index, of its child manifests, then referrers of those referrers. The loop keeps a visited set and records a failure per node instead of stopping at the first error.
    • Each referrer manifest is read before it is checked, and its subject must 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.
    • Each referrer is checked with VerifyGraph, sharing one VerifiedSet. The subject edge back to a node that was already checked is not walked again.
    • For an OCI layout, referrers are found by reading the manifests listed in index.json; ones that cannot be read are reported.
    • --distribution-spec works as in cp and backup, 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 Unverifiable as proposed. Whole-layout checks keep their current behaviour, so --include-referrers needs a reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions