agentleFS
surd-pollywog583surd-pollywog583/mycop/CLAUDE.md

mycop

CLAUDE.md2 starsChanged 10 months agoMITView on GitHub

mycop is an AI-powered code security scanner (SAST) written in Rust. It detects vulnerabilities in AI-generated code targeting Python, JavaScript, TypeScript, Go, and Java, with 200 built-in YAML security rules covering OWASP Top 10 and CWE Top 25. CI runs on both Ubuntu and macOS with stable Rust. All PRs must pass fmt, clippy, build, and test. CLI parsing (clap) → Config loading (.scanrc.yml) → File discovery (walkdir + gitignore) → Rule loading (embedded YAML via include_str!) → Parallel scanning…

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. AbdumajidRashidov/mycop★ 9100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repositoryOne other file it gives its agents.

The file

Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

What is mycop

mycop is an AI-powered code security scanner (SAST) written in Rust. It detects vulnerabilities in AI-generated code targeting Python, JavaScript, TypeScript, Go, and Java, with 200 built-in YAML security rules covering OWASP Top 10 and CWE Top 25.

Build & Development Commands

cargo build                    # Debug build
cargo build --release          # Optimized release build
cargo test --verbose           # Run all tests
cargo test scanner_tests       # Run a specific test module
cargo fmt --all -- --check     # Check formatting (CI enforced)
cargo clippy --all-targets -- -D warnings  # Lint (CI enforced, warnings are errors)

CI runs on both Ubuntu and macOS with stable Rust. All PRs must pass fmt, clippy, build, and test.

Architecture

Data Flow

CLI parsing (clap) → Config loading (.scanrc.yml) → File discovery (walkdir + gitignore) → Rule loading (embedded YAML via include_str!) → Parallel scanning (Rayon) → Severity filtering → Optional AI processing → Output reporting

Module Map (src/)

  • cli.rs — Clap-derived CLI definitions. Subcommands: scan, fix, review, init, rules list, deps check, mcp
  • main.rs — Command routing and orchestration for all subcommands
  • scanner/ — Core scanning engine
    • engine.rs — Parallel file scanning with Rayon (scan_files returns Vec<Finding>)
    • language.rs — Language detection from file extensions (Python, JS, TS, Go, Java)
    • file_discovery.rs — File globbing, gitignore-aware traversal, --diff mode via git
  • rules/ — Security rule system
    • registry.rs — Loads 200 YAML rules embedded at compile time via include_str! from rules/python/, rules/javascript/, rules/go/, and rules/java/
    • matcher.rs — Pattern matching using tree-sitter AST queries + regex. Produces Finding structs
    • parser.rs — YAML rule deserialization
  • ai/ — Pluggable AI backends behind the AiBackend trait
    • types.rs — AiBackend trait with explain(), deep_review(), fix_file() methods
    • mod.rs — Auto-detection and factory (detect_ai_provider, create_backend). Priority: Claude CLI → Anthropic API → OpenAI API → Ollama → rule-based fallback
    • Provider impls: claude_cli.rs, anthropic.rs, openai.rs, ollama.rs, rule_based.rs
    • prompt.rs — Prompt templates for AI interactions
  • fixer.rs — Auto-fix flow: groups findings per file, sends to AI, extracts <FIXED_FILE> tags from response, generates diffs, optionally writes back and re-scans for verification. Also provides diff_to_string() for generating plain-text diffs
  • mcp/ — MCP (Model Context Protocol) server for agentic tool integration
    • mod.rs — MycopMcpServer struct implementing ServerHandler trait. Handles list_tools, call_tool, list_resources, read_resource. Starts STDIO transport via MycopMcpServer::run()
    • tools.rs — 5 MCP tools implemented on MycopMcpServer using #[tool] proc macro: scan, list_rules, explain_finding, review, check_deps. The fix tool is intentionally excluded from MCP — agentic tools should read scan findings and apply fixes themselves. Sync impl functions bridged to async via tokio::task::spawn_blocking. Tools registered via rmcp::tool_box! macro
    • types.rs — MCP-specific request/response schemas with Deserialize + JsonSchema (inputs) and Serialize (outputs). Separate from core types to isolate MCP concerns
    • convert.rs — Conversions between core types (Finding, Rule) and MCP output types (FindingOutput, RuleOutput)
  • reporter/ — Output formatters implementing the Reporter trait
    • terminal.rs (colored), json.rs, sarif.rs (for CI/IDE integration)
  • config/scanrc.rs — Loads .scanrc.yml / .mycop.yml config (ignore patterns, min_severity, fail_on, ai_provider)

Rules (rules/)

200 YAML files (50 Python in rules/python/, 50 JavaScript in rules/javascript/, 50 Go in rules/go/, 50 Java in rules/java/). Each rule has: id, name, severity, CWE/OWASP mappings, pattern (regex and/or AST query), message, fix_hint. Rules are embedded into the binary at compile time.

Inline suppression: # mycop-ignore or # mycop-ignore:RULE-ID

Key Design Patterns

  • Embedded rules — No external files needed at runtime; YAML rules compiled into the binary
  • AST + regex dual matching — tree-sitter AST queries for structural analysis, regex for broader detection, with deduplication
  • AI provider chain — Auto-detects available providers with graceful fallback
  • Parallel scanning — Rayon parallel iterators with Arc<Mutex> for collecting findings
  • Severity ordinals — Critical=4, High=3, Medium=2, Low=1, Info=0; default fail threshold is High
  • MCP sync-to-async bridge — Core scanning uses Rayon (sync); MCP server uses tokio (async). Bridged with tokio::task::spawn_blocking. All stdout reserved for JSON-RPC in MCP mode; diagnostics go to stderr
  • Separate MCP types — FindingOutput/RuleOutput instead of adding Serialize/JsonSchema to core Finding/Rule, keeping MCP concerns isolated

Tests

Integration tests in tests/scanner_tests.rs with fixtures in tests/fixtures/. Tests cover file discovery, rule parsing, finding deduplication, config loading, and severity filtering.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.