規則違反コードの構造を反映した木パタンを用いるコード検査器

書誌事項

タイトル別名
  • A Code Checker That Uses Tree Patterns Reflecting the Structures of Rule Violation Code

この論文をさがす

抄録

プログラマはコーディング規約や規則に従わねばならない.ライブラリには,API呼び出しの手順などに特有の規則を定めているものがあり,規則に従わないプログラムは正しく動作しない.また,ソフトウェアの脆弱性の原因となる危険なコードパタンや,それを避けるためのコーディング規約がよく知られている.このような規則や規約に違反したコードを発見するために,多くの検出ツールが開発されている.しかし,規則や規約ごとに特化した検出ツールを作成するのは労力がかかる.検出モジュールだけ分離して開発できる機構を提供しているツールも存在するが,その多くは(1)検査対象コードの内部表現が専用のデータ構造で表現されており,可視化ツールを使わなければ構造を確認できない,(2)内部表現にはAPI経由でアクセスしなければならない,(3)検出モジュールは手続的なプログラムとして記述する必要があるという特徴があり,その開発は容易ではない.そこで,我々は,違反しているコードの構造を木パタンで表現し,ソースコード中からパタンにマッチする箇所を探すことで違反を検出するツールを提案する.このツールは,Clangコンパイラをもとに作った抽象構文木(AST)を生成する部分と,Clojureで記述された木パタンマッチ部で構成されている.規則違反パタンの作成者は,規則違反を含むソースコードのASTを見ながら規則違反パタンを記述できる.さらに,検査対象のASTと規則違反のパタンのどちらも同じ形式のS式で表現されており,ASTから一部を切り出して修正することで規則違反パタンを容易に作成することもできる.さらに,提案ツールの有用性を確認するため,実際にセキュアコーディング違反とJNIコーディング規約違反のうちいくつかのパタンの記述を行った.

Programmers must obey some coding rules or coding standards. For example, some libraries require the programmers to obey their own rules, such as the order of API calls. If a program violates one of these rules, it does not work correctly. As another example, many coding patterns leading to vulnerability and coding rules to avoid such coding patterns are widely known. Various tools that detect violations of these rules and standards are developed. However, it is costly to develop such checking tools for each individual violation. Although some tools allow users to develop violation detection mechanisms as separate modules, the development of detection modules is not straightforward because (1) these tools have the target source code in their own internal representations, and so we need some visualizers to look at the structure of the source code, (2) we also need to access the structure through their own API, (3) detection modules are expected to be written in an operational style. We propose a rule violation detection tool for C and C++, in which the structure of the code fragments violating a rule is represented as a tree pattern. Our tool searches for locations of source code that matches with the specified patterns. This tool comprises two parts; the abstract syntax tree (AST) generator built on the Clang compiler, and the tree pattern matcher written in Clojure. Pattern writers can look at the AST of a source code containing the rule violation while writing the pattern. Moreover, since both the AST and the pattern are represented as S-expressions, the pattern writers can compose a pattern by modifying a fragment extracted from the AST. To verify the usability of our tool, we wrote several patterns selected from secure coding standards and JNI coding rules.

収録刊行物

関連プロジェクト

もっと見る

詳細情報 詳細情報について

  • CRID
    1050564287860604928
  • NII論文ID
    170000148144
  • NII書誌ID
    AA11464814
  • ISSN
    18827802
  • Web Site
    http://id.nii.ac.jp/1001/00174565/
  • 本文言語コード
    ja
  • 資料種別
    article
  • データソース種別
    • IRDB
    • CiNii Articles
    • KAKEN

問題の指摘

ページトップへ