Based on Trail of Bits Testing HandbookSkills are based on the CodeQL Testing Handbook and Semgrep Testing Handbook.Author: Axel Mierczuk & Paweł Płatek
Installation
Skills Included
CodeQL
Deep security analysis with taint tracking and data flow
Semgrep
Fast pattern-based security scanning
SARIF Parsing
Parse and process results from static analysis tools
CodeQL Skill
Interprocedural security analysis with taint tracking and data flow for Python, JavaScript, Go, Java, C/C++, C#, Ruby, and Swift.Key Features
Database Creation
Database Creation
- Create databases for Python, JavaScript, Go, Java, C/C++, and more
- Automatic build method selection with fallbacks
- Quality assessment and validation
- macOS Apple Silicon workarounds
Security Queries
Security Queries
- SARIF/CSV output formats
- Multiple query pack support (security-extended, Trail of Bits, Community)
- Two scan modes: “run all” and “important only”
- Interprocedural taint tracking
Data Extension Models
Data Extension Models
- Generate project-specific source/sink models
- Detect custom API patterns
- Extend CodeQL’s built-in library knowledge
- YAML-based model definitions
Essential Principles
CodeQL Workflow
The skill provides three workflows:| Workflow | Purpose |
|---|---|
| Build Database | Create CodeQL database using build methods in sequence |
| Create Data Extensions | Detect or generate data extension models for project APIs |
| Run Analysis | Select rulesets, execute queries, process results |
Output Structure
All generated files are stored in a single output directory:Supported Languages
Python
Django, Flask, FastAPI support
JavaScript/TypeScript
Node.js, React, Vue
Go
Standard library coverage
Java/Kotlin
Spring, Android
C/C++
Build tracing required
C#
.NET, ASP.NET
Ruby
Rails support
Swift
iOS/macOS
Semgrep Skill
Fast pattern-based security scanning with parallel execution and automatic language detection.Key Features
Parallel Execution
Parallel Execution
- Spawns parallel scanner subagents for each language
- Automatic language detection from file extensions
- Merged SARIF output
- Support for GitHub repositories (auto-clones)
Scan Modes
Scan Modes
Run All: Complete coverage, all severity levelsImportant Only: High-confidence security vulnerabilities only
- Pre-filter:
--severity MEDIUM/HIGH/CRITICAL - Post-filter:
category=security,confidence∈{MEDIUM,HIGH}
Rulesets
Rulesets
- Official Semgrep registry (OWASP, CWE)
- Trail of Bits custom rules
- Third-party rules (0xdea, Decurity)
- Custom YAML rules with pattern matching
- Taint mode for data flow tracking
Semgrep Pro Support
Semgrep Pro Support
- Automatic detection of Pro license
- Cross-file taint tracking
- Interprocedural analysis
- Additional languages (Apex, C#, Elixir)
Essential Principles
Semgrep Workflow
- Resolve output directory - Auto-increment
static_analysis_semgrep_1,_2, etc. - Detect languages and Pro availability - Use Glob to find file types
- Select scan mode and rulesets - Present plan to user
- Get explicit approval - Hard gate, must approve before scanning
- Spawn parallel scanner Tasks - One Task per language category
- Merge results and report - Combine SARIF files, provide summary
Agents
| Agent | Tools | Purpose |
|---|---|---|
semgrep-scanner | Bash | Executes parallel semgrep scans for a language category |
semgrep-triager | Read, Grep, Glob, Write | Classifies findings as true/false positives by reading source |
Output Structure
SARIF Parsing Skill
Parse, analyze, and process SARIF files from static analysis tools.Key Features
Quick Analysis with jq
Quick Analysis with jq
Python with pysarif
Python with pysarif
Aggregation with sarif-tools
Aggregation with sarif-tools
Deduplication & Fingerprinting
Deduplication & Fingerprinting
- Stable fingerprints for tracking findings across runs
- Path normalization (handles different environments)
- Baseline comparison for regression detection
- Suppression of known false positives
SARIF Structure
Tool Selection Guide
| Use Case | Tool | Installation |
|---|---|---|
| Quick CLI queries | jq | brew install jq |
| Python scripting (simple) | pysarif | pip install pysarif |
| Python scripting (advanced) | sarif-tools | pip install sarif-tools |
| .NET applications | SARIF SDK | NuGet package |
Common Pitfalls
When to Use Each Tool
Use CodeQL When
- Need deep interprocedural analysis
- Tracking data flow across files/functions
- Complex taint tracking required
- Building a database is feasible
Use Semgrep When
- Need fast feedback
- Pattern-based detection sufficient
- No build capability for compiled languages
- Quick first-pass security scan
Related Skills
Variant Analysis
Use CodeQL/Semgrep patterns to find bug variants
Supply Chain Risk Auditor
Audit dependencies for exploitation risk
Success Criteria
CodeQL Analysis Complete
- Database built with quality assessment passed
- Data extensions evaluated or created
- Analysis run with explicit suite reference
- All available query packs used
- Results preserved in output directory
- Zero findings investigated
Semgrep Scan Complete
- Languages detected with Pro status checked
- User approved scan plan
- Third-party rulesets included
- All Tasks spawned in parallel
-
--metrics=offused everywhere - Results merged and summarized