subprocess.run is called without check, so a failing command goes unnoticed
What it finds
subprocess.run returns the exit status of the command and raises nothing when it fails, unless check=True is given. Without it a failed command is easy to miss; writing check=False says that the status is handled by hand. Reported are calls of subprocess.run without check and without **kwargs.
From the rule's source, subprocess_run_unchecked.rs.
import subprocessfrom subprocess import run subprocess.run(["ls"])tx0 reports: without check=True a failing command raises nothingrun(["ls"], capture_output=True)tx0 reports: without check=Truesubprocess.run(["ls"], check=True)subprocess.run(["ls"], check=False)runner.run(["ls"]) 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/python:subprocess-run-unchecked" = "note"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/python:subprocess-run-unchecked] reason="..."tx0 explain tx0/python:subprocess-run-unchecked shows the same in the terminal. Found a false positive? Report it.