Skip to content

Latest commit

Β 

History

History
106 lines (83 loc) Β· 3.8 KB

File metadata and controls

106 lines (83 loc) Β· 3.8 KB

Contributing to agentwise

Thanks for wanting to help make AI agents more secure.

Quick Start

git clone https://github.com/brandonwise/agentwise.git
cd agentwise
cargo test        # Run all tests
cargo clippy      # Lint
cargo run -- scan testdata/vulnerable-mcp.json  # Try it

Project Structure

src/
β”œβ”€β”€ main.rs              # CLI entry point (clap + tokio)
β”œβ”€β”€ config.rs            # MCP config parsing (serde)
β”œβ”€β”€ scanner.rs           # Scan orchestrator
β”œβ”€β”€ score.rs             # Scoring system (0-100)
β”œβ”€β”€ cvedb.rs             # Embedded CVE database
β”œβ”€β”€ osv.rs               # Live OSV vulnerability queries
β”œβ”€β”€ epss.rs              # EPSS exploitation probability scores
β”œβ”€β”€ supply_chain.rs      # npm registry supply chain analysis
β”œβ”€β”€ depsdev.rs           # deps.dev dependency graph analysis
β”œβ”€β”€ rules/
β”‚   β”œβ”€β”€ mod.rs           # Rule trait + registry
β”‚   β”œβ”€β”€ auth.rs          # AW-001: Missing authentication
β”‚   β”œβ”€β”€ filesystem.rs    # AW-002: Overpermissioned filesystem
β”‚   β”œβ”€β”€ shell.rs         # AW-003: Unrestricted shell
β”‚   β”œβ”€β”€ secrets.rs       # AW-004: Secrets in config
β”‚   β”œβ”€β”€ transport.rs     # AW-005: Insecure transport
β”‚   β”œβ”€β”€ cve.rs           # AW-006: Known CVE matching
β”‚   β”œβ”€β”€ allowlist.rs     # AW-007: Missing tool allowlist
β”‚   β”œβ”€β”€ write_tools.rs   # AW-008: Write-capable tools
β”‚   β”œβ”€β”€ network.rs       # AW-009: Unrestricted network
β”‚   β”œβ”€β”€ injection.rs     # AW-010: Prompt injection surface
β”‚   β”œβ”€β”€ supply_chain.rs  # AW-011: Supply chain risk signals
β”‚   └── deps.rs          # AW-012: Dependency graph analysis (deps.dev)
└── report/
    β”œβ”€β”€ terminal.rs      # Colorized terminal output
    β”œβ”€β”€ json.rs          # JSON output
    └── sarif.rs         # SARIF for GitHub Code Scanning

Adding a New Detection Rule

The easiest way to contribute is adding new detection rules.

  1. Create src/rules/your_rule.rs
  2. Implement the Rule trait:
pub struct YourRule;

impl Rule for YourRule {
    fn id(&self) -> &'static str { "AW-0XX" }
    fn check(&self, server_name: &str, server: &McpServer, config_file: &str) -> Vec<Finding> {
        let mut findings = vec![];
        // Your detection logic here
        findings
    }
}
  1. Register it in src/rules/mod.rs (add to all_rules())
  2. Add tests
  3. Run cargo test && cargo clippy -- -D warnings

For async analysis rules (like AW-011 and AW-012), see src/rules/supply_chain.rs and src/rules/deps.rs for the pattern β€” these are invoked from scanner.rs separately from the synchronous rule trait.

Adding CVEs

Edit cvedb/mcp-cves.json. Each entry needs:

{
  "id": "CVE-YYYY-XXXXX",
  "package": "@scope/package-name",
  "affected_versions": "<1.2.3",
  "severity": "critical|high|medium|low",
  "description": "What the vulnerability does",
  "fix": "How to fix it"
}

Adding Supply Chain Signals

Supply chain analysis lives in src/supply_chain.rs. To add new risk signals (e.g., checking for archived repos, deprecated packages), add detection logic to the analyze_package function and push a new RiskSignal to the signals vec.

Adding deps.dev Checks

Dependency graph analysis lives in src/depsdev.rs. The analyze_dependencies function queries the deps.dev API for transitive dependency counts, advisories, and license issues. Add new checks by extending the DepsAnalysis struct and the analysis logic.

Guidelines

  • Run cargo clippy -- -D warnings before submitting
  • Add tests for new rules (aim for edge cases)
  • Keep detection rules focused β€” one check per rule
  • False positives are worse than false negatives

Code of Conduct

Be kind. Be constructive. We're all here to make AI agents safer.