Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:416rehman DeepZero Semgrep

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Static_Analysis
Last Updated 2026-10-27 00:00 GMT

Overview

Semgrep CLI binary on PATH for batch static-analysis scanning of decompiled source across pipeline samples.

Description

This environment provides the `semgrep` CLI, which the `SemgrepScanner` BulkMapProcessor invokes as a subprocess. The scanner batches all uncached samples into a temporary directory, runs `semgrep scan --config <rules> --json --output <file>` against it, and distributes findings back to individual samples. The CLI must be discoverable via `shutil.which("semgrep")`. Rules are provided as a `rules_dir` config pointing to Semgrep YAML rule files (shipped with the loldrivers pipeline).

Usage

Use this environment when running any pipeline that includes the `SemgrepScanner` processor (e.g. the loldrivers BYOVD pipeline). It is the mandatory prerequisite for the SemgrepScanner implementation. The scanner's `validate()` method checks for the binary at pipeline load time and fails fast if it is missing.

System Requirements

Category Requirement Notes
OS Linux, macOS, or Windows Binary must be on PATH
Hardware Any modern CPU Scanning is CPU-bound
Disk Temporary space for bulk scan dirs `.bulk_temp/` under work directory

Dependencies

System Packages

  • `semgrep` CLI (install via `pip install semgrep`)

Python Packages

  • Python >= 3.11 (base DeepZero requirement)
  • `deepzero` core package

Credentials

No credentials required. Semgrep runs locally with `--metrics=off` and `--disable-version-check`.

Quick Install

# Install semgrep CLI
pip install semgrep

# Verify it is on PATH
which semgrep
semgrep --version

Code Evidence

Binary presence check at validation from `semgrep_scanner.py:48-49`:

if not shutil.which("semgrep"):
    errors.append("semgrep CLI not found in PATH - install with: pip install semgrep")

CLI invocation from `semgrep_scanner.py:181-194`:

cmd = [
    "semgrep",
    "scan",
    "--config",
    str(rules_path),
    "--json",
    "--output",
    str(report_path),
    "--no-git-ignore",
    "--quiet",
    "--metrics=off",
    "--disable-version-check",
    str(bulk_dir),
]

FileNotFoundError handling from `semgrep_scanner.py:210-213`:

except FileNotFoundError:
    for idx, _ in uncached_entries:
        results[idx] = ProcessorResult.fail("semgrep not installed - pip install semgrep")
    return

Common Errors

Error Message Cause Solution
`semgrep CLI not found in PATH - install with: pip install semgrep` semgrep not installed `pip install semgrep`
`semgrep not installed - pip install semgrep` Binary disappeared between validate and run Reinstall semgrep; check PATH
`semgrep batch timed out after 300s` Scan exceeded timeout Increase `timeout` config (default 300s)
`semgrep produced no results: <detail>` Rules failed to load Check `rules_dir` path and rule YAML syntax
`semgrep read none of the N files submitted` Target dir empty or unreadable Ensure a decompile processor ran before this stage

Compatibility Notes

  • Exit code not authoritative: Semgrep emits a complete results document on stdout even with an unexpected exit code (observed on Windows). A parseable scan result is authoritative over the exit code.
  • Silent empty results guarded: Three guards prevent "no vulnerabilities found" from masking failures — see Heuristic:416rehman_DeepZero_Silent_Empty_Results_Guard.
  • Batched invocation: One semgrep run per batch of samples (default `batch_size: 200`). A whole corpus in a single run means one failure discards all work.
  • Hard links preferred: Source files are hard-linked into the bulk dir; falls back to `shutil.copy2` on OSError.
  • File types scanned: Only `.c`, `.h`, `.cpp`, `.py` files are submitted to semgrep.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment