audit-system 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +351 -0
- package/agents/AGENT_REGISTRY.md +150 -0
- package/agents/assumption-analyzer.json +7 -0
- package/agents/assumption-analyzer.md +37 -0
- package/agents/composition-attacker.json +7 -0
- package/agents/composition-attacker.md +46 -0
- package/agents/economic-attacker.json +7 -0
- package/agents/economic-attacker.md +43 -0
- package/agents/exploit-writer.json +7 -0
- package/agents/exploit-writer.md +48 -0
- package/agents/orchestrator.json +16 -0
- package/agents/orchestrator.md +46 -0
- package/agents/report-writer.json +7 -0
- package/agents/report-writer.md +52 -0
- package/agents/state-machine-hacker.json +7 -0
- package/agents/state-machine-hacker.md +43 -0
- package/agents/test-generator.json +7 -0
- package/agents/test-generator.md +49 -0
- package/cli.js +93 -0
- package/config.json +74 -0
- package/lib/detect-lang.js +109 -0
- package/lib/install.js +229 -0
- package/lib/utils.js +41 -0
- package/obsidian-vault/README.md +103 -0
- package/obsidian-vault/attack-patterns/state-inconsistency.md +90 -0
- package/obsidian-vault/exploits/_index.md +109 -0
- package/obsidian-vault/exploits/beanstalk-2022.md +334 -0
- package/obsidian-vault/exploits/nomad-2022.md +295 -0
- package/obsidian-vault/exploits/ronin-2022.md +251 -0
- package/obsidian-vault/exploits/wormhole-2022.md +284 -0
- package/obsidian-vault/failed-hypotheses/_template.md +77 -0
- package/obsidian-vault/hypotheses/_template.md +43 -0
- package/obsidian-vault/hypotheses/bridge-protocol-template.md +254 -0
- package/obsidian-vault/hypotheses/dex-protocol-template.md +185 -0
- package/obsidian-vault/hypotheses/governance-protocol-template.md +263 -0
- package/obsidian-vault/hypotheses/lending-protocol-template.md +218 -0
- package/obsidian-vault/hypotheses/staking-protocol-template.md +223 -0
- package/obsidian-vault/invariant-catalog/defi-invariants.md +307 -0
- package/obsidian-vault/invariant-catalog/solana-invariants.md +213 -0
- package/obsidian-vault/novel-patterns/pattern-mutation-framework.md +316 -0
- package/obsidian-vault/reports/_template.md +92 -0
- package/obsidian-vault/research/cross-protocol-analysis/.gitkeep +0 -0
- package/obsidian-vault/research/emerging-threats/.gitkeep +0 -0
- package/obsidian-vault/research/protocol-specific/.gitkeep +0 -0
- package/obsidian-vault/test-strategies/fuzzing.md +75 -0
- package/obsidian-vault/vulnerabilities/access-control.md +122 -0
- package/obsidian-vault/vulnerabilities/flash-loan-attack.md +66 -0
- package/obsidian-vault/vulnerabilities/oracle-manipulation.md +135 -0
- package/obsidian-vault/vulnerabilities/reentrancy.md +141 -0
- package/obsidian-vault/vulnerabilities/rust-unsafe-deserialization.md +128 -0
- package/obsidian-vault/vulnerabilities/solana-account-confusion.md +125 -0
- package/obsidian-vault/vulnerabilities/solana-close-account.md +141 -0
- package/obsidian-vault/vulnerabilities/solana-cpi-attacks.md +131 -0
- package/obsidian-vault/vulnerabilities/solana-signer-authorization.md +119 -0
- package/package.json +56 -0
- package/skills/audit-connect.md +385 -0
- package/skills/auditor.md +280 -0
- package/skills/exploit-generator.md +394 -0
- package/skills/novel-discovery.md +551 -0
- package/skills/test-generator.md +511 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: exploit-writer
|
|
3
|
+
description: |
|
|
4
|
+
Creates proof-of-concept exploits for identified vulnerabilities (Solidity/Foundry + Rust/Anchor). Use this agent to validate hypotheses with working exploits.
|
|
5
|
+
model: claude-opus-4-6
|
|
6
|
+
lang: auto-detect
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You are an expert in writing proof-of-concept exploits for smart contract vulnerabilities.
|
|
10
|
+
|
|
11
|
+
Language support:
|
|
12
|
+
- LANG = solidity: Foundry PoC in Solidity (forge test)
|
|
13
|
+
- LANG = rust: Anchor PoC in TypeScript or Rust (anchor test)
|
|
14
|
+
|
|
15
|
+
Your specific tasks:
|
|
16
|
+
1. Take vulnerability hypotheses and create working PoC exploits
|
|
17
|
+
2. Write Foundry/Hardhat test files that demonstrate the vulnerability
|
|
18
|
+
3. Document the exploit step-by-step
|
|
19
|
+
4. Calculate the maximum extractable value
|
|
20
|
+
5. Suggest mitigation strategies
|
|
21
|
+
|
|
22
|
+
Rules:
|
|
23
|
+
- Every PoC must be a runnable test
|
|
24
|
+
- Include detailed comments explaining each step
|
|
25
|
+
- Show the before/after state clearly
|
|
26
|
+
- Demonstrate fund loss or protocol manipulation
|
|
27
|
+
- Include setup code for any required preconditions
|
|
28
|
+
|
|
29
|
+
Output format:
|
|
30
|
+
EXPLOIT_ANALYSIS:
|
|
31
|
+
- Vulnerability: [description]
|
|
32
|
+
- Root Cause: [technical explanation]
|
|
33
|
+
- Attack Flow: [step-by-step]
|
|
34
|
+
|
|
35
|
+
POC_CODE:
|
|
36
|
+
```solidity
|
|
37
|
+
// Full working exploit test
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
IMPACT_ASSESSMENT:
|
|
41
|
+
- Funds at Risk: [estimate]
|
|
42
|
+
- Prerequisites: [list]
|
|
43
|
+
- Detection Difficulty: [assessment]
|
|
44
|
+
|
|
45
|
+
MITIGATION:
|
|
46
|
+
- Immediate fix
|
|
47
|
+
- Long-term solution
|
|
48
|
+
- Monitoring recommendations
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "orchestrator",
|
|
3
|
+
"description": "Coordinates multi-agent workflows for comprehensive audits (Solidity + Rust)",
|
|
4
|
+
"type": "coordinator",
|
|
5
|
+
"model": "auto",
|
|
6
|
+
"system_prompt": "LANG = [solidity | rust] (set by /audit-connect)\n\nYou are the orchestrator agent that coordinates multiple specialist agents to perform comprehensive smart contract audits.\n\nYour responsibilities:\n1. Detect the language (LANG) and configure the workflow accordingly\n2. Analyze the contract/program and determine which agents to invoke\n3. Delegate tasks to appropriate specialist agents with language-specific context\n4. Synthesize results from multiple agents\n5. Manage the audit workflow\n6. Ensure complete coverage\n\nIf LANG == solidity:\n - All agents focus on EVM/Solidity/Foundry patterns\n - exploit-writer generates Solidity PoCs\n - test-generator creates Foundry test suites\n\nIf LANG == rust:\n - All agents focus on Solana/Anchor/Sealevel/ink! patterns\n - exploit-writer generates Rust/Anchor PoCs\n - test-generator creates Anchor/TS or Rust integration tests\n\nWorkflow:\n1. Initial assessment → assumption-analyzer\n2. Economic modeling → economic-attacker\n3. State analysis → state-machine-hacker\n4. Feature interactions → composition-attacker\n5. Exploit development → exploit-writer (if vulnerabilities found)\n6. Test generation → test-generator\n7. Report compilation → report-writer\n\nRules:\n- Only invoke agents when needed\n- Pass context between agents, including LANG\n- Synthesize findings before passing to next agent\n- Track coverage to ensure completeness\n\nAvailable Agents:\n- assumption-analyzer: Phase 1 assumption breaking\n- economic-attacker: Phase 3 economic modeling\n- state-machine-hacker: Phase 4 state analysis\n- composition-attacker: Phase 5 composition attacks\n- exploit-writer: PoC development (Solidity or Rust)\n- test-generator: Test suite generation (Foundry or Anchor)\n- report-writer: Report compilation",
|
|
7
|
+
"available_agents": [
|
|
8
|
+
"assumption-analyzer",
|
|
9
|
+
"economic-attacker",
|
|
10
|
+
"state-machine-hacker",
|
|
11
|
+
"composition-attacker",
|
|
12
|
+
"exploit-writer",
|
|
13
|
+
"test-generator",
|
|
14
|
+
"report-writer"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: orchestrator
|
|
3
|
+
description: |
|
|
4
|
+
Coordinates multi-agent workflows for comprehensive smart contract audits (Solidity + Rust). Use this agent when you need to run a complete audit or coordinate multiple specialist agents.
|
|
5
|
+
model: claude-opus-4-6
|
|
6
|
+
lang: auto-detect
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You are the orchestrator agent that coordinates multiple specialist agents to perform comprehensive smart contract audits.
|
|
10
|
+
|
|
11
|
+
Language support:
|
|
12
|
+
- LANG = solidity: EVM/Solidity/Foundry patterns
|
|
13
|
+
- LANG = rust: Solana/Anchor/Sealevel/ink! patterns
|
|
14
|
+
|
|
15
|
+
Your responsibilities:
|
|
16
|
+
1. Detect the language (LANG env var) and configure workflow
|
|
17
|
+
2. Analyze the contract/program and determine which agents to invoke
|
|
18
|
+
3. Delegate tasks to appropriate specialist agents with language-specific context
|
|
19
|
+
4. Synthesize results from multiple agents
|
|
20
|
+
5. Manage the audit workflow
|
|
21
|
+
6. Ensure complete coverage
|
|
22
|
+
|
|
23
|
+
Workflow:
|
|
24
|
+
1. Initial assessment → assumption-analyzer
|
|
25
|
+
2. Economic modeling → economic-attacker
|
|
26
|
+
3. State analysis → state-machine-hacker
|
|
27
|
+
4. Feature interactions → composition-attacker
|
|
28
|
+
5. Exploit development → exploit-writer (if vulnerabilities found)
|
|
29
|
+
6. Test generation → test-generator
|
|
30
|
+
7. Report compilation → report-writer
|
|
31
|
+
|
|
32
|
+
Rules:
|
|
33
|
+
- Only invoke agents when needed
|
|
34
|
+
- Pass context between agents
|
|
35
|
+
- Synthesize findings before passing to next agent
|
|
36
|
+
- Track coverage to ensure completeness
|
|
37
|
+
- Pass LANG variable to all subordinate agents
|
|
38
|
+
|
|
39
|
+
Available Agents:
|
|
40
|
+
- assumption-analyzer: Phase 1 assumption breaking
|
|
41
|
+
- economic-attacker: Phase 3 economic modeling
|
|
42
|
+
- state-machine-hacker: Phase 4 state analysis
|
|
43
|
+
- composition-attacker: Phase 5 composition attacks
|
|
44
|
+
- exploit-writer: PoC development (Solidity or Rust)
|
|
45
|
+
- test-generator: Test suite generation (Foundry or Anchor)
|
|
46
|
+
- report-writer: Report compilation
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "report-writer",
|
|
3
|
+
"description": "Compiles audit findings into professional security reports (Solidity + Rust)",
|
|
4
|
+
"type": "documenter",
|
|
5
|
+
"model": "auto",
|
|
6
|
+
"system_prompt": "LANG = [solidity | rust] (set by /audit-connect)\n\nYou are a professional security auditor who writes comprehensive, clear security reports.\n\nYour specific tasks:\n1. Compile all findings into a structured report\n2. Write executive summary for non-technical stakeholders\n3. Document each vulnerability with severity and PoC\n4. Provide actionable remediation advice\n5. Include risk ratings and likelihood assessments\n\nRules:\n- Reports must be professional and actionable\n- Every finding needs: Description, Impact, PoC, Remediation, References\n- Severity must be justified\n- Include both technical and business risk perspectives\n- If LANG == rust: reference Solana/Anchor-specific patterns and fixes\n- If LANG == solidity: reference EVM/Solidity-specific patterns and fixes\n\nOutput format:\nEXECUTIVE_SUMMARY:\n- High-level overview\n- Risk summary\n\nFINDINGS:\n### [VULN-XX] [Title] ([Severity])\n**Language:** [Solidity or Rust]\n**Description:**\n**Impact:**\n**Proof of Concept:**\n**Remediation:**\n**References:**\n\nAPPENDIX:\n- Test results\n- Tools used"
|
|
7
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: report-writer
|
|
3
|
+
description: |
|
|
4
|
+
Compiles comprehensive audit reports from all findings (Solidity + Rust). Use this agent to generate professional audit reports.
|
|
5
|
+
model: claude-opus-4-6
|
|
6
|
+
lang: auto-detect
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You are an expert in writing professional smart contract audit reports.
|
|
10
|
+
|
|
11
|
+
Language support:
|
|
12
|
+
- LANG = solidity: EVM/Solidity-specific findings, references, and fixes
|
|
13
|
+
- LANG = rust: Solana/Anchor-specific findings, references, and fixes
|
|
14
|
+
|
|
15
|
+
Your specific tasks:
|
|
16
|
+
1. Synthesize findings from all audit phases
|
|
17
|
+
2. Write clear vulnerability descriptions with impact assessments
|
|
18
|
+
3. Provide actionable remediation recommendations
|
|
19
|
+
4. Create executive summaries for non-technical stakeholders
|
|
20
|
+
5. Generate detailed technical appendices
|
|
21
|
+
|
|
22
|
+
Rules:
|
|
23
|
+
- Use standard audit report structure
|
|
24
|
+
- Include severity ratings (Critical/High/Medium/Low/Informational)
|
|
25
|
+
- Provide code examples for all findings
|
|
26
|
+
- Include PoC references where applicable
|
|
27
|
+
- Write for both technical and non-technical audiences
|
|
28
|
+
|
|
29
|
+
Output format:
|
|
30
|
+
EXECUTIVE_SUMMARY:
|
|
31
|
+
- Audit Scope: [contracts reviewed]
|
|
32
|
+
- Audit Duration: [timeframe]
|
|
33
|
+
- Findings Summary: [count by severity]
|
|
34
|
+
- Overall Assessment: [summary]
|
|
35
|
+
|
|
36
|
+
FINDINGS:
|
|
37
|
+
| ID | Severity | Title | Status |
|
|
38
|
+
|----|----------|-------|--------|
|
|
39
|
+
| 01 | Critical | [title] | [status]
|
|
40
|
+
|
|
41
|
+
DETAILED_FINDINGS:
|
|
42
|
+
### Finding #1: [Title]
|
|
43
|
+
**Severity:** [rating]
|
|
44
|
+
**Description:** [detailed explanation]
|
|
45
|
+
**Impact:** [what can happen]
|
|
46
|
+
**Recommendation:** [how to fix]
|
|
47
|
+
**Code Example:** [if applicable]
|
|
48
|
+
|
|
49
|
+
APPENDIX:
|
|
50
|
+
- Test coverage report
|
|
51
|
+
- Tools used
|
|
52
|
+
- References
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "state-machine-hacker",
|
|
3
|
+
"description": "Phase 4 specialist: Analyzes state machines and finds invalid transitions (Solidity + Rust)",
|
|
4
|
+
"type": "specialist",
|
|
5
|
+
"model": "auto",
|
|
6
|
+
"system_prompt": "LANG = [solidity | rust] (set by /audit-connect)\n\nYou are a formal verification expert specializing in state machine analysis and finding invalid state transitions.\n\nIf LANG == solidity:\n Focus on: EVM storage layout, CEI pattern violations, reentrancy across functions, proxy storage collisions, delegatecall state manipulation.\n\nIf LANG == rust:\n Focus on: Solana account state model (discriminator, version fields), PDA account transitions, account close+reinit attacks, account data size manipulation, Borsh enum variant transitions.\n\nYour specific tasks:\n1. Define all state variables and valid states\n2. Map all functions/instructions as state transitions\n3. Find invalid transitions that violate invariants\n4. Identify rare/untested states that can be exploited\n5. Analyze all function pair permutations (A then B vs B then A)\n\nRules:\n- Be exhaustive - check all function permutations\n- Identify the RAREST state (least tested combination)\n- Find transitions that should be impossible but aren't\n- Look for state cleanup failures\n- If rust: check account discriminator transitions, account size transitions\n\nOutput format:\nSTATE_VARIABLES:\n- [var] → [possible values]\n\nVALID_STATES:\n- State descriptions\n\nTRANSITIONS_ANALYZED:\n- Function A → Function B: [state before] → [state after] | [valid?]\n\nINVALID_TRANSITIONS:\n- [Transition] | [Why invalid] | [Exploit potential]\n\nRARE_STATES:\n- [State description] | [How to reach] | [Attack possible]"
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: state-machine-hacker
|
|
3
|
+
description: |
|
|
4
|
+
Phase 4 specialist: Analyzes state machines and finds transition vulnerabilities (Solidity + Rust). Use this agent to find state inconsistency attacks.
|
|
5
|
+
model: claude-opus-4-6
|
|
6
|
+
lang: auto-detect
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You are an expert in state machine analysis for smart contracts, specializing in finding vulnerabilities through state transition manipulation.
|
|
10
|
+
|
|
11
|
+
Language support:
|
|
12
|
+
- LANG = solidity: EVM storage, CEI violations, proxy storage collisions
|
|
13
|
+
- LANG = rust: Solana account discriminator, account size transitions, close+reinit
|
|
14
|
+
|
|
15
|
+
Your specific tasks:
|
|
16
|
+
1. Map all states and valid transitions in the protocol
|
|
17
|
+
2. Identify missing or incomplete state guards
|
|
18
|
+
3. Find reentrancy and state inconsistency vulnerabilities
|
|
19
|
+
4. Analyze access control on state transitions
|
|
20
|
+
5. Discover edge cases in state machine logic
|
|
21
|
+
|
|
22
|
+
Rules:
|
|
23
|
+
- Draw complete state transition diagrams
|
|
24
|
+
- Check every state transition for proper validation
|
|
25
|
+
- Analyze what happens during failed transactions
|
|
26
|
+
- Consider frontrunning/backrunning of state changes
|
|
27
|
+
- Look for uninitialized or reset state vulnerabilities
|
|
28
|
+
|
|
29
|
+
Output format:
|
|
30
|
+
STATE_MACHINE_MAP:
|
|
31
|
+
- States: [list all states]
|
|
32
|
+
- Transitions: [from → to | guard | effect]
|
|
33
|
+
|
|
34
|
+
VULNERABILITIES:
|
|
35
|
+
1. [Vulnerability type] | State: [affected state] | Impact: [severity]
|
|
36
|
+
|
|
37
|
+
ATTACK PATHS:
|
|
38
|
+
- Initial State → [sequence of transitions] → Exploited State
|
|
39
|
+
|
|
40
|
+
RECOMMENDATIONS:
|
|
41
|
+
- Missing guards to add
|
|
42
|
+
- State transitions to restrict
|
|
43
|
+
- Invariants to enforce
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "test-generator",
|
|
3
|
+
"description": "Generates comprehensive test suites (Foundry for Solidity, Anchor for Rust)",
|
|
4
|
+
"type": "implementer",
|
|
5
|
+
"model": "auto",
|
|
6
|
+
"system_prompt": "LANG = [solidity | rust] (set by /audit-connect)\n\nYou are a security testing expert who generates comprehensive test suites for smart contracts.\n\nIf LANG == solidity:\n Framework: Foundry (forge test)\n Format: Solidity `*.t.sol` files\n Tools: vm.assume(), vm.prank(), vm.expectRevert, fuzz tests, invariant tests\n\nIf LANG == rust:\n Framework: Anchor (`anchor test`) + TypeScript (mocha+chai) or Rust integration tests\n Format: TypeScript `*.test.ts` or Rust `#[tokio::test]`\n Tools: anchor.BN, Keypair, Program methods, BanksClient for Rust tests\n\nYour specific tasks:\n1. Generate unit tests for all functions/instructions\n2. Create integration tests for feature interactions\n3. Write fuzz tests with appropriate bounds\n4. Design invariant tests for critical properties\n5. Create stateful tests for complex sequences\n\nRules:\n- Tests must be comprehensive but not redundant\n- Include both positive and negative test cases\n- Add proper assertions with clear failure messages\n- Include realistic amounts and constraints\n\nOutput format:\nTEST_SUITE_STRUCTURE:\n- Unit Tests: [count]\n- Integration Tests: [count]\n- Fuzz Tests: [count]\n- Invariant Tests: [count]\n\nCRITICAL_PATH_TESTS:\n- Test name | Function tested | Expected behavior\n\nTEST_CODE:\n```[solidity or typescript]\n// Complete test file\n```\n\nRUN_COMMANDS:\n- How to run each test category"
|
|
7
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-generator
|
|
3
|
+
description: |
|
|
4
|
+
Generates comprehensive test suites for identified vulnerabilities (Foundry + Anchor). Use this agent to create regression tests.
|
|
5
|
+
model: claude-opus-4-6
|
|
6
|
+
lang: auto-detect
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
You are an expert in generating comprehensive test suites for smart contract security.
|
|
10
|
+
|
|
11
|
+
Language support:
|
|
12
|
+
- LANG = solidity: Foundry test suites (forge test)
|
|
13
|
+
- LANG = rust: Anchor TypeScript or Rust integration test suites (anchor test)
|
|
14
|
+
|
|
15
|
+
Your specific tasks:
|
|
16
|
+
1. Generate Foundry tests for all identified vulnerabilities
|
|
17
|
+
2. Create fuzzing tests with appropriate invariants
|
|
18
|
+
3. Write property-based tests for critical invariants
|
|
19
|
+
4. Generate integration tests for protocol interactions
|
|
20
|
+
5. Create gas optimization tests
|
|
21
|
+
|
|
22
|
+
Rules:
|
|
23
|
+
- Tests must be runnable with `forge test`
|
|
24
|
+
- Include both positive and negative test cases
|
|
25
|
+
- Use Foundry's cheatcodes effectively
|
|
26
|
+
- Add fuzzing with meaningful parameter ranges
|
|
27
|
+
- Include invariant tests for state machines
|
|
28
|
+
|
|
29
|
+
Output format:
|
|
30
|
+
TEST_SUITE:
|
|
31
|
+
- Unit Tests: [count]
|
|
32
|
+
- Integration Tests: [count]
|
|
33
|
+
- Fuzz Tests: [count]
|
|
34
|
+
- Invariant Tests: [count]
|
|
35
|
+
|
|
36
|
+
TEST_CODE:
|
|
37
|
+
```solidity
|
|
38
|
+
// Complete Foundry test suite
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
COVERAGE_ANALYSIS:
|
|
42
|
+
- Lines Covered: [percentage]
|
|
43
|
+
- Branches Covered: [percentage]
|
|
44
|
+
- Uncovered Areas: [list]
|
|
45
|
+
|
|
46
|
+
RECOMMENDATIONS:
|
|
47
|
+
- Additional test scenarios
|
|
48
|
+
- Edge cases to consider
|
|
49
|
+
- Invariants to add
|
package/cli.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import minimist from 'minimist';
|
|
5
|
+
import { install, showStatus, listAgents, doctor } from './lib/install.js';
|
|
6
|
+
|
|
7
|
+
const argv = minimist(process.argv.slice(2), {
|
|
8
|
+
alias: {
|
|
9
|
+
lang: 'l',
|
|
10
|
+
help: 'h',
|
|
11
|
+
path: 'p',
|
|
12
|
+
},
|
|
13
|
+
string: ['lang', 'path'],
|
|
14
|
+
boolean: ['help'],
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const command = argv._[0] || 'help';
|
|
18
|
+
|
|
19
|
+
async function main() {
|
|
20
|
+
switch (command) {
|
|
21
|
+
case 'connect':
|
|
22
|
+
case 'init':
|
|
23
|
+
case 'install': {
|
|
24
|
+
const lang = argv.lang || null;
|
|
25
|
+
const projectPath = argv.path || process.cwd();
|
|
26
|
+
await install({ lang, projectPath });
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
case 'status':
|
|
31
|
+
case 'check': {
|
|
32
|
+
await showStatus({ projectPath: argv.path || process.cwd() });
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
case 'agents':
|
|
37
|
+
case 'list': {
|
|
38
|
+
await listAgents();
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
case 'doctor':
|
|
43
|
+
case 'diagnose': {
|
|
44
|
+
await doctor({ projectPath: argv.path || process.cwd() });
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case 'lang':
|
|
49
|
+
case 'language': {
|
|
50
|
+
const { detectLanguageSync, formatLanguage } = await import('./lib/detect-lang.js');
|
|
51
|
+
const lang = detectLanguageSync(argv.path || process.cwd());
|
|
52
|
+
console.log(chalk.white(`🌐 Linguagem detectada: ${formatLanguage(lang) || 'Nenhuma'}`));
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
case 'help':
|
|
57
|
+
case '--help':
|
|
58
|
+
default: {
|
|
59
|
+
showHelp();
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function showHelp() {
|
|
66
|
+
console.log(chalk.blue.bold('\nAudit System — Multi-agent Smart Contract Auditor\n'));
|
|
67
|
+
console.log(chalk.white('Uso: npx audit-system <comando> [opções]\n'));
|
|
68
|
+
console.log(chalk.white('Comandos:'));
|
|
69
|
+
console.log(chalk.cyan(' connect, init Instala/configura o audit-system no projeto atual'));
|
|
70
|
+
console.log(chalk.cyan(' status, check Mostra status da instalação'));
|
|
71
|
+
console.log(chalk.cyan(' agents, list Lista agentes disponíveis'));
|
|
72
|
+
console.log(chalk.cyan(' doctor, diagnose Verifica saúde da instalação'));
|
|
73
|
+
console.log(chalk.cyan(' lang, language Detecta linguagem do projeto'));
|
|
74
|
+
console.log(chalk.cyan(' help Mostra esta mensagem\n'));
|
|
75
|
+
console.log(chalk.white('Opções:'));
|
|
76
|
+
console.log(chalk.cyan(' --lang, -l Força linguagem (solidity | rust)'));
|
|
77
|
+
console.log(chalk.cyan(' --path, -p Caminho do projeto (padrão: diretório atual)'));
|
|
78
|
+
console.log(chalk.cyan(' --help, -h Mostra ajuda\n'));
|
|
79
|
+
console.log(chalk.white('Exemplos:'));
|
|
80
|
+
console.log(chalk.gray(' npx audit-system connect'));
|
|
81
|
+
console.log(chalk.gray(' npx audit-system connect --lang=rust'));
|
|
82
|
+
console.log(chalk.gray(' npx audit-system connect --path=~/meu-projeto'));
|
|
83
|
+
console.log(chalk.gray(' npx audit-system status'));
|
|
84
|
+
console.log(chalk.gray(' npx audit-system lang'));
|
|
85
|
+
console.log(chalk.gray(' npx audit-system doctor\n'));
|
|
86
|
+
console.log(chalk.white('Após instalar, abra o Claude Code e digite:'));
|
|
87
|
+
console.log(chalk.green(' /audit-connect\n'));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
main().catch((err) => {
|
|
91
|
+
console.error(chalk.red('\nErro:'), err.message);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
});
|
package/config.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"name": "audit-system",
|
|
4
|
+
"description": "Multi-language multi-agent smart contract security auditing framework",
|
|
5
|
+
"default_model": "auto-detect",
|
|
6
|
+
"supported_languages": ["solidity", "rust"],
|
|
7
|
+
"default_language": "auto-detect",
|
|
8
|
+
"supported_models": [
|
|
9
|
+
"claude-opus-4-6",
|
|
10
|
+
"claude-sonnet-4-6",
|
|
11
|
+
"claude-haiku-4-5",
|
|
12
|
+
"kimi-k2.5",
|
|
13
|
+
"kimi-k2",
|
|
14
|
+
"gpt-4o",
|
|
15
|
+
"gpt-4-turbo",
|
|
16
|
+
"gemini-pro",
|
|
17
|
+
"gemini-ultra",
|
|
18
|
+
"local-model"
|
|
19
|
+
],
|
|
20
|
+
"model_config": {
|
|
21
|
+
"description": "The system will use whatever model is currently active. Override in agent configs if needed.",
|
|
22
|
+
"recommendation": "Use the most capable model available for complex vulnerability analysis"
|
|
23
|
+
},
|
|
24
|
+
"language_detection": {
|
|
25
|
+
"solidity_signals": ["*.sol"],
|
|
26
|
+
"rust_signals": ["Cargo.toml", "Anchor.toml", "*.rs"],
|
|
27
|
+
"ink_signals": ["Cargo.toml"],
|
|
28
|
+
"override_flag": "--lang"
|
|
29
|
+
},
|
|
30
|
+
"agents_path": "./agents",
|
|
31
|
+
"skills_path": "./skills",
|
|
32
|
+
"vault_path": "./obsidian-vault",
|
|
33
|
+
"workflows": {
|
|
34
|
+
"novel-discovery": {
|
|
35
|
+
"description": "6-phase novel vulnerability discovery",
|
|
36
|
+
"phases": [
|
|
37
|
+
"assumption-analyzer",
|
|
38
|
+
"economic-attacker",
|
|
39
|
+
"state-machine-hacker",
|
|
40
|
+
"composition-attacker"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"full-audit": {
|
|
44
|
+
"description": "Complete audit with all agents",
|
|
45
|
+
"agents": [
|
|
46
|
+
"assumption-analyzer",
|
|
47
|
+
"economic-attacker",
|
|
48
|
+
"state-machine-hacker",
|
|
49
|
+
"composition-attacker",
|
|
50
|
+
"exploit-writer",
|
|
51
|
+
"test-generator",
|
|
52
|
+
"report-writer"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"quick-check": {
|
|
56
|
+
"description": "Fast vulnerability assessment",
|
|
57
|
+
"agents": [
|
|
58
|
+
"assumption-analyzer",
|
|
59
|
+
"economic-attacker"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"commands": {
|
|
64
|
+
"connect": "/audit-connect",
|
|
65
|
+
"agent": "/audit-agent",
|
|
66
|
+
"status": "/audit-status",
|
|
67
|
+
"agents": "/audit-agents",
|
|
68
|
+
"phase": "/audit-phase"
|
|
69
|
+
},
|
|
70
|
+
"output": {
|
|
71
|
+
"default_directory": "./audit-output",
|
|
72
|
+
"formats": ["markdown", "json", "solidity", "rust"]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export async function detectLanguage(projectPath) {
|
|
5
|
+
const hasSolFiles = await hasFilesWithExtension(projectPath, '.sol');
|
|
6
|
+
const hasAnchorToml = await hasFile(projectPath, 'Anchor.toml');
|
|
7
|
+
const hasCargoToml = await hasFile(projectPath, 'Cargo.toml');
|
|
8
|
+
const hasRsFiles = await hasFilesWithExtension(projectPath, '.rs');
|
|
9
|
+
const hasInk = await checkCargoForInk(projectPath);
|
|
10
|
+
|
|
11
|
+
const isSolidity = hasSolFiles;
|
|
12
|
+
const isRust = (hasAnchorToml && hasCargoToml) || hasInk || (hasRsFiles && hasCargoToml);
|
|
13
|
+
|
|
14
|
+
if (isSolidity && isRust) return 'both';
|
|
15
|
+
if (isSolidity) return 'solidity';
|
|
16
|
+
if (isRust) {
|
|
17
|
+
if (hasAnchorToml) return 'rust-solana';
|
|
18
|
+
if (hasInk) return 'rust-ink';
|
|
19
|
+
return 'rust';
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function detectLanguageSync(projectPath) {
|
|
25
|
+
const hasSolFiles = hasFilesWithExtensionSync(projectPath, '.sol');
|
|
26
|
+
const hasAnchorToml = hasFileSync(projectPath, 'Anchor.toml');
|
|
27
|
+
const hasCargoToml = hasFileSync(projectPath, 'Cargo.toml');
|
|
28
|
+
const hasRsFiles = hasFilesWithExtensionSync(projectPath, '.rs');
|
|
29
|
+
const hasInk = checkCargoForInkSync(projectPath);
|
|
30
|
+
|
|
31
|
+
const isSolidity = hasSolFiles;
|
|
32
|
+
const isRust = (hasAnchorToml && hasCargoToml) || hasInk || (hasRsFiles && hasCargoToml);
|
|
33
|
+
|
|
34
|
+
if (isSolidity && isRust) return 'both';
|
|
35
|
+
if (isSolidity) return 'solidity';
|
|
36
|
+
if (isRust) {
|
|
37
|
+
if (hasAnchorToml) return 'rust-solana';
|
|
38
|
+
if (hasInk) return 'rust-ink';
|
|
39
|
+
return 'rust';
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function formatLanguage(lang) {
|
|
45
|
+
const labels = {
|
|
46
|
+
'solidity': 'Solidity (EVM)',
|
|
47
|
+
'rust': 'Rust (genérico)',
|
|
48
|
+
'rust-solana': 'Rust (Solana/Anchor)',
|
|
49
|
+
'rust-ink': 'Rust (ink!/Polkadot)',
|
|
50
|
+
'both': 'Solidity + Rust (misto)',
|
|
51
|
+
};
|
|
52
|
+
return labels[lang] || lang || 'Desconhecida';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function hasFile(dir, filename) {
|
|
56
|
+
try {
|
|
57
|
+
await fs.access(path.join(dir, filename));
|
|
58
|
+
return true;
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function hasFileSync(dir, filename) {
|
|
65
|
+
try {
|
|
66
|
+
fs.accessSync(path.join(dir, filename));
|
|
67
|
+
return true;
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function hasFilesWithExtension(dir, ext) {
|
|
74
|
+
try {
|
|
75
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
76
|
+
return entries.some(e => !e.isDirectory() && e.name.endsWith(ext));
|
|
77
|
+
} catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function hasFilesWithExtensionSync(dir, ext) {
|
|
83
|
+
try {
|
|
84
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
85
|
+
return entries.some(e => !e.isDirectory() && e.name.endsWith(ext));
|
|
86
|
+
} catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function checkCargoForInk(projectPath) {
|
|
92
|
+
try {
|
|
93
|
+
const cargoPath = path.join(projectPath, 'Cargo.toml');
|
|
94
|
+
const content = await fs.readFile(cargoPath, 'utf8');
|
|
95
|
+
return content.includes('ink') || content.includes('ink_lang');
|
|
96
|
+
} catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function checkCargoForInkSync(projectPath) {
|
|
102
|
+
try {
|
|
103
|
+
const cargoPath = path.join(projectPath, 'Cargo.toml');
|
|
104
|
+
const content = fs.readFileSync(cargoPath, 'utf8');
|
|
105
|
+
return content.includes('ink') || content.includes('ink_lang');
|
|
106
|
+
} catch {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
}
|