Skip to content

Commit f22fed4

Browse files
Logger should only be logged if the truststores and identities are present.
Signed-off-by: Jagpreet Singh Tamber <[email protected]>
1 parent 7d1e19e commit f22fed4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/oci/notation/notation.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,16 @@ func NewNotationVerifier(opts ...Options) (*NotationVerifier, error) {
193193
// SignatureVerification.VerificationLevel is set to trustpolicy.LevelSkip.Name.
194194
// If it is, it logs a warning message and removes the trust stores and trusted identities for that trust policy statement.
195195
// Finally, it returns the modified trustPolicy.
196-
func cleanTrustPolicy(trustPolicy *trustpolicy.Document, logger logr.Logger) *trustpolicy.Document {
196+
func CleanTrustPolicy(trustPolicy *trustpolicy.Document, logger logr.Logger) *trustpolicy.Document {
197197
if trustPolicy == nil {
198198
return nil
199199
}
200200

201201
for i, j := range trustPolicy.TrustPolicies {
202202
if j.SignatureVerification.VerificationLevel == trustpolicy.LevelSkip.Name {
203-
logger.Info(fmt.Sprintf("warning: trust policy statement '%s' is set to skip signature verification but configured with trust stores and/or trusted identities. Removing trust stores and trusted identities", j.Name))
203+
if len(j.TrustStores) > 0 || len(j.TrustedIdentities) > 0 {
204+
logger.Info(fmt.Sprintf("warning: trust policy statement '%s' is set to skip signature verification but configured with trust stores and/or trusted identities. Removing trust stores and trusted identities", j.Name))
205+
}
204206
trustPolicy.TrustPolicies[i].TrustStores = []string{}
205207
trustPolicy.TrustPolicies[i].TrustedIdentities = []string{}
206208
}

0 commit comments

Comments
 (0)