Skip to content

Commit

Permalink
passing kms options through for use in policy verification
Browse files Browse the repository at this point in the history
Signed-off-by: chaosinthecrd <[email protected]>
  • Loading branch information
ChaosInTheCRD committed Jun 24, 2024
1 parent c5be47a commit 79afd67
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
42 changes: 27 additions & 15 deletions cmd/keyloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ func providersFromFlags(prefix string, flags *pflag.FlagSet) map[string]struct{}
return
}

// we want to only initialize KMS provider if the ref is supplied
if parts[1] == "kms" {
if len(parts) < 3 {
return
}

if parts[2] != "ref" {
return
}
}

providers[parts[1]] = struct{}{}
})

Expand Down Expand Up @@ -99,30 +110,31 @@ func loadVerifiers(ctx context.Context, so options.VerifierOptions, ko options.K

// NOTE: We want to initialze the KMS provider specific options if a KMS signer has been invoked
if ksp, ok := sp.(*kms.KMSSignerProvider); ok {
var vp signer.SignerProvider
for _, opt := range ksp.Options {
pn := opt.ProviderName()
for _, setter := range ko[pn] {
vp, err := setter(ksp)
vp, err = setter(ksp)
if err != nil {
continue
}
}
}

// NOTE: KMS SignerProvider can also be a VerifierProvider. This is a nasty hack to cast things back in a way that we can add to the loaded verifiers.
// This must be refactored.
kspv, ok := vp.(*kms.KMSSignerProvider)
if !ok {
return nil, fmt.Errorf("provided verifier provider is not a KMS verifier provider")
}
// NOTE: KMS SignerProvider can also be a VerifierProvider. This is a nasty hack to cast things back in a way that we can add to the loaded verifiers.
// This must be refactored.
kspv, ok := vp.(*kms.KMSSignerProvider)
if !ok {
return nil, fmt.Errorf("provided verifier provider is not a KMS verifier provider")
}

s, err := kspv.Verifier(ctx)
if err != nil {
log.Errorf("failed to create %v verifier: %w", verifierProvider, err)
continue
}
verifiers = append(verifiers, s)
return verifiers, nil
}
s, err := kspv.Verifier(ctx)
if err != nil {
log.Errorf("failed to create %v verifier: %w", verifierProvider, err)
continue
}
verifiers = append(verifiers, s)
return verifiers, nil
}

s, err := sp.Verifier(ctx)
Expand Down
1 change: 1 addition & 0 deletions cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func runVerify(ctx context.Context, vo options.VerifyOptions, verifiers ...crypt
witness.VerifyWithPolicyCAIntermediates(policyIntermediates),
witness.VerifyWithPolicyCertConstraints(vo.PolicyCommonName, vo.PolicyDNSNames, vo.PolicyEmails, vo.PolicyOrganizations, vo.PolicyURIs),
witness.VerifyWithPolicyFulcioCertExtensions(vo.PolicyFulcioCertExtensions),
witness.VerifyWithKMSProviderOptions(vo.KMSVerifierProviderOptions),

Check failure on line 199 in cmd/verify.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: witness.VerifyWithKMSProviderOptions

Check failure on line 199 in cmd/verify.go

View workflow job for this annotation

GitHub Actions / Verify Docgen

undefined: witness.VerifyWithKMSProviderOptions

Check failure on line 199 in cmd/verify.go

View workflow job for this annotation

GitHub Actions / sast / witness

undefined: witness.VerifyWithKMSProviderOptions

Check failure on line 199 in cmd/verify.go

View workflow job for this annotation

GitHub Actions / unit-test / witness

undefined: witness.VerifyWithKMSProviderOptions

Check failure on line 199 in cmd/verify.go

View workflow job for this annotation

GitHub Actions / e2e-test / witness

undefined: witness.VerifyWithKMSProviderOptions
)
if err != nil {
if verifiedEvidence.StepResults != nil {
Expand Down

0 comments on commit 79afd67

Please sign in to comment.