Skip to content

Commit fc953f2

Browse files
committed
add ruleguard for exec.Command
1 parent 5076cf0 commit fc953f2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

scripts/rules.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,3 +487,17 @@ func workspaceActivity(m dsl.Matcher) {
487487
!m.File().Name.Matches(`_test\.go$`),
488488
).Report("Updating workspace activity should always be done in the workspacestats package.")
489489
}
490+
491+
// noExecInAgent ensures that packages under agent/ don't use exec.Command or
492+
// exec.CommandContext directly.
493+
//
494+
//nolint:unused,deadcode,varnamelen
495+
func noExecInAgent(m dsl.Matcher) {
496+
m.Import("os/exec")
497+
m.Match(
498+
`exec.Command($*_)`,
499+
`exec.CommandContext($*_)`,
500+
).
501+
Where(m.File().PkgPath.Matches("^github.com/coder/coder/agent")).
502+
Report("The agent and its subpackages should not use exec.Command or exec.CommandContext directly. Consider using agentexec.CommandContext instead.")
503+
}

0 commit comments

Comments
 (0)