Unify kms provider config for reusability#2326
Conversation
WalkthroughKMS provider config logic is extracted from ChangesKMS provider config extraction
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (13 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ardaguclu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/operator/encryption/controllers/kms_provider_config.go`:
- Around line 43-45: The referencedSecretName method can return an empty string
with required AppRole keys present, which causes the code to silently skip
adding PluginSecretData to the KMSState even though role-id and secret-id are
required downstream. Add validation after the referencedSecretName call (around
line 43-45) to reject cases where secretName is empty but expectedKeys indicates
required AppRole credentials are needed. Check if secretName is empty and
expectedKeys contains required keys like role-id or secret-id, and if so, return
an error rather than continuing to return incomplete KMSState without
PluginSecretData. This ensures required credential references are validated at
the trust boundary using an allow-list approach rather than silently accepting
invalid states.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 0b578376-2a75-4085-99ec-2e2fb68c366c
📒 Files selected for processing (2)
pkg/operator/encryption/controllers/key_controller.gopkg/operator/encryption/controllers/kms_provider_config.go
| if secretName, expectedKeys, err := providerCfg.referencedSecretName(); err != nil { | ||
| return nil, err | ||
| } else if len(secretName) > 0 { |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Reject empty Vault AppRole secret names before returning KMS state.
Line 110 can return "" with required AppRole keys, and Line 45 then treats that as “no secret reference,” returning a KMSState without PluginSecretData. That silently drops the required role-id / secret-id data used downstream.
Proposed fix
func (v *vaultProviderConfig) referencedSecretName() (string, []string, error) {
switch v.vault.Authentication.Type {
case configv1.VaultAuthenticationTypeAppRole:
- return v.vault.Authentication.AppRole.Secret.Name, []string{"role-id", "secret-id"}, nil
+ secretName := v.vault.Authentication.AppRole.Secret.Name
+ if secretName == "" {
+ return "", nil, fmt.Errorf("Vault AppRole secret name must not be empty")
+ }
+ return secretName, []string{"role-id", "secret-id"}, nil
default:
return "", nil, fmt.Errorf("unsupported Vault authentication type %q", v.vault.Authentication.Type)
}
}As per path instructions, “Validate at trust boundaries with allow-lists, not deny-lists.”
Also applies to: 107-110
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pkg/operator/encryption/controllers/kms_provider_config.go` around lines 43 -
45, The referencedSecretName method can return an empty string with required
AppRole keys present, which causes the code to silently skip adding
PluginSecretData to the KMSState even though role-id and secret-id are required
downstream. Add validation after the referencedSecretName call (around line
43-45) to reject cases where secretName is empty but expectedKeys indicates
required AppRole credentials are needed. Check if secretName is empty and
expectedKeys contains required keys like role-id or secret-id, and if so, return
an error rather than continuing to return incomplete KMSState without
PluginSecretData. This ensures required credential references are validated at
the trust boundary using an allow-list approach rather than silently accepting
invalid states.
Source: Path instructions
|
This was a PoC |
|
@ardaguclu: Closed this PR. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Preflight checker will call
KMSPluginStatefunction to get KMSState. After that we need to have another function to convert KMSState to EncryptionConfiguration. This PR aims to pave the way for #2321This PR must not make any logical changes.
Summary by CodeRabbit