Skip to main content

Overview

RAPTOR’s static analysis engine combines local security rules with Semgrep’s community packs for comprehensive code scanning. The scanner executes rules in parallel for improved performance and supports policy-based rule selection.

Architecture

The scanner is located at packages/static-analysis/scanner.py and orchestrates:
  • Parallel rule execution with configurable worker pools
  • Policy group selection for targeted scanning
  • SARIF output format for standardized reporting
  • Automatic deduplication across multiple rule sources
  • Repository validation with safe git cloning

Policy Groups

Available Groups

RAPTOR organizes rules into policy groups that map to both local rules and Semgrep registry packs:

Baseline Packs

These packs are always included regardless of policy group selection:

CLI Usage

Basic Scan

Scan a repository with default crypto rules:

Git Repository Clone

Scan a remote repository (clones automatically):

Multiple Policy Groups

Combine multiple policy groups:

Comprehensive Scan

Run all available policy groups:

Sequential Mode

Disable parallel scanning (useful for debugging):

Preserve Working Directory

Keep temporary clone directory for inspection:

Parallel Execution

Worker Pool Configuration

The scanner uses a configurable thread pool:

Performance Benefits

Parallel execution provides significant speedup:
  • 4 workers: 3-4x faster than sequential
  • Per-rule timeout: 120 seconds (configurable)
  • Total timeout: 900 seconds (15 minutes)

SARIF Output Format

Output Structure

Each scan produces multiple SARIF files:

SARIF Schema

RAPTOR validates all SARIF output against the official schema:

Merged Output

The scanner automatically merges and deduplicates findings:

Scan Metrics

Generated Metrics

Every scan produces comprehensive metrics:

Accessing Metrics

Repository Validation

URL Validation

Only trusted repository patterns are allowed:
Invalid URLs are rejected with security logging:

Safe Git Clone

Cloning uses restricted environment and timeouts:

Configuration Examples

Custom Rule Directory

Add your own Semgrep rules:

Environment Configuration

Integration with RAPTOR Pipeline

Automatic Invocation

Static analysis runs automatically in /agentic mode:

Phase Integration

The scanner is Phase 1 of the autonomous pipeline:
  1. Static Analysis (scanner.py) → SARIF findings
  2. Exploitability Validation → Confirmed vulnerabilities
  3. LLM Analysis → Root cause analysis
  4. Exploit Generation → Proof-of-concept code

Output Consumption

SARIF output feeds downstream tools:

Troubleshooting

Empty SARIF Output

If a scan produces no results:

Timeout Issues

Increase timeouts for large codebases:

Validation Failures

If SARIF validation fails:

Best Practices

Start with targeted scans: Use specific policy groups (e.g., crypto,secrets) for faster results, then expand to all for comprehensive coverage.
Repository validation: Only scan trusted repositories. The scanner validates URLs but you should verify repository authenticity before cloning.
Parallel vs Sequential: Use --sequential only for debugging. Parallel mode is 3-4x faster with no loss of accuracy.

See Also