Skip to content

Compare the blob policy verification level as a string - #593

Merged
yizha1 merged 2 commits into
notaryproject:mainfrom
arpitjain099:fix/global-blob-policy-skip-guard
Nov 27, 2026
Merged

yizha1 merged 2 commits into
notaryproject:mainfrom
arpitjain099:fix/global-blob-policy-skip-guard

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

BlobDocument.Validate means to forbid a global blob policy from skipping verification, but the comparison cannot fire. SignatureVerification.VerificationLevel is a string holding the level name, while LevelSkip is a *VerificationLevel, so reflect.DeepEqual is handed two different types and is always false.

The sibling in verifier.go:253 runs the same idiom correctly, because there verificationLevel really is a *VerificationLevel returned by GetVerificationLevel. Only the blob document path compares the raw string.

There is no second gate behind it. validatePolicyCore rejects skip when trust stores or trusted identities are set, but permits it when they are absent, which is the shape that reaches this check. So a blob policy document with globalPolicy: true and level: skip validates cleanly today and ends up with every enforcement field set to skip.

Comparing against LevelSkip.Name is what the field holds, and reflect was imported only for this line so it goes too.

The new case fails on main with got <nil> from Validate, and passes here. I added the non-global case beside it, since a statement that is not the global policy is still allowed to use skip and should stay that way. The repo is green, zero failures across all packages.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>

@cshung cshung left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code LGTM. This restores the existing intent to reject global skip; the previous comparison was broken. The updated code is now specification compliant in this regard and more secure by default.

One consideration is compatibility. If, in the worst case, an existing deployment depends on global skip, a possible short-term migration is to convert it to a non-global named skip policy and update the surrounding caller to select it explicitly. Where that caller is centrally controlled, this can preserve default-off behavior without requiring every end user to opt out.

Ideally, no deployments need that workaround, and things should be secure by default. Maintainers should explicitly accept the compatibility risk and communicate this migration option where applicable.

@yizha1 yizha1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM per the Notary Project specification:

For a given OCI artifact, if there is no applicable trust policy then implementations of the Notary Project verification specification MUST consider the artifact as untrusted and fail signature verification.

@yizha1

yizha1 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@arpitjain099 Could you please update the branch so we can proceed?

@arpitjain099

Copy link
Copy Markdown
Contributor Author

@yizha1 done, I have updated the branch with main. Please let me know if anything else is needed, and thanks for the review.

@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.88%. Comparing base (3babf25) to head (32e8a67).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #593      +/-   ##
==========================================
+ Coverage   82.80%   82.88%   +0.07%     
==========================================
  Files          36       36              
  Lines        2635     2635              
==========================================
+ Hits         2182     2184       +2     
+ Misses        311      310       -1     
+ Partials      142      141       -1     

☔ 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.

@yizha1
yizha1 merged commit 860dedc into notaryproject:main Nov 27, 2026
9 checks passed
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.

3 participants