Tokenize Credential Request#782
Conversation
Reviewer's GuideAdds cloud credentials support via OpenShift CredentialsRequest resources, configurable per cloud provider, and wires the resulting secrets into the Helm deployment for AWS, plus a sample dev-time credential request manifest. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 4 issues, and left some high level feedback:
- The Helm template for
credentialrequest.yamlhas inconsistent indentation and mixed static/dynamicstatementEntries/predefinedRolesblocks, which may produce invalid or unexpected YAML; consider simplifying to either fully static defaults or a cleanly mergedtoYamlblock with carefully aligned indentation. - The
deployment.yamlcurrently hardcodes an AWS-specific secret and environment variables; ifcloudProvidercan be GCP/Azure, it would be better to conditionally inject provider-specific env vars or secrets to avoid misconfigured deployments for non-AWS providers. - The values for AWS (
s3:*) and the hardcodeds3:GetObject/PutObject/ListBucketactions in the credentials request may be redundant or conflicting; aligning the default actions with what the template actually renders will make the permissions model clearer and easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The Helm template for `credentialrequest.yaml` has inconsistent indentation and mixed static/dynamic `statementEntries`/`predefinedRoles` blocks, which may produce invalid or unexpected YAML; consider simplifying to either fully static defaults or a cleanly merged `toYaml` block with carefully aligned indentation.
- The `deployment.yaml` currently hardcodes an AWS-specific secret and environment variables; if `cloudProvider` can be GCP/Azure, it would be better to conditionally inject provider-specific env vars or secrets to avoid misconfigured deployments for non-AWS providers.
- The values for AWS (`s3:*`) and the hardcoded `s3:GetObject`/`PutObject`/`ListBucket` actions in the credentials request may be redundant or conflicting; aligning the default actions with what the template actually renders will make the permissions model clearer and easier to maintain.
## Individual Comments
### Comment 1
<location path="helm-charts/redhat-trusted-profile-analyzer/values.yaml" line_range="82-85" />
<code_context>
+ cloudProvider: aws # aws | gcp | azure
+ cloudCredentials:
+ aws:
+ statementEntries:
+ - effect: Allow
+ action: [ "s3:*" ]
+ resource: "*"
+ gcp:
</code_context>
<issue_to_address>
**🚨 issue (security):** AWS credentials default to full S3 access, which is overly permissive
The default `cloudCredentials.aws.statementEntries` grant `"s3:*"` on all resources, which is effectively admin-level S3 access and may be unacceptable in locked-down environments. Please scope the default to specific buckets and limited actions, or require users to provide these permissions explicitly rather than shipping such broad defaults.
</issue_to_address>
### Comment 2
<location path="helm-charts/redhat-trusted-profile-analyzer/templates/credentialrequest.yaml" line_range="11-20" />
<code_context>
+ name: {{ .Release.Name }}-cloud-creds
+ namespace: {{ .Release.Namespace }}
+
+ {{- if eq .Values.cloudProvider "aws" }}
+ providerSpec:
+ apiVersion: cloudcredential.openshift.io/v1
+ kind: AWSProviderSpec
+ statementEntries:
+ - effect: Allow
+ action:
+ - "s3:GetObject"
+ - "s3:PutObject"
+ - "s3:ListBucket"
+ resource: "*"
+ {{- toYaml .Values.cloudCredentials.aws.statementEntries | nindent 6 }}
+ {{- else if eq .Values.cloudProvider "gcp" }}
</code_context>
<issue_to_address>
**issue (bug_risk):** Indentation and mixed static/dynamic `statementEntries` may yield invalid or duplicated YAML
The `providerSpec` block is over-indented relative to the `if`, and `statementEntries` is both hardcoded and redefined via `toYaml .Values.cloudCredentials.aws.statementEntries | nindent 6`. This can break the YAML structure or create a malformed `statementEntries` field. Please align `providerSpec` with its peers and use a single, consistently indented `statementEntries` definition (either fully templated or merged cleanly).
</issue_to_address>
### Comment 3
<location path="helm-charts/redhat-trusted-profile-analyzer/templates/credentialrequest.yaml" line_range="23-27" />
<code_context>
+ - "s3:ListBucket"
+ resource: "*"
+ {{- toYaml .Values.cloudCredentials.aws.statementEntries | nindent 6 }}
+ {{- else if eq .Values.cloudProvider "gcp" }}
+ providerSpec:
+ apiVersion: cloudcredential.openshift.io/v1
+ kind: GCPProviderSpec
+ predefinedRoles:
+ {{- toYaml .Values.cloudCredentials.gcp.permissions | nindent 6 }}
+ {{- end }}
</code_context>
<issue_to_address>
**issue (bug_risk):** GCP `predefinedRoles` seems to be used with permission strings instead of role names
Here `predefinedRoles` is populated from `cloudCredentials.gcp.permissions`, but those values look like permission strings (e.g. `compute.instances.list`) instead of IAM role IDs (e.g. `roles/...`). Since `GCPProviderSpec.predefinedRoles` requires role names, this is likely to fail or not grant the required access. Either switch to the appropriate field for listing permissions (e.g. `serviceAccountPermissions`) or map these permissions to suitable predefined roles before using this field.
</issue_to_address>
### Comment 4
<location path="helm-charts/redhat-trusted-profile-analyzer/templates/deployment.yaml" line_range="11-20" />
<code_context>
+ containers:
+ - name: my-operator
+ env:
+ - name: AWS_ACCESS_KEY_ID
+ valueFrom:
+ secretKeyRef:
+ name: {{ .Release.Name }}-cloud-creds
+ key: aws_access_key_id
+ - name: AWS_SECRET_ACCESS_KEY
+ valueFrom:
+ secretKeyRef:
+ name: {{ .Release.Name }}-cloud-creds
+ key: aws_secret_access_key
</code_context>
<issue_to_address>
**issue (bug_risk):** Deployment always expects AWS-style secrets even when using non-AWS providers
Env vars are always populated from `{{ .Release.Name }}-cloud-creds` using AWS-specific keys. For `cloudProvider: gcp` (or others), the credentialsRequest will likely create a different secret schema, so this pod won’t receive valid creds. Please gate these env vars on the provider, or introduce provider-specific secret layouts/templates so non-AWS providers don’t break this deployment.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| aws: | ||
| statementEntries: | ||
| - effect: Allow | ||
| action: [ "s3:*" ] |
There was a problem hiding this comment.
🚨 issue (security): AWS credentials default to full S3 access, which is overly permissive
The default cloudCredentials.aws.statementEntries grant "s3:*" on all resources, which is effectively admin-level S3 access and may be unacceptable in locked-down environments. Please scope the default to specific buckets and limited actions, or require users to provide these permissions explicitly rather than shipping such broad defaults.
| {{- if eq .Values.cloudProvider "aws" }} | ||
| providerSpec: | ||
| apiVersion: cloudcredential.openshift.io/v1 | ||
| kind: AWSProviderSpec | ||
| statementEntries: | ||
| - effect: Allow | ||
| action: | ||
| - "s3:GetObject" | ||
| - "s3:PutObject" | ||
| - "s3:ListBucket" |
There was a problem hiding this comment.
issue (bug_risk): Indentation and mixed static/dynamic statementEntries may yield invalid or duplicated YAML
The providerSpec block is over-indented relative to the if, and statementEntries is both hardcoded and redefined via toYaml .Values.cloudCredentials.aws.statementEntries | nindent 6. This can break the YAML structure or create a malformed statementEntries field. Please align providerSpec with its peers and use a single, consistently indented statementEntries definition (either fully templated or merged cleanly).
| {{- else if eq .Values.cloudProvider "gcp" }} | ||
| providerSpec: | ||
| apiVersion: cloudcredential.openshift.io/v1 | ||
| kind: GCPProviderSpec | ||
| predefinedRoles: |
There was a problem hiding this comment.
issue (bug_risk): GCP predefinedRoles seems to be used with permission strings instead of role names
Here predefinedRoles is populated from cloudCredentials.gcp.permissions, but those values look like permission strings (e.g. compute.instances.list) instead of IAM role IDs (e.g. roles/...). Since GCPProviderSpec.predefinedRoles requires role names, this is likely to fail or not grant the required access. Either switch to the appropriate field for listing permissions (e.g. serviceAccountPermissions) or map these permissions to suitable predefined roles before using this field.
| - name: AWS_ACCESS_KEY_ID | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: {{ .Release.Name }}-cloud-creds | ||
| key: aws_access_key_id | ||
| - name: AWS_SECRET_ACCESS_KEY | ||
| valueFrom: | ||
| secretKeyRef: | ||
| name: {{ .Release.Name }}-cloud-creds | ||
| key: aws_secret_access_key |
There was a problem hiding this comment.
issue (bug_risk): Deployment always expects AWS-style secrets even when using non-AWS providers
Env vars are always populated from {{ .Release.Name }}-cloud-creds using AWS-specific keys. For cloudProvider: gcp (or others), the credentialsRequest will likely create a different secret schema, so this pod won’t receive valid creds. Please gate these env vars on the provider, or introduce provider-specific secret layouts/templates so non-AWS providers don’t break this deployment.
a21b447 to
12dda7c
Compare
Signed-off-by: desmax74 <mdessi@redhat.com>
Assisted-by: Claude: Opus 4.6
Summary by Sourcery
Introduce cloud-provider-specific credential requests and wire them into the trusted profile analyzer Helm chart.
New Features: