Skip to content

Commit cb70b07

Browse files
committed
add ruleguard for pty.Command
1 parent fc953f2 commit cb70b07

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

scripts/rules.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,20 @@ func noExecInAgent(m dsl.Matcher) {
498498
`exec.Command($*_)`,
499499
`exec.CommandContext($*_)`,
500500
).
501-
Where(m.File().PkgPath.Matches("^github.com/coder/coder/agent")).
501+
Where(m.File().PkgPath.Matches("/agent/")).
502502
Report("The agent and its subpackages should not use exec.Command or exec.CommandContext directly. Consider using agentexec.CommandContext instead.")
503503
}
504+
505+
// noPTYInAgent ensures that packages under agent/ don't use pty.Command or
506+
// pty.CommandContext directly.
507+
//
508+
//nolint:unused,deadcode,varnamelen
509+
func noPTYInAgent(m dsl.Matcher) {
510+
m.Import("github.com/coder/coder/v2/pty")
511+
m.Match(
512+
`pty.Command($*_)`,
513+
`pty.CommandContext($*_)`,
514+
).
515+
Where(m.File().PkgPath.Matches(`/agent/`)).
516+
Report("The agent and its subpackages should not use pty.Command or pty.CommandContext directly. Consider using agentexec.PTYCommandContext instead.")
517+
}

0 commit comments

Comments
 (0)