OCPBUGS-99637: iterate PEM blocks in PemToPrivateKey to handle EC PARAMETERS - #10720
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@savio87: This pull request references Jira Issue OCPBUGS-99637, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesTLS private-key parsing
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 14 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (14 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions 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. Comment |
|
Hi @savio87. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
Note: The Jira bot flagged OCPBUGS-99637 as invalid because it doesn't have a target version set. I don't have permissions to update the target version on the Jira issue. Could a maintainer set the target version to 5.0.0 on OCPBUGS-99637? I can then comment /jira refresh to re-validate. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pkg/asset/tls/utils.go (1)
66-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for multi-block PEM input.
The current tests cover single RSA, EC, and PKCS#8 blocks, but not the motivating
EC PARAMETERSprefix or a failed supported block followed by a valid key. Add both cases topkg/asset/tls/utils_test.go.🤖 Prompt for 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. In `@pkg/asset/tls/utils.go` around lines 66 - 97, Add regression tests in utils_test.go for PemToPrivateKey covering an EC PARAMETERS PEM block preceding a valid EC private key, and a supported private-key block that fails parsing followed by a valid key block. Verify the function skips non-key blocks and continues after parse failures to return the later valid key.
🤖 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 `@pkg/asset/tls/utils.go`:
- Around line 77-85: Update the PEM block parsing function around the RSA
PRIVATE KEY, EC PRIVATE KEY, and PRIVATE KEY cases so parse failures are
retained rather than returned immediately. Continue scanning all subsequent
candidate blocks, return the first successful key, and return the retained parse
error only after every block has been tried.
---
Nitpick comments:
In `@pkg/asset/tls/utils.go`:
- Around line 66-97: Add regression tests in utils_test.go for PemToPrivateKey
covering an EC PARAMETERS PEM block preceding a valid EC private key, and a
supported private-key block that fails parsing followed by a valid key block.
Verify the function skips non-key blocks and continues after parse failures to
return the later valid key.
🪄 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: Pro Plus
Run ID: bfce8712-40a0-43d0-ba45-c22b035ef642
📒 Files selected for processing (1)
pkg/asset/tls/utils.go
|
/ok-to-test |
|
/jira refresh |
|
@tthvo: This pull request references Jira Issue OCPBUGS-99637, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
DetailsIn response to this:
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. |
|
/test e2e-agent-compact-ipv4-iso-no-registry |
|
@tthvo: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command
See details on https://pr-payload-tests.ci.openshift.org/runs/ci/6f7ec950-8ac0-11f1-9b78-f33805c2d5b4-0 |
|
@savio87: This pull request references Jira Issue OCPBUGS-99637, which is valid. 3 validation(s) were run on this bug
DetailsIn response to this:
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. |
|
/test e2e-aws-ovn-pki-rsa-techpreview |
|
/label tide/merge-method-squash |
|
/test e2e-agent-compact-ipv4-iso-no-registry |
tthvo
left a comment
There was a problem hiding this comment.
/lgtm
/approve
/hold
Thanks, looks good to me 👍 Though, I hope to see a few more e2e results before proceeding 👀
Meanwhile, just a quick note that the commits are stamped by 2 authors. I guess both are you, @savio87 😁, but later on, let's make sure we use the same account/email to commit...
|
Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: tthvo The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
|
Thanks for the review and approval @tthvo! Good catch on the dual author, that was a mistake on my end from having two Git identities configured :P. I'll make sure to use a consistent author going forward :). |
|
/hold cancel |
|
/verified by e2es |
|
@tthvo: This PR has been marked as verified by DetailsIn response to this:
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. |
|
@savio87: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
|
@savio87: Jira Issue Verification Checks: Jira Issue OCPBUGS-99637 Jira Issue OCPBUGS-99637 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓 DetailsIn response to this:
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. |
Summary
Fixes https://issues.redhat.com/browse/OCPBUGS-99637
Details
The previous implementation used a single pem.Decode call, so it would fail on any PEM file where the first block was not a recognized key type. The fix loops through all PEM blocks, skipping unrecognized types (like EC PARAMETERS), and returns an error only if no supported key block is found.
This is the same approach used in the cluster-network-operator fix (CNO PR #2958).
Test plan
Summary by CodeRabbit