Skip to content

feat: add content integrity verification (Verify, VerifyGraph, ExtendedVerify) - #1493

Merged
TerryHowe merged 8 commits into
oras-project:mainfrom
MohamedAliBouhaouala:feat/content-integrity-verification
Oct 7, 2026
Merged

TerryHowe merged 8 commits into
oras-project:mainfrom
MohamedAliBouhaouala:feat/content-integrity-verification

Conversation

@MohamedAliBouhaouala

@MohamedAliBouhaouala MohamedAliBouhaouala commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Partially resolves #986

Changes Included

Adds content integrity verification, as proposed in #986:

  • content.Verify(ctx, fetcher, desc): fetches a blob and checks size and
    digest via VerifyReader, streaming to io.Discard (no full-blob buffering).
  • oras.Verify / oras.VerifyGraph: walk a rooted DAG like
    Copy/CopyGraph, but discard content instead of writing it, in
    "on error resume next" mode. Per-node failures are collected in
    VerifyReport / VerifyGraphReport (Verified, Skipped, Failed;
    OK()), not returned as an error. An error is returned only when the walk
    itself stops (unresolvable ref, context cancellation, hook error), and the
    partial report is returned with it.
  • oras.VerifiedSet + VerifyGraphOptions.Verified: optional caller-provided
    set of already-verified digests, reusable across calls so blobs shared
    between artifacts in a repository or registry are not re-read. Manifests are
    always re-read, since that is the only way to discover their successors.
  • oras.ExtendedVerify / oras.ExtendedVerifyGraph: verify an artifact
    together with its referrers/predecessors, mirroring ExtendedCopy*
    (Depth, FindPredecessors).
  • Hooks PreVerify (may return SkipNode), PostVerify, OnVerifySkipped,
    FindSuccessors, plus Concurrency and MaxMetadataBytes, consistent with
    CopyGraphOptions.
  • findRoots now takes an unexported findRootsOptions so it can be shared
    by ExtendedCopyGraph and ExtendedVerifyGraph. No change to copy behavior.

Behavior worth reviewing

  • A cancelled or expired context stops the walk and is returned as an error;
    it is not recorded as a failed node.
  • PostVerify runs after the node's outcome has been recorded in the report,
    so a PostVerify error that aborts the walk does not lose that node.
  • A corrupt or unreadable manifest is reported as Failed; its successors are
    not discovered, but nodes reachable by another path are still verified.
  • If src implements registry.ReferenceFetcher, the root manifest is read
    while resolving the ref, so a corrupt or unreadable root is returned as an
    error with a nil report instead of a Failed entry. This is documented on
    Verify.
  • Foreign (non-distributable) layers are not verified and do not appear in the
    report, matching copyGraph.
  • Blobs are read from src directly (never through the caching proxy); only
    non-leaf nodes are cached.

Size and splitting

This is about 3000 lines (roughly two thirds tests) and covers three of the
four levels described in #986: blob content, DAG content, and artifact with
referrers. If reviewers prefer, I'm happy to split it into three PRs:

  1. content.Verify
  2. Verify / VerifyGraph / VerifiedSet
  3. ExtendedVerify / ExtendedVerifyGraph (plus the findRootsOptions
    refactor)

Not in scope

Level 4 of #986 (storage-medium verification)

Testing

  • content.Verify: success, empty, >32 MiB content, fetch/read errors, digest
    mismatch, short/long content, oversized (2^62), negative and invalid
    descriptors, unsupported algorithm, reader always closed.
  • Verify / VerifyGraph / ExtendedVerify*: full verify, resume after
    corruption, corrupt manifest, invalid successors, foreign layers, hooks,
    concurrency limit, VerifiedSet reuse, Depth, custom FindPredecessors,
    partial report on abort, context cancelled before and mid-walk, root fetched
    once via ReferenceFetcher.
  • make test (race + coverage) and make check-encoding pass locally.

@MohamedAliBouhaouala
MohamedAliBouhaouala force-pushed the feat/content-integrity-verification branch 2 times, most recently from b144bea to 7c8cd2b Compare October 1, 2026 16:52
Comment thread content/verify.go Resolved
Comment thread content/verify_test.go Resolved
Comment thread verify.go Resolved
Comment thread verify_test.go Resolved
Comment thread extendedverify.go Resolved
Comment thread verify.go Resolved
Comment thread verify.go Resolved
Comment thread extendedverify.go Resolved
Comment thread verify.go Resolved
Comment thread verify.go Resolved
@MohamedAliBouhaouala

Copy link
Copy Markdown
Contributor Author

@TerryHowe License headers added. Feedback addressed and suggestions applied. Thanks for the feedback! Excellent project 👍

Comment thread verify.go Resolved
Comment thread verify.go Resolved
@MohamedAliBouhaouala
MohamedAliBouhaouala force-pushed the feat/content-integrity-verification branch from cf78e71 to da22fb5 Compare October 2, 2026 23:17
Comment thread verify.go Resolved
Comment thread verify.go Resolved
Comment thread verify.go Resolved
@MohamedAliBouhaouala
MohamedAliBouhaouala force-pushed the feat/content-integrity-verification branch from 75c1c2d to be074d2 Compare October 3, 2026 14:29
@MohamedAliBouhaouala

Copy link
Copy Markdown
Contributor Author

@TerryHowe Resolved branch conflicts following the recently merged findRoots refactor in extendedcopy.go.

@codecov

codecov Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.08738% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.46%. Comparing base (c3a1aee) to head (21c3558).

Files with missing lines Patch % Lines
verify.go 95.80% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1493      +/-   ##
==========================================
+ Coverage   91.29%   91.46%   +0.17%     
==========================================
  Files          99      102       +3     
  Lines        7872     8076     +204     
==========================================
+ Hits         7187     7387     +200     
- Misses        674      678       +4     
  Partials       11       11              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread extendedverify.go Resolved
@MohamedAliBouhaouala
MohamedAliBouhaouala force-pushed the feat/content-integrity-verification branch from 43d8a4d to e2ed3c4 Compare October 5, 2026 12:19
Comment thread verify.go Resolved
Comment thread verify.go Resolved
Comment thread verify.go Resolved
Comment thread verify_test.go Resolved

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@TerryHowe
TerryHowe merged commit 9b52459 into oras-project:main Oct 7, 2026
10 checks passed
@TerryHowe

Copy link
Copy Markdown
Member

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Content Integrity Verification

3 participants