brakeman

presidentbeef活跃维护

针对 Ruby on Rails 应用的静态安全扫描器,不用跑起来就能查出代码里的 SQL 注入、XSS 等常见漏洞,适合接入 CI 做安全审计。

A static analysis security vulnerability scanner for Ruby on Rails applications

v8.1.0发布于 2026-09-30 23:29 UTC7,294star +1 / 7 天779fork同步于 2026-11-11 05:31 UTC

怎么上手

由 README 提炼,执行前请确认
gem install brakeman
brakeman /path/to/rails/application
硬件要求按 README 说明

README 未说明硬件要求;运行需 Ruby 3.2.0 及以上,可分析 Ruby 2.0 语法及更新的代码。

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

静态扫描 Ruby on Rails 应用安全漏洞的命令行工具,无需运行应用即可出报告

针对 Ruby on Rails 应用的静态安全扫描器,不用跑起来就能查出代码里的 SQL 注入、XSS 等常见漏洞,适合接入 CI 做安全审计。

核心能力

  • 静态分析 Rails 代码,无需启动应用
  • 支持 Rails 2.3.x 到 8.x 版本
  • 输出 text、html、json、sarif 等多种格式
  • 按高/中/低置信度过滤告警
  • 用 brakeman.ignore 忽略误报并支持对比两次扫描

容易踩的坑

运行环境至少需要 Ruby 3.2.0,低于此版本无法启动;默认发现安全告警或扫描错误时返回非零退出码,接入 CI 需注意或用 --no-exit-on-warn 关闭;--faster 会跳过部分检查,可能漏报漏洞。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v8.1.0
  1. v8.1.08.1.0最新正式版2026-09-30 · 2026-09-30 23:29 UTC
    • Update SonarQube report to use generic issue format (@fffx)
    • Include regex code in validation warnings (@eliotsykes)
    • Check validation regexes in non-activerecord models (@eliotsykes)
    • Skip top-level vendor directory before recursive globbing (@ronocod)
    • Support Rails 7.1+ positional enum syntax in SQL injection check (@cubasepp / @Eljees)
    • Recognize Haml::AttributeBuilder.build_class as an escaped output (@Eljees)
    • Fix frozen string error (@shaicoleman)
    • Better help and error message for --ensure-latest (#2036)
  2. v8.0.68.0.6 - EOL Dates2026-08-12 · 2026-08-12 21:33 UTC
    查看更新说明
    • Fix EOL date for Rails 8.0 (@yeaseul-kim)
    • Fix command injection false positives (@JacobEvelyn )
    • Fix unused variable warning (@viralpraxis)
    • Add EOL dates for Rails 8.1 and Ruby 4.0
  3. v8.0.58.0.52026-06-12 · 2026-06-12 22:54 UTC
    查看更新说明
  4. v8.0.38.0.32026-02-26 · 2026-02-26 21:26 UTC
    查看更新说明
    • Add release age option for --ensure-latest (#1989)
    • Fix polymorphic_name SQLi false positive (Fredrico Franco)
    • Fix logger behavior when loading config files (#2009)
    • Handle application names with module prefixes (#2011)
  5. v8.0.28.0.22026-02-03 · 2026-02-03 20:13 UTC
    查看更新说明
    • Reline console control should use stderr
    • Fix logger cleanup based method (Imran Iqbal)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Brakeman Logo

    Build Status Code Coverage

    Brakeman

    Brakeman is a static analysis tool which checks Ruby on Rails applications for security vulnerabilities.

    Installation

    Using RubyGems:

    gem install brakeman
    

    Using Bundler:

    group :development do
      gem 'brakeman', require: false
    end
    

    Using Docker:

    docker pull presidentbeef/brakeman
    

    Using Docker to build from source:

    git clone https://github.com/presidentbeef/brakeman.git
    cd brakeman
    docker build . -t brakeman
    

    Usage

    Running locally

    From a Rails application's root directory:

    brakeman
    

    Outside of Rails root:

    brakeman /path/to/rails/application
    
    Running with Docker

    From a Rails application's root directory:

    docker run -v "$(pwd)":/code presidentbeef/brakeman
    

    With a little nicer color:

    docker run -v "$(pwd)":/code presidentbeef/brakeman --color
    

    For an HTML report:

    docker run -v "$(pwd)":/code presidentbeef/brakeman -o brakeman_results.html
    

    Outside of Rails root (note that the output file is relative to path/to/rails/application):

    docker run -v 'path/to/rails/application':/code presidentbeef/brakeman -o brakeman_results.html
    

    Compatibility

    Brakeman should work with any version of Rails from 2.3.x to 8.x.

    Brakeman can analyze code written with Ruby 2.0 syntax and newer, but requires at least Ruby 3.2.0 to run.

    Basic Options

    For a full list of options, use brakeman --help or see the OPTIONS.md file.

    To specify an output file for the results:

    brakeman -o output_file
    

    The output format is determined by the file extension or by using the -f option. Current options are: text, html, tabs, json, junit, markdown, csv, codeclimate, github, sarif, and sonar.

    Multiple output files can be specified:

    brakeman -o output.html -o output.json
    

    To output to both a file and to the console, with color:

    brakeman --color -o /dev/stdout -o output.json
    

    To suppress informational warnings and just output the report:

    brakeman -q
    

    Note all Brakeman output except reports are sent to stderr, making it simple to redirect stdout to a file and just get the report.

    To see all kinds of debugging information:

    brakeman -d
    

    Specific checks can be skipped, if desired. The name needs to be the correct case. For example, to skip looking for default routes (DefaultRoutes):

    brakeman -x DefaultRoutes
    

    Multiple checks should be separated by a comma:

    brakeman -x DefaultRoutes,Redirect
    

    To do the opposite and only run a certain set of tests:

    brakeman -t SQL,ValidationRegex
    

    If Brakeman is running a bit slow, try

    brakeman --faster
    

    This will disable some features, but will probably be much faster (currently it is the same as --skip-libs --no-branching). WARNING: This may cause Brakeman to miss some vulnerabilities.

    By default, Brakeman will return a non-zero exit code if any security warnings are found or scanning errors are encountered. To disable this:

    brakeman --no-exit-on-warn --no-exit-on-error
    

    To skip certain files or directories that Brakeman may have trouble parsing, use:

    brakeman --skip-files file1,/path1/,path2/
    

    To compare results of a scan with a previous scan, use the JSON output option and then:

    brakeman --compare old_report.json
    

    This will output JSON with two lists: one of fixed warnings and one of new warnings.

    Brakeman will ignore warnings if configured to do so. By default, it looks for a configuration file in config/brakeman.ignore. To create and manage this file, use:

    brakeman -I
    

    If you want to temporarily see the warnings you ignored without affecting the exit code, use:

    brakeman --show-ignored
    

    Warning information

    See warning_types for more information on the warnings reported by this tool.

    Warning context

    The HTML output format provides an excerpt from the original application source where a warning was triggered. Due to the processing done while looking for vulnerabilities, the source may not resemble the reported warning and reported line numbers may be slightly off. However, the context still provides a quick look into the code which raised the warning.

    Confidence levels

    Brakeman assigns a confidence level to each warning. This provides a rough estimate of how certain the tool is that a given warning is actually a problem. Naturally, these ratings should not be taken as absolute truth.

    There are three levels of confidence:

    • High - Either this is a simple warning (boolean value) or user input is very likely being used in unsafe ways.
    • Medium - This generally indicates an unsafe use of a variable, but the variable may or may not be user input.
    • Weak - Typically means user input was indirectly used in a potentially unsafe manner.

    To only get warnings above a given confidence level:

    brakeman -w3
    

    The -w switch takes a number from 1 to 3, with 1 being low (all warnings) and 3 being high (only highest confidence warnings).

    Configuration files

    Brakeman options can be stored and read from YAML files.

    To simplify the process of writing a configuration file, the -C option will output the currently set options:

    $ brakeman -C --skip-files plugins/
    ---
    :skip_files:
    - plugins/
    

    Options passed in on the commandline have priority over configuration files.

    The default config locations are ./config/brakeman.yml, ~/.brakeman/config.yml, and /etc/brakeman/config.yml

    The -c option can be used to specify a configuration file to use.

    Continuous Integration

    There is a plugin available for Jenkins/Hudson.

    For even more continuous testing, try the Guard plugin.

    There are a couple GitHub Actions available.

    Building

    git clone git://github.com/presidentbeef/brakeman.git
    cd brakeman
    gem build brakeman.gemspec
    gem install brakeman*.gem
    

    Who is Using Brakeman?

    ..and more!

    Homepage/News

    Website: http://brakemanscanner.org/

    Twitter: https://twitter.com/brakeman

    Chat: https://gitter.im/presidentbeef/brakeman

    License

    Brakeman is free for non-commercial use.

    See COPYING for details.