Sachin Chaurasiya

Secure · SAST

Semgrep

Semgrep is a lightweight SAST engine that matches code patterns across 30+ languages. It runs locally and in CI in minutes, with registry rulesets for OWASP categories, secrets and framework-specific issues.

Stage
Secure
Category
SAST
Documentation
Official docs
License
LGPL-2.1 (OSS engine)
On this page

What it does

Semgrep matches abstract-syntax patterns (“grep for code”) using rules written in YAML. The OSS engine performs intra-file analysis; the commercial product adds cross-file dataflow and a findings UI.

Where it fits

Secure stage on every merge request. Because a scan typically finishes in under a minute, it belongs in the fast-feedback loop, not a nightly.

Quick start

semgrep scan --config p/default --error
semgrep scan --config p/owasp-top-ten --config p/secrets --sarif --output semgrep.sarif

Common pitfalls

  • Running without --error makes the job always pass.
  • Rulesets like p/default change over time; pin the CLI version and review new findings when it bumps.
  • Writing organisation rules is where the value is — generic rulesets rarely encode your real risks.

Articles about Semgrep

CI/CD intermediate

Building a Secure CI/CD Pipeline with Jenkins

A declarative Jenkins pipeline with secrets scanning, SAST, image scanning and least-privilege credential handling — and the agent, plugin and Docker decisions that keep it that way.

9 min read