mantis README

项目的 README,来自 github.com/google/mantis。合并为一个 markdown 文件:README.md。

Mantis: Portable Toolkit for Building Secure Software

[!CAUTION] USE AT YOUR OWN RISK. BE EXTREMELY CAREFUL. This suite is designed to generate and execute autonomously generated code that may be unstable or perform unexpected actions. USE THIS ONLY IN ISOLATED, RESTRICTED ENVIRONMENTS. Never run this suite on a machine with access to production systems, sensitive data, or internal networks.

[!IMPORTANT] RESPONSIBLE USE AI models are non-deterministic and can hallucinate findings or generate incorrect patches. All findings must be manually verified by a security expert before being reported. Do not mass-file unverified, AI-generated reports to open-source maintainers. A failure to automatically reproduce a vulnerability does not definitively mean it is a false positive, nor does a successful reproducer guarantee the bug is exploitable in all contexts. Use Mantis responsibly.

[!WARNING] The pull request scan is untested. The GitHub Action in action/, the mantis-pr-scan and mantis-knowledge-refresh workflows under .github/workflows/, and reference/scripts/setup_github_action.sh have been reviewed and exercised against stubs, but have not yet been run end-to-end against a live project. Do not use the action to gate merges. The status note at the top of reference/docs/github-action.md lists what execution has not verified and will be removed when it has.

Mantis is a set of skills along with an ADK reference harness for building secure software in the new AI era of software development.

Getting Started

Prerequisites

1. Install

cd reference && ./install.sh

install.sh creates reference/.venv and, if docker/podman/buildah is available, builds the optional local sandbox image for dynamic reproduction. If no container/VM tooling is available, Mantis falls back cleanly to static-only.

2. Configure & verify

# Auto-detect sandbox capabilities and Vertex AI / GEMINI_API_KEY defaults
# (or pass --interactive for a guided wizard). Writes gitignored workflow.local.json.
.venv/bin/python3 scripts/configure.py --auto

# Non-Vertex providers: set --model explicitly (required for Anthropic, OpenAI, and --api-base)
# Gemini API:    .venv/bin/python3 scripts/configure.py --model gemini-3.8-flash
# Anthropic:     .venv/bin/python3 scripts/configure.py --model anthropic/claude-sonnet-5-5
# OpenAI/custom: .venv/bin/python3 scripts/configure.py --model openai/gpt-4o --api-base https://api.openai.com/v1

# Optional: force static-only mode (zero VM/container requirements)
.venv/bin/python3 scripts/configure.py --sandbox static-only

# Fast preflight check (~1s) + live LLM reachability probe
.venv/bin/python3 scripts/configure.py --test --probe

3. Run your first scan

./run.sh activates reference/.venv automatically and accepts either a single file or a repository directory:

# Balanced full-stack + firmware/RTL scan (defaults to --depth 30)
./run.sh /path/to/repo

# Fast triage (Critical/High focus, single campaign on typical repos)
./run.sh /path/to/repo --depth 10

# Exhaustive multi-pass deep audit across the repository
./run.sh /path/to/repo --depth 100

# Scan a single file
./run.sh /path/to/file.py

--depth takes any integer from 1 (fast shallow triage) to 100 (exhaustive full-coverage multi-pass audit) and defaults to 30. It smoothly scales risk-ranked file coverage, batch granularity, reasoning effort, deterministic sink checklists, and pass count while always respecting existing budget guardrails (--token-budget, --max-time) and explicit CLI overrides (--scan-mode, --passes, --reasoning-effort, --model, --sandbox). See reference/README.md for the full breakdown.

4. Inspect results & use Mantis during development

Every run prints a summary to the terminal and saves verified findings, threat models, risk scores, coverage, and learnings in reference/knowledge.db (custom path via --db):

# Query accumulated threat models, findings, and prior fixes for a file
.venv/bin/python3 scripts/advise.py --file /path/to/repo/src/auth.py

Common Options

# One-shot model or sandbox override without changing workflow.local.json
./run.sh /path/to/repo --sandbox static-only --model vertex_ai/gemini-3.8-flash

# Steer the planner in plain language, or exclude vendored/generated paths
./run.sh /path/to/repo --focus "look for IDOR"
./run.sh /path/to/repo --exclude vendor,testdata --exclude 'third_party/*'

# Choose an explicit scan mode, or verify fixes incrementally after editing code
./run.sh /path/to/repo --scan-mode file-by-file   # or whole, uncovered, cross-functional, auto
./run.sh /path/to/repo --scan-mode changed        # new run after edits (omit --resume)

# Resume an interrupted or budget-paused run on the same snapshot
./run.sh /path/to/repo --resume                   # inherits recorded scan mode

# Export/import learned knowledge alongside a repository (.mantis/knowledge/)
.venv/bin/python3 scripts/knowledge.py export --db knowledge.db --repo /path/to/repo
./run.sh /path/to/repo --import-knowledge /path/to/repo/.mantis/knowledge

# Control spend ceilings and parallelism (SQLite lock wait defaults to max(60s, 15s x --parallel))
./run.sh /path/to/repo --max-tokens 2M --cache-discount 1
./run.sh /path/to/repo --no-budget --parallel 32 --db-timeout 600   # or MANTIS_DB_TIMEOUT=600

# Synthesize a custom multi-agent research graph for a specific objective
./run.sh /path/to/repo --objective "Audit for SSRF in webhook handlers"

See reference/README.md for the complete CLI reference, scan modes, sandboxes, and Harness² evolution loop.

Overview of Mantis

Mantis is roughly designed to:

Additionally, the ADK reference harness shows some of the neat ways in which we can build agentic workflows. Specifically, reference/workflow.json shows how a deep review is done, and research graph synthesis (./run.sh target --objective "...") allows generating custom graph topologies on the fly. This is a very powerful construct because you can use this to build any kind of agentic deep dive security review you might imagine.

Mantis works out of the box across full-stack web apps, backend/systems code, firmware/RTL (Verilog, SystemVerilog, VHDL, embedded/eBPF), Smart Contracts/ZK, CI/CD supply chains, mobile (Swift, Objective-C, Dart, Android), AI/ML/agentic pipelines, desktop/browser extensions, and Cloud/IaC/policy repos — with blocklist-default file selection so novel languages and DSLs are never silently dropped. It is also intended to be a starting point rather than a rigid set of instructions: you can further adapt, tune, and extend the skills and specialized domain guides to fit your organization's specific stack. We provide an ADK-based reference harness which works out of the box, but any competent coding agent should be able to convert this to use your framework of choice.

We strongly recommend using AI to iterate on Mantis or integrate it with your existing harness. Use your internal documentation, coding standards, and build systems to augment the threat models you use for scanning. We also strongly recommend adapting risk calibration to your environment and risk tolerance.

Above all, while orchestrated vulnerability discovery is incredibly powerful and useful, it is even more important to use this in a suitably isolated environment to prevent impacting production systems. The ADK reference harness provides some example sandboxes for testing, but if you use the most advanced frontier models you should go beyond this and additionally set up an additional sandboxing layer that itself contains very strong monitoring to look for escape attempts.

License

Mantis is licensed under the Apache License, Version 2.0. Every Python and shell file carries the license header; reference/scripts/check_license_headers.py (run by pre-commit and the test suite) keeps it that way.

Disclaimers

This is not an officially supported Google product. If you are looking for a managed and hosted code security agent rather than building your own, we recommend CodeMender. This project is not eligible for the Google Open Source Software Vulnerability Rewards Program.

This project is intended for demonstration purposes only. It is not intended for use in a production environment.

mantis (google/mantis)

正在搜索数据库…

这是什么?Mantis 是一套技能工具箱外加一个参考智能体框架(基于 Google 的 ADK 构建),让 AI 编程智能体能够自主发现、复现、分诊并修补代码库中的漏洞。
这是现成的安全扫描器,还是需要我自己改造的东西?它明确只是一个起点,而非成品:一组技能和一个基于 ADK 的参考框架,供你适配、调整并扩展到自己的技术栈,任何称职的编程智能体都能把它移植到其他框架。
怎么让它跑起来?安装 python3-venv(例如“sudo apt install python3-venv”),然后运行仓库的安装脚本;Mantis 提供 mantis-configure 和 mantis-launch 工具,可在此之后自动完成设置和启动。
运行安装程序前需要先装好什么?除了 Python 3 的 venv 模块外,该项目还依赖一个基于 ADK 的参考框架;venv 可用之后,其余设置由 mantis-configure 处理。
直接把它指向我的代码库安全吗?不安全——README 警告它会执行自主生成的代码,这些代码可能不稳定或做出意料之外的事,并坚持要求只在隔离受限的环境中运行,绝不能在能访问生产环境、敏感数据或内部网络的机器上运行。
安装过程是否假定特定的操作系统?快速上手命令使用 apt(“sudo apt install python3-venv”),这意味着它面向 Debian/Ubuntu 风格的 Linux 环境;文档中没有 macOS 或 Windows 的安装步骤。
这是我可以依赖其官方支持的 Google 产品吗?不是——尽管它来自 google 组织并采用 Apache-2.0 许可,但它明确不是 Google 官方支持的产品,不符合 Google 开源漏洞奖励计划的资格,仅用于演示目的。
我可以不加自查就相信它报告的漏洞吗?不能。README 指出 AI 模型可能凭空捏造发现或生成错误的补丁,因此每条发现都必须由安全专家人工核实,并且要求不要把未经核实的 AI 生成报告批量提交给维护者。
它能直接投入生产安全流水线使用吗?不能,该项目明确仅用于演示目的,不打算在生产环境中使用。
这条流水线对一个代码库具体按什么步骤处理?它会审查提交历史并构建语义索引,生成威胁模型和研究假设,运行智能体进行调查,对发现去重和分诊,复现漏洞利用(甚至包括启动模拟服务器),串联漏洞以放大影响,通过对抗性的修复-验证循环修补 bug,并校准严重程度,让人类只需要看到最关键的问题。
Mantis 能用在典型 Web/应用代码之外的领域吗,比如硬件或基础设施?可以——README 称这些技能可以适配到 Hardware/RTL、Infrastructure as Code、ML 流水线或编译后的固件等专门领域,不过威胁模型需要你自己调整。
作者
google
大小
7.1 MB
星标
2.8K
更新
提交Nov 17
时长
5个月
提交 · 90 天