RATS - Rough Auditing Tool for Security
たまたま見つけました。C, C++, Perl, PHP, Pythonのソースコードスキャナです。ライセンスはGPL。
「簡単なセキュリティ監査ツール」ってところでしょうか?ソースとWin32用バイナリが配布されていて、今回はrpmにしてインストールしてみました。
RATS - Rough Auditing Tool for Security - is an open source tool developed and maintained by Secure Software security engineers. Secure Software was recently acquired by Fortify Software, Inc. RATS is a tool for scanning C, C++, Perl, PHP and Python source code and flagging common security related programming errors such as buffer overflows and TOCTOU (Time Of Check, Time Of Use) race conditions.
$ wget http://www.fortifysoftware.com/servlet/downloads/public/rats-2.1.tar.gz $ rpmbuild -ta rats-2.1.tar.gz $ sudo rpm -ivh ~/rpm/RPMS/i386/rats-2.1-1.i386.rpm $ which rats /usr/bin/rats $ rats -h RATS v2.0 - Rough Auditing Tool for Security Copyright 2001, 2002 Secure Software Inc http://www.securesoftware.com usage: rats [-adhilrwxR] [--help] [--database|--db] name1 name2 ... namen -a <fun> report any occurence of function 'fun' in the source file(s) -d <filename> specify an alternate vulnerability database. --db --database -h display usage information (what you're reading) --help -i report functions that accept external input --input -l <language> force the specified langauge to be used --language <language> -r include references that are not function calls --references -w <1,2,3> set warning level (default 2) --warning <1,2,3> -x do not load default databases -R don't recurse subdirectories scanning for matching files --no-recursion --xml Output in XML. --html Output in HTML. --follow-symlinks Follow symlinks and process files found. --noheader Don't print initial header in output --nofooter Don't show timing information footer at end of analysis --quiet Don't print status information regarding what file is being analyzed --resultsonly No header, footer, or status information --columns Show column number of hte line where the problem occured. --context Display the line of code that caused the problem report $
使い方は、チェックするファイル(ディレクトリ指定も可能)とオプションを指定するだけ。
$ rats --resultsonly --html /usr/local/lib/php5/pear/ > pear.html $
上記の実行結果をDo You PHP?にUPしておきましたので、参考まで。
。。。という風に簡単そうに書いてますが、実は結構「ダメじゃん!」ということが。。。ロングオプションを付けて実行するとsegfault。チェックした結果をHTMLで出力しようとすると途中でsegfault。。。まあ、ちょっと試してみようと思ったのが運の尽き。ソースのタイムスタンプも2002年だし。。。orz
折角なので、動く状態まで持って行ったソースから作ったrpmとsrpmをDo You PHP?にUPしておきました。完全無保証ですが、地雷が好きな方はどうぞ ;-)
- rats-2.1-1.i386.rpm(md5:b5177869c0d88436eb7b7c153132bf54)
- rats-debuginfo-2.1-1.i386.rpm(md5:dea2f963cc853acd2df7348021665dfd)
- rats-2.1-1.src.rpm(md5:ff6a64b6101e59d85d5413cc6ae22d7b)
やっぱ、specファイルが用意されてる時って、rpmにする方が楽だなぁ :-D