Interview Prep/DevSecOps/SAST, SCA and secrets scanning in CI

Semgrep flags `subprocess.run(cmd, shell=True)` in a script where `cmd` is a hard-coded constant

BeginnerTroubleshootingSAST, SCA and secrets scanning in CI
Answer

Likely causes → The rule is a pattern match on shell=True, not a taint rule, so it cannot tell a constant from user input.

Diagnose →

semgrep --config p/python --json path/to/script.py | jq '.results[] | {check_id, line: .start.line}'

Fix → If genuinely safe, suppress inline with a reason:

subprocess.run(CMD, shell=True)  # nosemgrep: python.lang.security.audit.subprocess-shell-true.subprocess-shell-true -- constant, no input

Better: drop shell=True and pass a list.

Prevent → Prefer taint-mode rules for injection classes, and require a justification string on every nosemgrep (enforce with a review rule).

All DevSecOps questions Roadmap: Security in the pipeline

More on SAST, SCA and secrets scanning in CI