Conversation
Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
| } | ||
|
|
||
| func dryRunEnabled(cmd *cobra.Command) bool { | ||
| enabled, _ := cmd.Flags().GetBool(dryRunFlag) |
There was a problem hiding this comment.
🟡 Suggestion: dryRunEnabled reads the pflag directly, but dry-run is also viper-bound (initConfig → BindPFlags, and getSubViperForProfile with AutomaticEnv). Since generate_alias.go:180 reads it as v.GetBool("dry-run"), CONE_DRY_RUN=true (or dry-run: true in config) previews for generate-alias but is silently ignored for get/drop/task approve|deny|comment|escalate — the real mutation is sent. Consider resolving dry-run through viper everywhere so the env/config path can't silently fail open on a safety flag.
| if dryRunEnabled(cmd) { | ||
| previewMutations(cmd, c, v, mutation{ | ||
| Action: "Create access request", | ||
| Target: fmt.Sprintf("app %s, entitlement %s", appID, entitlementID), | ||
| Details: input.previewDetails(userID), | ||
| }) | ||
| return nil, nil | ||
| } |
There was a problem hiding this comment.
🟡 Suggestion: previewMutations is documented as returning "true when the caller must return without making a change", and the other five call sites use if previewMutations(...) { return nil }. Here (and in runDrop at line 343) the return value is discarded and the gate is duplicated as a separate dryRunEnabled(cmd) check, so any future change to previewMutations' gating would silently diverge in exactly the two commands that create tasks. if previewMutations(...) { return nil, nil } keeps a single source of truth.
| t.Fatalf("%s unexpectedly supports --dry-run", cmd.CommandPath()) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
🟡 Suggestion: the new tests cover the printer and the annotation scoping, but nothing asserts the actual safety property — that --dry-run prevents CreateGrantTask/CreateRevokeTask/ApproveTask/DenyTask/CommentOnTask/EscalateTask from being called. A fake client.C1Client that fails the test if any mutating method fires would lock that in and catch a future refactor that reorders the preview check past the API call.
| 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(dryRunFlag, false, "Preview supported mutations without sending them") |
There was a problem hiding this comment.
🟡 Suggestion: as a root persistent flag, --dry-run now shows up under "Global Flags" in every command's help (cone login --help, cone secret create --help, …) while PersistentPreRunE rejects it at runtime for all but eight commands. Consider cmd.PersistentFlags().MarkHidden plus per-command re-exposure, or at least mentioning the supported command list in the flag usage string, so the help output matches what actually works.
General PR Review: Add safe dry-run previews for mutationsBlocking Issues: 0 | Suggestions: 4 | Threads Resolved: 0 Review SummaryScanned the full PR diff for security and correctness: the new Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agents |
Summary
Validation
go test ./...go test -race ./...go vet ./...Static analysis
golangci-lint run ./...andgosec ./...retain five findings in pre-existing AWS code outside this PR (cmd/cone/aws.go).