JP2012160101A - Information processing unit, software testing method and software testing program - Google Patents
Information processing unit, software testing method and software testing program Download PDFInfo
- Publication number
- JP2012160101A JP2012160101A JP2011020460A JP2011020460A JP2012160101A JP 2012160101 A JP2012160101 A JP 2012160101A JP 2011020460 A JP2011020460 A JP 2011020460A JP 2011020460 A JP2011020460 A JP 2011020460A JP 2012160101 A JP2012160101 A JP 2012160101A
- Authority
- JP
- Japan
- Prior art keywords
- state
- transition
- symbol
- information
- extracted
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Abstract
Description
本発明は情報処理装置、ソフトウェア検査方法およびソフトウェア検査プログラムに関する。 The present invention relates to an information processing apparatus, a software inspection method, and a software inspection program.
オペレーティングシステム(OS:Operating System)やミドルウェアなどのソフトウェア実行環境は、アプリケーションソフトウェアから利用可能なAPI(Application Programming Interface)を用意しておくことがある。APIでは、ファイル入出力や描画処理など、複数のアプリケーションソフトウェアから利用されると考えられる機能が実装されている。アプリケーションソフトウェアは、APIにおいて提供される関数(メソッド、手続き、サブルーチンなどと呼ばれることもある)を呼び出すことで、実装された機能を利用することができる。APIを利用することで、全ての機能を自前でプログラミングしなくてもよく、アプリケーションソフトウェアを効率的に開発することができる。 A software execution environment such as an operating system (OS) or middleware may have an API (Application Programming Interface) that can be used from application software. In the API, functions that are considered to be used from a plurality of application software such as file input / output and drawing processing are implemented. The application software can use the implemented function by calling a function (sometimes called a method, procedure, or subroutine) provided in the API. By using the API, it is not necessary to program all functions by yourself, and application software can be efficiently developed.
APIの中には、ファイルからのデータの入力やファイルへのデータの出力など、入力または出力のストリームを扱うものがある。アプリケーションソフトウェアは、例えば、APIにおいて提供されるファイル入力用の関数を呼び出すことで、呼び出し毎にデータをファイルから逐次読み込む。また、例えば、APIにおいて提供されるファイル出力用の関数を呼び出すことで、呼び出し毎にデータをファイルに逐次書き込む。 Some APIs handle input or output streams such as data input from a file and data output to a file. For example, the application software calls a file input function provided in the API to sequentially read data from the file for each call. Also, for example, by calling a file output function provided in the API, data is sequentially written to the file for each call.
なお、APIに関する処理の制御方法として、API呼び出しが検出されると、アプリケーションソフトウェアからOSに制御権が渡される前に当該制御権を取得し、処理を継続してよいか判断する方法が提案されている。また、テキストから特定の文字列を検索する方法として、状態機械を複数の分割状態機械に変換し、分割状態機械それぞれが入力記号の一部分の処理を担当することで、メモリ使用量を抑制する方法が提案されている。 As a method for controlling processing related to an API, a method is proposed in which when an API call is detected, the control right is acquired before the control right is passed from the application software to the OS, and it is determined whether the processing can be continued. ing. In addition, as a method of searching for a specific character string from text, a method of suppressing memory usage by converting a state machine into a plurality of divided state machines, and each divided state machine is responsible for processing a part of an input symbol. Has been proposed.
ところで、あるアプリケーションソフトウェアが、実行中に特定の記号列を入力または出力したか検査したいことがある。例えば、アプリケーションソフトウェアが、機密情報であるパスワードを扱っているか確認するために、“password”という記号列がAPIを通じて入力または出力されたか検査することが考えられる。しかし、アプリケーションソフトウェアが入力または出力のストリームを扱うAPIを利用する場合、ストリームに特定の記号列が含まれるか否かの検査を、どのように行えばよいかが問題となる。 By the way, there is a case where a certain application software wants to check whether a specific symbol string is input or output during execution. For example, in order to confirm whether the application software handles a password that is confidential information, it is possible to check whether a symbol string “password” has been input or output through an API. However, when the application software uses an API that handles an input or output stream, the question is how to check whether or not a specific symbol string is included in the stream.
入力または出力のストリームでは、検査対象の記号列が複数回の関数呼び出しに分けて入力または出力される可能性がある。例えば、“password”に含まれる記号が、関数呼び出し毎に1字ずつ入力または出力される可能性がある。このため、関数呼び出し単位で戻り値や引数を検査するだけでは、検出漏れが生じ得る。一方、検査のために、アプリケーションソフトウェアがAPIを通じて入力または出力したデータを全てバッファに保持するようにすると、メモリ消費量や検索負荷が増大するという問題がある。 In the input or output stream, there is a possibility that the symbol string to be inspected is input or output in a plurality of function calls. For example, there is a possibility that a symbol included in “password” is input or output by one character for each function call. For this reason, detection failure may occur only by checking return values and arguments in function call units. On the other hand, if all the data input or output by the application software through the API is held in the buffer for inspection, there is a problem that memory consumption and search load increase.
本発明はこのような点に鑑みてなされたものであり、入力または出力のストリームの検査を効率的に行うことができる情報処理装置、ソフトウェア検査方法およびソフトウェア検査プログラムを提供することを目的とする。 The present invention has been made in view of these points, and an object thereof is to provide an information processing apparatus, a software inspection method, and a software inspection program capable of efficiently inspecting an input or output stream. .
複数回の関数の呼び出しを行うプログラムの実行によって検査対象の記号列が入力または出力されたことを検出する情報処理装置が提供される。当該情報処理装置は、記憶手段と抽出手段と検出手段とを有する。記憶手段は、複数の状態と遷移条件としての記号が対応付けられた状態間の遷移と複数の状態の中の受理状態とを示す状態遷移情報を記憶する。抽出手段は、複数回の関数の呼び出しそれぞれが行われるとき、戻り値および引数の少なくとも一方に含まれる記号を抽出する。検出手段は、抽出手段で記号が抽出されると、複数の状態の中の現在の状態と抽出された記号とから、記憶手段に記憶された状態遷移情報が示す遷移に従って現在の状態を更新し、更新後の現在の状態が受理状態であるか否かに応じて、記号列の検出結果の情報を出力する。 There is provided an information processing apparatus that detects that a symbol string to be inspected is input or output by executing a program that calls a function multiple times. The information processing apparatus includes storage means, extraction means, and detection means. The storage means stores state transition information indicating transitions between states in which a plurality of states and symbols as transition conditions are associated with each other and accepted states among the plurality of states. The extraction means extracts symbols included in at least one of the return value and the argument when each of the plurality of function calls is performed. When the extraction unit extracts the symbol, the detection unit updates the current state according to the transition indicated by the state transition information stored in the storage unit from the current state in the plurality of states and the extracted symbol. The information on the detection result of the symbol string is output according to whether or not the current state after the update is the accepting state.
また、複数回の関数の呼び出しを行うプログラムの実行によって検査対象の記号列が入力または出力されたことを検出する、コンピュータが実行するソフトウェア検査方法が提供される。当該ソフトウェア検査方法では、複数回の関数の呼び出しそれぞれが行われるとき、戻り値および引数の少なくとも一方に含まれる記号を抽出する。記号が抽出されると、複数の状態と遷移条件としての記号が対応付けられた状態間の遷移と複数の状態の中の受理状態とを示す状態遷移情報を記憶する記憶手段を参照して、複数の状態の中の現在の状態と抽出された記号とから、現在の状態を更新する。更新後の現在の状態が受理状態であるか否かに応じて、記号列の検出結果の情報を出力する。また、コンピュータに実行させるソフトウェア検査プログラムが提供される。 In addition, a computer-implemented software inspection method is provided that detects that a symbol string to be inspected is input or output by executing a program that calls a function a plurality of times. In the software inspection method, when each of the plurality of function calls is performed, a symbol included in at least one of a return value and an argument is extracted. When the symbol is extracted, referring to a storage unit that stores state transition information indicating a transition between a state in which a plurality of states and a symbol as a transition condition are associated with each other and an accepted state in the plurality of states, The current state is updated from the current state in the plurality of states and the extracted symbols. Information on the detection result of the symbol string is output according to whether or not the current state after the update is the accepting state. A software inspection program to be executed by a computer is also provided.
上記情報処理装置、ソフトウェア検査方法およびソフトウェア検査プログラムによれば、入力または出力のストリームの検査を効率的に行うことができる。 According to the information processing apparatus, software inspection method, and software inspection program, it is possible to efficiently inspect an input or output stream.
以下、本実施の形態を図面を参照して説明する。
[第1の実施の形態]
図1は、第1の実施の形態の情報処理装置を示す図である。情報処理装置10は、複数回の関数の呼び出しを行うプログラムの実行によって検査対象の記号列が入力または出力されたことを検出することができる。情報処理装置10は、記憶手段11、抽出手段12および検出手段13を有する。記憶手段11は、RAM(Random Access Memory)やHDD(Hard Disk Drive)などの任意の記憶装置を用いて実現できる。抽出手段12および検出手段13は、例えば、CPU(Central Processing Unit)およびRAMを用いて、ソフトウェア検査プログラムを実行することで実現できる。
Hereinafter, the present embodiment will be described with reference to the drawings.
[First Embodiment]
FIG. 1 is a diagram illustrating the information processing apparatus according to the first embodiment. The
記憶手段11は、状態遷移情報11aを記憶する。状態遷移情報11aには、複数の状態と、遷移条件としての記号が対応付けられた状態間の遷移と、複数の状態の中の受理状態を示す情報が含まれる。状態遷移情報11aが示す状態遷移関係は、検査対象の記号列に対応している。情報処理装置10は、検査対象の記号列を示す情報が入力されると、当該記号列に含まれる各記号が順に抽出されると現在の状態が受理状態になるように、状態遷移情報11aを生成して記憶手段11に格納するようにしてもよい。
The
抽出手段12は、関数の呼び出しそれぞれが行われるとき、戻り値および引数の少なくとも一方に含まれる記号を抽出する。記号の抽出を行う対象の関数には、入力または出力のストリームを扱うAPIにおいて提供される関数が含まれる。関数は、メソッド、手続きまたはサブルーチンと呼ばれるものであってもよい。抽出手段12は、例えば、入力ストリームの場合、入力された記号を戻り値から抽出し、出力ストリームの場合、出力される記号を引数から抽出する。また、検査対象のプログラムが複数のストリームを扱う可能性がある場合、各ストリームを識別するための識別情報を更に抽出してもよい。
The extraction means 12 extracts a symbol included in at least one of a return value and an argument when each function call is made. Functions to be subjected to symbol extraction include functions provided in APIs that handle input or output streams. A function may be called a method, procedure or subroutine. For example, in the case of an input stream, the
検出手段13は、記憶手段11に記憶された状態遷移情報11aを参照して、現在の状態を管理する。検出手段13は、抽出手段12で記号が抽出されると、現在の状態と抽出された記号とから、状態遷移情報11aが示す遷移に従って現在の状態を更新する。検査対象のプログラムが複数のストリームを扱う可能性がある場合、抽出手段12で抽出された識別情報に基づいて、ストリーム毎に現在の状態を管理してもよい。
The
また、検出手段13は、更新後の現在の状態が、状態遷移情報11aが示す受理状態であるか否かに応じて、記号列の検出結果を示す情報を出力する。例えば、現在の状態が受理状態になると、検査対象の記号列が検出されたと判断し、検出された記号列を示す情報を出力する。情報処理装置10は、検出手段13により出力された検出結果の情報を、ファイルに書き込んでもよいし、コンソール画面に表示してもよい。
Moreover, the detection means 13 outputs the information which shows the detection result of a symbol sequence according to whether the present state after an update is the acceptance state which the
例えば、検査対象の記号列が“ABC”であるとする。また、記号“A”を受けて状態#0(初期状態)から状態#1に遷移し、記号“B”を受けて状態#1から状態#2へ遷移し、記号“C”を受けて状態#2から状態#3(受理状態)に遷移することが、状態遷移情報11aに定義されているとする。また、検査対象のプログラムにより、引数として与えられた記号を1字ずつ出力する関数writeが呼び出されるとする。
For example, assume that the symbol string to be inspected is “ABC”. In addition, the state transitions from state # 0 (initial state) to
関数呼び出しwrite(A)が行われると、抽出手段12が引数から記号“A”を抽出し、検出手段13が現在の状態を状態#0から状態#1に更新する。続いて、関数呼び出しwrite(B)が行われると、抽出手段12が引数から記号“B”を抽出し、検出手段13が現在の状態を状態#2に更新する。続いて、関数呼び出しwrite(C)が行われると、抽出手段12が引数から記号“C”を抽出し、検出手段13が現在の状態を状態#3に更新する。そして、検出手段13は、状態#3が受理状態であるため、出力ストリーム内に記号列“ABC”が検出されたことを示す情報を出力する。
When the function call write (A) is performed, the
第1の実施の形態の情報処理装置10によれば、複数回の関数の呼び出しそれぞれが行われるとき、戻り値および引数の少なくとも一方に含まれる記号を抽出する。記号が抽出されると、複数の状態と遷移条件としての記号が対応付けられた状態間の遷移と複数の状態の中の受理状態とを示す状態遷移情報11aを記憶する記憶手段11を参照して、複数の状態の中の現在の状態と抽出された記号とから、現在の状態を更新する。更新後の現在の状態が受理状態であるか否かに応じて、記号列の検出結果の情報を出力する。
According to the
これにより、入力または出力のストリームの検査を効率的に行うことができる。情報処理装置10は、複数回の関数呼び出しを通して状態遷移情報11aに基づく状態の管理を行うため、複数回に分けて入力または出力された記号列を検出できる。また、抽出された記号に基づいて現在の状態を順次更新すればよく、入力または出力された記号をバッファに記憶しておかなくてもよいため、メモリ消費量や検索負荷を抑制できる。また、関数呼び出しを監視することで記号列を検出するため、操作される対象(ファイルなど)を予め具体的に特定しなくても、検査を行うことが可能となる。
Thereby, it is possible to efficiently inspect the input or output stream. Since the
また、情報処理装置10は、入力または出力のストリーム毎に現在の状態を管理することで、複数のストリームを扱うプログラムを適切に検査することができる。例えば、記号を1字ずつ出力するためのストリーム#1,#2が生成され、ストリーム#1によって記号列“ABD”が出力され、ストリーム#2によって記号列“CEF”が出力されるとする。ストリーム#1,#2を区別しないと、各記号が出力されるタイミング次第では、記号列“ABC”が出力されたと判断されてしまう可能性がある。一方、ストリーム毎に現在の状態を管理することで、記号列“ABD”と記号列“CEF”を区別できる。
In addition, the
[第2の実施の形態]
次に、第2の実施の形態を説明する。第2の実施の形態に係る情報処理装置は、Java(登録商標)などのプログラミング言語を用いて記述されたアプリケーションプログラムを実行する。また、この情報処理装置は、アプリケーションプログラムの実行中、入力または出力のストリームを扱うAPIの呼び出しを検出し、ストリームに含まれる文字列を検査する。API呼び出しが行われたときに制御権を取得して検査などの処理が行われるようにすることを、APIフッキングと呼ぶことがある。以下の説明では、Javaを用いて記述されたプログラムの例を挙げている。ただし、第2の実施の形態のソフトウェア検査方法は、適用対象を特定のプログラミング言語に限定するものではない。
[Second Embodiment]
Next, a second embodiment will be described. An information processing apparatus according to the second embodiment executes an application program described using a programming language such as Java (registered trademark). Also, this information processing apparatus detects an API call that handles an input or output stream during execution of the application program, and inspects a character string included in the stream. Acquiring a control right when an API call is made so that processing such as inspection is performed may be called API hooking. In the following description, an example of a program written using Java is given. However, the software inspection method of the second embodiment does not limit the application target to a specific programming language.
図2は、情報処理装置のハードウェア例を示すブロック図である。情報処理装置100は、CPU101、RAM102、HDD103、画像信号処理部104、入力信号処理部105、ディスクドライブ106および通信部107を有する。上記ユニットは、情報処理装置100内でバスに接続されている。
FIG. 2 is a block diagram illustrating a hardware example of the information processing apparatus. The
CPU101は、情報処理を制御する演算装置である。CPU101は、HDD103に記憶されたプログラムやデータの少なくとも一部を読み出し、RAM102に展開してプログラムを実行する。
The
RAM102は、CPU101が扱うプログラムやデータを一時的に記憶する揮発性メモリである。ただし、情報処理装置100は、他の種類のメモリを備えてもよい。
HDD103は、OSプログラムやアプリケーションプログラムなどのプログラム、および、CPU101の処理に用いられるデータを記憶する不揮発性の記憶装置である。HDD103は、内蔵の磁気ディスクに対し読み書きを行う。ただし、情報処理装置100は、他の種類の不揮発性の記憶装置を備えてもよい。
The
The
画像信号処理部104は、CPU101の命令に従って、情報処理装置100に接続されたディスプレイ21に画像を表示する。ディスプレイ21として、例えば、CRT(Cathode Ray Tube)ディスプレイや液晶ディスプレイを用いることができる。
The image
入力信号処理部105は、情報処理装置100に接続された入力デバイス22から入力信号を取得し、CPU101に出力する。入力デバイス22として、例えば、マウスなどのポインティングデバイスやキーボードを用いることができる。
The input
ディスクドライブ106は、記録媒体23に記録されたプログラムやデータを読み取る駆動装置である。記録媒体23として、例えば、フレキシブルディスク(FD:Flexible Disk)などの磁気ディスク、CD(Compact Disc)やDVD(Digital Versatile Disc)などの光ディスク、光磁気ディスク(MO:Magneto-Optical disk)を用いることができる。ディスクドライブ106は、例えば、CPU101の命令に従って、記録媒体23から読み取ったプログラムやデータをRAM102またはHDD103に出力する。
The
通信部107は、ネットワーク24に接続して通信を行う通信インタフェースである。ネットワーク24への接続方法は、有線でも無線でもよい。すなわち、通信部107は、有線通信インタフェースでも無線通信インタフェースでもよい。
The
図3は、オートマトンの例を示す図である。情報処理装置100は、オートマトンを用いて、入力または出力のストリームに含まれる文字列の中から特定の文字列を検出する。オートマトンは、仮想的な自動機械であり、複数の状態の間の遷移関係を定義している。
FIG. 3 is a diagram illustrating an example of an automaton. The
第2の実施の形態では、オートマトンとして、エイホ・コラシックアルゴリズムに従って生成される決定性有限オートマトンを用いる場合を考える。エイホ・コラシックアルゴリズムについては、例えば、文献“Alfred V. Aho and Margaret J. Corasick, Efficient String Matching: An Aid to Bibliographic Search, Communications of the ACM, Vol. 18, Number 6, pp. 333-340, June 1975”に記載されている。ただし、文字列の検出は、他の種類のオートマトンを用いて実現することも可能である。
In the second embodiment, a case is considered in which a deterministic finite automaton generated according to the Aiho Colasic algorithm is used as the automaton. For the Aho Collasic algorithm, see, for example, the document “Alfred V. Aho and Margaret J. Corasick, Efficient String Matching: An Aid to Bibliographic Search, Communications of the ACM, Vol. 18,
文字列“password”および“asset”を検出することを考える。図3のオートマトンの例では、状態#0〜#13の14個の状態が定義されている。状態#0〜#13のうち、状態#0が初期状態であり、状態#8,#13が受理状態である。状態#0から開始し、オートマトンに文字が入力されると遷移が発生する。状態#8は、文字列“password”が検出されたことを意味する。状態#13は、文字列“asset”が検出されたことを意味する。
Consider detecting the character strings “password” and “asset”. In the example of the automaton in FIG. 3, 14 states of
遷移には、通常遷移(図3の実線の矢印)とfailure遷移(図3の点線の矢印であり、suffixリンクと呼ぶことがある)が含まれる。通常遷移が発生する条件は、当該遷移に対応付けられた文字が入力されたことである。failure遷移が発生する条件は、入力された文字が何れの通常遷移の条件にも合致しないことである。failure遷移は、条件に合致する通常遷移が見つかるまで連鎖的に発生する。すなわち、オートマトンに文字が入力されると、failure遷移が発生せずに通常遷移が1回発生するか、または、1回以上のfailure遷移が発生した後に通常遷移が1回発生する。 The transition includes a normal transition (solid arrow in FIG. 3) and a failure transition (dotted arrow in FIG. 3 and may be referred to as a suffix link). A condition for causing a normal transition is that a character associated with the transition is input. The condition for the failure transition to occur is that the input character does not match any of the conditions for the normal transition. The failure transition occurs in a chain until a normal transition that meets the conditions is found. That is, when a character is input to the automaton, a normal transition occurs once without a failure transition, or a normal transition occurs once after one or more failure transitions occur.
例えば、状態#4のとき“w”が入力されると、通常遷移に従って、現在の状態が状態#5に遷移する。状態#4のとき“e”が入力されると、failure遷移に従って、現在の状態が状態#11に遷移し、更に通常遷移に従って、状態#12に遷移する。状態#4のとき“w”,“e”以外の文字が入力されると、2回のfailure遷移に従って、現在の状態が状態#0に戻る。なお、図3では、状態#0,#2,#3,#4以外の状態から状態#0へのfailure遷移の記載を省略している。
For example, when “w” is input in the
オートマトンにfailure遷移を定義することで、ストリームの中から複数の文字列を効率的に検出することができる。例えば、ストリームから抽出された文字列が“pass”である場合、現在の状態は状態#4である。この時点において、検出が期待される文字列は“password”である。しかし、次に“e”が抽出され、ストリームから抽出された文字列が“passe”になると、現在の状態が状態#12に遷移する。この時点において、検出が期待される文字列が“asset”に変化する。
By defining a failure transition in the automaton, a plurality of character strings can be efficiently detected from the stream. For example, when the character string extracted from the stream is “pass”, the current state is
図4は、情報処理装置の機能を示すブロック図である。情報処理装置100には、CPU101がプログラムを実行することで、プログラム記憶部110、状態情報記憶部120、検出情報記憶部130、APIフッキング部140、オートマトン生成部150、解析部160および検出部170が実現される。ただし、上記ユニットの一部または全部を専用の電子回路として実現することも可能である。
FIG. 4 is a block diagram illustrating functions of the information processing apparatus. In the
プログラム記憶部110は、検査対象のプログラムを記憶する。例えば、バイトコードを含むJavaのクラスファイルを記憶する。プログラム記憶部110は、例えば、RAM102またはHDD103上に確保された記憶領域として実現できる。
The
状態情報記憶部120は、生成されたオートマトンに関する状態遷移情報を記憶する。状態遷移情報には、通常遷移を示す情報、failure遷移を示す情報、受理状態を示す情報、および、現在の状態を示す情報が含まれる。状態情報記憶部120は、例えば、RAM102またはHDD103上に確保された記憶領域として実現できる。
The state
検出情報記憶部130は、文字列の検出結果に関する検出情報を記憶する。検出情報には、入力または出力のストリームから検出された文字列や、当該ストリームを扱うAPIを示す情報が含まれる。検出情報記憶部130は、例えば、RAM102またはHDD103上に確保された記憶領域として実現できる。
The detection
APIフッキング部140は、ユーザ操作によりプログラムを実行するコマンドが入力されると、コマンドで指定されたプログラムをプログラム記憶部110から取得する。そして、プログラムの中から所定のAPI呼び出しを行うコードを検索し、API呼び出しの際に、呼び出されるAPIの処理に加えて解析部160による処理が実行されるようにコードを書き換える。例えば、APIフッキング部140は、ReaderやWriterなどのAPIのメソッドを呼び出すコードを、解析部160に相当するプログラムを呼び出すコードに書き換える。または、メソッド呼び出しのコードの直後に、解析部160に相当するプログラムが実行されるようなコードを挿入する。
When a command for executing a program is input by a user operation, the
オートマトン生成部150は、ユーザ操作により検査対象の文字列を示すパターン情報が入力されると、検査対象の文字列に対応するオートマトンを生成し、状態遷移情報を状態情報記憶部120に格納する。パターン情報は、例えば、プログラムを実行するコマンドと併せて入力される。検査対象の文字列は、正規表現など、任意の表現形式で記載することができる。例えば、検査対象の文字列が“password”と“asset”である場合、“password|asset”というテキストが入力される。
When the pattern information indicating the character string to be inspected is input by a user operation, the
解析部160は、APIフッキング部140により書き換えられたプログラムから呼び出される。解析部160は、ストリームを扱うAPIが呼び出された際、API呼び出しを解析し、戻り値または引数に含まれる文字とストリームを識別するためのストリーム識別子とを抽出し、検出部170に出力する。文字およびストリーム識別子の抽出方法は、APIの種類によって異なる。解析部160は、APIの種類毎に、API呼び出しから文字およびストリーム識別子を抽出するモジュールを備える。
The
例えば、解析部160は、Reader解析部161とWriter解析部162を有する。Reader解析部161は、Readerクラスのreadメソッドが呼び出されると、入力された文字を戻り値から抽出し、Readerクラスのインスタンス(オブジェクト)の識別子を抽出する。Writer解析部162は、Writerクラスのwriteメソッドが呼び出されると、出力された文字を引数から抽出し、Writerクラスのインスタンスの識別子を抽出する。
For example, the
なお、APIフッキング部140がAPIのメソッドを呼び出すコードを書き換える場合、解析部160は、検査対象のプログラムに代わってAPIのメソッドを呼び出す。例えば、Reader解析部161は、Readerクラスのreadメソッドを呼び出し、その後に戻り値を解析する。一方、Writer解析部162は、Writerクラスのwriteメソッドを呼び出す前または呼び出した後に、引数を解析する。
When the
検出部170は、ストリーム毎に現在の状態を管理し、検査対象の文字列が検出されたか判断する。検出部170は、解析部160から文字とストリーム識別子を取得すると、ストリーム識別子に対応する現在の状態を検索する。そして、状態情報記憶部120に記憶された状態遷移情報に基づいて、現在の状態と取得した文字から、現在の状態を更新する。検出部170は、更新後の現在の状態が受理状態であれば、検査対象の文字列が検出されたと判断し、検出情報を生成して検出情報記憶部130に出力する。ただし、検出部170は、検出情報を、コンソール画面などのユーザ操作画面に表示してもよい。
The
なお、状態情報記憶部120は、第1の実施の形態の記憶手段11の一例である。APIフッキング部140および解析部160は、第1の実施の形態の抽出手段12の一例である。検出部170は、第1の実施の形態の検出手段13の一例である。
The state
図5は、通常遷移テーブルの例を示す図である。通常遷移テーブル121は、オートマトン生成部150によって生成され、状態情報記憶部120に格納される。通常遷移テーブル121は、前状態、入力および後状態の項目を含む。前状態の項目には、遷移前の状態を示す状態ID(図3の例では、0〜13の何れか)が登録される。入力の項目には、遷移条件である文字または1またはそれ以上の文字を含む論理式が登録される。後状態の項目には、遷移後の状態を示す状態IDが登録される。
FIG. 5 is a diagram illustrating an example of a normal transition table. The normal transition table 121 is generated by the
前状態の項目が示す状態のときに入力の項目に合致する文字が入力されると、前状態の項目が示す状態から後状態の項目が示す状態への通常遷移が発生する。図5のテーブルの例は、図3のオートマトンの例に対応し、14個の通常遷移を含む。なお、通常遷移テーブル121は、ハッシュテーブルとして実装してもよい。例えば、JavaのHashMapクラスを用いることが考えられる。その場合、ハッシュテーブルには、前状態と入力の組がキーとして登録され、後状態がエントリとして登録される。ハッシュテーブルは、例えば、RAM102上に確保された領域に記憶される。
When a character that matches the input item is input in the state indicated by the previous state item, a normal transition from the state indicated by the previous state item to the state indicated by the subsequent state item occurs. The example of the table in FIG. 5 corresponds to the example of the automaton in FIG. 3 and includes 14 normal transitions. Note that the normal transition table 121 may be implemented as a hash table. For example, it is conceivable to use Java's HashMap class. In that case, the set of the previous state and the input is registered as a key in the hash table, and the subsequent state is registered as an entry. The hash table is stored in an area secured on the
図6は、failure遷移テーブルの例を示す図である。failure遷移テーブル122は、オートマトン生成部150によって生成され、状態情報記憶部120に格納される。failure遷移テーブル122は、前状態および後状態の項目を含む。通常遷移テーブル121と同様、前状態の項目には、遷移前の状態を示す状態IDが登録される。後状態の項目には、遷移後の状態を示す状態IDが登録される。
FIG. 6 is a diagram illustrating an example of a failure transition table. The failure transition table 122 is generated by the
現在の状態と解析部160で抽出された文字の組に対応する通常遷移が、通常遷移テーブル121に登録されていないとき、現在の状態から後状態の項目が示す状態へのfailure遷移が発生する。図6のテーブルの例は、13個のfailure遷移を含む。なお、failure遷移テーブル122は、通常遷移テーブル121と同様、ハッシュテーブルとして実装してもよい。その場合、ハッシュテーブルには、前状態がキーとして登録され、後状態がエントリとして登録される。
When a normal transition corresponding to the current state and the character set extracted by the
図7は、受理状態テーブルの例を示す図である。受理状態テーブル123は、オートマトン生成部150によって生成され、状態情報記憶部120に格納される。受理状態テーブル123は、受理状態および文字列の項目を含む。受理状態の項目には、受理状態を示す状態IDが登録される。文字列の項目には、現在状態が受理状態になったときに検出されたと判断される、検査対象の文字列が登録される。
FIG. 7 is a diagram illustrating an example of an acceptance state table. The acceptance state table 123 is generated by the
例えば、図3のオートマトンの場合、受理状態=8,文字列=passwordという情報、および、受理状態=13,文字列=assetという情報が、受理状態テーブル123に登録される。なお、受理状態テーブル123は、通常遷移テーブル121と同様に、ハッシュテーブルとして実装してもよい。その場合、ハッシュテーブルには、受理状態がキーとして登録され、文字列がエントリとして登録される。 For example, in the case of the automaton of FIG. 3, information that the acceptance state = 8, character string = password, and information that the acceptance state = 13 and character string = asset are registered in the acceptance state table 123. Note that the acceptance state table 123 may be implemented as a hash table in the same manner as the normal transition table 121. In that case, in the hash table, the acceptance state is registered as a key, and a character string is registered as an entry.
図8は、状態管理テーブルの例を示す図である。オートマトン生成部150によって、空の状態管理テーブル124が生成され、状態情報記憶部120に格納される。また、検出部170によって、状態情報記憶部120に記憶された状態管理テーブル124が更新される。状態管理テーブル124は、ストリーム識別子および状態の項目を含む。ストリーム識別子の項目には、解析部160で抽出された識別子が登録される。図8の例では、ストリーム識別子として、Javaクラスのインスタンスの識別子を用いている。状態の項目には、現在の状態を示す状態IDが登録される。
FIG. 8 is a diagram illustrating an example of a state management table. The
例えば、検査対象のプログラムによってReaderやWriterなどのクラスのインスタンスが生成され、当該インスタンスを指定してreadやwriteなどのメソッドが呼び出されると、状態管理テーブル124にインスタンスの識別子が追加される。また、当該メソッドが呼び出される毎に、現在の状態が更新される。状態管理テーブル124は、検査対象のプログラムの実行が終了すると破棄される。 For example, when an instance of a class such as Reader or Writer is generated by a program to be inspected and a method such as read or write is called by specifying the instance, an instance identifier is added to the state management table 124. Each time the method is called, the current state is updated. The state management table 124 is discarded when execution of the program to be inspected is completed.
ただし、検査対象のプログラムの実行中に、不要となったストリームの情報を状態管理テーブル124から削除するようにしてもよい。例えば、インスタンスを指定してストリームを閉じるメソッド(例えば、close)が呼び出されたときに、当該インスタンスに対応する情報を状態管理テーブル124から削除するようにする。または、ガーベッジコレクションの機能を利用して、インスタンスが消滅すると、当該インスタンスに依存する情報が状態管理テーブル124から自動的に削除されるようする。 However, information about streams that are no longer necessary may be deleted from the state management table 124 during execution of the program to be inspected. For example, when a method for closing a stream by designating an instance (for example, close) is called, information corresponding to the instance is deleted from the state management table 124. Alternatively, when an instance disappears using the garbage collection function, information dependent on the instance is automatically deleted from the state management table 124.
図9は、プログラム制御の手順例を示すフローチャートである。
(ステップS1)オートマトン生成部150は、検査対象となる1またはそれ以上の文字列を示すパターン情報(例えば、正規表現により文字列のパターンを記載したもの)を取得する。そして、オートマトン生成部150は、パターン情報が示す文字列を検出するためのオートマトンを生成する。
FIG. 9 is a flowchart illustrating a procedure example of program control.
(Step S1) The
(ステップS2)APIフッキング部140は、検査対象のプログラムの中のコード(例えば、Javaのバイトコード)を書き換えることで、入力または出力のストリームを扱うAPIが呼び出される際に、解析部160が制御権を取得できるようにする。
(Step S2) The
(ステップS3)情報処理装置100は、APIフッキング部140により書き換えられたプログラムの実行を開始する。例えば、書き換えられたプログラムをRAM102上の適切な領域に展開し、当該プログラムのmainメソッドを呼び出す。
(Step S <b> 3) The
(ステップS4)情報処理装置100は、入力または出力のストリームを扱うAPIが呼び出されたか判断する。APIが呼び出された場合、処理をステップS5に進める。呼び出されていない場合、処理をステップS6に進める。
(Step S4) The
(ステップS5)解析部160は、API呼び出しにおける戻り値または引数から、当該APIを通して入力または出力される文字を抽出する。検出部170は、オートマトンと抽出された文字とに基づいて、ストリームの現在の状態を更新する。検出部170は、更新後の現在の状態が受理状態であれば、検出された文字列を示す検出情報を出力する。
(Step S5) The
(ステップS6)情報処理装置100は、検査対象のプログラムの実行が終了したか判断する。終了した場合、文字列の検出の処理も終了する。終了していない場合、処理をステップS4に進める。なお、検査対象のプログラムの実行が終了するとき、情報処理装置100は、状態情報記憶部120に記憶された状態遷移情報を消去してもよい。
(Step S6) The
以下では、ステップS1で実行されるオートマトン生成の処理、ステップS2で実行されるAPIフッキングの処理、および、ステップS5で実行される文字列検出の処理それぞれについて、更に説明を加える。 Hereinafter, the automaton generation process executed in step S1, the API hooking process executed in step S2, and the character string detection process executed in step S5 will be further described.
図10は、オートマトン生成の手順例を示すフローチャートである。図10に示す処理は、前述のステップS1の中で実行される。なお、図10に示すオートマトンの生成手順は一例であり、他の手順によってオートマトンを生成することも可能である。 FIG. 10 is a flowchart illustrating an exemplary procedure for generating an automaton. The process shown in FIG. 10 is executed in step S1 described above. Note that the automaton generation procedure shown in FIG. 10 is an example, and the automaton can be generated by other procedures.
(ステップS11)オートマトン生成部150は、パターン情報から1またはそれ以上の文字列を抽出する。例えば、正規表現で記載された文字列パターン“password|asset”から、文字列“password”と“asset”を抽出する。
(Step S11) The
(ステップS12)オートマトン生成部150は、初期状態(状態#0)を追加する。
(ステップS13)オートマトン生成部150は、ステップS11で抽出した1またはそれ以上の文字列の中から、文字列を1つ選択する。
(Step S12) The
(Step S13) The
(ステップS14)オートマトン生成部150は、現在の状態を状態#0とする。
(ステップS15)オートマトン生成部150は、ステップS13で選択した文字列の先頭側から、文字を1つ抽出する。
(Step S14) The
(Step S15) The
(ステップS16)オートマトン生成部150は、現在の状態が遷移元でありステップS15で抽出した文字が遷移条件である通常遷移が存在するか判断する。存在する場合、処理をステップS18に進める。存在しない場合、処理をステップS17に進める。
(Step S16) The
(ステップS17)オートマトン生成部150は、オートマトンに新たな状態を追加すると共に、現在の状態から当該新たな状態への通常遷移を追加する。また、追加した通常遷移に、ステップS15で抽出した文字を遷移条件として対応付ける。
(Step S17) The
(ステップS18)オートマトン生成部150は、現在の状態を、ステップS16で見つかった通常遷移の遷移先、または、ステップS17で追加した状態に遷移させる。
(ステップS19)オートマトン生成部150は、ステップS15で抽出した文字が、文字列の末尾の文字であるか判断する。末尾の文字である場合、処理をステップS20に進める。末尾の文字でない場合、処理をステップS15に進める。
(Step S18) The
(Step S19) The
(ステップS20)オートマトン生成部150は、現在の状態を受理状態に指定する。
(ステップS21)オートマトン生成部150は、ステップS13で選択した文字列が最後の文字列であるか判断する。最後の文字列である場合、処理をステップS22に進める。最後の文字列でない場合、処理をステップS13に進める。
(Step S20) The
(Step S21) The
(ステップS22)オートマトン生成部150は、通常遷移として、状態#0から状態#0に遷移する自己遷移をオートマトンに追加する。また、当該自己遷移に、他の何れの通常遷移の遷移条件にも合致しないことを示す論理式を対応付ける。例えば、文字“p”が対応付けられた状態#0から状態#1への通常遷移と、文字“a”が対応付けられた状態#0から状態#9への通常遷移とが存在する場合、“not(pまたはa)”という論理式が、遷移条件として自己遷移に対応付けられる。
(Step S22) The
図11は、オートマトン生成の手順例を示すフローチャート(続き)である。図11に示す処理は、図10に示す処理に続いて、前述のステップS1の中で実行される。なお、図11に示すオートマトンの生成手順は一例であり、他の手順によってオートマトンを生成することも可能である。 FIG. 11 is a flowchart (continuation) illustrating an example of a procedure for generating an automaton. The process shown in FIG. 11 is executed in the above-described step S1 following the process shown in FIG. Note that the automaton generation procedure shown in FIG. 11 is an example, and the automaton can be generated by other procedures.
(ステップS23)オートマトン生成部150は、各状態の深さを算出する。深さは、初期状態(状態#0)を起点として通常遷移を辿った場合のホップ数とする。図3の例の場合、状態#0の深さは0、状態#8の深さは8、状態#13の深さは5である。
(Step S23) The
(ステップS24)オートマトン生成部150は、深さ1の状態(図3の例の場合、状態#1,#9)から状態#0へのfailure遷移を、オートマトンに追加する。
(ステップS25)オートマトン生成部150は、変数n=2に設定する。
(Step S24) The
(Step S25) The
(ステップS26)オートマトン生成部150は、深さnの状態Snを選択する。以下のステップS27〜S30の処理を、状態Snそれぞれについて実行する。
(ステップS27)オートマトン生成部150は、前状態=Sn-1,入力=x,後状態=Snである通常遷移を抽出する(Sn-1は深さn−1の状態であり、xは任意の1文字である)。また、オートマトン生成部150は、前状態=Sn-1,後状態=Stであるfailure遷移を抽出する(Stは任意の状態である)。
(Step S26)
(Step S27) The
(ステップS28)オートマトン生成部150は、前状態=St,入力=x,後状態=Suである通常遷移が存在するか判断する(Suは任意の状態である)。存在する場合、処理をステップS29に進める。存在しない場合、処理をステップS30に進める。
(Step S28) The
(ステップS29)オートマトン生成部150は、状態Snから状態Suへのfailure遷移を、オートマトンに追加する。
(ステップS30)オートマトン生成部150は、状態Snから状態#0へのfailure遷移を、オートマトンに追加する。
(Step S29)
(Step S30)
(ステップS31)オートマトン生成部150は、ステップS29またはステップS30で追加したfailure遷移の前状態と後状態の間で、受理状態を統合する。
(ステップS32)オートマトン生成部150は、nを1だけ増加させる。
(Step S31) The
(Step S32) The
(ステップS33)オートマトン生成部150は、nがオートマトンの深さの最大値(図3の例の場合は8)より大きいか判断する。条件を満たす場合、処理を終了する。条件を満たさない場合、処理をステップS26に進める。
(Step S33) The
以上のステップS11〜S33の処理により、オートマトン生成部150は、オートマトンを生成することができる。次に、APIフッキングの実装例を説明する。
図12は、APIフッキングの第1の方法を示す図である。第1の方法では、解析部160が、検査対象のプログラムに代わってAPI呼び出しを行う。
Through the processes in steps S11 to S33, the
FIG. 12 is a diagram illustrating a first method of API hooking. In the first method, the
例えば、APIフッキング部140は、Javaのinstrumentation機能を用いて、検査対象のプログラムのロード時に、ReaderクラスまたはWriterクラスのメソッドを呼び出す命令(invokevirtual,invokespecial,invokestatic,invokeinterfaceなど)を検索する。そして、APIフッキング部140は、検索した命令を、Reader解析部161またはWriter解析部162を呼び出す命令に書き換える。
For example, the
Reader解析部161は、検索対象のプログラムからの呼び出しの際に、Readerクラスのインスタンスへの参照を取得する。そして、当該インスタンスを指定して、readメソッドを呼び出す。Reader解析部161は、readメソッドの戻り値から文字を抽出し、抽出した文字を検出部170に出力する。また、Readerクラスのインスタンスの識別子を、ストリーム識別子として検出部170に出力する。
The
Writer解析部162は、検索対象のプログラムからの呼び出しの際に、Writerクラスのインスタンスへの参照と引数を取得する。そして、当該インスタンスを指定し、当該引数を用いてwriteメソッドを呼び出す。Writer解析部162は、引数から文字を抽出し、抽出した文字を検出部170に出力する。また、Writerクラスのインスタンスの識別子を、ストリーム識別子として検出部170に出力する。
The
なお、API呼び出しのコードを書き換える方法として、文献“Galen Hunt and Doug Brubacher, Detours: Binary Interception of Win32 Functions, Proceedings of the 3rd USENIX Windows NT Symposium, July 1999”に記載された方法を用いてもよい。 As a method of rewriting the API call code, the method described in the document “Galen Hunt and Doug Brubacher, Detours: Binary Interception of Win32 Functions, Proceedings of the 3rd USENIX Windows NT Symposium, July 1999” may be used.
図13は、APIフッキングの第1の実装例を示す図である。図13に示すようなプログラムによって、解析部160を実現できる。Analyzerクラスが、解析部160に対応する。AnalyzerクラスのreadメソッドがReader解析部161に対応し、writeメソッドがWriter解析部162に対応する。また、Detectorクラスが、検出部170に対応する。
FIG. 13 is a diagram illustrating a first implementation example of API hooking. The
検査対象のプログラムでは、Readerクラスのreadメソッドを呼び出すコードが、Analyzerクラスのreadメソッドを呼び出すコードに書き換えられる。Analyzerクラスのreadメソッドが呼び出されると、検査対象のプログラムに代わってReaderクラスのreadメソッドが呼び出され、文字(streamData)とストリーム識別子(streamID)が抽出される。 In the program to be inspected, the code for calling the read method of the Reader class is rewritten to the code for calling the read method of the Analyzer class. When the read method of the Analyzer class is called, the read method of the Reader class is called instead of the program to be inspected, and a character (streamData) and a stream identifier (streamID) are extracted.
また、検査対象のプログラムでは、Writerクラスのwriteメソッドを呼び出すコードが、Analyzerクラスのwriteメソッドを呼び出すコードに書き換えられる。Analyzerクラスのwriteメソッドが呼び出されると、検査対象のプログラムに代わってWriterクラスのwriteメソッドが呼び出され、文字とストリーム識別子が抽出される。なお、Writerクラスのwriteメソッドの呼び出しを、文字とストリーム識別子の抽出の後に行うようにしてもよい。 Further, in the program to be inspected, the code that calls the write method of the writer class is rewritten to the code that calls the write method of the analyzer class. When the write method of the Analyzer class is called, the write method of the Writer class is called instead of the program to be inspected, and characters and stream identifiers are extracted. Note that the write method of the Writer class may be called after extraction of characters and stream identifiers.
図14は、APIフッキングの第2の方法を示す図である。第2の方法では、検査対象のプログラムによってAPI呼び出しが行われた後に、解析部160の処理が行われる。
例えば、APIフッキング部140は、検査対象のプログラムのロード時に、ReaderクラスまたはWriterクラスのメソッドを呼び出す命令を検索する。そして、検索した命令の直後にReader解析部161またはWriter解析部162の処理が実行されるように、検査対象のプログラムにコードを挿入する。コード挿入は、BCEL(Byte Code Engineering Library)などのライブラリを用いて実現してもよい。また、AspectJのLoadTimeWeaving機能を利用して実現してもよい。
FIG. 14 is a diagram illustrating a second method of API hooking. In the second method, after the API call is performed by the program to be inspected, the processing of the
For example, the
Reader解析部161は、検査対象のプログラムによってReaderクラスのreadメソッドが呼び出された直後に、戻り値とReaderクラスのインスタンスへの参照を取得する。Reader解析部161は、戻り値から文字を抽出し、抽出した文字を検出部170に出力する。また、Readerクラスのインスタンスの識別子を、ストリーム識別子として検出部170に出力する。
The
Writer解析部162は、検査対象のプログラムによってWriterクラスのwriteメソッドが呼び出された直後に、引数とWriterクラスのインスタンスへの参照を取得する。Writer解析部162は、引数から文字を抽出し、抽出した文字を検出部170に出力する。また、Writerクラスのインスタンスの識別子を、ストリーム識別子として検出部170に出力する。
The
図15は、APIフッキングの第2の実装例を示す図である。図15に示すようなプログラムによって、APIフッキング部140および解析部160を実現できる。図15のプログラム例では、Javaのinstrumentation機能とAspectJの機能を利用している。
FIG. 15 is a diagram illustrating a second implementation example of API hooking. The
Agentクラスのpremainメソッドが実行されると、検査対象のプログラムから、アノテーションAfterReturningのpointcutの条件に合致するコードが検索される。図15の例では、Readerクラスを継承しているクラスのreadメソッドを呼び出すコードが検索される。そして、検索されたコードの直後に、アノテーションAfterReturningが付与されたメソッド(図15の例では、readメソッド)を呼び出すコードが挿入される。 When the prepare method of the Agent class is executed, a code that matches the pointcut condition of the annotation AfterReturning is searched from the inspection target program. In the example of FIG. 15, a code that calls the read method of a class that inherits the Reader class is searched. Then, immediately after the retrieved code, a code for calling a method (read method in the example of FIG. 15) to which annotation AfterReturning is assigned is inserted.
次に、文字列検出の処理を説明する。
図16は、文字列検出の手順例を示すフローチャートである。図16に示す処理は、前述のステップS5の中で実行される。
Next, the character string detection process will be described.
FIG. 16 is a flowchart illustrating a procedure example of character string detection. The process shown in FIG. 16 is executed in step S5 described above.
(ステップS41)解析部160は、ストリーム識別子を抽出する。また、戻り値または引数から、APIを通して入力または出力される文字を抽出する。
(ステップS42)検出部170は、解析部160で抽出されたストリーム識別子に対応する現在の状態を、状態管理テーブル124から検索する。
(Step S41) The
(Step S <b> 42) The
(ステップS43)検出部170は、ストリーム識別子に対応する現在の状態が、状態管理テーブル124に登録されているか判断する。登録されている場合、処理をステップS45に進める。登録されていない場合、処理をステップS44に進める。
(Step S43) The
(ステップS44)検出部170は、ストリーム識別子に対応付けて、初期状態を示す状態IDを状態管理テーブル124に登録する。
(ステップS45)検出部170は、ストリームの現在の状態および解析部160で抽出された文字に対応する通常遷移を、通常遷移テーブル121から検索する。そして、該当する通常遷移が存在するか判断する。存在する場合、処理をステップS47に進める。存在しない場合、処理をステップS46に進める。
(Step S44) The
(Step S <b> 45) The
(ステップS46)検出部170は、ストリームの現在の状態に対応するfailure遷移を、failure遷移テーブル122から検索する。そして、状態管理テーブル124に登録された現在の状態を、failure遷移後の状態に書き換える。その後、処理をステップS45に進める。
(Step S46) The
(ステップS47)検出部170は、状態管理テーブル124に登録された現在の状態を、ステップS45で検索された通常遷移後の状態に書き換える。
(ステップS48)検出部170は、受理状態テーブル123を参照して、ストリームの現在の状態が受理状態であるか判断する。受理状態である場合、処理をステップS49に進める。受理状態でない場合、処理を終了して次のAPI呼び出しを待つ。
(Step S47) The
(Step S48) The
(ステップS49)検出部170は、受理状態テーブル123を参照して、検出された文字列を判断する。そして、検出情報を生成して検出情報記憶部130に格納する。
図17は、検出情報の例を示す図である。検出部170が生成する検出情報には、例えば、検出された文字列、当該文字列が含まれるストリームの識別子、呼び出されたAPIの情報、および、検査対象プログラム中のAPI呼び出しを記載したコードの位置が含まれる。文字列は、受理状態テーブル123から取得できる。ストリーム識別子は、状態管理テーブル124から取得できる。API情報およびコード位置は、例えば、ThreadクラスのgetStackTraceメソッドを呼び出すことで取得できる。
(Step S49) The
FIG. 17 is a diagram illustrating an example of detection information. The detection information generated by the
例として、検査対象のプログラムによりReaderクラスのインスタンスが2つ生成され(オブジェクトA,B)、以下の順序で文字が取得された場合を考える。
(1)オブジェクトAを通して文字“p”を取得する。
As an example, consider a case where two instances of the Reader class are generated by the program to be inspected (objects A and B) and characters are acquired in the following order.
(1) The character “p” is acquired through the object A.
(2)オブジェクトBを通して文字“a”を取得する。
(3)オブジェクトAを通して文字“a”を取得する。
(4)オブジェクトBを通して文字“p”を取得する。
(2) The character “a” is acquired through the object B.
(3) The character “a” is acquired through the object A.
(4) The character “p” is acquired through the object B.
(5)オブジェクトAを通して文字“s”を取得する。
(6)オブジェクトAを通して文字“s”を取得する。
(7)オブジェクトAを通して文字“e”を取得する。
(5) The character “s” is acquired through the object A.
(6) The character “s” is acquired through the object A.
(7) The character “e” is acquired through the object A.
(8)オブジェクトAを通して文字“t”を取得する。
1番目の文字が抽出されると、検出部170は、まずオブジェクトAの識別子と状態#0を状態管理テーブル124に登録する。次に、入力pによる通常遷移が発生するため、検出部170は、オブジェクトAの状態を状態#0から状態#1に更新する。状態#1は受理状態でないため、検出情報を出力せずに次の文字が抽出されるのを待つ。
(8) The character “t” is acquired through the object A.
When the first character is extracted, the
2番目の文字が抽出されると、検出部170は、まずオブジェクトBの識別子と状態#0を状態管理テーブル124に登録する。次に、入力aによる通常遷移が発生するため、検出部170は、オブジェクトBの状態を状態#0から状態#9に更新する。状態#9は受理状態でないため、検出情報を出力せずに次の文字が抽出されるのを待つ。
When the second character is extracted, the
3番目の文字が抽出されると、検出部170は、状態管理テーブル124を参照して、オブジェクトAの状態が状態#1であると判断する。入力aによる通常遷移が発生するため、検出部170は、オブジェクトAの状態を状態#1から状態#2に更新する。状態#2は受理状態でないため、検出情報を出力せずに次の文字が抽出されるのを待つ。
When the third character is extracted, the
4番目の文字が抽出されると、検出部170は、状態管理テーブル124を参照して、オブジェクトBの状態が状態#9であると判断する。ここではfailure遷移が発生するため、検出部170は、オブジェクトBの状態を状態#9から状態#0に更新する。更に、入力pによる通常遷移が発生するため、検出部170は、オブジェクトBの状態を状態#0から状態#1に更新する。状態#1は受理状態でないため、検出情報を出力せずに次の文字が抽出されるのを待つ。
When the fourth character is extracted, the
5番目の文字が抽出されると、検出部170は、状態管理テーブル124を参照して、オブジェクトAの状態が状態#2であると判断する。入力sによる通常遷移が発生するため、検出部170は、オブジェクトAの状態を状態#2から状態#3に更新する。状態#3は受理状態でないため、検出情報を出力せずに次の文字が抽出されるのを待つ。
When the fifth character is extracted, the
6番目の文字が抽出されると、検出部170は、状態管理テーブル124を参照して、オブジェクトAの状態が状態#3であると判断する。入力sによる通常遷移が発生するため、検出部170は、オブジェクトAの状態を状態#3から状態#4に更新する。状態#4は受理状態でないため、検出情報を出力せずに次の文字が抽出されるのを待つ。
When the sixth character is extracted, the
7番目の文字が抽出されると、検出部170は、状態管理テーブル124を参照して、オブジェクトAの状態が状態#4であると判断する。ここではfailure遷移が発生するため、検出部170は、オブジェクトAの状態を状態#4から状態#11に更新する。更に、入力eによる通常遷移が発生するため、検出部170は、オブジェクトAの状態を状態#11から状態#12に更新する。状態#12は受理状態でないため、検出情報を出力せずに次の文字が抽出されるのを待つ。
When the seventh character is extracted, the
8番目の文字が抽出されると、検出部170は、状態管理テーブル124を参照して、オブジェクトAの状態が状態#12であると判断する。入力tによる通常遷移が発生するため、検出部170は、オブジェクトAの状態を状態#12から状態#13に更新する。状態#13は受理状態であるため、検出部170は、検出情報を生成し出力する。なお、オブジェクトAを通して更に文字が取得された場合、状態#13を遷移元とする通常遷移が存在しないため、failure遷移が発生して状態#0に戻ることになる。
When the eighth character is extracted, the
以上の説明では、文字を1字ずつ入力または出力するAPIの例を示したが、1回のメソッド呼び出しで複数の文字を入力または出力できるAPIについても、同様の方法で文字列の検出を行うことができる。その場合、例えば、検出部170は、抽出された複数の文字を順にオートマトンに入力すればよい。また、以上の説明では、文字列を検出する例を示したが、文字以外の記号を含む記号列やバイトパターンを検出してもよい。また、情報処理装置100は、ストリームで用いられている文字コードを判断し、文字コードに応じて、検出するバイトパターンを決定するようにしてもよい。
In the above description, an example of an API that inputs or outputs characters one by one has been shown. However, for an API that can input or output a plurality of characters with a single method call, a character string is detected in the same manner. be able to. In this case, for example, the
第2の実施の形態の情報処理装置100によれば、入力または出力のストリームの検査を効率的に行うことができる。複数回のAPI呼び出しを通してオートマトンに基づいて状態管理を行うため、複数回に分けて入力または出力される文字列を検出できる。また、抽出された文字に基づいて現在の状態を順次更新すればよく、入力または出力された文字列をバッファに記憶しておかなくてもよいため、メモリ消費量や検索負荷を抑制できる。また、API呼び出しを監視することで文字列を検出するため、ファイルなどの操作対象を予め具体的に特定しなくても、検査を行うことが可能となる。また、入力または出力のストリーム毎に現在の状態を管理するため、複数のストリームを適切に検査できる。
According to the
なお、前述の通り、第2の実施の形態のソフトウェア検査方法は、コンピュータとしての能力を備える情報処理装置100に、ソフトウェア検査プログラムを実行させることで実現できる。当該プログラムは、コンピュータ読み取り可能な記録媒体(例えば、記録媒体23)に記録しておくことができる。記録媒体として、例えば、磁気ディスク、光ディスク、光磁気ディスク、半導体メモリなどを使用できる。磁気ディスクには、HDDおよびFDが含まれる。光ディスクには、CD、CD−R(Recordable)/RW(Rewritable)、DVDおよびDVD−R/RWが含まれる。
As described above, the software inspection method according to the second embodiment can be realized by causing the
プログラムを流通させる場合、例えば、当該プログラムを記録した可搬記録媒体が提供される。また、プログラムを他の情報処理装置の記憶装置に格納しておき、ネットワーク24経由で当該プログラムを配布することもできる。情報処理装置100は、例えば、可搬記録媒体に記録されたプログラムまたは他の情報処理装置から受信したプログラムを、HDD103などの記憶装置に格納し、記憶装置からプログラムを読み込んで実行する。ただし、可搬型記録媒体からプログラムを直接読み込んで実行してもよい。また、他の情報処理装置からプログラムを受信する毎に逐次、受信したプログラムを実行してもよい。
When distributing the program, for example, a portable recording medium in which the program is recorded is provided. It is also possible to store the program in a storage device of another information processing apparatus and distribute the program via the
10 情報処理装置
11 記憶手段
11a 状態遷移情報
12 抽出手段
13 検出手段
DESCRIPTION OF
Claims (5)
複数の状態と、遷移条件としての記号が対応付けられた状態間の遷移と、前記複数の状態の中の受理状態と、を示す状態遷移情報を記憶する記憶手段と、
前記複数回の関数の呼び出しそれぞれが行われるとき、戻り値および引数の少なくとも一方に含まれる記号を抽出する抽出手段と、
前記抽出手段で記号が抽出されると、前記複数の状態の中の現在の状態と抽出された記号とから、前記記憶手段に記憶された前記状態遷移情報が示す遷移に従って現在の状態を更新し、更新後の現在の状態が前記受理状態であるか否かに応じて、前記記号列の検出結果の情報を出力する検出手段と、
を有する情報処理装置。 An information processing apparatus that detects that a symbol string to be inspected is input or output by executing a program that calls a function multiple times,
Storage means for storing state transition information indicating a plurality of states, a transition between states associated with a symbol as a transition condition, and an accepting state in the plurality of states;
An extraction means for extracting a symbol included in at least one of a return value and an argument when each of the plurality of function calls is performed;
When a symbol is extracted by the extraction unit, the current state is updated according to the transition indicated by the state transition information stored in the storage unit from the current state in the plurality of states and the extracted symbol. Detecting means for outputting information on the detection result of the symbol string according to whether or not the current state after the update is the acceptance state;
An information processing apparatus.
前記抽出手段は、指定されたストリームの識別情報を更に抽出し、
前記検出手段は、前記識別情報に基づいてストリーム毎に現在の状態を管理する、
請求項1記載の情報処理装置。 The multiple function calls are made by specifying an input or output stream;
The extraction means further extracts identification information of the designated stream,
The detection means manages a current state for each stream based on the identification information;
The information processing apparatus according to claim 1.
を更に有する請求項1記載の情報処理装置。 Generating means for acquiring information indicating the symbol string and generating the state transition information so that a current state after the respective symbols included in the symbol string are sequentially extracted becomes the acceptance state;
The information processing apparatus according to claim 1, further comprising:
前記複数回の関数の呼び出しそれぞれが行われるとき、戻り値および引数の少なくとも一方に含まれる記号を抽出し、
記号が抽出されると、複数の状態と遷移条件としての記号が対応付けられた状態間の遷移と前記複数の状態の中の受理状態とを示す状態遷移情報を記憶する記憶手段を参照して、前記複数の状態の中の現在の状態と抽出された記号とから、現在の状態を更新し、
更新後の現在の状態が前記受理状態であるか否かに応じて、前記記号列の検出結果の情報を出力する、
ソフトウェア検査方法。 A computer-implemented software inspection method that detects that a symbol string to be inspected is input or output by executing a program that calls a function multiple times,
When each of the plurality of function calls is performed, a symbol included in at least one of a return value and an argument is extracted.
When a symbol is extracted, refer to a storage unit that stores state transition information indicating a transition between states associated with a plurality of states and a symbol as a transition condition and an accepted state in the plurality of states. Updating the current state from the current state in the plurality of states and the extracted symbols;
Depending on whether or not the current state after the update is the acceptance state, information on the detection result of the symbol string is output.
Software inspection method.
前記複数回の関数の呼び出しそれぞれが行われるとき、戻り値および引数の少なくとも一方に含まれる記号を抽出し、
記号が抽出されると、複数の状態と遷移条件としての記号が対応付けられた状態間の遷移と前記複数の状態の中の受理状態とを示す状態遷移情報を記憶する記憶手段を参照して、前記複数の状態の中の現在の状態と抽出された記号とから、現在の状態を更新し、
更新後の現在の状態が前記受理状態であるか否かに応じて、前記記号列の検出結果の情報を出力する、
処理を実行させるソフトウェア検査プログラム。 A software inspection program for detecting that a symbol string to be inspected is input or output by executing a program that calls a function a plurality of times.
When each of the plurality of function calls is performed, a symbol included in at least one of a return value and an argument is extracted.
When a symbol is extracted, refer to a storage unit that stores state transition information indicating a transition between states associated with a plurality of states and a symbol as a transition condition and an accepted state in the plurality of states. Updating the current state from the current state in the plurality of states and the extracted symbols;
Depending on whether or not the current state after the update is the acceptance state, information on the detection result of the symbol string is output.
Software inspection program that executes processing.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2011020460A JP5728979B2 (en) | 2011-02-02 | 2011-02-02 | Information processing apparatus, software inspection method, and software inspection program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2011020460A JP5728979B2 (en) | 2011-02-02 | 2011-02-02 | Information processing apparatus, software inspection method, and software inspection program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2012160101A true JP2012160101A (en) | 2012-08-23 |
JP5728979B2 JP5728979B2 (en) | 2015-06-03 |
Family
ID=46840562
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2011020460A Expired - Fee Related JP5728979B2 (en) | 2011-02-02 | 2011-02-02 | Information processing apparatus, software inspection method, and software inspection program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP5728979B2 (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112015393A (en) * | 2020-08-25 | 2020-12-01 | 中国银联股份有限公司 | Service processing method and device |
JP2021002276A (en) * | 2019-06-24 | 2021-01-07 | 富士通株式会社 | Analysis program, program analyzing method, and program analyzing apparatus |
CN112015393B (en) * | 2020-08-25 | 2024-05-03 | 中国银联股份有限公司 | Service processing method and device |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS63213024A (en) * | 1987-02-28 | 1988-09-05 | Fujitsu Ltd | Japanese word processing system |
JPH1055363A (en) * | 1996-04-25 | 1998-02-24 | Sharp Corp | Information processor and computer-readable recording medium where information processing program is recorded |
US20060085657A1 (en) * | 2002-04-10 | 2006-04-20 | Microsoft Corporation | ACPI Name Space Validation |
JP2007287078A (en) * | 2006-04-20 | 2007-11-01 | Internatl Business Mach Corp <Ibm> | Information processor for supporting protection of personal information |
US20070282835A1 (en) * | 2006-04-28 | 2007-12-06 | Roke Manor Research Limited | Aho-corasick methodology for string searching |
WO2010026804A1 (en) * | 2008-09-05 | 2010-03-11 | 日本電信電話株式会社 | Approximate collation device, approximate collation method, program, and recording medium |
US20100161536A1 (en) * | 2008-12-19 | 2010-06-24 | Clark Christopher F | Pattern matching |
-
2011
- 2011-02-02 JP JP2011020460A patent/JP5728979B2/en not_active Expired - Fee Related
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS63213024A (en) * | 1987-02-28 | 1988-09-05 | Fujitsu Ltd | Japanese word processing system |
JPH1055363A (en) * | 1996-04-25 | 1998-02-24 | Sharp Corp | Information processor and computer-readable recording medium where information processing program is recorded |
US20060085657A1 (en) * | 2002-04-10 | 2006-04-20 | Microsoft Corporation | ACPI Name Space Validation |
JP2007287078A (en) * | 2006-04-20 | 2007-11-01 | Internatl Business Mach Corp <Ibm> | Information processor for supporting protection of personal information |
US20070282835A1 (en) * | 2006-04-28 | 2007-12-06 | Roke Manor Research Limited | Aho-corasick methodology for string searching |
WO2010026804A1 (en) * | 2008-09-05 | 2010-03-11 | 日本電信電話株式会社 | Approximate collation device, approximate collation method, program, and recording medium |
US20100161536A1 (en) * | 2008-12-19 | 2010-06-24 | Clark Christopher F | Pattern matching |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2021002276A (en) * | 2019-06-24 | 2021-01-07 | 富士通株式会社 | Analysis program, program analyzing method, and program analyzing apparatus |
JP7244756B2 (en) | 2019-06-24 | 2023-03-23 | 富士通株式会社 | Analysis program, program analysis method and program analysis device |
CN112015393A (en) * | 2020-08-25 | 2020-12-01 | 中国银联股份有限公司 | Service processing method and device |
CN112015393B (en) * | 2020-08-25 | 2024-05-03 | 中国银联股份有限公司 | Service processing method and device |
Also Published As
Publication number | Publication date |
---|---|
JP5728979B2 (en) | 2015-06-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Sambasivan et al. | Principled workflow-centric tracing of distributed systems | |
JP2006185211A (en) | Program analysis system, test execution device, and analysis method and program thereof | |
JP6179331B2 (en) | Log output condition setting program, apparatus, and method | |
JP2006031109A (en) | Management system and management method | |
US20090064088A1 (en) | Method and system for displaying http session entry and exit points | |
JP6070847B2 (en) | Verification method, verification apparatus, and verification program | |
JP2020119348A (en) | Analysis program, analysis method, and analysis device | |
CN115576600A (en) | Code change-based difference processing method and device, terminal and storage medium | |
JP2008204405A (en) | Software regression test system, regression test program and regression test method | |
US9244821B2 (en) | Latent defect indication | |
JP5728979B2 (en) | Information processing apparatus, software inspection method, and software inspection program | |
US8762953B2 (en) | Exception-based error handling in an array-based language | |
JP7077909B2 (en) | Dead code analysis program, dead code analysis method and dead code analysis device | |
JP2009075886A (en) | Specification defect verification system, method thereof, and program | |
US20180365129A1 (en) | Dynamic instrumentation based on detected errors | |
KR101052735B1 (en) | Method for detecting presence of memory operation and device using same | |
JP7111967B2 (en) | Program verification program, program verification method and program verification device | |
JP2016018227A (en) | Work log edition method, information processor, and program | |
US8843896B2 (en) | Metamodeling contextual navigation of computer software applications | |
JP6770335B2 (en) | Analyst and program | |
JP5550578B2 (en) | Entry rewriting device and entry rewriting program | |
WO2011104889A1 (en) | Computer system, memory management method and memory management program | |
JP7327471B2 (en) | Test equipment, test method and program | |
WO2023067665A1 (en) | Analysis function addition method, analysis function addition device, and analysis function addition program | |
JP2008262473A (en) | Equipment maintenance management system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20131007 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20140611 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20140617 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20140804 |
|
A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20141111 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20150212 |
|
A911 | Transfer to examiner for re-examination before appeal (zenchi) |
Free format text: JAPANESE INTERMEDIATE CODE: A911 Effective date: 20150219 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20150310 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20150323 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 5728979 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
LAPS | Cancellation because of no payment of annual fees |