fix(security): use secretKeyRef for S3 credentials - #678
fix(security): use secretKeyRef for S3 credentials#678platex-rehor-bot wants to merge 4 commits into
Conversation
RHCLOUD-49507 Replace literal env values with valueFrom.secretKeyRef for PUSHCACHE_AWS_ACCESS_KEY_ID and PUSHCACHE_AWS_SECRET_ACCESS_KEY in generated Deployments and Jobs. The operator now creates a managed pushcache-s3-credentials Secret and all containers reference it instead of embedding credentials as plain text. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@platex-rehor-bot can you fix up the linter? |
RHCLOUD-49507 The constant is a Kubernetes Secret resource name, not a hardcoded credential. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Fixed — suppressed the gosec G101 false positive on the |
There was a problem hiding this comment.
Hey @platex-rehor-bot — solid security improvement! A few questions about the approach:
-
Missing owner reference on
pushcache-s3-credentialsSecret: I noticedensurePushCacheCredentialsSecret()doesn't callSetOwnerReferences(), unlike every other resource the reconciler creates (Deployments, ConfigMaps, Jobs, etc.). Was this intentional — e.g. because the Secret is shared across multiple Frontends and shouldn't be owned by a single one? Or was it an oversight? Curious about your thinking here. -
deploy.ymlsecretKeyRef withoutoptional: true: The operator's Deployment now requires a pre-existingpushcache-aws-credentialsSecret to start. In Clowder environments, credentials come fromenv-<ns>-minioinstead. Was there a reason not to setoptional: trueon the secretKeyRef, or is the expectation that Clowder environments don't usedeploy.ymlat all? -
compareEnvVarsonly handlesSecretKeyRef: The updated comparison logic checksValueFrom.SecretKeyRefbut doesn't handleConfigMapKeyRef,FieldRef, orResourceFieldRef. Was this a deliberate scope decision (only comparing what's currently used), or would you want to handle those for completeness?
Just want to understand the reasoning. Thanks!
…pareEnvVars RHCLOUD-49507 - Move secretKeyRef changes from deploy.yml to kustomize source (config/deployment-template/manager.yaml) and template.yml so `make build-template` stays in sync. Fixes Konflux CI failure. - Replace PUSHCACHE_AWS_ACCESS_KEY_ID/SECRET_ACCESS_KEY template params with PUSHCACHE_AWS_SECRET_NAME (Secret resource name). - Extend compareEnvVars to handle ConfigMapKeyRef, FieldRef, and ResourceFieldRef for completeness alongside existing SecretKeyRef. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for the thorough review, @tahmidefaz! Great questions — here's the reasoning for each: 1. Missing owner reference on Intentional. The Secret is shared across all Frontends in the namespace — every Frontend reconciler calls
2.
Leaving 3. Originally a deliberate scope decision (only comparing what's currently used). But your point about completeness is valid — if the function is called Pushed |
Summary
Resolves RHCLOUD-49507 — AWS S3 credentials (
PUSHCACHE_AWS_ACCESS_KEY_ID,PUSHCACHE_AWS_SECRET_ACCESS_KEY) were embedded as literalvalue:entries in generated Deployment and Job specs, making them visible to any namespace viewer.Changes
controllers/reconcile.go: AddedensurePushCacheCredentialsSecret()helper that creates/updates an opaquepushcache-s3-credentialsSecret, andpushCacheCredentialEnvVars()returning env vars withvalueFrom.secretKeyRef. ModifiedpopulatePushCacheContainer()to use env-var expansion ($PUSHCACHE_AWS_ACCESS_KEY_ID) in the valpop command instead of literal credentials.controllers/reconcile_reverse_proxy.go: ChangedcreateReverseProxyContainer()to source S3 credentials from the managed Secret viasecretKeyRefinstead of literal values. UpdatedcompareEnvVars()to handleValueFromcomparison. Switched fromExtractBucketConfigFromEnv()togetObjectStoreConfig()for Clowder secret fallback support.deploy.yml: Operator's own Deployment template now references a${PUSHCACHE_AWS_SECRET_NAME}Secret (default:pushcache-aws-credentials) viasecretKeyRefinstead of literal template parameter values.secretKeyRefenv vars.Deployment note
The operator's own Deployment now expects a pre-existing Secret named by the
PUSHCACHE_AWS_SECRET_NAMEparameter (defaultpushcache-aws-credentials) in the operator namespace, containing keysaws-access-key-idandaws-secret-access-key. This Secret must be provisioned by the deployment infrastructure (e.g. app-interface / Vault) before the operator pod starts.🤖 Generated with Claude Code