A call stops the program in a debugger

tx0/python:debugger-callrecommendedwarningbug, cwe-489

What it finds

breakpoint(), pdb.set_trace(): a call that stops the program in a debugger was left in the code. Where no one is at the terminal, the program hangs; where someone is, they get a prompt that runs any code (CWE-489).

From the rule's source, debugger_call.rs.

Example from the rule's tests
import pdbimport ipdb as debugger  def work(x):    breakpoint()tx0 reports: breakpoint stops the program in a debugger    pdb.set_trace()tx0 reports: pdb.set_trace stops    debugger.set_trace()tx0 reports: ipdb.set_trace stops    return x  class Runner:    def set_trace(self):        self.set_trace()
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:debugger-call" = "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/python:debugger-call] reason="..."

tx0 explain tx0/python:debugger-call shows the same in the terminal. Found a false positive? Report it.