Semgrep

Categories

Static Application Security Testing (SAST)

Import Options
File Types
Integrations

Semgrep

Semgrep is a fast, open-source static analysis tool that performs static application security testing (SAST), software composition analysis (SCA), and secrets scanning across 30+ programming languages to identify security vulnerabilities, code quality issues, and insecure dependencies by using pattern-based rules that resemble actual source code rather than complex regex or abstract syntax trees. The platform integrates seamlessly into IDEs, CI/CD pipelines, and developer workflows with AI-powered analysis to reduce false positives by up to 98% through dataflow reachability analysis, providing automated remediation guidance, customizable security rules, and enforcement of secure coding standards throughout the software development lifecycle.

Semgrep Integration with DefectDojo

If your team runs Semgrep in CI, you're already generating structured SAST output on every push or pull request. Feeding those results into DefectDojo gives you a persistent, deduplicated record of findings across every repo and every scan — with the ability to track remediation status, assign findings to engineers, enforce SLA compliance, and report on code security posture over time. Without a platform like DefectDojo behind it, Semgrep findings live and die with the pipeline run that produced them.

Why Semgrep Matters

Advantages of This Integration

How This Integration Works

Semgrep produces JSON or SARIF output that DefectDojo's parsers consume directly. For most teams, the JSON format is the simpler path.

Step 1 — Run Semgrep and capture output

# Run with all configured rules and output JSON

semgrep --config auto --json --output semgrep-results.json.

# Run with a specific ruleset

semgrep --config p/owasp-top-ten --json --output semgrep-results.json.

# SARIF output (alternative format, also supported by DefectDojo)

semgrep --config auto --sarif --output semgrep-results.sarif.

Step 2 — Import into DefectDojo

Use Semgrep JSON Report as the scan type for JSON output, or SARIF for SARIF output:

curl -X POST https://<defectdojo-host>/api/v2/import-scan/ \
-H "Authorization: Token <your-api-token>" \
-F "scan_type=Semgrep JSON Report" \
-F "file=@semgrep-results.json" \
-F "engagement=<engagement-id>" \
-F "product=<product-id>" \
-F "active=true" \
-F "verified=false"

Step 3 — Reimport for ongoing CI scans

For repositories scanned on every PR, use the reimport endpoint to update existing findings:

curl -X POST https://<defectdojo-host>/api/v2/reimport-scan/ \
-H "Authorization: Token <your-api-token>" \
-F "scan_type=Semgrep JSON Report" \
-F "file=@semgrep-results.json" \
-F "test=<test-id>"

Data Granularity: What Gets Imported

Field Source in Semgrep Output Notes
Title check_id (rule ID) e.g., python.django.security.injection.tainted-sql-string
Severity extra.severity ERROR → High, WARNING → Medium, INFO → Low
CWE ID extra.metadata.cwe Populated for rules that include CWE metadata
OWASP Category extra.metadata.owasp Where rule metadata includes OWASP mapping
Description extra.message Rule-specific finding message, often includes context
File Path path Relative path to the affected file
Line Number start.line / end.line Start and end line of the matched code
Matched Code extra.lines The actual code snippet that triggered the rule
Remediation extra.metadata.fix Fix guidance where included in rule metadata
References extra.metadata.references Links to CVE, CWE, OWASP, or rule documentation
Rule Source extra.metadata.source URL to the rule definition in Semgrep Registry
Confidence extra.metadata.confidence HIGH, MEDIUM, LOW where rule provides it
Language Inferred from path extension Used for filtering in DefectDojo

Use Cases

In a pull request gate: Semgrep runs on every PR. Results import into a DefectDojo engagement scoped to that repository.

Across a monorepo with multiple services: A single Semgrep scan on a monorepo produces findings across dozens of services.

For a custom rule rollout: The security team writes Semgrep rules and aggregates results in DefectDojo to track progress.

During an audit or compliance review: DefectDojo provides an engagement history that aids in reporting for compliance purposes.

Operational Tips