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

fix: Passing kms provider options down to initialisation of functionaries #475

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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
Loading