Skip to content

0xRayaa/scoping-bee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐝 Scoping Bee

━━━━⬑⬑⬑━━━━ AI-POWERED AUDIT SCOPING ━━━━⬑⬑⬑━━━━

Point it at a codebase. Get a structured scope report.

Solidity (Foundry/Hardhat) Β· Solana/Anchor (Rust)


⬑ THE HIVE ⬑

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 β”‚
  β”‚                                                              β”‚
  ⬑─────────────────────────────────────────────────────────────⬑

⬑ INSTALLATION ⬑

πŸ”§ Install

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.

1. Clone the repo

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.)

2. Prerequisites

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.

3. Wire it into an AI assistant (optional)

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.
EOF

Cursor / other assistants: reference SKILL.md directly and pass the skill folder path in your prompt.

4. Environment variables (optional)

Only needed for explorer / contract-address inputs:

export EXPLORER_API_KEY=<your_etherscan_or_chain_api_key>

5. Smoke test

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/contracts

If nSLOC prints, you're ready.


⬑ RENDERING THE REPORT ⬑

πŸ–ΌοΈ How to view Mermaid diagrams in the report

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

βœ… Recommended: VS Code / Cursor extension

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-mermaid

Then open the report and press Cmd/Ctrl+Shift+V to preview β€” diagrams render inline.

βœ… Alternative: push to GitHub

Commit the report to any GitHub repo (public or private) and open it in the web UI β€” Mermaid blocks render without any configuration.

⚠️ Note on mermaid.live

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.


⬑ As an AI Skill ⬑

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"

⬑ FEATURES ⬑

πŸ“₯ Multi-Source Input

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 ./src

Supported explorers: Etherscan, BSCScan, Polygonscan, Arbiscan, Optimism, Fantom, Avalanche, Base (+ testnets)


πŸ›‘οΈ Pre-Audit Threat Intelligence Scan

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 πŸ›‘            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ—ΊοΈ Codebase Complexity Visualizer

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.md

8 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

πŸ“Š Configurable Audit Pace

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 400

πŸ” Dual Language Support

Auto-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

🎯 42 Attack Surface Checks

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

⬑ HIVE STRUCTURE ⬑

  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

⬑ SCOPING WORKFLOW ⬑

  ⬑─────────────────────────────────────────────────────────────⬑
  β”‚                                                              β”‚
  β”‚  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

⬑ COMPLEXITY SCORING ⬑

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

⬑ QUICK START ⬑

πŸ”§ Standalone Scripts

# 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 300

License

MIT


  ⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑
  🐝  Built for auditors, by auditors.                     🍯
      Stop wasting time on manual scoping.
  ⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑⬑

About

🐝 Scoping Bee - AI-powered pre-audit scoping skill for Solidity & Solana smart contract security engagements

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors