Skip to content

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
paureis merged 7 commits into
mainfrom
fix/153-exempt-leftovers
Nov 4, 2026
Merged

paureis merged 7 commits into
mainfrom
fix/153-exempt-leftovers

Conversation

@paureis

@paureis paureis commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

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)

  1. kubectl and helm plugins given --help. A plugin gets --help as an argument and may still act on the cluster. Help is now exempt only for built-in commands (KUBECTL_BUILTIN, HELM_BUILTIN).
    • kubectl's plugin lookup runs before cobra parses anything (kubectl 1.36.1 pkg/cmd/cmd.go, plugin.go).
    • kubectl create <x> runs kubectl-create-<x> when <x> isn't a built-in subcommand's name (IsSubcommandPluginAllowed).
    • helm plugins are cobra commands with DisableFlagParsing (helm v3.22.1, v4.3.1).
  2. A value flag that swallows --help. In gh secret set X --body --help, pflag gives --help to --body as its value and the command runs. For pflag CLIs (gh, kubectl, helm), the new hasPflagHelp doesn't count a help flag that comes right after a -x/--x word without =. Supabase (effect/cli) and Wrangler (yargs-parser) never take a word starting with - as a value, so they're unchanged, with control tests.
    • Cost: gh pr create --web --help is now checked.
    • In 4,506 commands from local agent transcripts, 0 of the 65 real help calls would be affected.
  3. Wrangler's yargs booleans. --help false, -h false and --no-help turn help off (yargs-parser 21.1.1, last one wins), so the command is checked.
    • On 200,000 random argument lists, compared with the real yargs-parser 21.1.1: cloudpin never exempted a command yargs would run. The old rule did 8,363 times.

The builder also noticed that kubectl --help 2>&1 would 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:

  • blocked: kubectl myplugin --help, helm diff upgrade --help, gh secret set X --body --help, wrangler deploy --help false;
  • still exempt: 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

  • helm v3 doesn't stop a plugin that uses a built-in's name.
  • kuberc and plugin stay always exempt.
  • Some help-only spellings are now checked: supabase --help=false, gh ... --web --help.

🤖 Generated with Claude Code

paureis and others added 5 commits October 25, 2026 21:26
…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>
@paureis paureis added this to the 1.3.0 milestone Oct 26, 2026
paureis and others added 2 commits November 4, 2026 18:39
#147's lines were missed when #150 merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paureis
paureis marked this pull request as ready for review November 4, 2026 23:40
@paureis
paureis merged commit 1a088d4 into main Nov 4, 2026
5 checks passed
@paureis
paureis deleted the fix/153-exempt-leftovers branch November 4, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant