Schemathesis
$ schemathesis 社区开源 中风险schemathesis 基于 Hypothesis 自动从 OpenAPI 和 GraphQL 规范生成边界测试用例,以发现 500 错误和契约偏离。支持 --checks all、--report json,junit、--max-examples 与 --no-color,适合确定性 CI 与 Agent 接口验证。
brew install schemathesis 基于 OpenAPI/GraphQL 规范驱动的本地属性模糊测试器,自动批量发送生成的 HTTP 测试用例。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
支持无头执行、--report json,junit、--no-color、--include-method 范围过滤及可复现 --seed。
- Structured
--report json/ndjson/junitexports - Operation filters (
--include-method,--include-path)
默认会向 POST/PUT/DELETE 发送随机载荷,除非通过 --include-method GET 限制;v4 已移除 --dry-run。
- Mutating HTTP methods fuzzed unless explicitly filtered
- Legacy
--dry-runflag removed in Schemathesis v4
可通过 Homebrew、pip 与 uvx 在 macOS、Linux 与 Windows 安装,亦提供官方 Docker 镜像。
- Cross-platform Python package and Homebrew formula
无需手写用例即可基于 OpenAPI/GraphQL 自动发现边界崩溃与契约漂移。
- Stateful and property-based fuzzing via Hypothesis
由 Schemathesis 团队(schemathesis/schemathesis)积极维护,MIT 开源协议。
- Rapid active development and v4 releases
文档与 --help 对检查项、过滤规则与报告格式说明详尽。
- Detailed CLI guide on Read the Docs
安全边界、鉴权与放权指南
无内置凭证库;接口鉴权令牌通过 --header "Authorization: Bearer ..." 或 --auth 显式传递。
MIT 开源 Python CLI,完全免费。
# Schemathesis Agent Rules - Restrict read-only probes with `--include-method GET` when testing shared environments. - Never run full fuzzing (`POST`/`DELETE`) against production APIs—only target `localhost` or disposable test environments. - Always pass `--no-color` and `--report json --report-json-path <file>` when parsing failures.
Agent 高频安全命令配方
只读查询(安全推荐)
schemathesis run --include-method GET --checks all --max-examples 20 --no-color http://127.0.0.1:8000/openapi.json
将模糊测试限制在只读 GET 操作,每个接口最多生成 20 组边界用例。
受控写入与预演
schemathesis run --checks all --report json,junit --report-json-path report.json --report-junit-path junit.xml --no-color http://127.0.0.1:8000/openapi.json
对本地测试实例执行包含写操作在内的全量规范检查,并导出 JSON 与 JUnit 报告。
核心优势
- + 自动对 OpenAPI 与 GraphQL 接口做模糊测试,暴露 5xx 崩溃与响应体偏差。
- + 支持细粒度过滤(
--include-method、--include-path)及--report json,junit导出。 - + 支持随机种子(
--seed)以便确定性复现问题。
注意事项与踩坑点
- ! 除非显式限定
GET,否则默认会对POST、DELETE等写接口发起模糊请求。 - ! Schemathesis v4 已移除
--dry-run,执行即会发送真实请求。