A program is started by a bare name, so the directories of PATH decide which one runs
What it finds
exec.Command("git", "status"): a program named without a directory is looked up in the directories of PATH, so whoever controls PATH, or can write to one of its directories, decides which program runs. Services that run with more privileges than their callers name programs by absolute path, or set PATH themselves.
Reported are calls of Command, CommandContext and LookPath of os/exec, resolved through the imports, whose program is a constant string without a / or \. Most programs rely on PATH deliberately, so the rule is strict.
From the rule's source, command_from_path.rs.
package p import "os/exec" func run() { exec.Command("git", "status").Run()tx0 reports: git is looked up in the directories of PATH exec.Command("/usr/bin/git", "status").Run()} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:command-from-path" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:command-from-path] reason="..."tx0 explain tx0/go:command-from-path shows the same in the terminal. Found a false positive? Report it.