Repository navigation
Add exec credential plugin policy (kuberc credentialPluginPolicy parity) - #3109
Draft
brendandburns with Copilot wants to merge 1 commit into
Draft
brendandburns with Copilot wants to merge 1 commit into
brendandburns with Copilot wants to merge 1 commit into
Conversation
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Copilot The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
This branch has not been deployed
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
execcredential plugins start local processes. This PR lets applications restrict which plugins can run, using the same rules as kubectl's kuberc credential plugin policy. It ports kubernetes-client/csharp#1930. The default staysAllowAll, so existing behaviour doesn't change.Changes
src/exec_credential_policy.ts(new)credentialPluginPolicy,credentialPluginAllowlist[].command, and the deprecatednamealias.validateExecCredentialPluginPolicyfollows client-go'sValidatePluginPolicy. These are errors:Allowlistnameandcommand./foo)checkExecCredentialPluginPolicyfollows client-go'scheckAllowlistLocked. A plugin is allowed if its command exactly matches an entry, or if both resolve throughPATHto the same executable. Symlinks and globs are not resolved. RelativePATHentries are ignored.ExecCredentialPluginDeniedError.parseKubercExecCredentialPluginPolicyreads only the policy fields from a kuberc file (kubectl.config.k8s.io/v1beta1orv1, kindPreference) and ignores everything else.ExecAuthsetPolicy(). It is checked before any process starts, on the first call and on every token refresh.Allowlistmode the resolved full path is executed. Node'sspawnusesoptions.env.PATHfor lookup, so without this a kubeconfigenv: PATH=...could swap in a different binary with an allowlisted name. Go'sexec.Commandresolves against the parent'sPATH, so this matches its behaviour.KubeConfigsetExecCredentialPluginPolicy(policy?)loadExecCredentialPluginPolicyFromKuberc(file?):fileargument, then$KUBERC, then~/.kube/kuberc.KUBERC=offorKUBECTL_KUBERC=false.$KUBERC) is an error.index.ts, and the README has a new section.Review notes
PATHcan't change which binary runs (see above), but other variables such asLD_PRELOADstill reach the plugin, as they do in kubectl. Rejecting them would be stricter but would break parity with kubectl.PATHis refused before spawning, even if its name is listed. kubectl also fails here, just later when it runs the command. Refusing early stops a kubeconfig-suppliedPATHfrom being used for the lookup.execplugins are covered, including theauthProvider.config.execform. Thecmd-pathoptions of the Azure and GCP auth providers are not, which matches kubectl.