Skip to content

Latest commit

 

History

History
215 lines (178 loc) · 15.4 KB

AGENTS.md

File metadata and controls

215 lines (178 loc) · 15.4 KB

RedAmon - Agent Ruleset (Repository Root)

Skills: on-demand rulesets live in skills/. The full list is the SKILLS CATALOGUE at the bottom of this file. The table directly below is generated by sync.sh from each skill's frontmatter - never hand-edit it.

This ruleset system is documented in docs/readmes/skills_management/SKILLS_MANAGEMENT.md.

Auto-invoke Skills

When performing these actions, ALWAYS invoke the corresponding skill FIRST:

Action Skill
Adding a Tradecraft setting, table or column tradecraft-library
Adding a node label, relationship, or property to the graph schema graph-db-writes
Adding a path a project collaborator can reach, or a ticket, token or job that carries a tenant and an actor rbac-authz
Adding a tool AI Navigator can call navigator
Adding an agent model call site, a retry loop, or a path that builds an LLM from a model id agent-in-the-loop
Adding or editing a test file in any section redamon-testing
Adding, cleaning or refreshing a wordlist (mcp/kali-sandbox/wordlists, tooling/scripts/wordlists) wordlist-catalog
Changing how a triage score, review or verdict is computed or written priority-board-triage
Changing how plugin services, networks or the plugins overlay are started by redamon.sh or compose plugin-platform
Changing test tiers, conftest.py, pytest.ini, or the runner in redamon.sh redamon-testing
Checking or ratcheting a coverage floor redamon-testing
Editing AI Navigator (agentic/navigator, lib/navigator, the navigator routes or components) navigator
Editing Tradecraft (agentic/tradecraft, lib/tradecraft, the tradecraft routes or components) tradecraft-library
Editing the Agent in the Loop broker, adapter, routes or loop MCP tools agent-in-the-loop
Editing the Logs tab, its routes, lib/logs or a logging setting logs-management
Editing the Priority Board, the triage graph mixin, or the MCP triage tools priority-board-triage
Editing the agent's log routing or levels, or a scan's detail writer (tool_log.py, detail_log.py) logs-management
Editing the caller-supplied Cypher filters (injectProjectFilter.ts, graph_db/tenant_filter.py) rbac-authz
Editing the log archive, the logs file service or the sweeper (recon_orchestrator/log_archive) logs-management
Editing the plugin platform: the plugins lib or routes, the plugin runner, or the Gateway plugin-platform
Editing the wordlists tool, wl, wordlists_lib or the wordlist map wordlist-catalog
Editing webapp/src/lib/authz, a route's permission guard, or the route manifest rbac-authz
Investigating a red, skipped or xfailed test redamon-testing
Naming a wordlist path in a prompt, skill or tool description wordlist-catalog
Removing a scan container, or editing _discard, in recon_orchestrator/container_manager.py logs-management
Writing to the Neo4j graph or editing a graph_db mixin graph-db-writes

CRITICAL RULES - NON-NEGOTIABLE

  • NEVER commit real-world target data - live hostnames, IPs, scan output, recon results, captured traffic, or credentials - in code, fixtures, tests, issues, or PRs. See CONTRIBUTING.md -> "Legal and Ethical Responsibilities".
  • NEVER validate a change by running pytest on the host. The Python gate runs each section INSIDE its Docker image (redamon-agent, redamon-recon, ...) via ./redamon.sh test / ./agentic/run_tests.sh; host pytest sees the wrong dependency set and mis-collects. The unit tier must stay 100% green.

CODE COMMENTS

Comment the why, not the what. Keep them short - a comment earns its place by saying something the code cannot.

  • DON'T restate the line below it. # CVE Lookup above 'CVE_LOOKUP_ENABLED' or // IncludeSecurity blog above { name: 'IncludeSecurity blog' } adds nothing. Delete echo comments; let the identifier speak.
  • DO explain non-obvious intent: why a value is what it is, a footgun, an ordering constraint, or the provenance of a magic constant (e.g. the source repo + byte size behind a favicon hash). These are the comments worth keeping, even when long.
  • NO changelog narration. # was 900 MB, now 1.75 GB / # renamed from X belongs in the git log. State current behavior; keep the rationale only if it still guides a future edit.
  • NO commented-out code. Delete it - git remembers.
  • Prefer a clearer name or a helper over a comment when the comment only exists to decode the code. Reach for prose (a docstring / block comment) when the reasoning genuinely needs more than a line.

LLM-facing text is exempt: tool docstrings and prompt strings the agent reads at runtime are content, not code comments - size them for the model, not this rule.


TECH STACK

Polyglot monorepo orchestrated by Docker Compose. Python services on 3.11 (the agent, recon pipeline, recon orchestrator, plugin runner, the two supply-chain images) and 3.12 (the gvm, github-hunt, trufflehog, baddns, ai-attack-surface and capture-proxy scanners, the docker broker); the MCP/kali-sandbox runs whatever Python kalilinux/kali-rolling:latest ships, in /opt/venv, so check a pin against that, not 3.11. Plus a Next.js 16 / React 19 / TypeScript / Prisma webapp, Neo4j graph DB and Postgres. redamon.sh (bash) is the control plane for build/run/test.

PROJECT STRUCTURE

Only the roots an agent needs to place a file. agentic/, recon/, recon_orchestrator/ and webapp/ carry their own AGENTS.md (so do scanners/capture_proxy/ and scanners/supply_chain_scan/); the other roots follow this file alone.

agentic/              Python - the LangGraph agent (baked into redamon-agent image)
recon/                Python - the recon pipeline (spawned per scan job)
recon_orchestrator/   Python - orchestrates scan containers (volume-mounted)
mcp/                  Python - MCP servers incl. kali-sandbox
graph_db/             Python - Neo4j graph layer (COPY-baked into agent image)
webapp/               TypeScript - Next.js frontend + API + Prisma
skills/               agent skills (this ruleset system)
tests/                repo-root Python tests + shell integration tests

scanners/             the 11 scan tools, each its own container image
  supply_chain_*/       malicious/vulnerable package detection (OSV offline)
  capture_proxy/        mitmproxy HTTP capture
  ai_attack_surface_scan/  LLM/AI attack-surface scanning
  gvm_scan/  github_secret_hunt/  trufflehog_scan/  baddns_scan/  wcvs/  codefix_sandbox/
services/             supporting services (docker_broker, knowledge_base, postgres_db,
                      plugin_runner: the plugin runner + plugin-gateway proxy image)
testing/              e2e/ (Playwright) + guinea_pigs/ (vulnerable targets)
tooling/              scripts/ (e.g. pytest_isolated.py), hooks/, deploy/
docs/                 readmes/ (prose docs) + assets/ (media)

A scanner's container-side paths stay /app/<scanner>; only host-side paths carry the scanners/ prefix.

redamon-plugins/, if present at the root, is a separate git repository (the plugins and their signed catalog, public as samugit83/redamon-plugins), ignored by .gitignore: never commit it here, and never put plugin logic in this repository.

Prose docs live in docs/readmes/ (architecture, README.<SUBSYSTEM>.md, and docs/readmes/coding_agent_prompts/ "how to add X" guides) and redamon.wiki/ (the published GitHub wiki). This ruleset system and its templates live in docs/readmes/skills_management/.

COMMANDS

# Build & run the stack (always via Docker; never local npx/node/pip)
# There is no `build` subcommand: building happens inside install/update, which
# wrap it in the adaptive, memory-safe batching (compose_build).
./redamon.sh install          # first run (add --gvm / --kbase)
./redamon.sh update           # pull + smart-rebuild only what changed
./redamon.sh up               # start what is already built

# Test - runs each section inside its Docker image, per-file isolated
./redamon.sh test unit        # the gate; must be 100% green
./agentic/run_tests.sh        # agent-image unit gate (alias: focused)

# Webapp (needs the webapp image or `npm ci` in webapp/)
cd webapp && npm run test     # vitest run --no-file-parallelism
cd webapp && npm run type-check && npm run lint

CREDENTIALS

Never write a credential value into a tracked file (this one is public on GitHub) and never echo one: read it inline, into the command that needs it.

  • Local stack: repo-root .env (gitignored). For UI / browser e2e tests sign in with UI_LOGIN_USERNAME / UI_LOGIN_PASSWORD. For the inbound MCP server send MCP_SERVER_TOKEN as Authorization: Bearer to http://localhost:3000/api/mcp-server (the port is WEBAPP_PORT if changed).
  • GitHub (gh): the maintainer's .env.local (gitignored, may be absent) holds fine-grained PATs: GH_TOKEN_REDAMON for samugit83/redamon, GH_TOKEN_REDAMON_PLUGINS for samugit83/redamon-plugins. Its comments record what each token was verified to allow; read them before a write.
curl -s -H "Authorization: Bearer $(grep -m1 '^MCP_SERVER_TOKEN=' .env | cut -d= -f2-)" \
  -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' http://localhost:3000/api/mcp-server
GH_TOKEN="$(grep -m1 '^GH_TOKEN_REDAMON=' .env.local | cut -d= -f2-)" gh pr list

QA CHECKLIST

  • ./redamon.sh test unit is green (Docker gate, not host pytest).
  • Changed a component? Its AGENTS.md QA checklist also satisfied.
  • Rebuilt/restarted the right container for the files you touched.
  • No real-world target data added anywhere.
  • Commit follows Conventional Commits; branch is feature|fix|refactor|docs/*.

SKILLS CATALOGUE

Maintained by hand (not touched by sync.sh). One row per skill.

Skill Description URL
redamon-testing How tests run + how to author them: the per-file Docker gate, tiers, and green-run-that-lies failure modes SKILL.md
agentic-tool-integration Wiring a new tool the agent can call: registry, phase map, dispatch chokepoint, duplicated exec paths SKILL.md
builtin-agent-skill Adding a built-in attack skill across its 10 layers (incl. the KNOWN_ATTACK_PATHS gate, the skill-part registry + silent drawer layers) SKILL.md
project-settings-cascade Changing/adding a project default across Prisma + two Python modules + /defaults + frontend + existing rows SKILL.md
graph-db-writes Writing the Neo4j graph: the tenant-isolation MERGE key, mixin placement, schema-sync SKILL.md
recon-ai-enrichment Wiring an LLM into a recon tool: never-raise, per-target cache, full+partial, two toggles one field SKILL.md
recon-tool-integration Adding a recon pipeline tool: the enrichment _isolated contract, graph completeness, preset catalog SKILL.md
llm-provider-integration Adding an LLM provider: keys never reach scan containers, prefix-routed model ids, the registry SKILL.md
orchestrator-container-spawn Spawning/hardening scan containers: the cap_drop / no-new-privileges footgun, sibling bind mounts SKILL.md
traffic-capture Capture proxy + replay/fuzz: the egress guard (resolved-IP SSRF denylist), off the scan's critical path SKILL.md
supply-chain-scan Supply-chain scanner: offline OSV DB (not scan-bootstrapped), world-readable DB, soft-error markers SKILL.md
add-community-skill Importable .md attack workflow: real tool names only, no rebuild, stay classifiable, per-user SKILL.md
add-partial-recon Partial-recon support: graph-sourced inputs, MERGE dedup, the input-node modal, mirror the right ref impl SKILL.md
mcp-server-tools Inbound MCP server tools: regenerate the wiki API reference, spec-accurate destructiveHint, runnable example calls SKILL.md
priority-board-triage Priority Board layers: nobody writes a score (combine_layers only), one layer per writer, never updated_at, legacy-tolerant readers SKILL.md
plugin-platform Plugin platform: no plugin logic in the base, plugin services only via plugins_converge, overlay-only webapp wiring, every Gateway call re-authorized, plugins only propose SKILL.md
agent-in-the-loop Agent in the Loop (an external MCP client answers the agent's model calls): only inside its own run scope, never retried, refused on every session-less builder, a driver token holds read scopes only, a person picks the brain and answers every approval SKILL.md
navigator AI Navigator, the read-only docs and project-data chat: every project read is a webapp callback re-authorized fresh, the person's own model only, no write tool, each tool declares its permissions, exact MCP scopes and level, nothing a chat calls takes a process-wide resource SKILL.md
tradecraft-library Tradecraft, each account's library of knowledge sites: every page-store statement keyed by owner and resource, reads never write, page text always untrusted, a login only to its own host and its owner's runs, one catalog policy, model calls labelled and never retried, settings only in the generated spec SKILL.md
rbac-authz Authorization: every check through lib/authz (the helper per case), the read views for non-owners, the Cypher allowlists, tenant vs actor in every hop, onAccessReduced on every access loss, audit inside auditedTransaction, a switch with its flags-off test, the route manifest SKILL.md
wordlist-catalog The Kali sandbox's wordlist catalog: licensed lists only, no payloads, breach corpora or real data (checked by an independent scan), catalog.yaml the source of truth with every prompt path required, the index after the Metasploit refresh, a read-only companion tool that sees only the run's project SKILL.md
logs-management The per-project logs in ./logs: detail never on a scan's stdout, every container removal through _discard, ids walked by descriptor (injective route keys, exact names), the database decides who reads a chat's log, the two redaction copies identical, no detail redacted or served while its scan runs, logging settings closed to MCP, the agent's policy never from get_setting, a group off writes nothing, diff the schema before a webapp rebuild SKILL.md