fix: suppress gosec G204 warning for trusted local config commands - #848
fix: suppress gosec G204 warning for trusted local config commands#848euxaristia wants to merge 1 commit into
Conversation
Addresses a Gosec G204 (Command Injection) warning where provider command strings were passed directly into `sh -c` and `cmd /C`. Since these commands originate from the user's trusted local config and explicitly require shell features (like pipes and variable expansions) to function, removing the shell invocation introduces a breaking change. This adds a documented `#nosec` annotation to suppress the false positive instead of degrading functionality. Co-authored-by: euxaristia <25621994+euxaristia@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughChangesProvider command security annotations
Estimated code review effort: 1 (Trivial) | ~2 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Vasanthdev2004
left a comment
There was a problem hiding this comment.
Approving. I traced the provenance claim rather than taking it at face value, because a #nosec G204 on sh -c is exactly the kind of suppression that ages badly if the input source ever widens.
It holds today. runProviderCommand is reached only from LoadProviderCommand, which has one caller — resolver.go:92, gated on options.ProviderCommand — and that field is populated in exactly one place, paths.go:32, from the ZERO_PROVIDER_COMMAND environment variable. Notably it does not come from ProjectConfigPath, which was my concern: if a project-local config could set it, cloning a hostile repo would be arbitrary code execution, and "the user's trusted local config" would be false. It can't, so the comment is accurate.
Shell evaluation is also the point of the feature here — pipes and env expansion in a provider command only work if a shell sees it — so this isn't a case where the warning could be fixed by dropping to exec.Command with an argv.
One suggestion, non-blocking: it might be worth saying environment variable rather than "local config" in the comment. The load-bearing fact is that the string comes from ZERO_PROVIDER_COMMAND and not from any config file on disk, and naming that makes the suppression self-checking if someone later wires provider commands into the config schema.
Summary
sh -c/cmd /Cto support pipes and env expansions, and originate only from the user's trusted local config#nosec G204annotation instead of degrading functionalityTest plan
gosecno longer flagsinternal/config/command.goSummary by CodeRabbit