Compare digest contents when trust and simple signing are both required - #516
Open
arpitjain099 wants to merge 1 commit into
Open
Compare digest contents when trust and simple signing are both required#516arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
DigestByPolicy compared the notary and simple signing digests as *bytes.Buffer pointers, which are never equal, so any policy that required both methods denied every image with a conflicting digest error naming the same digest twice. Compare the buffer contents instead. Adds test cases for the agreeing and the conflicting case. Fixes IBM#515 Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #515
A policy with
trust.enabled: trueand simple signing requirements denies every image, including correctly signed ones. The deny reason gives the game away, it prints the same digest on both sides:notaryDigest != digestcompares two*bytes.Bufferpointers, so it's true whenever both verifiers ran. Now it compares the contents.Only the both-methods path was affected. Trust-only and simple-only policies never reach the check, which is probably why nobody tripped over it.
Test cases are in
Test_enforcer_DigestByPolicy: same digest from both verifiers now returns the digest with no deny, and different digests still deny with the same error as before. The agreeing case fails on main and passes with the change. I added the notary mock wiring to the existing table since no case had exercised the trust branch, plus a trust-only allow and a trust deny while I was there. The one-line assert change is sowantDigestworks for cases without a simple mock.make copyright-checkwanted the year on the second line, that's the header change.go test ./pkg/controller/multi/,go vet, andgofmtare clean.