Weitere ähnliche Inhalte
Ähnlich wie Ruby用の静的コード解析ツールざくっと紹介 by SideCI #omotesandorb (20)
Mehr von Koichiro Sumi (20)
Ruby用の静的コード解析ツールざくっと紹介 by SideCI #omotesandorb
- 2. [Confidential] © 2013 Actcat, Inc.
はじめに 自己紹介
n プログラマ向けサービス「SideCI」を
開発している角(スミ) です
n エンジニアとしては
Ruby,
Obj-‐C,
Android
Javaなどが長いです
n 毎月第四水曜日に「新宿.rb」を開催して
ます
2
- 11. [Confidential] © 2013 Actcat, Inc.
HoundCIの裏側は?
OSSのLintツール・Styleチェックツール
n RuboCop
n CoffeeLint
n JSHint
n SCSS-‐Lint
n haml-‐lint
11
- 13. [Confidential] © 2013 Actcat, Inc.
SideCIの裏側は?
n RuboCop
n CoffeeLint
n JSHint
n SCSS-‐Lint
n haml-‐lint
n Brakeman
n RailsBestPractices
n Reek
n PHP_CodeSniffer
n PHPMD
13
- 15. [Confidential] © 2013 Actcat, Inc.
HoundCI
-‐
haml-‐lint,
SCSS-‐Lint
+
Brakeman,
RailsBestPractices,
Reek
−
$12
/month
=
SideCI
15
- 16. [Confidential] © 2013 Actcat, Inc.
今日紹介したい3つの静的解析ツール
1. Brakeman
2. Reek
3. RailsBestPractices
16
- 17. [Confidential] © 2013 Actcat, Inc.
Brakeman
n 個人的に一押しのGem
n Rails用セキュリティスキャナ
n 初心者から、普段Rails使いの方まで
17
- 20. [Confidential] © 2013 Actcat, Inc.
Possible SQL injection
Problem
Code
User.first(:conditions
=>
"username
=
'#{params[:username]}'")
Brakeman
Scan
Result
Possible
SQL
injection
20
- 22. [Confidential] © 2013 Actcat, Inc.
XSS Vulnerability in
ActiveSupport::JSON.encode
There
is
an
XSS
vulnerability
in
the
ActiveSupport::JSON.encode
method
in
Ruby
on
Rails.
This
vulnerability
has
been
assigned
the
CVE
identifier
CVE-‐2015-‐3226.
Versions
Affected:
3.0.x,
3.1.x,
3.2.x,
4.1.x,
4.2.x.
Not
affected:
4.0.x.
Fixed
Versions:
4.2.2,
4.1.11
22
Found
in
Gemfile.lock
- 24. [Confidential] © 2013 Actcat, Inc.
Reek
n コードのSmellを見つけるGem
n Smellは「コードが読みにくい、または保
守しづらい場所を示唆するもの(indicators
of
where
your
code
might
be
hard
to
read,
maintain
or
evolve)」
24
- 30. [Confidential] © 2013 Actcat, Inc.
Reekの詳細記事と
設定のカスタマイズ
ブログ書いたよ
Rubyのコードスメルチェックツールreekで
「こんなコードは嫌!」っていうのを防ごう
http://sideci.hatenablog.com/entry/
2015/05/19/161330
30
- 31. [Confidential] © 2013 Actcat, Inc.
RailsBestPractices
n コミュニティサイトの投票結果を元
に作られたGem
n Railsのコードのベスト・プラクティスを使
うべきところを見つけてくれる
n わりと面白い。色々出る
31
- 33. [Confidential] © 2013 Actcat, Inc.
Always add DB index
*_id系は常にdb index貼ろうよ警告
ActiveRecord::Schema.define(version:
20131103153637)
do
create_table
"book_authors",
force:
true
do
|t|
t.integer
"book_id"
t.integer
"author_id"
t.datetime
"created_at"
t.datetime
"updated_at"
end
33
- 35. [Confidential] © 2013 Actcat, Inc.
3つの静的解析ツール まとめ
1. Brakeman
l セキュリティのアップデート情報と
初歩的ミスに役立つ
2. Reek
l コードの悪い傾向を検知、予防でき
る
3. RailsBestPractices
l Rails特有のbetterな方法について
チェックできる
35
- 36. [Confidential] © 2013 Actcat, Inc. 36
紹介した全てのツールで自動的にプルリクを解析、
プルリクに結果をコメントします。
設定の所要時間は30秒,
利用料無料。今すぐ!
SideCIをいっしょに作らなイカ?
エンジニア様募集中!