ββββ⬑⬑⬑ββββ AI-POWERED AUDIT SCOPING ββββ⬑⬑⬑ββββ
Point it at a codebase. Get a structured scope report.
Solidity (Foundry/Hardhat) Β· Solana/Anchor (Rust)
Scoping Bee automates the most critical (and most tedious) phase of a security audit β the initial scoping. Give it a codebase and receive a bee-themed scope report with flow diagrams, complexity scoring, prioritized hitlists, and time estimates.
⬑βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ⬑
β β
β π₯ Source Fetch β π‘οΈ Threat Scan β π Analysis β π Report β
β β
⬑βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ⬑
Scoping Bee is a set of bash scripts plus an AI-skill definition β no compile step, no package install. Clone it and point your AI assistant at it, or run the scripts directly.
git clone https://github.com/<owner>/scoping-bee.git ~/.scoping-bee(Or clone anywhere you prefer; the path is referenced from your project via CLAUDE.md or the skill loader.)
| Tool | Why | Install |
|---|---|---|
bash 4+ |
Runs the scripts | macOS: brew install bash; Linux: pre-installed |
perl |
Comment-stripping / nSLOC counting | macOS/Linux: pre-installed |
find, wc, grep, sed, awk, od |
Core shell utilities | Pre-installed |
git |
GitHub clone input | brew install git / apt / dnf |
curl, jq |
Block-explorer API fetch (only for address / explorer-URL inputs) | brew install curl jq |
unzip |
ZIP archive input | Pre-installed |
The threat-intel scan and the analysis phases use only the tools above β no pip/npm installs required.
Claude Code (per-project):
cd /path/to/your/scoping-project
mkdir -p .claude
cat > CLAUDE.md << 'EOF'
# π Scoping Project
Use the scoping-bee skill at ~/.scoping-bee for all audit scoping tasks.
When given a GitHub URL, ZIP, or contract address, run the full scoping pipeline from SKILL.md.
EOFCursor / other assistants: reference SKILL.md directly and pass the skill folder path in your prompt.
Only needed for explorer / contract-address inputs:
export EXPLORER_API_KEY=<your_etherscan_or_chain_api_key>bash ~/.scoping-bee/scripts/sloc_counter.sh ~/.scoping-bee --lang solidity
# Expect: "No source files found" (scoping-bee itself has no .sol files)
bash ~/.scoping-bee/scripts/sloc_counter.sh /path/to/some/contractsIf nSLOC prints, you're ready.
The generated <protocol>_scope_report.md embeds Mermaid flow diagrams. They render natively in some viewers and need a plugin in others.
| Viewer | Works out of the box? | Notes |
|---|---|---|
| GitHub web UI | β Yes | Native rendering in any .md file since 2022 |
| GitLab web UI | β Yes | Native |
| VS Code (default preview) | β No | Needs an extension (see below) |
| Cursor | β No | Same extension as VS Code |
| Obsidian | β Yes | Native |
| Typora | β Yes | Native |
| Any plain editor | β No | Paste the fenced ```mermaid block into a Mermaid-aware viewer |
Install Markdown Preview Mermaid Support (free, no subscription, no sign-in):
# VS Code
code --install-extension bierner.markdown-mermaid
# Cursor
cursor --install-extension bierner.markdown-mermaidThen open the report and press Cmd/Ctrl+Shift+V to preview β diagrams render inline.
Commit the report to any GitHub repo (public or private) and open it in the web UI β Mermaid blocks render without any configuration.
mermaid.live works in the browser without an account for quick one-off rendering. It prompts for sign-in only if you try to save or share diagrams to their cloud. For viewing reports you don't need to sign up β prefer the VS Code extension or GitHub for a smoother local workflow.
When integrated with an AI coding assistant, simply ask:
"Scope the audit for https://github.com/org/repo" "Scope this contract: 0x1234... on BSC" "Scope the audit for ./src"
Accepts audit targets from multiple sources β no manual setup needed:
# GitHub repo
bash scripts/source_fetcher.sh https://github.com/org/repo
# Verified contract on any block explorer
bash scripts/source_fetcher.sh https://bscscan.com/address/0x1234...
# Raw address + chain
bash scripts/source_fetcher.sh 0x1234...abcd --chain bsc
# ZIP file from client
bash scripts/source_fetcher.sh ./contracts.zip
# Local directory
bash scripts/source_fetcher.sh ./srcSupported explorers: Etherscan, BSCScan, Polygonscan, Arbiscan, Optimism, Fantom, Avalanche, Base (+ testnets)
Every scoping session starts with a mandatory 10-phase hive security sweep. Untrusted audit codebases can contain shell injection, network exfiltration, phishing kits, supply chain attacks, and obfuscated payloads targeting auditor machines.
β οΈ IMPORTANT: Always run the threat scan in a sandbox first (VM, Docker container, or isolated environment). Only after the scan returns CLEAN should you proceed to analyze the codebase on your local machine. This protects your host from malicious code that the scan is designed to detect.
Recommended workflow:
1. Fetch source β sandbox environment (VM / Docker / cloud instance)
2. Run threat_intel_scan.sh inside the sandbox
3. If CLEAN β
β clone/copy to local machine and proceed with scoping
4. If BLOCKED π β do NOT move to local. Review findings in sandbox first.
# Step 1: Run in sandbox first
bash scripts/threat_intel_scan.sh ./target-repo
# Step 2: Only after CLEAN verdict, proceed on local
bash scripts/sloc_counter.sh ./target-repoβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π HIVE SECURITY SWEEP β 10 PHASES β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ⬑ Phase 1 Code Behavior Analysis (HIGH) β
β ⬑ Phase 2 HTML Fingerprint Matching (MED-HI) β
β ⬑ Phase 3 Banner & Favicon Analysis (HIGH) β
β ⬑ Phase 4 Client-Side JS Inspection (MED-HI) β
β ⬑ Phase 5 Post-Signature Distributor Check (HIGH) β
β ⬑ Phase 6 Codebase Profile Analysis (MED) β
β ⬑ Phase 7 Function Purpose Analysis (MED-HI) β
β ⬑ Phase 8 Dependency Audit (HIGH) β
β ⬑ Phase 9 Reachability Analysis (MED) β
β ⬑ Phase 10 OSS Feed & Vuln Check (MED-HI) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Verdict: CLEAN β
/ WARNING β οΈ / BLOCKED π β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Generate Mermaid diagrams to visually map code complexity, contract relationships, and attack surfaces:
# Generate all diagrams to a markdown file
bash scripts/codebase_visualizer.sh ./src --output complexity_map.md
# Generate only inheritance diagram
bash scripts/codebase_visualizer.sh ./src --diagram inheritance
# Include test files
bash scripts/codebase_visualizer.sh ./src --include-tests --output full_map.md8 Diagram Types:
| # | Diagram | What it shows |
|---|---|---|
| 1 | Inheritance Hierarchy | Contract is chains and trait implementations |
| 2 | Inter-Contract Call Graph | Which contracts call which |
| 3 | State Variable Map | Class diagram of state vars and functions |
| 4 | Access Control Flow | Roles, modifiers, and protected functions |
| 5 | External Dependency Graph | OpenZeppelin, Solmate, custom imports |
| 6 | Function Flow | Entry points β internal β external calls |
| 7 | Complexity Heatmap | Per-file metrics table |
| 8 | Value Flow | Token deposit, withdraw, transfer paths |
Effort estimation uses a configurable lines-of-code per day rate:
# Default: 350 nSLOC/day
bash scripts/sloc_counter.sh ./src
# High-complexity code: 300 nSLOC/day
bash scripts/sloc_counter.sh ./src --pace 300
# Simple patterns: 400 nSLOC/day
bash scripts/sloc_counter.sh ./src --pace 400Auto-detects Solidity or Rust/Anchor and applies the correct analysis:
| Feature | Solidity | Rust/Anchor |
|---|---|---|
| nSLOC counting | Strips pragma, imports, SPDX | Strips use, mod, attributes |
| Attack surfaces | 24 EVM-specific checks | 18 Solana-specific checks |
| System mapping | Functions, modifiers, events | Instructions, PDAs, CPIs |
| Framework detection | Foundry / Hardhat | Anchor / Native Solana |
| EVM (24) | Solana (18) |
|---|---|
| Reentrancy, proxy patterns, auth bypass | Missing signer, PDA seed confusion |
| Oracle manipulation, share inflation | CPI exploits, type cosplay |
| Flash loans, precision loss, MEV | Account closure, reinitialization |
| Signature replay, gas griefing | Remaining accounts, lamport manipulation |
scoping-bee/
βββ π CLAUDE.md # Pipeline instructions
βββ π SKILL.md # Core methodology
βββ π README.md # This file
β
βββ π― references/
β βββ scope-report-template.md # Bee-themed output template
β βββ attack-surfaces.md # 42 attack surface checklists
β βββ complexity-rubric.md # 5-metric scoring rubric
β
βββ π§ scripts/
βββ source_fetcher.sh # Multi-source input fetcher
βββ threat_intel_scan.sh # 10-phase threat scanner
βββ codebase_visualizer.sh # Mermaid diagram generator
βββ sloc_counter.sh # Dual-language nSLOC counter
⬑βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ⬑
β β
β 1. π₯ Source Acquisition β
β β GitHub / Explorer / ZIP / Local β
β β β
β 2. π‘οΈ Threat Intel Scan (MANDATORY) β
β β CLEAN β proceed / BLOCKED β stop β
β β β
β 3. π Codebase Ingestion β
β β Contract inventory, nSLOC, dependencies β
β β β
β 4. π Flow Diagram & Dependencies β
β β Value flow, cross-contract calls, trust map β
β β β
β 5. π¬ Complexity & Risk Scoring β
β β 5-metric weighted score per contract β
β β β
β 6. π Report Assembly β
β β Bee-themed scope document β
β β
⬑βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ⬑
Output: A structured <protocol>_scope_report.md with:
| Section | Content |
|---|---|
| π‘οΈ Threat Scan | Hive security sweep results |
| π Executive Summary | Protocol at a glance |
| β±οΈ Estimated Effort | Days breakdown with complexity multipliers |
| π¦ Contract Inventory | The Honeycomb β contracts with bee roles |
| π Flow Diagram | The Waggle Dance β value flow + dependencies |
| π¬ Complexity Scores | Per-contract weighted scoring |
| π― Audit Hitlist | Sting Zone / Watch Zone / Low Pollen |
| π οΈ Methodology | Recommended approach per contract |
| β Open Questions | Items for protocol team |
Each contract is scored on 5 weighted metrics:
| Metric | Weight |
|---|---|
| nSLOC | 25% |
| External Integration Risk | 25% |
| State Coupling | 20% |
| Access Control Complexity | 15% |
| Upgradeability Risk | 15% |
Risk Tiers:
π’ LOW (1.0β1.5) β Checklist review β Low Pollen
π‘ MEDIUM (1.6β2.5) β Vector scan β Watch Zone
π HIGH (2.6β3.5) β Deep interrogation β Sting Zone
π΄ CRITICAL (3.6β4.0) β Full methodology + PoC β Critical Sting Zone
# Fetch from GitHub
bash scripts/source_fetcher.sh https://github.com/org/repo
# Fetch verified contract from BSCScan
bash scripts/source_fetcher.sh https://bscscan.com/address/0x1234... --api-key YOUR_KEY
# Fetch by address + chain
bash scripts/source_fetcher.sh 0xAbCd...1234 --chain polygon
# Extract a ZIP
bash scripts/source_fetcher.sh ./client-contracts.zip --output ./audit-target
# Threat intel scan a repo before opening it
bash scripts/threat_intel_scan.sh /path/to/audit/repo
# Generate Mermaid complexity diagrams
bash scripts/codebase_visualizer.sh /path/to/src --output complexity_map.md
# Count nSLOC with effort estimate
bash scripts/sloc_counter.sh /path/to/src --pace 350
# Count Rust/Solana nSLOC
bash scripts/sloc_counter.sh /path/to/programs --lang rust --pace 300MIT
⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑
π Built for auditors, by auditors. π―
Stop wasting time on manual scoping.
⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑