python.lang.correctness.pdb.pdb-remove

profile photo of semgrepsemgrep
Author
7,892
Download Count*

pdb is an interactive debugging tool and you may have forgotten to remove it before committing your code

Run Locally

Run in CI

Defintion

rules:
  - id: pdb-remove
    pattern-either:
      - pattern: pdb.$X(...)
      - pattern: pdb.Pdb.$X(...)
    message: pdb is an interactive debugging tool and you may have forgotten to
      remove it before committing your code
    languages:
      - python
    severity: WARNING
    metadata:
      category: correctness
      technology:
        - python
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]

Examples

pdb.py

import pdb as db


def foo():
    # ruleid:pdb-remove
    db.set_trace()
    # ok:pdb-remove
    a = "apple"
    #ok:pdb-remove
    db = "the string, not the library"
    #ok:pdb-remove
    pdb = "also a string"
    # ruleid:pdb-remove
    pdb.Pdb.set_trace()
    # ruleid:pdb-remove
    db.Pdb.set_trace(...)