Skip to main content

Overview

The Static Analysis package provides automated security vulnerability scanning using Semgrep rules and optional CodeQL integration. It features parallel scanning, policy-based rule selection, and SARIF output for unified vulnerability processing.

Purpose

Scan source code repositories for security vulnerabilities using:
  • Semgrep: Pattern-based static analysis with custom and standard rule packs
  • CodeQL: Advanced semantic analysis (optional)
  • Parallel execution: Multiple scans run concurrently for speed
  • Policy groups: Organized rule categories (crypto, secrets, injection, auth)
  • SARIF output: Standardized format for downstream processing

Main Entry Point

main()

CLI entry point for automated code security scanning.

CLI Usage

Basic Scan

With CodeQL

Advanced Options

Python API

Parallel Scanning

Sequential Scanning

Safe Repository Cloning

Core Functions

semgrep_scan_parallel()

Run Semgrep scans in parallel for improved performance.
Path
required
Path to repository to scan
List[str]
required
List of rule directory paths
Path
required
Output directory for SARIF results
int
default:"1800"
Timeout per scan in seconds
Optional[Callable]
Optional callback for progress updates
List[str]
List of generated SARIF file paths

run_single_semgrep()

Run a single Semgrep scan (used internally by parallel scanner).
str
required
Scan name (e.g., “category_crypto”)
str
required
Semgrep config (path or pack ID)
Path
required
Repository path
Path
required
Output directory
int
required
Timeout in seconds
Tuple[str, bool]
Tuple of (sarif_path, success)

validate_repo_url()

Validate repository URL against allowed patterns.

sha256_tree()

Generate SHA256 hash of directory tree for caching.

Configuration

Policy Groups

Available policy groups in RaptorConfig:
  • crypto: Cryptographic vulnerabilities
  • secrets: Hardcoded secrets, API keys
  • injection: SQL injection, command injection, XSS
  • auth: Authentication and authorization flaws
  • all: All available rule categories

Environment Variables

Timeouts

Configured in core/config.py:

Output Structure

Manifest Example

Metrics Example

Performance

Parallel Scanning

  • Small repos (<1K files): 2-5 minutes
  • Medium repos (1K-10K files): 5-15 minutes
  • Large repos (10K+ files): 15-30 minutes

Sequential vs Parallel

  • Sequential: 1 scan at a time (slower, easier to debug)
  • Parallel: Up to 4 scans simultaneously (4x faster)

Best Practices

  1. Use parallel scanning for production (default)
  2. Select specific policy groups for targeted analysis
  3. Enable CodeQL for comprehensive coverage
  4. Merge SARIFs for unified downstream processing
  5. Cache results using repository hash for repeat scans