Skip to content

Commit

Permalink
[TEP-0091] add VerificationResult
Browse files Browse the repository at this point in the history
This commit adds VerificationResult struct, the new struct has 2 fields, VerificationResultType and Err. VerificationResultType has 5 types: IgnoreNoMatchPolicy, WarnNoMatchPolicy, VerificationPass, VerificationError, WarnModeVerificationFail.

Signed-off-by: Yongxuan Zhang [email protected]
  • Loading branch information
Yongxuanzhang committed May 16, 2023
1 parent d6c0f69 commit 9dd7a1e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pkg/trustedresources/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,30 @@ const (
SignatureAnnotation = "tekton.dev/signature"
)

const (
IgnoreWhenNoMatchPolicy = iota
WarnWhenNoMatchPolicy
VerificationPass
VerificationError
WarnModeVerificationFail
)

// VerificationResultType indicates different cases of a verification result
type VerificationResultType int

// VerificationResult contains the type and message about the result of verification
type VerificationResult struct {
// VerificationResultType has 5 types which is corresponding to 5 cases:
// 1) IgnoreWhenNoMatchPolicy: There are no matching policies, and verification was skipped. Err is nil in this case.
// 2) WarnWhenNoMatchPolicy: There are no matching policies, and warning is logged.
// 3) VerificationPass: The verification passed. Err is nil in this case.
// 4) VerificationError: The verification failed, it could be the signature doesn't match the public key or there are errors during verification.
// 5) WarnModeVerificationFail: Only Warn mode verification policies fail, there may be no enforce mode policies or all enforce mode policies mode pass.
VerificationResultType VerificationResultType
// Err contains the error message when there is a warning logged or error returned.
Err error
}

// VerifyTask verifies the signature and public key against task.
// Skip the verification when no policies are found and trusted-resources-verification-no-match-policy is set to ignore or warn
// Return an error when no policies are found and trusted-resources-verification-no-match-policy is set to fail,
Expand Down

0 comments on commit 9dd7a1e

Please sign in to comment.