Brakeman
$ brakeman 社区开源 低风险Brakeman 是 Ruby on Rails 应用的标准静态安全扫描器,无需加载或运行 Rails 应用即可解析 Ruby AST。它原生支持 -f json 与 -f sarif、--only-files 定向扫描、-q 静默模式及 --no-exit-on-warn,自动化输出高度可预测。
https://github.com/presidentbeef/brakeman/releases brakeman -f json 在本地数秒内静态解析 Rails 代码库,无需启动应用或通过 MCP 传输源码。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
支持 -f json|sarif、--only-files、-q、--no-pager、--no-color 与 --no-exit-on-warn,无头自动化体验干净。
- Native
-f json,-f sarif,--only-files, and--no-exit-on-warn
纯静态 Ruby AST 检查,绝不执行应用代码或数据库迁移。
- Zero code execution; read-only unless
-owrites a report
可通过 RubyGems(gem install brakeman)或 Docker 跨平台运行,但依赖 Ruby 运行时且无 Homebrew 核心配方。
- RubyGem distribution requiring Ruby runtime
深度理解 Rails 路由、ActiveRecord、ERB 模板与批量赋值模式。
- Deep Rails framework semantics
长期公认的 Rails 安全标准,但 2018 年后代码采用非完全开源的 Brakeman Public Use License。
- Maintained at presidentbeef/brakeman under Brakeman Public Use License
brakemanscanner.org 提供详尽的参数、告警类型与 CI 集成文档。
- Official docs at brakemanscanner.org/docs/
安全边界、鉴权与放权指南
无需凭据;完全离线分析本地 Rails 源码目录。
在 Brakeman Public Use License 下非商业用途免费;商业用途可能需要额外许可。
# Brakeman Agent Rules - Always pass `-q --no-pager -f json` (and `--no-exit-on-warn` when parsing JSON rather than failing immediately on `-z`). - Verify commercial usage terms under the Brakeman Public Use License for proprietary pipelines.
Agent 高频安全命令配方
只读查询(安全推荐)
brakeman -f json -q --no-exit-on-warn --no-pager .
以静默模式(-q)禁用分页运行默认检查,并向 stdout 输出结构化 JSON。
brakeman -A -f sarif --only-files app/controllers/users_controller.rb -o brakeman.sarif .
仅针对 --only-files 指定文件运行全部检查(-A),并将 SARIF 报告保存至 brakeman.sarif。
核心优势
- + 无需启动应用即可静态理解 Rails 特有攻击面。
- + 提供成熟的
-f json/-f sarif、--only-files与-q --no-pager参数。
注意事项与踩坑点
- ! 2018 年后的版本使用带有商业使用限制的 Brakeman Public Use License。
- ! 依赖 Ruby 环境(
gem install brakeman),非独立静态二进制文件。