fix: accept line breaks in kubeconfig certificate data - #640
Merged
Merged
Conversation
The strict base64 decoder rejects CR and LF in inline certificate and key data that kubectl accepts, including decoded YAML !!binary values. Normalize these fields before config construction so CA data and client credentials work across the shared connection paths. Closes #635
|
Keep the missing current-context check from main before loading normalized certificate data. This resolves the startup conflict without removing either fix.
The startup context check returned before configuration inference could load service-account credentials. Check for a missing context only after inference fails, and keep empty context names out of shell commands. Keep the selection message when credentials are unavailable and retain other inference errors. Cover both outcomes with regression tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kubeconfig certificate and key data with line breaks fails in the strict base64 decoder used by kube-rs. This also affects YAML
!!binaryvalues when their decoded content contains line breaks, although kubectl accepts them.Remove CR and LF from inline CA, client certificate, and client key data before building the configuration. Use the shared loader for startup, context selection, completion, and sanitize commands. Other invalid characters remain rejected.
Allow configuration inference to try in-cluster authentication before reporting a missing
current-context. Keep a successful inferred configuration, retain the context-selection message when inference fails, and omit empty context names from shell commands.Validation:
just checkpassed. Regression tests cover plain YAML and!!binary, wrapped and unwrapped data, invalid characters, startup, and context selection throughhandle_key. Tests also cover accepted service-account configuration results, failed inference, and both headless modes without a current context. These tests use local fixtures and simulated inference results; they do not need a cluster.The first commit hook run failed in the existing port-forward test after it released a local port. The test passed when run alone, and all commit hooks passed on the next run.
Closes #635