Skip to content

fix(cli): confirm before destructive compound-verb deletes (#285) - #329

Merged
scttfrdmn merged 1 commit into
mainfrom
audit/285-destructive-gate-compound-verbs
Jul 11, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
audit/285-destructive-gate-compound-verbs

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #285.

Problem

isDestructive() in cmd/flag_conventions_test.go keyed on the exact cobra command name. But Name() returns only the first whitespace-delimited token of Use, so hyphenated compound verbs arrive as a single token and never matched the destructive set (cancel/terminate/delete/remove/destroy).

Result: two commands did an irreversible delete with no --yes and no prompt:

  • spawn notify workspace-remove → DeleteItem on the DynamoDB workspaces table (cmd/bot.go:599)
  • spawn autoscale remove-schedule → drops a scheduled scaling action via UpdateGroup (cmd/autoscale.go)

Fix

  • Guard now inspects every hyphen-segment of the verb, so compound destructive verbs are caught (and can't regress). workspace-destroy remains satisfied via its existing --confirm/dry-run.
  • Both commands now call confirmYes(...) before acting and register -y/--yes to skip the prompt for scripts. Piped/EOF stdin reads as "no" → aborts rather than deleting silently.

Verification

  • TestFlagConventions fails on the pre-fix code (flagging exactly these two commands), passes after.
  • Manual: echo "" | spawn notify workspace-remove --platform slack --workspace-id TTEST → prints prompt, exits 1, makes zero AWS calls. --help shows -y, --yes on both.
  • go vet ./cmd clean. (Pre-existing unrelated failure: TestCatalogValid / feat(plugin): permissions declaration block (#388) #392 private catalog images — fails on main too.)

Part of the 2026-07-11 audit (tracker #328, Phase 0). Report added under docs/spawn-audit-2026-07-11.md.

No user-facing rename; adds --yes (additive) and a prompt. CHANGELOG updated under Fixed.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/autoscale.go 25.00% 3 Missing ⚠️
cmd/bot.go 25.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

isDestructive() in the flag-conventions guard keyed on the exact cobra
command name, but Name() is the first whitespace token of Use — so
hyphenated compound verbs like `workspace-remove` and `remove-schedule`
never matched the destructive set. Both commands did an irreversible
delete (DynamoDB workspace registration; scheduled scaling action) with
no --yes flag and no confirmation prompt.

- Guard now inspects every hyphen-segment of the verb, so compound
  destructive verbs can't slip past it (and future ones can't regress).
- `notify workspace-remove` and `autoscale remove-schedule` now prompt
  via confirmYes and accept -y/--yes to skip for scripts. Piped/EOF
  stdin reads as "no" → aborts rather than deleting silently.

Also adds the 2026-07-11 audit report under docs/.
@scttfrdmn
scttfrdmn force-pushed the audit/285-destructive-gate-compound-verbs branch from 73b011c to fe6a216 Compare July 11, 2026 18:47
@scttfrdmn
scttfrdmn merged commit ea61fa9 into main Jul 11, 2026
6 of 7 checks passed
@scttfrdmn
scttfrdmn deleted the audit/285-destructive-gate-compound-verbs branch July 11, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant