Skip to content

Tokenize Credential Request#782

Draft
desmax74 wants to merge 1 commit into
trustification:release/2.y.zfrom
desmax74:occ
Draft

Tokenize Credential Request#782
desmax74 wants to merge 1 commit into
trustification:release/2.y.zfrom
desmax74:occ

Conversation

@desmax74
Copy link
Copy Markdown
Collaborator

@desmax74 desmax74 commented May 11, 2026

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:

  • Add configurable cloudProvider and cloudCredentials values for AWS and GCP to the redhat-trusted-profile-analyzer Helm values.
  • Add a CredentialsRequest template that generates provider-specific credentials for AWS or GCP and exposes them via a secret to the chart.
  • Add a sample Deployment manifest that consumes generated AWS credentials as environment variables.
  • Add a development AWS CredentialsRequest manifest under devel/cco for local or example usage.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 11, 2026

Reviewer's Guide

Adds 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

Change Details Files
Introduce configurable cloud provider and credentials options in Helm values for use by credential requests.
  • Added cloudProvider value to select between aws and gcp (with comment noting azure placeholder).
  • Added cloudCredentials.aws.section with default statementEntries structure for IAM policy configuration.
  • Added cloudCredentials.gcp.permissions list for defining required GCP IAM permissions.
helm-charts/redhat-trusted-profile-analyzer/values.yaml
Add a templated CredentialsRequest resource that emits provider-specific specs for AWS and GCP using values.yaml configuration.
  • Created credentialrequest.yaml Helm template defining a CredentialsRequest bound to a per-release secretRef.
  • Implemented conditional templating based on .Values.cloudProvider to render AWSProviderSpec or GCPProviderSpec.
  • Injected default AWS S3 permissions and merged additional statementEntries from values, and rendered GCP predefinedRoles from configured permissions.
helm-charts/redhat-trusted-profile-analyzer/templates/credentialrequest.yaml
Wire generated cloud credentials secret into the application Deployment as environment variables for AWS.
  • Added a Deployment template that names the workload as the Helm release.
  • Configured container env vars AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to read from the generated cloud-creds secret keys.
helm-charts/redhat-trusted-profile-analyzer/templates/deployment.yaml
Provide a standalone development/example CredentialsRequest manifest for AWS.
  • Added a devel/cco/credentialRequest.yaml example manifest targeting AWSProviderSpec.
  • Defined a sample secretRef and minimal S3 permission actions for local/development usage.
devel/cco/credentialRequest.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@desmax74 desmax74 marked this pull request as draft May 11, 2026 16:26
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 4 issues, and left some high level feedback:

  • 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +82 to +85
aws:
statementEntries:
- effect: Allow
action: [ "s3:*" ]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 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.

Comment on lines +11 to +20
{{- if eq .Values.cloudProvider "aws" }}
providerSpec:
apiVersion: cloudcredential.openshift.io/v1
kind: AWSProviderSpec
statementEntries:
- effect: Allow
action:
- "s3:GetObject"
- "s3:PutObject"
- "s3:ListBucket"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment on lines +23 to +27
{{- else if eq .Values.cloudProvider "gcp" }}
providerSpec:
apiVersion: cloudcredential.openshift.io/v1
kind: GCPProviderSpec
predefinedRoles:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +11 to +20
- 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@desmax74 desmax74 force-pushed the occ branch 2 times, most recently from a21b447 to 12dda7c Compare May 12, 2026 07:38
Signed-off-by: desmax74 <mdessi@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant