rules:
- id: subprocess-shell-true
  patterns:
  - pattern: subprocess.$FUNC(..., shell=True, ...)
  - pattern-not: subprocess.$FUNC("...", shell=True, ...)
  message: >-
    Found 'subprocess' function '$FUNC' with 'shell=True'. This is dangerous because
    this call will spawn
    the command using a shell process. Doing so propagates current shell settings
    and variables, which
    makes it much easier for a malicious actor to execute commands. Use 'shell=False'
    instead.
  fix-regex:
    regex: (shell\s*=\s*)True
    replacement: \1False
  metadata:
    owasp: 'A1: Injection'
    cwe: "CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')"
    references:
    - https://stackoverflow.com/questions/3172470/actual-meaning-of-shell-true-in-subprocess
    - https://docs.python.org/3/library/subprocess.html
    category: security
    technology:
    - python
  languages: [python]
  severity: ERROR
