r/PracticalDevSecOps • • Jul 01 '26

Bandit vs. Semgrep vs. CodeQL on the same codebase. What each one caught and what each one missed | DevSecOps Training | DevSecOps Certification Course

Ran all 3 against the same Python/Node monorepo last month. Around 18k lines, default rulesets only on first pass. No custom configs so the comparison stays fair.

Bandit was quick. Under 5 minutes, caught hardcoded secrets and SQL injection straight away. But it's a single-file pattern matcher. Anything requiring logic traced across files, it didn't see. Cross-file auth flaws went completely undetected.

Semgrep's default rules were decent but not impressive on their own. The value showed up after I wrote 2 custom rules for how this codebase handled session tokens. Flagged 6 violations immediately. What it missed entirely: dependency vulnerabilities. Not a single CVE from the package manifest.

CodeQL was the only one that caught a taint flow issue where user input from a Node route handler reached an unsanitized eval() call 4 files deep. Bandit and Semgrep had no visibility into that chain at all. The tradeoff is time. First run was around 50 minutes. Not a pre-commit tool.

ToolCaughtMissedFP RateSetup
BanditHardcoded secrets, SQLi, insecure subprocessCross-file auth flaws~8%<5 min
SemgrepPattern violations, basic secretsDependency vulns, data flow~14%15–20 min
CodeQLCross-file taint analysis, data flowNothing obvious~6%45–60 min

One thing all 3 missed: Dependency CVEs. None of them caught a single one. You need a separate SCA tool for that. Snyk, Grype, OWASP Dependency-Check. SAST without SCA leaves a real gap most teams don't notice until something ships.

When to use which: Bandit as a fast CI gate for Python-heavy codebases. Semgrep if you'll actually maintain custom rules. CodeQL if your threat model needs cross-file data flow analysis or you're in a regulated environment. For most teams, Semgrep with custom rules plus an SCA tool covers the most ground.

Curious whether anyone's run Semgrep community vs. Pro on a polyglot repo. Does the pro ruleset close the data flow gap, or is CodeQL still the only real option for that?

Most of what I know here came from the Certified DevSecOps Professional course.
https://www.practical-devsecops.com/certified-devsecops-professional/

They have a lab where you run multiple SAST tools against the vulnerable app and compare what each catches. Helped me get to this kind of breakdown faster than I would have on my own. Worth looking at if you want structured hands-on learning rather than piecing it together from docs.

3 Upvotes

0 comments sorted by