Repository navigation
Help flags that reach a plugin, a flag's value or yargs' off switch no longer exempt the command (#153, items 1-3) - #158
Merged
Conversation
…gs booleans do not stop (#153) Failing tests for #153 items 1 to 3, with guard-level wrong-pin controls: kubectl and helm plugins given --help, a pflag value flag that takes --help as its value (gh, kubectl, helm), and wrangler's --help false, -h false and --no-help. Controls show supabase and wrangler value flags never take --help, and real help stays exempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…153) kubectl runs kubectl-<name> from PATH when the first word is not a command, and kubectl-create-<x> when <x> right after `create` is not a built-in subcommand name; helm plugins are commands with DisableFlagParsing. Either way the plugin gets --help and may act on the cluster, so --help now exempts only built-in commands (kubectl 1.36.1, helm v3.22.1 and v4.3.1 source). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pflag gives a flag that takes a value the next word whatever it is, so `gh secret set X --body --help` sets the body to "--help" and runs. Which flags take a value depends on the command, so a help flag right after any -x or --x word without "=" no longer exempts the command. Real help requests seldom end with a flag: none of 65 gh, kubectl, helm, supabase and wrangler help calls in local agent transcripts did. supabase (effect/cli) and wrangler (yargs) never take a word starting with "-" as a value, so they keep their rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yargs-parser 21.1.1 (yargs 17.7.2) takes a "true" or "false" right after a boolean flag as its value, reads --no-help and --no-h as off, and keeps the last one, so `wrangler deploy --help false` deploys. cloudpin now reads help the same way. Other spellings (--help=true, -xh) count as off, which only adds a check. Compared with yargs-parser on 200,000 random argument lists: cloudpin never exempted a command yargs would run; the old rule did 8,363 times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous commit inserted yargsHelp between the comment and the function it documents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Part of #153 (items 1 to 3). Target: 1.3.0. Items 4 and 5 are still to do, so #153 stays open after this merges.
What changes (each change only adds checks)
--help. A plugin gets--helpas an argument and may still act on the cluster. Help is now exempt only for built-in commands (KUBECTL_BUILTIN,HELM_BUILTIN).pkg/cmd/cmd.go,plugin.go).kubectl create <x>runskubectl-create-<x>when<x>isn't a built-in subcommand's name (IsSubcommandPluginAllowed).DisableFlagParsing(helm v3.22.1, v4.3.1).--help. Ingh secret set X --body --help, pflag gives--helpto--bodyas its value and the command runs. For pflag CLIs (gh, kubectl, helm), the newhasPflagHelpdoesn't count a help flag that comes right after a-x/--xword without=. Supabase (effect/cli) and Wrangler (yargs-parser) never take a word starting with-as a value, so they're unchanged, with control tests.gh pr create --web --helpis now checked.--help false,-h falseand--no-helpturn help off (yargs-parser 21.1.1, last one wins), so the command is checked.The builder also noticed that
kubectl --help 2>&1would be checked here because of the redirection word. That parsing bug is fixed separately in 1.2.0 (#154): redirections are no longer arguments.Tests
The tests are in the new file
test/exempt-leftovers.test.ts, 64 of them. They were committed failing first (26 failed), and include guard-level wrong-pin controls:kubectl myplugin --help,helm diff upgrade --help,gh secret set X --body --help,wrangler deploy --help false;kubectl get pods --help,gh secret set X --body y --help,wrangler deploy --help.Typecheck passes. Full suite: 53 files, 1452 passed, 8 skipped. The builder ran 11 mutations, and all 11 were caught. I ran one more: letting help count for any first word in kubectl and helm makes 10 tests fail. The file was restored afterwards.
Left open
kubercandpluginstay always exempt.--help=false,gh ... --web --help.🤖 Generated with Claude Code