Skip to content
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

Instead of continuing when Attestation data is not present, this shou… #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

trmiller
Copy link
Collaborator

…ld be failing with a clear error. Otherwise it will incorrectly return success

…ld be failing with a clear error. Otherwise it will incorrectly return success
@trmiller
Copy link
Collaborator Author

@sudo-bmitch PTAL - I think the previous change inadvertently marked the request successful, where as this should fail, just not crash like it was.

Copy link
Member

@pxp928 pxp928 left a comment

Choose a reason for hiding this comment

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

LGTM

@sudo-bmitch
Copy link
Contributor

Thinking through this, the for loop on 35 feels like the issue. We continue if the uuid's don't match. It's a success if the for loop is empty or only has bad uuid entries. It fails if any one of the entries is bad. And I'm guessing we want logic that succeeds if any entry matches, and fails for all other scenarios.

@sudo-bmitch
Copy link
Contributor

Here's a diff of the option I'm thinking of:

$ git diff
diff --git a/cmd/cli/rekor/rekoruuid_validator.go b/cmd/cli/rekor/rekoruuid_validator.go
index bea88ab..0bc4ba0 100644
--- a/cmd/cli/rekor/rekoruuid_validator.go
+++ b/cmd/cli/rekor/rekoruuid_validator.go
@@ -69,9 +69,11 @@ func Validate(vendorFile config.VendorFile, downloadedFile string) (err error) {
                        }
                        return err
                }
+               // valid entry found
+               return nil
        }
 
-       return nil
+       return fmt.Errorf("no valid rekor entries found, payload contained %v", resp.Payload)
 }
 
 type ImageValidationError struct {

However, that does trigger an error with the validation we're trying to run. Looking at the log entry, Attestation is allowed to be nil and is not marked as a required field, so I suspect we want to validate based on the Body which is required:
https://pkg.go.dev/github.com/sigstore/[email protected]/pkg/generated/models#LogEntryAnon

Looking at that body field in at least one failing command, it appears to be base64 encoded data, but since it's an empty interface, we probably can't assume it will always be the same format:

...
Error: no valid rekor entries found, payload contained map[de02942bd2a6ebca8c094b7e69d31ccb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RE00TmxORGIwY3daWGRKU0RWTlFqZ3JSMnBKUkVkQmNsVlZURk5FWm1wbVRUTXhSV0ZsTHpjeGEyRjJRVlZKTUU5QlBUMEtMUzB0TFMxRlRrUWdVRlZDVEVsRElFdEZXUzB0TFMwdENnPT0ifX0=
{"apiVersion":"0.0.1","kind":"intoto","spec":{"content":{"hash":{"algorithm":"sha256","value":"02f2ced05585c66655f8893795743f96871ea222a887f5c66df5e2fd2a1dff01"}},"publicKey":"LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFbkxOdzNSWXg5eFFqWGJVRXc4dm9uWDNVNCt0QgprUG5KcSt6dDM4NlNDb0cwZXdJSDVNQjgrR2pJREdBclVVTFNEZmpmTTMxRWFlLzcxa2F2QVVJME9BPT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg=="}}

TL;DR we can prevent the false positives, but I think there's still work to validate when Attestation is nil to prevent false negatives.

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