LoginSignup
76
52

More than 5 years have passed since last update.

Brakemanで無視する警告の設定の仕方

Posted at

Railsアプリのセキュリティチェックの自動化にはBrakemanというGemが便利です。

Werckerに

      - script:
          name: Run Brakeman
          code: bundle exec brakeman -qz

という感じのステップを追加して、脆弱性が発見された場合はビルドを落としてしまうという運用をすると、セキュリティチェックも自動化される訳ですが、中には意図的に無視して良い警告があったりします。

そんな警告を無理やり潰す、というのも運用上無理があるので、Brakemanには指定した警告は無視する、といったことができる機能があります。

下記のようにbundle exec brakeman -Iとコマンドを打ち込むと、インタラクティブに無視する警告を設定することができます。

[Enter]と書いている部分はエンターキーを打ち込んでください。

$ bundle exec brakeman -I

Input file: |config/brakeman.ignore| [Enter]
No such file. Continue with empty config? [Enter]
Your answer isn't within the expected range (included in ["y", "n", "yes", "no"]).
?  y
1. Inspect all warnings
2. Hide previously ignored warnings
3. Skip - use current ignore configuration
?  1
--------------------
Confidence: High
Category: Session Setting
Message: Session secret should not be included in version control
File: config/initializers/secret_token.rb
Line: 12
Action: (i, n, k, u, a, s, q, ?) 

ここで?を選択すると以下のような説明が出てきます。

i - Add warning to ignore list
n - Add warning to ignore list and add note
s - Skip this warning (will remain ignored or shown)
u - Remove this warning from ignore list
a - Ignore this warning and all remaining warnings
k - Skip this warning and all remaining warnings
q - Quit, do not update ignored warnings
? - Display this help

基本的には以下の選択肢だけ覚えておけば良いかと思います。

  • iで無視リストに追加
  • sでスキップ
  • uで無視リストから除外

それでは良きBrakemanライフを!

76
52
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
76
52