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

Semgrep custom rule matches nothing although you can see the vulnerable code

AdvancedTroubleshootingSAST, SCA and secrets scanning in CI
Answer

Likely causes → Wrong languages, a pattern that does not parse as code in that language, missing ... for arguments, or paths excluded by .semgrepignore.

Diagnose →

semgrep --validate --config rules/my-rule.yml
semgrep --config rules/my-rule.yml --debug src/target.py 2>&1 | grep -i -E "skipp|parse"
semgrep --test rules/

Fix → Use the Playground-style iteration: start with the exact snippet, generalise with metavariables, e.g. pattern: requests.get($URL, ..., verify=False, ...).

Prevent → Ship every custom rule with a test file containing # ruleid: and # ok: annotations and run semgrep --test in CI.

All DevSecOps questions Roadmap: Security in the pipeline

More on SAST, SCA and secrets scanning in CI