Skip to content

PROJQUAY-11867: fix(apis): restrict secretRef to tls component only - #1281

Open
Rachimypala-RM wants to merge 3 commits into
quay:masterfrom
Rachimypala-RM:PROJQUAY-11867-secretref-tls-only
Open

PROJQUAY-11867: fix(apis): restrict secretRef to tls component only#1281
Rachimypala-RM wants to merge 3 commits into
quay:masterfrom
Rachimypala-RM:PROJQUAY-11867-secretref-tls-only

Conversation

@Rachimypala-RM

Copy link
Copy Markdown

secretRef was exposed on the generic Component struct without any kind-level guard, allowing it to be set on components such as postgres, redis, and clair where it has no effect. The only consumer of SecretRef in the codebase is GetTLSSecretRef, which already gates on kind == tls.

Add a supportsSecretRef allowlist (tls only), a new CEL admission rule that rejects secretRef on any component whose kind is not tls, and a ValidateOverrides runtime check that fires during reconciliation as a belt-and-suspenders guard.

@openshift-ci

openshift-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown

Hi @Rachimypala-RM. Thanks for your PR.

I'm waiting for a quay member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Enterprise

Run ID: aabbd512-eecb-48e0-a555-62431c82317b

📥 Commits

Reviewing files that changed from the base of the PR and between 1c1aaa9 and d31058c.

📒 Files selected for processing (4)
  • apis/quay/v1/quayregistry_types.go
  • apis/quay/v1/quayregistry_types_test.go
  • bundle/manifests/quayregistries.crd.yaml
  • config/crd/bases/quay.redhat.com_quayregistries.yaml
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • quay/quay (manual)
🚧 Files skipped from review as they are similar to previous changes (3)
  • config/crd/bases/quay.redhat.com_quayregistries.yaml
  • bundle/manifests/quayregistries.crd.yaml
  • apis/quay/v1/quayregistry_types.go

Summary by CodeRabbit

Release Notes

  • New Features

    • Added secretRef override support for TLS components, with CRD and runtime validation to prevent secretRef from being set on non-TLS components.
  • Bug Fixes

    • Improved override validation to catch unsupported secretRef usage on other component kinds and return clear error messages.
  • Tests

    • Added and expanded test coverage for allowed and rejected secretRef override scenarios, including component support expectations.

Walkthrough

secretRef override support is restricted to the TLS component through schema validation, runtime override validation, and generated CRD updates. ComponentSupportsOverride now recognizes "secretRef" with a TLS-only allowlist. Tests were expanded to cover accepted and rejected component cases.

Changes

secretRef override restricted to TLS component

Layer / File(s) Summary
Schema and override support
apis/quay/v1/quayregistry_types.go
Adds a TLS-only allowlist for secretRef, updates the component XValidation rule to reject non-TLS secretRef, and extends ComponentSupportsOverride to handle "secretRef".
Runtime override checks
apis/quay/v1/quayregistry_types.go
ValidateOverrides now checks each component's top-level secretRef and errors when that component kind does not support the override.
Tests and generated CRDs
apis/quay/v1/quayregistry_types_test.go, bundle/manifests/quayregistries.crd.yaml, config/crd/bases/quay.redhat.com_quayregistries.yaml
Tests cover allowed and rejected secretRef cases, and both generated CRD manifests add the matching CEL validation rule.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: restricting secretRef to the tls component only.
Description check ✅ Passed The description is directly related to the change and accurately describes the new guardrails around secretRef.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@fullsend-ai-review

Copy link
Copy Markdown

🤖 Review · Started 5:39 PM UTC
Commit: 0a60f80 · View workflow run →

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 `@apis/quay/v1/quayregistry_types.go`:
- Line 160: The kubebuilder validation marker with the CEL rule restricting
secretRef to the tls component has been added to the quayregistry_types.go
source file but the generated CRD has not been regenerated to include this
constraint. Regenerate the CRD manifest files by running the appropriate
kubebuilder code generation command (typically make manifests or similar in your
project build system) to ensure the new XValidation rule from the marker at line
160 is properly included in the generated CRD output, so the admission
validation is enforced at runtime.
🪄 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 UI

Review profile: CHILL

Plan: Enterprise

Run ID: 5a9774fa-209b-41d2-93bc-57298f6abd4e

📥 Commits

Reviewing files that changed from the base of the PR and between ac2492d and 0a60f80.

📒 Files selected for processing (1)
  • apis/quay/v1/quayregistry_types.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • quay/quay (manual)

Comment thread apis/quay/v1/quayregistry_types.go
@fullsend-ai-review

fullsend-ai-review Bot commented Jun 17, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 5:47 PM UTC · Completed 5:57 PM UTC
Commit: d877d33 · View workflow run →

@jbpratt jbpratt changed the title apis: restrict secretRef to tls component only (PROJQUAY-11867) PROJQUAY-11867: fix(apis): restrict secretRef to tls component only Jun 17, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

@Rachimypala-RM: This pull request references [Jira Issue PROJQUAY-11867](https://redhat.atlassian.net/browse/PROJQUAY-11867), which is invalid:

  • expected the bug to target the "quay-v3.18.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

secretRef was exposed on the generic Component struct without any kind-level guard, allowing it to be set on components such as postgres, redis, and clair where it has no effect. The only consumer of SecretRef in the codebase is GetTLSSecretRef, which already gates on kind == tls.

Add a supportsSecretRef allowlist (tls only), a new CEL admission rule that rejects secretRef on any component whose kind is not tls, and a ValidateOverrides runtime check that fires during reconciliation as a belt-and-suspenders guard.

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 openshift-eng/jira-lifecycle-plugin repository.

@fullsend-ai-review

fullsend-ai-review Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review

Findings

Medium

  • [missing-test] apis/quay/v1/quayregistry_types.go:551 — No unit tests are included for the new secretRef validation logic in ValidateOverrides. The existing test table validateOverridesTests in quayregistry_types_test.go has no test cases exercising the new secretRef guard. Neither the positive case (secretRef on TLS accepted) nor the negative case (secretRef on non-TLS rejected) is tested.
    Remediation: Add test cases to validateOverridesTests covering secretRef on TLS (accepted) and non-TLS (rejected) components.

  • [backward-incompatible] config/crd/bases/quay.redhat.com_quayregistries.yaml:1214 — New CEL validation rule rejects QuayRegistry resources with secretRef on non-TLS components. Existing resources with secretRef on postgres, redis, or clair components will fail validation on update after CRD upgrade. Practical risk is limited since secretRef on non-TLS components was never functional (GetTLSSecretRef already ignores them), but this is technically a breaking validation change.
    Remediation: Document as a potentially breaking change in release notes. Note that since secretRef on non-TLS components was never functional, real-world impact is limited to misconfigurations.

Low

  • [api-contract] apis/quay/v1/quayregistry_types.go:551 — The secretRef check dispatches through ComponentSupportsOverride, but secretRef is not an override — it is a separate top-level field on the Component struct. This overloads the semantics of ComponentSupportsOverride to cover a non-override field.

  • [naming-convention] apis/quay/v1/quayregistry_types.go:131 — Variable name supportsSecretRef does not follow established naming convention. All similar allowlist variables use the suffix Override (e.g., supportsVolumeOverride, supportsEnvOverride, supportsSecurityContextOverride).
    Remediation: Rename to supportsSecretRefOverride to maintain consistency.

  • [error-handling-idiom] apis/quay/v1/quayregistry_types.go:556 — Error message format does not match established pattern. All existing validation errors use "component %s does not support <field> overrides", but the new message omits overrides.
    Remediation: Change to "component %s does not support secretRef overrides" to match the established pattern.

  • [backward-incompatible] apis/quay/v1/quayregistry_types.go:551 — During operator upgrades, if the operator is upgraded before the CRD, existing resources with secretRef on non-TLS components will pass admission but fail during reconciliation. This is a standard OLM upgrade ordering concern; OLM bundles typically apply CRDs before operator deployments.
    Remediation: Document CRD upgrade ordering in release notes.

  • [incomplete-doc] apis/quay/v1/quayregistry_types.go:165 — SecretRef field godoc reads as an example use case ("For the TLS component, this references...") rather than an explicit restriction. Given the new validation, the doc should clearly state TLS-only support.
    Remediation: Update godoc to explicitly state the restriction, e.g., "SecretRef is only valid for the TLS component."

Info

  • [missing-authorization] — PR references external Jira issue PROJQUAY-11867 which cannot be fetched for verification. The Jira reference is present in the PR title, satisfying the project's mechanical requirement.

  • [scope-alignment] — Change is consistent with codebase usage. GetTLSSecretRef already enforces kind == ComponentTLS. The implementation follows established allowlist + CEL + runtime validation patterns.

@codecov-commenter

codecov-commenter commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.41%. Comparing base (a0c7313) to head (d31058c).
⚠️ Report is 24 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1281      +/-   ##
==========================================
+ Coverage   65.35%   65.41%   +0.05%     
==========================================
  Files          26       26              
  Lines        4327     4334       +7     
==========================================
+ Hits         2828     2835       +7     
  Misses       1499     1499              
Flag Coverage Δ
unit-tests 65.41% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
apis/quay/v1/quayregistry_types.go 42.45% <100.00%> (+0.96%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fullsend-ai-review fullsend-ai-review Bot added the requires-manual-review Review requires human judgment label Jun 17, 2026
@jbpratt

jbpratt commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

/jira refresh

@openshift-ci-robot

openshift-ci-robot commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

@jbpratt: This pull request references [Jira Issue PROJQUAY-11867](https://redhat.atlassian.net/browse/PROJQUAY-11867), which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (quay-v3.18.0) matches configured target version for branch (quay-v3.18.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

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 openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Rachimypala-RM could we also get some unit tests to validate this fix? Thank you!

@jbpratt
jbpratt force-pushed the PROJQUAY-11867-secretref-tls-only branch from d877d33 to 1c1aaa9 Compare June 17, 2026 20:08
Rachimypala-RM and others added 3 commits June 24, 2026 02:49
secretRef was exposed on the generic Component struct without any
kind-level guard, allowing it to be set on components such as postgres,
redis, and clair where it has no effect. The only consumer of SecretRef
in the codebase is GetTLSSecretRef, which already gates on kind == tls.

Add a supportsSecretRef allowlist (tls only), a new CEL admission rule
that rejects secretRef on any component whose kind is not tls, and a
ValidateOverrides runtime check that fires during reconciliation as a
belt-and-suspenders guard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The XValidation marker added to Component in quayregistry_types.go was
not reflected in the generated CRD manifests. Manually patched both
bundle/manifests/quayregistries.crd.yaml and
config/crd/bases/quay.redhat.com_quayregistries.yaml to include the new
x-kubernetes-validations entry that rejects secretRef on any component
kind other than tls, matching the source marker exactly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…triction

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jbpratt
jbpratt force-pushed the PROJQUAY-11867-secretref-tls-only branch from 1c1aaa9 to d31058c Compare June 24, 2026 07:55
@jbpratt

jbpratt commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@openshift-ci

openshift-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown

PR needs rebase.

Details

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants