-
Notifications
You must be signed in to change notification settings - Fork 547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix comparison in replace option for attestation #1366
Conversation
I think this broke with #1248 which changed the DSSE envelope to always be the in-toto media type. |
cc @priyawadhwa could you take a look when you get a chance here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this @bburky! Just left a couple nits. It might also be useful to test the --replace
flag so that this type of bug can't be reintroduced.
I think modifying the existing test would probably work:
Line 204 in d2781b8
func TestAttestVerify(t *testing.T) { |
You could try attest a second time with the --replace
flag and make sure the # of attestations on the image is still 1 (if replacement fails, then there should be an additional attestation, on which the test would fail)
lmk if you run into any issues!
@priyawadhwa I can't easily add the test to Edit: actually I see now cosign.FetchAttestationsForReference may work |
I added an e2e test for the the replace option using Somehow this is only failing on I used skopeo to copy real images to a local registry when testing, the replace option works perfectly fine on them. I can reproduce the buggy behavior on the command line with I honestly have no idea what's wrong. This bug predates my changes, it occurs with the v1.5.0 release |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for trying to add the test @bburky ! I left a comment for simplifying the test for now, & if you wouldn't mind maybe you could open an issue for the bug you found.
Looks like DCO got dropped somehow, you'll need to add that back. |
I think everything should be ready now. |
Currently the replace option compares the following when evaluating each signature: r.predicateURI == payloadData["payloadType"] This appears to be comparing the payload's predicateType (e.g a URI "https://example.com/predicate" or "cosign.sigstore.dev/attestation/v1" for custom to the signature's payloadType (which is always "application/vnd.in-toto+json"). Fix this by making the replace option replace all attestations which match the current predicate type. Signed-off-by: Blake Burkhart <[email protected]>
Signed-off-by: Blake Burkhart <[email protected]>
Signed-off-by: Blake Burkhart <[email protected]>
Signed-off-by: Blake Burkhart <[email protected]>
This reverts commit d1784cd. Signed-off-by: Blake Burkhart <[email protected]>
Signed-off-by: Blake Burkhart <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @bburky !
* Fix comparison in replace option for attestation Currently the replace option compares the following when evaluating each signature: r.predicateURI == payloadData["payloadType"] This appears to be comparing the payload's predicateType (e.g a URI "https://example.com/predicate" or "cosign.sigstore.dev/attestation/v1" for custom to the signature's payloadType (which is always "application/vnd.in-toto+json"). Fix this by making the replace option replace all attestations which match the current predicate type. Signed-off-by: Blake Burkhart <[email protected]> * refactor attesatation replace Signed-off-by: Blake Burkhart <[email protected]> * Add e2e test for replace option in attest Signed-off-by: Blake Burkhart <[email protected]> * Cleanup test Signed-off-by: Blake Burkhart <[email protected]> * Revert removal of 2nd replace=true attest test This reverts commit d1784cd. Signed-off-by: Blake Burkhart <[email protected]> * Move attestation replace test to TestAttestationReplace Signed-off-by: Blake Burkhart <[email protected]> Co-authored-by: Blake Burkhart <[email protected]>
* Fix comparison in replace option for attestation Currently the replace option compares the following when evaluating each signature: r.predicateURI == payloadData["payloadType"] This appears to be comparing the payload's predicateType (e.g a URI "https://example.com/predicate" or "cosign.sigstore.dev/attestation/v1" for custom to the signature's payloadType (which is always "application/vnd.in-toto+json"). Fix this by making the replace option replace all attestations which match the current predicate type. Signed-off-by: Blake Burkhart <[email protected]> * refactor attesatation replace Signed-off-by: Blake Burkhart <[email protected]> * Add e2e test for replace option in attest Signed-off-by: Blake Burkhart <[email protected]> * Cleanup test Signed-off-by: Blake Burkhart <[email protected]> * Revert removal of 2nd replace=true attest test This reverts commit d1784cd. Signed-off-by: Blake Burkhart <[email protected]> * Move attestation replace test to TestAttestationReplace Signed-off-by: Blake Burkhart <[email protected]> Co-authored-by: Blake Burkhart <[email protected]>
Summary
Currently the replace option compares
r.predicateURI == payloadData["payloadType"]
when evaluating each signature:cosign/pkg/cosign/remote/remote.go
Line 142 in 21e6b80
This appears to be comparing the payload's
predicateType
(e.g a URIhttps://example.com/predicate
orcosign.sigstore.dev/attestation/v1
for custom) to the signature'spayloadType
(which is always(?)application/vnd.in-toto+json
). This appears to be a bug unless I'm misunderstanding something.Fix this by making the replace option replace all attestations which match the current predicate type. I think this is the intended behavior?
The command line output has been updated to clarify the actions taken, clearly listing all the attestations retained and deleted:
This feature was initially requested in #923 and implemented in #1039.
Ticket Link
No ticket.
Release Note