Skip to content

CNTRLPLANE-3429: Respect configured cipher order for inject-tls#1386

Open
vincentdephily wants to merge 2 commits into
openshift:mainfrom
vincentdephily:vdp-respect-cipher-order
Open

CNTRLPLANE-3429: Respect configured cipher order for inject-tls#1386
vincentdephily wants to merge 2 commits into
openshift:mainfrom
vincentdephily:vdp-respect-cipher-order

Conversation

@vincentdephily

@vincentdephily vincentdephily commented May 7, 2026

Copy link
Copy Markdown

Cipher order is meaningful, don't sort alphabetically.

  • Remove unwanted string sort
  • Adjust unittests
  • Tweak logs

Summary by CodeRabbit

  • Bug Fixes

    • TLS injection now preserves cipher-suite order from the APIServer profile, skips unsupported config entries, and logs the detected config kind (operator or controller) and accepted kinds.
    • Observation no longer sorts observed cipher suites.
  • Tests

    • Fixtures and helpers updated to treat cipher order as significant, validate injection/update behavior (including reversed-order cases), and cover both operator and controller config kinds.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 7, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@vincentdephily: This pull request explicitly references no jira issue.

Details

In response to this:

Cipher order is meaningful, don't sort alphabetically.

  • Remove unwanted string sort
  • Adjust unittests
  • Tweak logs

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.

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 0eeec9d7-b18a-4dfd-871e-ccdc06859c07

📥 Commits

Reviewing files that changed from the base of the PR and between 7e9dbd4 and f8e2063.

📒 Files selected for processing (3)
  • lib/resourcebuilder/core.go
  • lib/resourcebuilder/core_test.go
  • lib/resourcebuilder/resourcebuilder_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • lib/resourcebuilder/resourcebuilder_test.go
  • lib/resourcebuilder/core.go
  • lib/resourcebuilder/core_test.go

Walkthrough

Core TLS injection records each parsed RNode kind (operator or controller) and uses it for kind-specific handling; observed cipher-suite order is preserved; tests and helpers were refactored to assert order-preserving TLS injection.

Changes

TLS Injection Logic & Cipher Suite Ordering

Layer / File(s) Summary
Core kind detection & logging
lib/resourcebuilder/core.go
Capture parsed RNode kind into rnodeKind, use it for supported-kind switching and logging, and remove the now-unused sort import.
Preserve observed cipher order
lib/resourcebuilder/core.go
observeTLSConfiguration no longer sorts cipherSuites; the observed order is stored into returned tlsConfig.
Test helpers & fixtures
lib/resourcebuilder/core_test.go
Replace sorted default-cipher helper with unsorted getDefaultCipherSuites(), split cipher fixtures into IANA (YAML) and OpenSSL (API) lists, and refactor makeConfigMap/makeAPIServerConfig signatures.
Test cases updated for order-preserving behavior
lib/resourcebuilder/core_test.go
Remove sorting from validation comparisons, update many TestModifyConfigMap scenarios and expectations so cipher order is significant; repurpose the reversed-order case to expect injection and validate resulting order.
Builder test table updates
lib/resourcebuilder/resourcebuilder_test.go
Adjust TestModifyConfigMapWithBuilder entries to use new helper inputs and expected YAML reflecting the updated TLS injection behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Test Structure And Quality ❓ Inconclusive The custom check specifies Ginkgo test code review requirements (It blocks, BeforeEach/AfterEach), but this PR contains standard Go tests using testing.T with no Ginkgo patterns present. Clarify whether the check applies only to Ginkgo tests. If yes, this check is not applicable (tests pass by default). If standard Go tests should be reviewed under similar criteria, they meet all quality requirements demonstrated above.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: respecting configured cipher order for TLS injection, which aligns with the primary objective of removing unwanted string sorting of cipher suites.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.
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.
Stable And Deterministic Test Names ✅ Passed The modified test files use standard Go testing framework, not Ginkgo. The check for Ginkgo test name stability is not applicable to these table-driven unit tests.
Microshift Test Compatibility ✅ Passed PR modifies only standard Go unit tests using testing.T. No Ginkgo e2e tests are added, so the MicroShift compatibility check does not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests are added in this PR. Changes are limited to unit tests (core_test.go, resourcebuilder_test.go) using standard Go testing package, not Ginkgo framework. Check not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies TLS/cipher suite handling in ConfigMaps only. No deployment manifests, pod specs, affinity rules, topology constraints, or replica logic are changed.
Ote Binary Stdout Contract ✅ Passed All klog calls are within modifyConfigMap() method (not process-level), use klog.V() with verbosity, and test changes are exempt.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR contains only changes to standard Go unit tests (testing.T) in lib/resourcebuilder/, not Ginkgo e2e tests. No new e2e tests with IPv4 assumptions or external connectivity were added.
No-Weak-Crypto ✅ Passed PR uses strong TLS cipher suites (AES-GCM with ECDHE, SHA256/384), no weak crypto, standard library only, no non-constant-time secret comparisons.
Container-Privileges ✅ Passed PR modifies only TLS cipher ordering logic in Go source/test files; no container/Kubernetes manifests with privileged security settings were changed.
No-Sensitive-Data-In-Logs ✅ Passed No sensitive data exposure detected. Logging includes only standard Kubernetes metadata, public TLS version strings, and cipher suite names—not credentials, PII, tokens, hostnames, or customer data.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@openshift-ci

openshift-ci Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vincentdephily
Once this PR has been reviewed and has the lgtm label, please assign fao89 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vincentdephily

Copy link
Copy Markdown
Author

/retest

}

func getDefaultCipherSuitesSorted() []string {
cipherSuites := crypto.CipherSuitesToNamesOrDie(crypto.DefaultCiphers())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just drop the sort.Strings statement?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Because crypto.DefaultCiphers() and configv1.TLSProfiles[crypto.DefaultTLSProfileType] return the same ciphers but in a different order. The new TLS1.3 ciphers have a higher precedence in os library-go than in golang crypto.

Ideally I would have taken the cipher suite by calling apiserver.ObserveTLSSecurityProfile(), but the context args made that akward. So instead I extracted the core logic for the 'default case', and added a comment. If the apiserver code drifts, we'll have to update this test.

@ingvagabund ingvagabund May 12, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The new TLS1.3 ciphers have a higher precedence in os library-go than in golang crypto.

That does not play well with the cipher ordering either. Both config/v1/types_tlssecurityprofile.go and DefaultCiphers() need to respect the same ordering then. Maybe noone has though of it before?

Comment thread lib/resourcebuilder/core_test.go Outdated
Comment thread lib/resourcebuilder/core_test.go Outdated
@vincentdephily vincentdephily changed the title NO-JIRA: Respect configured cipher order for inject-tls CNTRLPLANE-3429: Respect configured cipher order for inject-tls May 11, 2026
@openshift-ci-robot

openshift-ci-robot commented May 11, 2026

Copy link
Copy Markdown
Contributor

@vincentdephily: This pull request references CNTRLPLANE-3429 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target only the "5.0.0" version, but multiple target versions were set.

Details

In response to this:

Cipher order is meaningful, don't sort alphabetically.

  • Remove unwanted string sort
  • Adjust unittests
  • Tweak logs

Summary by CodeRabbit

  • Bug Fixes

  • TLS cipher suite injection now preserves the order from the APIServer TLS profile configuration instead of reordering them.

  • Tests

  • Updated test fixtures to validate TLS injection behavior with preserved cipher suite ordering.

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.

@DavidHurta

Copy link
Copy Markdown
Contributor

/cc

@openshift-ci openshift-ci Bot requested a review from DavidHurta May 11, 2026 15:27
Comment thread lib/resourcebuilder/core.go Outdated

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.

nit:

Thank you for the fix! Could we also update the various existing comments referencing GenericOperatorConfig in the file to something more generic, perhaps? There are a few of them.

return nil, err
} else if ciphersFound {
// Sort cipher suites for consistent ordering
sort.Strings(cipherSuites)

@DavidHurta DavidHurta May 11, 2026

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.

This is very interesting.

Have you reached out to the relevant centralized-tls-profile folks about whether the API description should be updated?

Currently, the relevant APIServer API is described as [1]:

// TLSProfileSpec is the desired behavior of a TLSSecurityProfile.
type TLSProfileSpec struct {
	// ciphers is used to specify the cipher algorithms that are negotiated
	// during the TLS handshake. Operators may remove entries that their operands
	// do not support. For example, to use only ECDHE-RSA-AES128-GCM-SHA256 (yaml):
	//
	//   ciphers:
	//     - ECDHE-RSA-AES128-GCM-SHA256
	//
	// TLS 1.3 cipher suites (e.g. TLS_AES_128_GCM_SHA256) are not configurable
	// and are always enabled when TLS 1.3 is negotiated.
	// +listType=atomic
	Ciphers []string `json:"ciphers"`

No mention of preferred ordering. Maybe there should be?

Ideally, the majority of components use library functions, which hopefully respect the ordering. Hopefully. However, at a minimum, some components will not respect this.

Also, the tls-scanner compliance check does not seem to check the ordering [2] as well. Maybe it should?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a note: this will be less a problem from TLS v1.3 given the list of ciphers will be ignored/rejected.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Having investigated this properly, it turns out that Go actually does ignore the configured cipher order (and cipher list, with TLS1.3). This is Go-specific behaviour (and new since 1.17), so I don't feel too bad for having assumed that order mattered 😅

I'll update this PR with clarifying comments.

There's a future-proofing/least-surprise argument to be made for keeping the user's order, but I think that the config-reconcilation-minimizing argument wins out, so I'll put the sort back in place unless you have other opinions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice exploration. This is quite surprising.

Yeah, dropping down a comment makes sense here.

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.

Yes, a nice exploration indeed 🙇

I think that the config-reconcilation-minimizing argument wins out

Me as well 👍

* Fix assumptions about NodeKind in comments
* Log the actual NodeKind during tls injection
* Other minor tweaks
@vincentdephily vincentdephily force-pushed the vdp-respect-cipher-order branch from 4efff84 to 7e9dbd4 Compare June 8, 2026 11:32

@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 `@lib/resourcebuilder/core_test.go`:
- Around line 108-112: The "reversed" test data isn't reversed: update
testCipherSuitesYmlReversed so its elements are the opposite order of
testCipherSuitesYml (i.e., swap the two entries) so the test at lines ~445-456
actually exercises order preservation; locate the variable
testCipherSuitesYmlReversed in core_test.go and change its element order to be
the reverse of testCipherSuitesYml.
🪄 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 YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 0193b92c-a844-42b7-9b4e-8a41326679ff

📥 Commits

Reviewing files that changed from the base of the PR and between 4efff84 and 7e9dbd4.

📒 Files selected for processing (3)
  • lib/resourcebuilder/core.go
  • lib/resourcebuilder/core_test.go
  • lib/resourcebuilder/resourcebuilder_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/resourcebuilder/core.go

Comment thread lib/resourcebuilder/core_test.go
Although Go TLS ignores ciphersuites order, and has some complicated
rules about ciphersuites content, other implementations (and perhaps
future Go implementations) have different bahaviors, so we shouldn't
optimize for the current implementation too closely.

Also, ciphersuites opinions should be have a single source of truth,
and be implemented at the APIServer level. Applying changes at the
CluserVersionOperator level makes the config flow harer to follow.

* Don't sort ciphersuites, and document the rationale
* Add testscases and remove redundant ones
* Clarify test labels and testdata name/comments
* Reorder testcases and data to be more thematic
* Simplify test helpers
@vincentdephily vincentdephily force-pushed the vdp-respect-cipher-order branch from 7e9dbd4 to f8e2063 Compare June 8, 2026 11:57
@vincentdephily

Copy link
Copy Markdown
Author

I've identified that unittest race condition with @ricardomaraschini but I'll treat it in another PR, just retrying here.

/retest

@openshift-ci

openshift-ci Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@vincentdephily: all tests passed!

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@vincentdephily

Copy link
Copy Markdown
Author

PR updated: I've addressed the comment nitpicks, added/removed/tweaked some testcases, refactored the test code... And kept the "no sorting" behavior despite my earlier opinion about minimizing config reconciliation.

The rationale is in the commit message and code comments, but the main arguments are that we don't want the CVO to inject a different config than what the operator can get via the APIServer, and that we don't want to make an assumption that might not be valid for some operators.

I've spent a lot of time trying to get the best of both worlds by keeping the order when injecting, but only injecting when it makes a semantic difference (eg ignoring order, old-style names, etc). But the deeper I dug, the more opinionated quirks I found in Go and library-go. Too many opportunities for bitrot and false negatives, so I deleted those attempts and kept things simple, stupid.

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants