-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: refactor error messages for cosign verification #230
base: refactor-error-msg
Are you sure you want to change the base?
Conversation
0e31b2f
to
dd98fe2
Compare
86e32c9
to
fac5b5a
Compare
c258392
to
65617a1
Compare
99bd939
to
7bd896d
Compare
pkg/verifier/cosign/cosign.go
Outdated
} | ||
|
||
config, err := parseVerifierConfig(verifierConfig) | ||
if err != nil { | ||
return nil, re.ErrorCodeConfigInvalid.WithComponentType(re.Verifier).WithPluginName(verifierName) | ||
return nil, re.ErrorCodeConfigInvalid.WithDetail("Failed to create Cosign Verifier").WithError(err) |
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.
return nil, re.ErrorCodeConfigInvalid.WithDetail("Failed to create Cosign Verifier").WithError(err) | |
return nil, re.ErrorCodeConfigInvalid.WithDetail("Failed to create the Cosign Verifier").WithError(err) |
pkg/verifier/cosign/trustpolicy.go
Outdated
} | ||
cosignOpts.RootCerts = roots | ||
if tp.config.Keyless.CTLogVerify != nil && *tp.config.Keyless.CTLogVerify { | ||
cosignOpts.CTLogPubKeys, err = cosign.GetCTLogPubs(ctx) | ||
if err != nil { | ||
return cosignOpts, fmt.Errorf("failed to fetch certificate transparency log public keys: %w", err) | ||
return cosignOpts, re.ErrorCodeVerifyPluginFailure.WithDetail("Failed to fetch certificate transparency log public keys").WithError(err).WithRemediation("Please check if TUF root is experiencing any outages") |
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.
return cosignOpts, re.ErrorCodeVerifyPluginFailure.WithDetail("Failed to fetch certificate transparency log public keys").WithError(err).WithRemediation("Please check if TUF root is experiencing any outages") | |
return cosignOpts, re.ErrorCodeVerifyPluginFailure.WithDetail("Failed to fetch public keys of the certificate transparency log").WithError(err).WithRemediation("Please check if TUF root is available") |
pkg/verifier/cosign/trustpolicy.go
Outdated
} | ||
} else { | ||
cosignOpts.IgnoreSCT = true | ||
} | ||
cosignOpts.IntermediateCerts, err = fulcio.GetIntermediates() | ||
if err != nil { | ||
return cosignOpts, fmt.Errorf("failed to get fulcio intermediate certificates: %w", err) | ||
return cosignOpts, re.ErrorCodeVerifyPluginFailure.WithDetail("Failed to get fulcio intermediate certificates").WithError(err).WithRemediation("Please check if Fulcio is experiencing any outages") |
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.
return cosignOpts, re.ErrorCodeVerifyPluginFailure.WithDetail("Failed to get fulcio intermediate certificates").WithError(err).WithRemediation("Please check if Fulcio is experiencing any outages") | |
return cosignOpts, re.ErrorCodeVerifyPluginFailure.WithDetail("Failed to get fulcio intermediate certificates").WithError(err).WithRemediation("Please check if Fulcio is available") |
} | ||
|
||
for _, keyConfig := range config.Keys { | ||
// check if the key is defined by file path or by key management provider | ||
if keyConfig.File == "" && keyConfig.Provider == "" { | ||
return re.ErrorCodeConfigInvalid.WithComponentType(re.Verifier).WithPluginName(verifierName).WithDetail(fmt.Sprintf("trust policy %s failed: key management provider name is required when not using file path", config.Name)) | ||
return re.ErrorCodeConfigInvalid.WithDetail(fmt.Sprintf("Invalid trust policy %s: key management provider name is required when not using file path", config.Name)) |
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.
return re.ErrorCodeConfigInvalid.WithDetail(fmt.Sprintf("Invalid trust policy %s: key management provider name is required when not using file path", config.Name)) | |
return re.ErrorCodeConfigInvalid.WithDetail(fmt.Sprintf("Invalid trust policy %s: key management provider name is required if not using file path", config.Name)) |
} | ||
|
||
if config.Name == "" { | ||
return re.ErrorCodeConfigInvalid.WithComponentType(re.Verifier).WithPluginName(verifierName).WithDetail("missing trust policy name") | ||
return re.ErrorCodeConfigInvalid.WithDetail("name parameter is required in trust policy configuration").WithRemediation("Please provide a name for the trust policy.") |
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.
return re.ErrorCodeConfigInvalid.WithDetail("name parameter is required in trust policy configuration").WithRemediation("Please provide a name for the trust policy.") | |
return re.ErrorCodeConfigInvalid.WithDetail("The name parameter is required in trust policy configuration").WithRemediation("Please provide a name for the trust policy.") |
} | ||
|
||
if len(config.Scopes) == 0 { | ||
return re.ErrorCodeConfigInvalid.WithComponentType(re.Verifier).WithPluginName(verifierName).WithDetail(fmt.Sprintf("trust policy %s failed: no scopes defined", config.Name)) | ||
return re.ErrorCodeConfigInvalid.WithDetail(fmt.Sprintf("scopes parameter is required in trust policy configuration %s", config.Name)).WithRemediation("Please provide at least one scope for the trust policy.") |
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.
return re.ErrorCodeConfigInvalid.WithDetail(fmt.Sprintf("scopes parameter is required in trust policy configuration %s", config.Name)).WithRemediation("Please provide at least one scope for the trust policy.") | |
return re.ErrorCodeConfigInvalid.WithDetail(fmt.Sprintf("The scopes parameter is required in trust policy configuration %s", config.Name)).WithRemediation("Please provide at least one scope for the trust policy.") |
0c99179
to
51d56e5
Compare
b10327e
to
2a44030
Compare
…ject#1779) Co-authored-by: Binbin Li <[email protected]>
Description
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, using
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when the PR gets merged):Fixes #
Type of change
Please delete options that are not relevant.
main
branch)How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration
Checklist:
Post Merge Requirements
Helm Chart Change