Conversation
Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
| enabled, _ := cmd.Flags().GetBool(confirmFlag) | ||
| if !enabled { | ||
| return nil | ||
| } | ||
|
|
||
| nonInteractive, _ := cmd.Flags().GetBool(nonInteractiveFlag) |
There was a problem hiding this comment.
🟠 Bug: Both flags are read straight off the pflag set, bypassing viper. Everywhere else in this repo non-interactive is read as v.GetBool(nonInteractiveFlag) (get_drop_task.go:136,190,449, form_fields.go:37), and getSubViperForProfile binds cmd.Flags() so config-profile and CONE_* env values resolve. Two consequences: CONE_CONFIRM=true / confirm: true in a profile silently does nothing (the safety control fails open, no prompt), and CONE_NON_INTERACTIVE=true combined with --confirm skips the guard and falls through to pterm, which opens /dev/tty directly — so it blocks on a terminal prompt instead of returning the intended error.
Suggest threading the *viper.Viper that all four call sites already have from cmdContext into this helper and using v.GetBool(...) for both reads. Confidence: high.
| if _, err := c.GetTask(ctx, taskID); err != nil { | ||
| return err | ||
| } |
There was a problem hiding this comment.
🟡 Suggestion: This GetTask runs unconditionally, so every cone task comment invocation now pays an extra API round-trip and gains a new failure mode even when --confirm is not passed — contrary to the PR's "default scripting behavior is unchanged". Approve/deny already needed the task for its policy ID, but here the result is discarded. Consider gating it on the confirm flag, and since you are fetching it anyway, using the display name in the prompt text so the resolved task is actually visible to the user. Same pattern at cmd/cone/task_escalate.go:32. Confidence: high on the behavior change, medium on user impact.
| func TestConfirmMutationIsOptIn(t *testing.T) { | ||
| if err := confirmMutation(&cobra.Command{}, "creating an access request"); err != nil { | ||
| t.Fatalf("confirmMutation without --confirm: %v", err) | ||
| } | ||
| } |
There was a problem hiding this comment.
🟡 Suggestion: This test passes vacuously. &cobra.Command{} has no confirm flag registered, so GetBool returns an error that confirmMutation discards and enabled is false regardless of the opt-in logic — the test would still pass if the default flipped to opt-out. Register confirmFlag (defaulting false) on the command so the assertion exercises the real path. A case covering rejection (confirmed == false → mutation cancelled) and one for confirmationSupported on an un-annotated command would also be worth adding. Confidence: high.
| cliCmd.PersistentFlags().StringP("output", "o", "table", "Output format. Valid values: table, json, json-pretty, wide.") | ||
| cliCmd.PersistentFlags().Bool("debug", false, "Enable HTTP debug logging") | ||
| cliCmd.PersistentFlags().String("log-level", "", "Set log level (debug, info, warn, error)") | ||
| cliCmd.PersistentFlags().Bool(confirmFlag, false, "Prompt before supported task mutations") |
There was a problem hiding this comment.
🟡 Suggestion: --confirm is registered as a root persistent flag, so it appears in the help output of every command (cone login --confirm, cone get --confirm, …) while the PersistentPreRunE guard rejects all but the four annotated task commands. The guard also only fires for runnable commands: cone task --confirm returns flag.ErrHelp before PersistentPreRunE runs, so it silently prints help instead of erroring. Registering the flag on the four supported commands directly would make the surface self-describing and remove the need for the annotation plumbing. Confidence: high.
General PR Review: Add opt-in confirmations for task mutationsBlocking Issues: 1 | Suggestions: 3 | Threads Resolved: 0 Review SummaryScanned the full PR diff for security and correctness: a new Security IssuesNone found. Correctness Issues
Suggestions
Prompt for AI agents |
Summary
--confirmflag for task approve, deny, comment, and escalation mutationsValidation
go test ./...go vet ./...