Skip to content

Compare digest contents when trust and simple signing are both required - #516

Open
arpitjain099 wants to merge 1 commit into
IBM:mainfrom
arpitjain099:fix/dual-signing-digest-compare
Open

Compare digest contents when trust and simple signing are both required#516
arpitjain099 wants to merge 1 commit into
IBM:mainfrom
arpitjain099:fix/dual-signing-digest-compare

Conversation

@arpitjain099

Copy link
Copy Markdown

Fixes #515

A policy with trust.enabled: true and 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:

Notary signs conflicting digest: sha256:cafe0000 simple: sha256:cafe0000

notaryDigest != digest compares two *bytes.Buffer pointers, 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 so wantDigest works for cases without a simple mock.

make copyright-check wanted the year on the second line, that's the header change.

go test ./pkg/controller/multi/, go vet, and gofmt are clean.

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

Policy requiring both trust and simple signing always denies with a conflicting digest error

1 participant