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.
More on SAST, SCA and secrets scanning in CI
gitleaks fails the PR on `tests/fixtures/fake_rsa.pem` and `testdata/aws_creds.json`, which only contain dummy valuesBeginnergitleaks passes locally but the CI job reports 40 old leaks nobody touched in this PRIntermediate`fatal: ambiguous argument 'origin/main..HEAD': unknown revision` in the secrets-scan stepBeginnerSemgrep flags `subprocess.run(cmd, shell=True)` in a script where `cmd` is a hard-coded constantBeginnerSemgrep in CI reports findings in `node_modules/`, `vendor/` and minified `dist/*.js`BeginnerSemgrep job takes 35 minutes and gets killed with `exit code 137`Intermediate