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 inRaptorConfig:
- 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 incore/config.py:
Output Structure
Manifest Example
Metrics Example
Related Packages
- CodeQL - Advanced semantic analysis
- LLM Analysis - AI-powered vulnerability analysis
- Exploitability Validation - Validate findings are exploitable
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
- Use parallel scanning for production (default)
- Select specific policy groups for targeted analysis
- Enable CodeQL for comprehensive coverage
- Merge SARIFs for unified downstream processing
- Cache results using repository hash for repeat scans