JP2013030017A - Method, device, and program for generating test program - Google Patents

Method, device, and program for generating test program Download PDF

Info

Publication number
JP2013030017A
JP2013030017A JP2011165947A JP2011165947A JP2013030017A JP 2013030017 A JP2013030017 A JP 2013030017A JP 2011165947 A JP2011165947 A JP 2011165947A JP 2011165947 A JP2011165947 A JP 2011165947A JP 2013030017 A JP2013030017 A JP 2013030017A
Authority
JP
Japan
Prior art keywords
rule
program
detection
test
history
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.)
Withdrawn
Application number
JP2011165947A
Other languages
Japanese (ja)
Inventor
Takao Okubo
隆夫 大久保
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2011165947A priority Critical patent/JP2013030017A/en
Publication of JP2013030017A publication Critical patent/JP2013030017A/en
Withdrawn legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

PROBLEM TO BE SOLVED: To improve working efficiency related to a black box test.SOLUTION: A method for generating test programs includes: recording a history of execution of a method by a use program using a collection of methods, according to a detection of the execution of the method; collating the history with rule information on a context related to the collection of the methods that a storage part stores, detecting violation of the rule information on the execution of the method by the use program, and recording the detection result in the storage part; and generating a test program for executing a test code that the storage part stores by associating with a combination of the rule information and the detection result.

Description

本発明は、テストプログラム生成方法、テストプログラム生成装置、及びテストプログラム生成プログラムに関する。   The present invention relates to a test program generation method, a test program generation device, and a test program generation program.

従来、プログラムに関して、ブラックボックステストと呼ばれる形態のテストが行われている。ブラックボックステストとは、プログラムの内部構造を意識せずに、入力に対する出力が期待されているものであるか否かを確認するテストである。ブラックボックステストのテスト項目は、通常、機能仕様書等、プログラムの外部インタフェースが規定された文書に基づいて作成される。したがって、ブラックボックステストのテスト項目は、コーディング担当者等、プログラムの内部構造を知らない者でも作成することができる。よって、コーディング作成、テスト項目の作成、及びテストの実施等といった作業の分業が比較的容易であり、プログラム開発作業の効率化を図ることができる。   Conventionally, a test called a black box test has been performed on a program. The black box test is a test for confirming whether an output for an input is expected without being conscious of the internal structure of the program. The test item of the black box test is usually created based on a document that defines the external interface of the program, such as a functional specification. Therefore, the test item of the black box test can be created even by a person who does not know the internal structure of the program, such as a person in charge of coding. Therefore, the division of work such as coding creation, test item creation, and test execution is relatively easy, and the efficiency of the program development work can be improved.

他方において、近年、プログラムの部品化が進み、部品化されたプログラムがファイルとしてまとめられた既存のライブラリを利用して、プログラムの開発効率の向上が図られている。ライブラリの中には、含まれる関数又はメソッドの文脈(例えば、呼び出し順等)に関して明確な規則(又は制約)を有るものがある。斯かる規則に従わない場合、ライブラリの本来の機能が有効に得られないといった事態が生じうる。ここでメソッドとは、オブジェクト指向プログラミングやアスペクト指向プログラミング等で、各オブェクト等が持っている自身に対する操作、手続きを表すものである。   On the other hand, in recent years, program componentization has progressed, and the development efficiency of the program has been improved by using an existing library in which the componentized program is collected as a file. Some libraries have clear rules (or constraints) regarding the context of the function or method involved (eg, call order, etc.). If such a rule is not followed, a situation may occur in which the original functions of the library cannot be obtained effectively. Here, the method represents an operation or procedure for each object or the like that each object has in object-oriented programming or aspect-oriented programming.

顕著な例として、暗号化通信等を行うためのセキュリティ関連のライブラリ(以下、「セキュリティライブラリ」という。)が挙げられる。セキュリティライブラリを利用する際、例えば、不適切な初期化が行われたり、初期化が行われなかったりした場合、本来期待される程度の安全性が確保されないといった事態が発生しうる。   A prominent example is a security-related library (hereinafter referred to as “security library”) for performing encrypted communication or the like. When the security library is used, for example, if inappropriate initialization is performed or initialization is not performed, a situation may occur in which the safety expected to be originally expected cannot be ensured.

特開平11−224211号公報JP-A-11-224211 特開平7−210424号公報Japanese Patent Laid-Open No. 7-210424

しかしながら、ブラックボックステストでは、以下の4つのケースにおいて、結果が同じであるケースAとケースB、又はケースCとケースDとを明確に区別できないという問題がある。
(A)正しい実装で、かつ、結果もOK
(B)誤った実装(バグ)の可能性が有り、結果はOK
(C)正しい実装であるにも拘わらず、結果はNG
(D)誤った実装(バグ)の可能性が有り、結果はNG
以上を区別するためには、テストを詳細化する必要がある。詳細化に関して、従来のブラックボックステストでは、テスト対象のプログラムの全ての入力箇所に対してテストを追加したり、考えられる全ての入力値を入力したりする必要がある。その結果、多数の冗長なテスト項目が発生し、開発作業の効率性を低下させてしまう可能性があった。
However, in the following four cases, the black box test has a problem in that case A and case B or case C and case D, which have the same result, cannot be clearly distinguished.
(A) Correct implementation and result is OK
(B) There is a possibility of incorrect implementation (bug), the result is OK
(C) Despite the correct implementation, the result is NG
(D) There is a possibility of incorrect implementation (bug), and the result is NG
In order to distinguish the above, it is necessary to refine the test. With regard to refinement, in the conventional black box test, it is necessary to add a test to all input locations of a test target program or to input all possible input values. As a result, a large number of redundant test items are generated, which may reduce the efficiency of development work.

そこで、ブラックボックステストに関する作業効率を向上させることのできるテストプログラム生成方法、テストプログラム生成装置、及びテストプログラム生成プログラムの提供を目的とする。   Therefore, an object of the present invention is to provide a test program generation method, a test program generation device, and a test program generation program that can improve the work efficiency related to the black box test.

そこで上記課題を解決するため、テストプログラム生成方法は、メソッドの集合を利用する利用プログラムによる前記メソッドの実行の検知に応じて該実行の履歴を記録し、前記履歴を、記憶部が記憶する、前記メソッドの集合に関する文脈上の規則情報と照合して、前記利用プログラムによる前記メソッドの実行に関して前記規則情報に対する違反を検出し、検出結果を前記記憶部に記録し、前記規則情報と前記検出結果との組み合わせに対応付けて前記記憶部が記憶するテストコードを実行させるテストプログラムを生成する処理をコンピュータが実行する。   Therefore, in order to solve the above-described problem, the test program generation method records the execution history in response to detection of the execution of the method by the use program that uses a set of methods, and the storage unit stores the history. Collating with contextual rule information regarding the set of methods, detecting violations of the rule information regarding execution of the method by the using program, recording a detection result in the storage unit, and detecting the rule information and the detection result The computer executes a process of generating a test program for executing the test code stored in the storage unit in association with the combination.

ブラックボックステストに関する作業効率を向上させることができる。   Work efficiency related to black box test can be improved.

本発明の実施の形態におけるテストプログラム生成装置のハードウェア構成例を示す図である。It is a figure which shows the hardware structural example of the test program production | generation apparatus in embodiment of this invention. 本発明の実施の形態におけるテストプログラム生成装置の機能構成例を示す図である。It is a figure which shows the function structural example of the test program production | generation apparatus in embodiment of this invention. ルール記述を構成するルール要素の例を示す図である。It is a figure which shows the example of the rule element which comprises a rule description. ルール記述を構成するオペレータの例を示す図である。It is a figure which shows the example of the operator who comprises a rule description. ルール解析部が実行する処理手順の一例を説明するためのフローチャートである。It is a flowchart for demonstrating an example of the process sequence which a rule analysis part performs. 第一のルール記述の一例を示す図である。It is a figure which shows an example of a 1st rule description. XML形式による第一のルール記述の一例を示す図である。It is a figure which shows an example of the 1st rule description by an XML format. 第一のルール要素一覧の例を示す図であるIt is a figure which shows the example of a 1st rule element list. プログラム生成部が実行する処理手順の一例を説明するためのフローチャートである。It is a flowchart for demonstrating an example of the process sequence which a program production | generation part performs. アスペクト雛形の一例を示す図である。It is a figure which shows an example of an aspect model. 本実施の形態においてライブラリの呼び出し履歴を管理するためのデータ構造の一例を概念的に示す図である。It is a figure which shows notionally an example of the data structure for managing the call history of a library in this Embodiment. 第一のアスペクトコードの具体例を示す図である。It is a figure which shows the specific example of a 1st aspect code. Beforeルール要素に関する履歴記録プログラム生成処理の処理手順の一例を説明するためのフローチャートである。It is a flowchart for demonstrating an example of the process sequence of the history recording program production | generation process regarding a Before rule element. ポイントカット定義雛形の一例を示す図である。It is a figure which shows an example of a pointcut definition model. 履歴記録プログラムにおけるポイントカット定義の第一の具体例を示す図である。It is a figure which shows the 1st specific example of the pointcut definition in a log | history recording program. beforeアドバイス定義雛形の一例を示す図である。It is a figure which shows an example of a before advice definition model. 履歴記録雛形の一例を示す図である。It is a figure which shows an example of a log | history recording model. 具体的なbeforeアドバイス定義の第一の例を示す図である。It is a figure which shows the 1st example of a concrete before advice definition. 履歴記録プログラムにおけるポイントカット定義の第二の具体例を示す図である。It is a figure which shows the 2nd specific example of the pointcut definition in a log | history recording program. afterアドバイス定義雛形の一例を示す図である。It is a figure which shows an example of an after advice definition model. 具体的なafterアドバイス定義の第一の例を示す図である。It is a figure which shows the 1st example of a concrete after advice definition. 履歴記録プログラムにおけるポイントカット定義の第三の具体例を示す図である。It is a figure which shows the 3rd specific example of the pointcut definition in a log | history recording program. 履歴参照雛形の一例を示す図である。It is a figure which shows an example of a log | history reference model. 具体的なafterアドバイス定義の第二の例を示す図である。It is a figure which shows the 2nd example of a concrete after advice definition. 検出プログラム生成処理の処理手順の一例を説明するためのフローチャートである。It is a flowchart for demonstrating an example of the process sequence of a detection program production | generation process. 検出プログラムにおけるポイントカット定義の具体例を示す図である。It is a figure which shows the specific example of the pointcut definition in a detection program. 検出ログ記録雛形の一例を示す図である。It is a figure which shows an example of a detection log recording model. 検出プログラムにおけるafterアドバイス定義の具体例を示す図である。It is a figure which shows the specific example of the after advice definition in a detection program. 一行分の検出ログの構成例を示す図である。It is a figure which shows the structural example of the detection log for one line. 本実施の形態の第一のルール記述に関して生成される履歴記録プログラム及び検出プログラムのアスペクトコードの具体例を示す図である。It is a figure which shows the specific example of the aspect code of the log | history recording program produced | generated regarding the 1st rule description of this Embodiment, and a detection program. 本実施の形態の第一のルール記述に関して生成される履歴記録プログラム及び検出プログラムのアスペクトコードの具体例を示す図である。It is a figure which shows the specific example of the aspect code of the log | history recording program produced | generated regarding the 1st rule description of this Embodiment, and a detection program. 第二のルール記述の一例を示す図である。It is a figure which shows an example of a 2nd rule description. 第二のルール要素一覧の例を示す図である。It is a figure which shows the example of a 2nd rule element list. 本実施の形態の第二のルール記述に関して生成される履歴記録プログラム及び検出プログラムのアスペクトコードの具体例を示す図である。It is a figure which shows the specific example of the aspect code of the log | history recording program produced | generated regarding the 2nd rule description of this Embodiment, and a detection program. 本実施の形態の第二のルール記述に関して生成される履歴記録プログラム及び検出プログラムのアスペクトコードの具体例を示す図である。It is a figure which shows the specific example of the aspect code of the log | history recording program produced | generated regarding the 2nd rule description of this Embodiment, and a detection program. Afterルール要素に関する履歴記録プログラム生成処理の処理手順の一例を説明するためのフローチャートである。It is a flowchart for demonstrating an example of the process sequence of the history recording program production | generation process regarding an After rule element. Callルール要素に関する履歴記録プログラム生成処理の処理手順の一例を説明するためのフローチャートである。It is a flowchart for demonstrating an example of the process sequence of the log | history recording program production | generation process regarding a Call rule element. 履歴記録プログラム及び検出プログラムの実行時の処理手順の一例を説明するためのフローチャートである。It is a flowchart for demonstrating an example of the process sequence at the time of execution of a history recording program and a detection program. ブラックボックステスト用のテストプログラムの生成処理の処理手順の一例を説明するためのフローチャートである。It is a flowchart for demonstrating an example of the process sequence of the production | generation process of the test program for black box tests. テストポリシーリスト記憶部の構成例を示す図である。It is a figure which shows the structural example of a test policy list memory | storage part. シナリオコードの第一の例を示す図である。It is a figure which shows the 1st example of a scenario code. シナリオコードの第二の例を示す図である。It is a figure which shows the 2nd example of a scenario code. 第三のルール記述の一例を示す図である。It is a figure which shows an example of a 3rd rule description. 第三のルール要素一覧の例を示す図である。It is a figure which shows the example of a 3rd rule element list. 検査対象のアプリケーションの実装例を示す図である。It is a figure which shows the example of mounting of the application of a test object. 検出ログの具体例を示す図である。It is a figure which shows the specific example of a detection log. テストプログラムの第一の例を示す図である。It is a figure which shows the 1st example of a test program. テストプログラムの第二の例を示す図である。It is a figure which shows the 2nd example of a test program.

以下、図面に基づいて本発明の実施の形態を説明する。図1は、本発明の実施の形態におけるテストプログラム生成装置のハードウェア構成例を示す図である。同図のテストプログラム生成装置10は、それぞれバスBで相互に接続されているドライブ装置100と、補助記憶装置102と、メモリ装置103と、CPU104と、インタフェース装置105と、表示装置106と、入力装置107とを有する。   Hereinafter, embodiments of the present invention will be described with reference to the drawings. FIG. 1 is a diagram illustrating a hardware configuration example of a test program generation device according to an embodiment of the present invention. The test program generation device 10 in FIG. 1 includes a drive device 100, an auxiliary storage device 102, a memory device 103, a CPU 104, an interface device 105, a display device 106, and an input connected to each other via a bus B. Device 107.

テストプログラム生成装置10での処理を実現するプログラムは、CD−ROM等の記録媒体101によって提供される。プログラムを記録した記録媒体101がドライブ装置100にセットされると、プログラムが記録媒体101からドライブ装置100を介して補助記憶装置102にインストールされる。但し、プログラムのインストールは必ずしも記録媒体101より行う必要はなく、ネットワークを介して他のコンピュータよりダウンロードするようにしてもよい。補助記憶装置102は、インストールされたプログラムを格納すると共に、必要なファイルやデータ等を格納する。   A program that realizes processing in the test program generation device 10 is provided by a recording medium 101 such as a CD-ROM. When the recording medium 101 on which the program is recorded is set in the drive device 100, the program is installed from the recording medium 101 to the auxiliary storage device 102 via the drive device 100. However, the program need not be installed from the recording medium 101 and may be downloaded from another computer via a network. The auxiliary storage device 102 stores the installed program and also stores necessary files and data.

メモリ装置103は、プログラムの起動指示があった場合に、補助記憶装置102からプログラムを読み出して格納する。CPU104は、メモリ装置103に格納されたプログラムに従ってテストプログラム生成装置10に係る機能を実現する。インタフェース装置105は、ネットワークに接続するためのインタフェースとして用いられる。表示装置106はプログラムによるGUI(Graphical User Interface)等を表示する。入力装置107はキーボード及びマウス等であり、様々な操作指示を入力させるために用いられる。   The memory device 103 reads the program from the auxiliary storage device 102 and stores it when there is an instruction to start the program. The CPU 104 realizes functions related to the test program generation device 10 in accordance with a program stored in the memory device 103. The interface device 105 is used as an interface for connecting to a network. The display device 106 displays a GUI (Graphical User Interface) or the like by a program. The input device 107 is a keyboard, a mouse, or the like, and is used for inputting various operation instructions.

図2は、本発明の実施の形態におけるテストプログラム生成装置の機能構成例を示す図である。   FIG. 2 is a diagram illustrating a functional configuration example of the test program generation device according to the embodiment of the present invention.

テストプログラム生成装置10は、例えば、或るライブラリを使用して開発されるアプリケーションに関して、当該ライブラリの文脈上のルール(規則)又は制約等(以下、「ルール」で統一する)に対する違反の有無を検出する。文脈上のルールとは、ライブラリに含まれる関数又はメソッドの呼び出しの有無や呼び出しの前後関係(呼び出し順)等に関するルールをいう。テストプログラム生成装置10は、更に、ルールの違反の有無の検出に基づいて、ブラックボックステストの範囲を限定し、当該範囲に関してブラックボックステストを行うプログラム(テストプログラムTp)を生成する。   The test program generation device 10 determines whether there is a violation of rules (rules) or restrictions on the context of the library (hereinafter referred to as “rules”) for an application developed using a library, for example. To detect. A contextual rule is a rule regarding whether or not a function or method included in a library is called, and the context (call order) of the call. The test program generation device 10 further generates a program (test program Tp) that limits the range of the black box test based on the detection of the violation of the rule and performs the black box test for the range.

斯かる機能を実現するため、テストプログラム生成装置10は、ルール解析部12、プログラム生成部13、及びテストプログラム生成部15等を有する。これら各部は、テストプログラム生成装置10にインストールされたプログラムがCPU104に実行させる処理により実現される。テストプログラム生成装置10は、また、ルール記述記憶部11、雛形データ記憶部14、検出ログ記憶部16、テストポリシーリスト記憶部17、及びシナリオコード記憶部18等を有する。これら各記憶部は、補助記憶装置102、又はテストプログラム生成装置10とネットワークを介して接続される記憶装置等を用いて実現可能である。   In order to realize such a function, the test program generation device 10 includes a rule analysis unit 12, a program generation unit 13, a test program generation unit 15, and the like. Each of these units is realized by processing executed by the CPU 104 by a program installed in the test program generation apparatus 10. The test program generation device 10 also includes a rule description storage unit 11, a template data storage unit 14, a detection log storage unit 16, a test policy list storage unit 17, a scenario code storage unit 18, and the like. Each of these storage units can be realized by using the auxiliary storage device 102 or a storage device connected to the test program generation device 10 via a network.

ルール記述記憶部11は、例えば、アプリケーションより利用されるライブラリについて、ルール記述を記憶する。ルール記述とは、ライブラリの利用に関する文脈上のルールが所定の形式又は文法によって記述されたテキストデータをいう。本実施の形態において、ルール記述は、ルール要素がオペレータによって接続された式形式によって記述される。ルール要素とは、ルールの最小要素をいう。ルール要素単体でも、一つのルール記述が成立しうる。オペレータは、ルール要素間の論理関係を示す記号をいう。   The rule description storage unit 11 stores a rule description for a library used by an application, for example. The rule description refers to text data in which contextual rules relating to library use are described in a predetermined format or grammar. In the present embodiment, the rule description is described in an expression format in which rule elements are connected by an operator. A rule element refers to the minimum element of a rule. One rule description can be established by a single rule element. An operator refers to a symbol indicating a logical relationship between rule elements.

図3は、ルール記述を構成するルール要素の例を示す図である。同図には、4つのルール要素と、それぞれのルール要素のルール記述内における記述形式が示されている。なお、同図の記述形式において、小文字のアルファベット(a〜j)は、ライブラリに含まれる関数又はメソッド(以下、「メソッド」で統一する。)を示す。   FIG. 3 is a diagram illustrating an example of rule elements constituting the rule description. The figure shows four rule elements and a description format in the rule description of each rule element. In the description format shown in the figure, lower case alphabets (a to j) indicate functions or methods (hereinafter, referred to as “methods”) included in the library.

一つ目は、cメソッド内において、aメソッドがbメソッドの実行前の必須条件であることを示すルール要素である。すなわち、cメソッド内において、bメソッドが実行される場合は、bメソッドの実行前にaメソッドが必ず実行されなければならないことを示すルール要素である。当該ルール要素は、「@Before(a,b,c)」の形式でルール記述に記述される。以下、当該ルール要素を「Beforeルール要素」という。   The first is a rule element indicating that the a method is an essential condition before the execution of the b method in the c method. That is, in the c method, when the b method is executed, the rule element indicates that the a method must be executed before the b method is executed. The rule element is described in the rule description in the format of “@Before (a, b, c)”. Hereinafter, the rule element is referred to as “Before rule element”.

二つ目は、fメソッド内において、dメソッドがeメソッドの実行後の必須条件であることを示すルール要素である。すなわち、fメソッド内において、eメソッドが実行される場合は、eメソッドの実行後に必ずdメソッドが実行されなければならないことを示すルール要素である。当該ルール要素は、「@After(d,e,c)」の形式でルール記述に記述される。以下、当該ルール要素を「Afterルール要素」という。   The second is a rule element indicating that the d method is an essential condition after the execution of the e method in the f method. That is, in the f method, when the e method is executed, the rule element indicates that the d method must be executed after the e method is executed. The rule element is described in the rule description in the format of “@After (d, e, c)”. Hereinafter, the rule element is referred to as “After rule element”.

三つ目は、hメソッド内におけるgメソッドの呼び出しが必須条件であることを示すルール要素である。すなわち、gメソッドが、hメソッド内において必ず呼び出されなければならないことを示すルール要素である。当該ルール要素は、「@Call(g,h)」の形式でルール記述に記述される。以下、当該ルール要素を「Callルール要素」という。   The third is a rule element indicating that calling the g method within the h method is an essential condition. That is, it is a rule element indicating that the g method must be called in the h method. The rule element is described in the rule description in the format of “@Call (g, h)”. Hereinafter, the rule element is referred to as “Call rule element”.

四つ目は、引数の型が指定されたメソッドの呼び出しの必須条件を示すルール要素である。すなわち、iメソッドについて、特定の型の引数が指定されたバージョンがjメソッド内において必ず呼び出されなければならないことを示すルール要素である。当該ルール要素は、「@Call(i(型),j)」の形式でルール記述に記述される。以下、当該ルール要素を「型指定Callルール要素」という。   The fourth element is a rule element indicating a necessary condition for calling a method in which an argument type is specified. That is, a rule element indicating that a version for which an argument of a specific type is specified for an i method must be called in the j method. The rule element is described in the rule description in the format of “@Call (i (type), j)”. Hereinafter, the rule element is referred to as a “type designation call rule element”.

また、図4は、ルール記述を構成するオペレータの例を示す図である。同図には4つのオペレータと、それぞれのオペレータのルール記述内における記述形式が示されている。   FIG. 4 is a diagram illustrating an example of an operator constituting the rule description. The figure shows four operators and the description format in the rule description of each operator.

一つ目は、(式k)かつ(式l)の関係を示すためのオペレータである。すなわち、(式k)及び(式l)の双方が必ず満たされなければならないというルールを記述するためのオペレータである。当該オペレータは、「&&」によってルール記述に記述される。   The first is an operator for indicating the relationship between (Equation k) and (Equation 1). That is, it is an operator for describing a rule that both (expression k) and (expression 1) must be satisfied. The operator is described in the rule description by “&&”.

二つ目は、(式m)又は(式n)の関係を示すためのオペレータである。すなわち、(式m)又は(式n)のいずれか一方が満たされなければならないというルールを記述すためのオペレータである。当該オペレータは、「||」によってルール記述に記述される。   The second is an operator for indicating the relationship of (Formula m) or (Formula n). That is, it is an operator for describing a rule that either (Expression m) or (Expression n) must be satisfied. The operator is described in the rule description by “||”.

三つ目は、(式o)ならば(式p)の関係を示すためのオペレータである。すなわち、(式o)が満たされる場合は、(式p)が必ず満たされなければならないというルールを記述するためのオペレータである。当該オペレータは、「−>」によってルール記述に記述される。   The third is an operator for indicating the relationship of (Expression p) if (Expression o). That is, it is an operator for describing a rule that (Expression p) must be satisfied when (Expression o) is satisfied. The operator is described in the rule description by “−>”.

四つ目は、(式q)の否定を示すためのオペレータである。すなわち、(式q)が満たされてはならないというルールを記述ためのオペレータである。当該オペレータは、「!」によってルール記述に記述される。   The fourth is an operator for indicating negation of (formula q). That is, it is an operator for describing a rule that (formula q) must not be satisfied. The operator is described in the rule description by “!”.

なお、ルールは、ライブラリごとに異なる。したがって、ルール記述は、例えば、ライブラリの開発者、又はライブラリの使用者の中でライブラリの仕様に精通している者等によってライブラリごとに作成されるとよい。   The rules are different for each library. Therefore, the rule description may be created for each library by, for example, a library developer or a library user who is familiar with the library specifications.

ルール解析部12は、ルール記述記憶部11に記憶されているルール記述を解析し、ルール記述の内容を、プログラム生成部13にとって処理し易い形式に変換する。より詳しくは、ルール解析部12は、ルール記述よりその構成要素(後述されるルール要素一覧及び式構造)を抽出する。すなわち、ルール記述は、人によって記述されうるため、人に理解し易い形式を有する。一方、人に理解し易い形式は、コンピュータによるロジカルな処理には不向きである傾向がある。そこで、ルール解析部12は、人とコンピュータ(プログラム生成部13)との間を仲介するための処理を実行する。   The rule analysis unit 12 analyzes the rule description stored in the rule description storage unit 11 and converts the content of the rule description into a format that can be easily processed by the program generation unit 13. More specifically, the rule analysis unit 12 extracts constituent elements (a rule element list and a formula structure described later) from the rule description. That is, since the rule description can be described by a person, it has a format that is easy for a person to understand. On the other hand, formats that are easy to understand for humans tend to be unsuitable for logical processing by computers. Therefore, the rule analysis unit 12 executes a process for mediating between a person and a computer (program generation unit 13).

プログラム生成部13は、ルール解析部12による解析結果(ルール解析部12によって抽出されたルール記述の構成要素)に基づいて、ルール違反の有無を検出するためのプログラムのソースコードを自動的に生成する。プログラム生成部13は、履歴記録プログラム生成部131及び検出プログラム生成部132等を含む。履歴記録プログラム生成部131は、ルール違反の有無を検出するためのプログラムの一部として履歴記録プログラムPrを生成する。検出プログラム生成部132は、ルール違反の有無を検出するためのプログラムの一部として検出プログラムPcを生成する。   The program generation unit 13 automatically generates a source code of a program for detecting the presence or absence of rule violation based on the analysis result (the rule description component extracted by the rule analysis unit 12) by the rule analysis unit 12. To do. The program generation unit 13 includes a history recording program generation unit 131, a detection program generation unit 132, and the like. The history recording program generation unit 131 generates the history recording program Pr as part of a program for detecting the presence or absence of rule violation. The detection program generation unit 132 generates the detection program Pc as part of a program for detecting the presence or absence of rule violation.

履歴記録プログラムPrは、開発対象のアプリケーションによるメソッドの呼び出し(メソッドの実行)を検知し、当該呼び出しの履歴を記録するプログラムである。検出プログラムPcは、履歴記録プログラムPrによって記録された履歴に基づいて、ルール違反の有無を検出するプログラムである。検出プログラムPcは、ルール違反の有無の検出結果を示すデータ(以下、「検出ログ」という。)を、検出ログ記憶部16に記録する。すなわち、検出ログ記憶部16は、検出ログを記憶する。   The history recording program Pr is a program that detects a method call (method execution) by an application to be developed and records a history of the call. The detection program Pc is a program that detects the presence or absence of rule violation based on the history recorded by the history recording program Pr. The detection program Pc records data (hereinafter referred to as “detection log”) indicating the detection result of the presence or absence of rule violation in the detection log storage unit 16. That is, the detection log storage unit 16 stores a detection log.

雛形データ記憶部14は、履歴記録プログラムPr又は検出プログラムPcのソースコードの雛形となるデータ(雛形データ)を補助記憶装置102を用いて記憶する。   The template data storage unit 14 stores data (model data) serving as a template of the source code of the history recording program Pr or the detection program Pc using the auxiliary storage device 102.

テストプログラム生成部15は、検出ログに基づいてテスト範囲が限定されたブラックボックスを実行するテストプログラムTpを生成する。テスト範囲が限定されることで、テスト作業の効率化を期待することができる。テストプログラム生成部15は、テストプログラムTpの生成に際し、テストポリシーリスト記憶部17が記憶するテストポリシーを参照する。テストポリシーとは、各ルール(ルール記述)に対する違反の有無の検出結果(すなわち、検出ログの内容)に応じて、実行すべきシナリオコードを示すデータをいう。テストポリシーリスト記憶部17は、斯かるテストポリシーの一覧(テストポリシーリスト)を記憶する。   The test program generation unit 15 generates a test program Tp that executes a black box whose test range is limited based on the detection log. By limiting the test range, it can be expected that test work will be more efficient. The test program generation unit 15 refers to the test policy stored in the test policy list storage unit 17 when generating the test program Tp. The test policy is data indicating a scenario code to be executed in accordance with a detection result (that is, the content of the detection log) of whether or not there is a violation of each rule (rule description). The test policy list storage unit 17 stores a list of such test policies (test policy list).

シナリオコードとは、予め作成されている、ブラックボックステスト用のテストコードの雛形(テンプレート)である。シナリオコード記憶部18は、斯かるシナリオコード群を記憶する。   The scenario code is a template (template) of a test code created in advance for a black box test. The scenario code storage unit 18 stores such a scenario code group.

したがって、テストプログラム生成部15は、検出ログに係るルールの違反の有無の検出結果に応じたシナリオコードをシナリオコード記憶部18より取得し、当該シナリオコードを使用してテストプログラムTpを生成する。   Therefore, the test program generation unit 15 acquires a scenario code corresponding to the detection result of the presence or absence of rule violation related to the detection log from the scenario code storage unit 18, and generates the test program Tp using the scenario code.

なお、履歴記録プログラムPr、検出プログラムPc、及びテストプログラムTpは、アスペクト指向プログラミングに基づいて作成される。アスペクト指向プログラミングが有する特長の一つが、履歴記録プログラムPr、検出プログラムPc、及びテストプログラムTpに好適だからである。当該特長とは、テスト対象(検査対象)のプログラム(本実施の形態におけるアプリケーション)の外側から当該対象のプログラムに対して作用することができるという性質である。斯かる性質により、ライブラリやアプリケーション等に変更を加えずに、アプリケーションによるライブラリのメソッドの呼び出し(実行)を検知等することができる。本実施の形態では、アスペクト指向プログラミング言語として、AspectJを利用する。但し、他のプログラミング言語が用いられてもよい。   The history recording program Pr, the detection program Pc, and the test program Tp are created based on aspect-oriented programming. One of the features of aspect-oriented programming is that it is suitable for the history recording program Pr, the detection program Pc, and the test program Tp. The feature is a property that it can act on the target program from the outside of the test target (inspection target) program (the application in the present embodiment). With such a property, it is possible to detect a call (execution) of a library method by an application without changing the library, the application, or the like. In this embodiment, AspectJ is used as an aspect-oriented programming language. However, other programming languages may be used.

以下、テストプログラム生成装置10の処理手順について説明する。図5は、ルール解析部が実行する処理手順の一例を説明するためのフローチャートである。同図の処理は、例えば、ユーザによって入力される、処理の開始指示に応じて開始される。当該指示において、解析対象のルール記述の識別情報が指定される。なお、ルール記述の識別情報を、以下「ルール名」という。   Hereinafter, a processing procedure of the test program generation device 10 will be described. FIG. 5 is a flowchart for explaining an example of a processing procedure executed by the rule analysis unit. The process shown in the figure is started in response to a process start instruction input by the user, for example. In this instruction, identification information of the rule description to be analyzed is specified. The identification information of the rule description is hereinafter referred to as “rule name”.

ステップS101において、ルール解析部12は、指定されたルール名に係るルール記述をルール記述記憶部11よりメモリ装置103に読み込む。すなわち、ルール記述は、ルール名に関連付けられてルール記述記憶部11に記憶されている。   In step S <b> 101, the rule analysis unit 12 reads the rule description relating to the specified rule name from the rule description storage unit 11 into the memory device 103. That is, the rule description is stored in the rule description storage unit 11 in association with the rule name.

図6は、第一のルール記述の一例を示す図である。同図に示されるルール記述rd1は、記述d11及び記述d12を含む。   FIG. 6 is a diagram illustrating an example of the first rule description. The rule description rd1 shown in the figure includes a description d11 and a description d12.

記述d11は、ルール記述rd1の対象となるメソッド名を示す。したがって、記述d11より、ルール記述rd1は、メソッド「SSLSocket.startHandshake()」に関するルール記述であることが分かる。なお、一つのルール記述内に、複数のメソッドに関するルールが記述されてもよい。また、対象となるメソッド名を示す記述は、必須ではない。   A description d11 indicates a method name that is a target of the rule description rd1. Therefore, it can be seen from the description d11 that the rule description rd1 is a rule description related to the method “SSLSocket.startHandshake ()”. Note that rules relating to a plurality of methods may be described in one rule description. A description indicating the target method name is not essential.

記述d12は、ルールを示す式である。記述d12では、二つのBeforeルール要素が「−>」オペレータによって接続されている。第一項のBeforeルール要素は、「@Before(X509TrustManager.checkServerTrusted(),SSLSocket.startHandshake(),httpServlet.doPost())」であり、第二項のBeforeルール要素は、「@Before(X509Certificate.checkValidity(),SSLSocket.startHandshake(),httpServlet.doPost()))」である。   The description d12 is an expression indicating a rule. In the description d12, two Before rule elements are connected by the “−>” operator. The Before rule element of the first term is “@Before (X509TrustManager.checkServerTrusted (), SSLSocket.startHandshake (), httpServlet.doPost ())”, and the Before rule element of the second term is “@Before (X509Certificate. checkValidity (), SSLSocket.startHandshake (), httpServlet.doPost ())) ”.

したがって、記述d12に係る式は、「httpServlet.doPost()内において、SSLSocket.startHandshake()より前にX509TrustManager.checkServerTrusted()が実行される場合(実行されるならば)、httpServlet.doPost()内において、SSLSocket.startHandshake()より前にX509Certificate.checkValidity()が実行されなければならない。」というルールを示す。   Therefore, the expression related to the description d12 is “in httpServlet.doPost (), if X509TrustManager.checkServerTrusted () is executed before SSLSocket.startHandshake () (if executed), it will be in httpServlet.doPost (). , X509Certificate.checkValidity () must be executed before SSLSocket.startHandshake (). "

ルール記述rd12は、Java(登録商標)のSSL(Secure Socket Layer)クライアントとしてのアプリケーションの実装におけるSSLSocketライブラリの利用に関するルールを記述したものである。   The rule description rd12 describes rules regarding the use of the SSLSocket library in the implementation of an application as a Java (registered trademark) SSL (Secure Socket Layer) client.

すなわち、SSL通信では、サーバ証明書が信頼できるものか否かを検証することが必要とされる。Java(登録商標)のSSLSocketライブラリは、startHandshake()を呼び出してハンドシェークを開始する場合、証明書の検証処理は自動的に行われるため通常は問題ない。但し、X509TrustManagerの実装クラスにおいてcheckServerTrusted()がオーバーライドされた場合、上記証明書の検証処理は、オーバーライドされてしまう。したがって、この場合、上記証明書の検証処理は、アプリケーションの開発者が適切に実装しなければならない。   That is, in SSL communication, it is necessary to verify whether or not the server certificate is reliable. In the case of a Java (registered trademark) SSLSocket library, when handshake is started by calling startHandshake (), certificate verification processing is automatically performed, so there is usually no problem. However, if checkServerTrusted () is overridden in the X509TrustManager implementation class, the certificate verification process is overridden. Therefore, in this case, the certificate verification process must be appropriately implemented by the application developer.

したがて、SSLクライアントとしてのアプリケーションを実装する場合におけるSSLSocketライブラリの利用に関するルールは、以下のようになる。   Therefore, the rules regarding the use of the SSLSocket library when an application as an SSL client is implemented are as follows.

対象メソッド:javax.net.ssl.SSLSocket#startHandshake()
ルール:サーブレッドから呼び出された処理内において、javax.net.ssl.SSLSocket#startHandshake()よりも前に、X509TrustManager(の実装クラス)の checkServerTrusted()が実行される場合、必ずX509Certificate#checkValidity()も実行されなければならない
当該ルールをルール要素及びオペレータを用いて表現したものが、ルール記述rd1である。
Target method: javax.net.ssl.SSLSocket # startHandshake ()
Rule: When checkServerTrusted () of X509TrustManager (implementing class) is executed before javax.net.ssl.SSLSocket # startHandshake () in the process called from the servlet, X509Certificate # checkValidity () The rule description rd1 represents the rule using a rule element and an operator.

なお、ここでは、サーブレットから呼び出されるWebアプリケーションが、検査対象のアプリケーションの例とされている。また、httpServlet.doPost()は、Webサーバにおいて、HTTPリクエストのPOSTコマンドが受信されたときに呼び出されるメソッドである。したがって、上記の「サーブレットから呼び出された処理」に対して、「httpServlet.doPost()」が当てはめられている。   Here, a Web application called from a servlet is an example of an application to be inspected. HttpServlet.doPost () is a method that is called when a POST command of an HTTP request is received in the Web server. Therefore, “httpServlet.doPost ()” is applied to the “process called from the servlet”.

ルール記述は、その解析処理の便宜を考慮して、XML形式等の構造化文書形式によって記述されてもよい。   The rule description may be described in a structured document format such as an XML format in consideration of the convenience of the analysis processing.

図7は、XML形式による第一のルール記述の一例を示す図である。同図のルール記述rd2は、図6のルール記述rd1において定義されているルールと同じルールをXML形式によって記述したものである。   FIG. 7 is a diagram illustrating an example of the first rule description in the XML format. The rule description rd2 in the figure describes the same rules as those defined in the rule description rd1 in FIG. 6 in the XML format.

ルート要素であるrule要素(<rule>タグによって囲まれた要素)のlibrary属性の値(「SSLSocket.startHandshake()」は、対象となるメソッド名を示す。rule要素の子要素rd21のタグ名(「−>」)は、当該子要素の値として含まれている二つのBeforeルール要素を接続するオペレータを示す。before要素rd22は、図6の記述d12における第一項のBeforeルール要素に対応する。before要素rd23は、図6の記述d12における第二項のBeforeルール要素に対応する。すなわち、各before要素において、proc属性、succ属性、within属性は、それぞれ、Before要素のaメソッド、bメソッド、cメソッド(図3参照)に対応する。   The value of the library attribute (“SSLSocket.startHandshake ()” of the rule element (element enclosed by the <rule> tag) that is the root element indicates the name of the target method. The tag name of the child element rd21 of the rule element ( “->”) Indicates an operator that connects two Before rule elements included as the value of the child element, before element rd22 corresponds to the Before rule element of the first term in the description d12 of FIG. The before element rd23 corresponds to the before rule element of the second term in the description d12 of Fig. 6. That is, in each before element, the proc attribute, the succ attribute, and the with attribute are the a method and b method of the Before element, respectively. , C method (see FIG. 3).

XML形式のデータは、既存のXMLパーサによって解析が容易である。したがって、ルール解析部12の処理内容を簡便化することができる。   Data in XML format can be easily analyzed by an existing XML parser. Therefore, the processing content of the rule analysis unit 12 can be simplified.

続いて、ルール解析部12は、読み込んだルール記述の構造を解析する(S102)。具体的には、ルール記述内のルール要素とオペレータとが分解され、構造化される。すなわち、各ルール要素間の論理関係がルール解析部12によって認識される。なお、ルール記述が図7に示されるようにXML形式の場合、XMLパーサによってDOM(Document Object Model)形式に読み込まれることが、ステップS102でいうところの解析に相当する。したがって、ルール記述が構造化文書形式によって記述されている場合、ステップS101及びS102は、実質的に一つのステップとなりうる。   Subsequently, the rule analysis unit 12 analyzes the structure of the read rule description (S102). Specifically, rule elements and operators in the rule description are disassembled and structured. That is, the rule analysis unit 12 recognizes the logical relationship between each rule element. In the case where the rule description is in the XML format as shown in FIG. 7, reading into the DOM (Document Object Model) format by the XML parser corresponds to the analysis in step S102. Therefore, when the rule description is described in a structured document format, steps S101 and S102 can be substantially one step.

続いて、ルール解析部12は、必要に応じてルール記述の式を変形(又は変換)する(S103)。本実施の形態では、オペレータ「−>」を含む式に関して、オペレータ「!」及び「||」を用いて変形(又は変換)が行われる。具体的には、「A−>B」の構造を有する式は、「!A||B」に変形される。この場合、変形の前後においてAとBとの論理関係は同じであるところ、「!」及び「||」のオペレータの方が、式の論理値(真偽値)の評価(式が示すルールが満たされているか否かの評価)をし易いからである。なお、ここでの「A」及び「B」は、一つのルール要素又は式を示す。ステップS103において、オペレータ「−>」は、全て解決(置換)される。   Subsequently, the rule analysis unit 12 transforms (or converts) the rule description formula as necessary (S103). In the present embodiment, the expression including the operator “->” is transformed (or converted) using the operators “!” And “||”. Specifically, an expression having a structure of “A-> B” is transformed into “! A || B”. In this case, where the logical relationship between A and B is the same before and after the transformation, the operators “!” And “||” evaluate the logical value (true value) of the expression (the rule indicated by the expression). This is because it is easy to evaluate whether or not the above is satisfied. Here, “A” and “B” indicate one rule element or expression. In step S103, all the operators “->” are resolved (replaced).

続いて、ルール解析部12は、ルール記述rd1の解析結果よりルール要素を抽出する(S104)。続いて、ルール解析部12は、抽出されたルール要素ごとに変数名を生成する(割り当てる)(S105)。変数名とは、ルール要素の論理値(真偽値)を記憶するための変数に対する識別名である。ルール要素間で一意性が保証されれば変数名の命名規則は所定のものに限定されない。続いて、ルール解析部12は、ルール要素と変数名との組の一覧を、ルール名に関連付けて補助記憶装置102に記憶(出力)する(S106)。当該一覧を、以下「ルール要素一覧」という。   Subsequently, the rule analysis unit 12 extracts a rule element from the analysis result of the rule description rd1 (S104). Subsequently, the rule analysis unit 12 generates (assigns) a variable name for each extracted rule element (S105). The variable name is an identification name for a variable for storing a logical value (true / false value) of the rule element. As long as uniqueness is ensured between rule elements, the naming rules for variable names are not limited to predetermined ones. Subsequently, the rule analysis unit 12 stores (outputs) a list of pairs of rule elements and variable names in the auxiliary storage device 102 in association with the rule names (S106). This list is hereinafter referred to as “rule element list”.

図8は、第一のルール要素一覧の例を示す図である。同図のルール要素一覧rL1は、図6に示したルール記述rd1に基づいて生成されるルール要素一覧である。同図では、第一項のBeforeルール要素に対して、変数名「R1」が割り当てられ(生成され)、第二項のBeforeルール要素に対して、変数名「R2」が割り当てられた(生成された)例が示されている。   FIG. 8 is a diagram illustrating an example of a first rule element list. The rule element list rL1 in the same figure is a rule element list generated based on the rule description rd1 shown in FIG. In the figure, the variable name “R1” is assigned (generated) to the Before rule element of the first term, and the variable name “R2” is assigned (generated) to the Before rule element of the second term. Example) is shown.

続いて、ルール解析部12は、ルール記述の式における各ルール要素を、当該ルール要素に対応する変数名によって置き換えたものを、式構造とする(S107)。なお、ステップS103において変形された式については、変形後の式が置換の対象とされる。図6のルール要素記述rd1及び図8のルール要素一覧rL1に基づく式構造は、以下の(1)のようになる。   Subsequently, the rule analysis unit 12 sets an expression structure in which each rule element in the rule description expression is replaced with a variable name corresponding to the rule element (S107). In addition, about the formula deform | transformed in step S103, the formula after a deformation | transformation is made into the object of substitution. The formula structure based on the rule element description rd1 in FIG. 6 and the rule element list rL1 in FIG. 8 is as shown in (1) below.

!R1||R2 ・・・(1)
なお、ルール記述rd1の各ルール要素について、単純に変数名への置換を行った結果は、
R1−>R2
であるが、ステップS103における変形により、ルール記述rd1より抽出される式構造は、上記(1)の通りとなる。
! R1 || R2 (1)
For each rule element of the rule description rd1, the result of simple substitution with a variable name is
R1-> R2
However, the expression structure extracted from the rule description rd1 by the modification in step S103 is as described in (1) above.

続いて、ルール解析部12は、式構造をルール名に関連付けて補助記憶装置102に記憶(出力)する(S108)。   Subsequently, the rule analysis unit 12 stores (outputs) the formula structure in the auxiliary storage device 102 in association with the rule name (S108).

続いて、プログラム生成部13の処理手順について説明する。図9は、プログラム生成部が実行する処理手順の一例を説明するためのフローチャートである。同図の処理は、例えば、ユーザによって入力される、処理の開始指示に応じて開始される。当該指示において、ルール名が指定される。但し、図5の処理と同期的に(図5の処理に続いて自動的に)実行されてもよい。この場合、図5の処理の開始時に指定されたルール名が、図9の処理において使用されればよい。   Subsequently, a processing procedure of the program generation unit 13 will be described. FIG. 9 is a flowchart for explaining an example of a processing procedure executed by the program generation unit. The process shown in the figure is started in response to a process start instruction input by the user, for example. In the instruction, a rule name is specified. However, it may be executed synchronously with the process of FIG. 5 (automatically following the process of FIG. 5). In this case, the rule name specified at the start of the process of FIG. 5 may be used in the process of FIG.

ステップS201において、プログラム生成部13は、アスペクトの雛形(アスペクト雛形)を雛形データ記憶部14よりメモリ装置103に読み込む。   In step S <b> 201, the program generation unit 13 reads an aspect template (aspect template) from the template data storage unit 14 into the memory device 103.

図10は、アスペクト雛形の一例を示す図である。同図に示されるように、アスペクト雛形は、アスペクト指向プログラミング言語(AspectJ)におけるアスペクトの定義の雛形である。同図のアスペクト雛形t1において、アスペクト名は、パラメタ化されている。すなわち、アスペクト名には具体的な値ではなく、「<アスペクト名>」が記述されている。また、アスペクト雛形t1には、一行のステップs11が記述されている。ステップs11では、MAP<MAP>型の変数varTableのメモリ(メモリ装置103)への生成が定義されている。MAP<MAP>型とは、キー名とMAP型の変数とを関連付けて記憶することのできるデータ型をいう。本実施の形態では、斯かるMAP<MAP>型の変数varTableを用いて、検査対象のアプリケーションによるライブラリのメソッドの呼び出し履歴(実行履歴)を管理する。   FIG. 10 is a diagram illustrating an example of an aspect template. As shown in the figure, the aspect template is a template for defining an aspect in an aspect-oriented programming language (AspectJ). In the aspect template t1 in the figure, the aspect name is parameterized. That is, “<aspect name>” is described in the aspect name, not a specific value. In addition, one line of step s11 is described in the aspect template t1. In step s11, the generation of a MAP <MAP> type variable varTable in the memory (memory device 103) is defined. The MAP <MAP> type refers to a data type that can store a key name and a MAP type variable in association with each other. In the present embodiment, using such a MAP <MAP> type variable varTable, a library method call history (execution history) by an application to be inspected is managed.

図11は、本実施の形態においてライブラリの呼び出し履歴を管理するためのデータ構造の一例を概念的に示す図である。   FIG. 11 is a diagram conceptually illustrating an example of a data structure for managing a library call history in the present embodiment.

同図には、変数varTableが、便宜上、テーブル形式によって表現されている。変数varTableは、キーとしてスレッドの識別子を記憶し、値として履歴テーブルを記憶する。スレッドの識別子とは、アプリケーションのテスト(検査)時において履歴記録プログラムPrが動作するスレッドの識別子である。マルチスレッド環境では、履歴記録プログラムPrは、複数のスレッド上で並列的に実行されうる。そして、ライブラリに関するルール記述(文脈に関するルール)は、スレッドごとに満たされる必要がある。そこで、変数varTableは、スレッドごとに履歴テーブルを対応付けて記憶する。なお、通信用のライブラリの場合は、変数varTableにおいて、セッションごとに(セッションIDに対応付けて)履歴テーブルが記憶されてもよい。また、スレッド又はセッション以外の単位で、ルール記述が満たされる必要が有る場合、当該単位ごとに、履歴テーブルが対応付けられればよい。   In the figure, the variable varTable is represented in a table format for convenience. The variable varTable stores a thread identifier as a key and a history table as a value. The thread identifier is an identifier of a thread in which the history recording program Pr operates during application test (inspection). In a multi-thread environment, the history recording program Pr can be executed in parallel on a plurality of threads. And the rule description about the library (rule about the context) needs to be satisfied for each thread. Therefore, the variable varTable stores a history table in association with each thread. In the case of a library for communication, a history table may be stored for each session (corresponding to a session ID) in the variable varTable. In addition, when the rule description needs to be satisfied in units other than threads or sessions, a history table may be associated with each unit.

一方、履歴テーブルとは、本実施の形態において生成される履歴記録プログラムPr内においてcurrentTableという変数名によって参照される、MAP<boolean>型の変数である。currentTable変数(履歴テーブル)は、キーとしてルール要素の変数名又はルール要素内のメソッドごとに割り当てられる変数名を記憶し、値として当該ルール要素が満たされているか否かを示す真偽値、又は当該メソッドが呼び出されたか(実行されたか)否かを示す真偽値を記憶する。   On the other hand, the history table is a variable of the MAP <boolean> type that is referred to by a variable name “currentTable” in the history recording program Pr generated in the present embodiment. The currentTable variable (history table) stores a variable name of a rule element as a key or a variable name assigned to each method in the rule element, and a true / false value indicating whether the rule element is satisfied as a value, or A true / false value indicating whether or not the method is called (executed) is stored.

続いて、プログラム生成部13は、アスペクト雛形t1の<アスペクト名>に対して、ユーザによって指定されたルール名を当てはめて(<アスペクト名>をルール名によって置換して)、当該ルール名に係るルール記述rd1に対応した具体的なアスペクトのソースコード(アスペクトコード)を生成する(S202)。   Subsequently, the program generation unit 13 applies the rule name specified by the user to the <aspect name> of the aspect template t1 (replaces <aspect name> with the rule name) and relates to the rule name. A specific aspect source code (aspect code) corresponding to the rule description rd1 is generated (S202).

図12は、第一のアスペクトコードの具体例を示す図である。同図におけるアスペクトコードac1では、図10の「<アスペクト名>」が、「SSLSocket」に置換されている。すなわち、本実施の形態において、ルール記述rd1に関するルール名は、「SSLSocket」であるとする。   FIG. 12 is a diagram illustrating a specific example of the first aspect code. In the aspect code ac1 in the figure, “<Aspect name>” in FIG. 10 is replaced with “SSLSocket”. That is, in the present embodiment, it is assumed that the rule name related to the rule description rd1 is “SSLSocket”.

なお、ステップS202では、ルール名の当てはめだけでなく、ルール名が当てはめられたアスペクトコードac1を含むファイルが補助記憶装置102に生成される。   In step S202, not only the rule name fitting but also a file including the aspect code ac1 to which the rule name is applied is generated in the auxiliary storage device 102.

続いて、履歴記録プログラム生成部131は、指定されたルール名に関連付けられているルール要素一覧rL1(図8)及び式構造を補助記憶装置102からメモリ装置103に読み込む(S203)。続いて、履歴記録プログラム生成部131は、読み込まれたルール要素一覧rL1の中で、未処理のルール要素を処理対象とする(S204)。未処理のルール要素とは、ステップS205の処理対象とされていないルール要素をいう。したがって、最初は、読み込まれたルール要素一覧rL1に含まれる全てのルール要素が未処理のルール要素である。   Subsequently, the history recording program generation unit 131 reads the rule element list rL1 (FIG. 8) and the formula structure associated with the designated rule name from the auxiliary storage device 102 into the memory device 103 (S203). Subsequently, the history recording program generation unit 131 sets an unprocessed rule element as a processing target in the read rule element list rL1 (S204). An unprocessed rule element refers to a rule element that is not a processing target in step S205. Accordingly, initially, all rule elements included in the read rule element list rL1 are unprocessed rule elements.

続いて、履歴記録プログラム生成部131は、処理対象のルール要素(以下、「カレントルール要素」という。)について、履歴記録プログラムPrの生成処理を実行する(S205)。履歴記録プログラムPrの生成処理においては、カレントルール要素について、履歴記録プログラムPrとしてのソースコードが、ステップS202において生成されたアスペクトコードac1に追加される。ステップS205は、読み込まれたルール要素一覧rL1に含まれる全てのルール要素について順番に実行される(S206)。   Subsequently, the history recording program generation unit 131 executes generation processing of the history recording program Pr for the rule element to be processed (hereinafter referred to as “current rule element”) (S205). In the generation process of the history recording program Pr, the source code as the history recording program Pr is added to the aspect code ac1 generated in step S202 for the current rule element. Step S205 is executed in order for all rule elements included in the read rule element list rL1 (S206).

続いて、検出プログラム生成部132は、検出プログラムPcの生成処理を実行する(S207)。検出プログラムPcの生成処理においては、指定されたルール名に対応するルール記述に対する検出プログラムPcとしてのソースコードが、ステップS202において生成されたアスペクトコードac1に追加される。したがって、履歴記録プログラムPrと検出プログラムPcとは、ファイル単位としては(ソースコードの単位としては)、一つのソースコードとして生成される。   Subsequently, the detection program generation unit 132 executes generation processing of the detection program Pc (S207). In the generation process of the detection program Pc, the source code as the detection program Pc for the rule description corresponding to the specified rule name is added to the aspect code ac1 generated in step S202. Therefore, the history recording program Pr and the detection program Pc are generated as one source code as a file unit (as a source code unit).

続いて、ステップS205の履歴記録プログラムPrの生成処理の詳細について説明する。履歴記録プログラムPrの生成処理は、カレントルール要素が、Beforeルール要素、Afterルール要素、Callルール要素、又は型指定Callルール要素のいずれのタイプであるかに応じて異なる。したがって、履歴記録プログラム生成部131は、カレントルール要素が、いずれのタイプであるかを判定し、処理を分岐させる。以下、分岐後の各処理手順について説明する。   Next, details of the process of generating the history recording program Pr in step S205 will be described. The generation process of the history recording program Pr differs depending on whether the current rule element is a Before rule element, an After rule element, a Call rule element, or a type designation Call rule element. Therefore, the history recording program generation unit 131 determines which type the current rule element is, and branches the process. Hereinafter, each processing procedure after branching will be described.

まず、Beforeルール要素(@Before(a,b,c))に関する履歴記録プログラムPrの生成処理について説明する。当該生成処理では、要するに次のような処理を実行する履歴記録プログラムPrが生成される。以下の説明において、aメソッド、bメソッド、cメソッドとは、@Before(a,b,c)における、aメソッド、bメソッド、又はcメソッドをいう。   First, generation processing of the history recording program Pr related to the Before rule element (@Before (a, b, c)) will be described. In the generation process, a history recording program Pr for executing the following process is generated. In the following description, a method, b method, and c method refer to a method, b method, or c method in @Before (a, b, c).

(1)cメソッドの実行をフックし(検知し)、Beforeルール要素の評価値(当該要素の要件が満たされているか否かを示す真偽値)をtrueとする。また、aメソッドが実行されたか否かを示す真偽値をfalse(実行されていない)とする。   (1) The execution of the c method is hooked (detected), and the evaluation value of the Before rule element (a true / false value indicating whether the requirement of the element is satisfied) is set to true. Further, a true / false value indicating whether or not the a method has been executed is set to false (not executed).

(2)aメソッドの実行をフックし(検知し)、aメソッドが実行されたか否かを示す真偽値をtrue(実行された)とする。   (2) The execution of the a method is hooked (detected), and a true / false value indicating whether or not the a method has been executed is set to true (executed).

(3)bメソッドの実行をフックし(検知し)、aメソッドが実行されたか否かを示す真偽値を、当該Beforeルール要素の評価値とする。   (3) The execution of the b method is hooked (detected), and a true / false value indicating whether or not the a method has been executed is set as the evaluation value of the Before rule element.

したがって、bメソッドが実行されたにも拘わらず、bメソッドの実行前にaメソッドが実行されていない場合は、当該Beforeルール要素の評価値としてfalseを記録する履歴記録プログラムPrが生成される。   Therefore, when the a method is not executed before the b method is executed even though the b method is executed, the history recording program Pr that records false as the evaluation value of the Before rule element is generated.

以下、斯かる履歴記録プログラムPrの生成処理の詳細について説明する。   The details of the process of generating the history recording program Pr will be described below.

図13は、Beforeルール要素に関する履歴記録プログラム生成処理の処理手順の一例を説明するためのフローチャートである。すなわち、同図は、カレントルール要素がBeforeルール要素である場合の履歴記録プログラムPrの生成処理の処理手順の一例である。   FIG. 13 is a flowchart for explaining an example of the processing procedure of the history recording program generation processing regarding the Before rule element. That is, this figure is an example of the processing procedure of the generation process of the history recording program Pr when the current rule element is the Before rule element.

ステップS301において、カレントルール要素のcメソッドの呼び出しをフックするためのポイントカット定義をアスペクトコードac1に追加生成する。具体的には、履歴記録プログラム生成部131は、雛形データ記憶部14よりポイントカット定義雛形を取得し、ポイントカット定義雛形にカレントルール要素のcメソッドを当てはめた結果をアスペクトコードac1に追加する。なお、ポイントカット定義とは、アスペクト指向プログラミング言語において、1以上のジョインポイントの集合の定義をいう。ジョインポイントとは、アスペクトをウィーブするコード上のポイントをいう。すなわち、ジョインポイントとは、対象のプログラムにおいて、フックされる位置をいう。   In step S301, a pointcut definition for hooking the call to the c method of the current rule element is additionally generated in the aspect code ac1. Specifically, the history recording program generation unit 131 acquires the pointcut definition template from the template data storage unit 14, and adds the result of applying the c method of the current rule element to the pointcut definition template to the aspect code ac1. The point cut definition is a definition of a set of one or more join points in an aspect-oriented programming language. A join point is a point on the code that weaves an aspect. In other words, the join point refers to a position where hooking is performed in the target program.

図14は、ポイントカット定義雛形の一例を示す図である。同図のポイントカット定義雛形t2において、ポイントカット名と、ジョインポイントとされるメソッドのメソッド名とは、それぞれ、<ポイントカット名>又は<メソッド名>としてパラメタ化されている。なお、ポイントカット定義雛形t2のポイントカットタイプは、callである。したがって、ポイントカット定義雛形t2は、<メソッド名>に係るメソッドの呼び出しをジョインポイントとするポイントカット定義の雛形である。   FIG. 14 is a diagram illustrating an example of a pointcut definition template. In the pointcut definition template t2 in the figure, the pointcut name and the method name of the method to be the join point are parameterized as <pointcut name> or <method name>, respectively. The point cut type of the point cut definition template t2 is “call”. Accordingly, the pointcut definition template t2 is a pointcut definition template that uses a method call related to <method name> as a join point.

ステップS301において、履歴記録プログラム生成部131は、ポイントカット定義雛形t2の<ポイントカット名>を適当な値に置換し、<メソッド名>をカレントルール要素のcメソッドのメソッド名に置換して、当該cメソッドに対するポイントカット定義を生成する。   In step S301, the history recording program generating unit 131 replaces <pointcut name> of the pointcut definition template t2 with an appropriate value, replaces <method name> with the method name of the c method of the current rule element, and A pointcut definition for the c method is generated.

図15は、履歴記録プログラムにおけるポイントカット定義の第一の具体例を示す図である。同図のポイントカット定義pc11は、図14のポイントカット定義雛形t2に対して、図8の1行目のルール要素(以下、「ルール要素R1」という。)のcメソッドが当てはめられた場合に生成されるポイントカット定義である。すなわち、現段階において、ルール要素R1がカレント要素であるとする。   FIG. 15 is a diagram showing a first specific example of the pointcut definition in the history recording program. The point cut definition pc11 in the figure is applied when the c method of the rule element on the first line in FIG. 8 (hereinafter referred to as “rule element R1”) is applied to the point cut definition template t2 in FIG. Pointcut definition to be generated. That is, it is assumed that the rule element R1 is the current element at the current stage.

ポイントカット定義pc11において、ポイントカット定義雛形t2の<ポイントカット名>は、「callR1−c」に置換されている。また、ポイントカット定義雛形t2の<メソッド名>は、ルール要素R1におけるcメソッドのメソッド名「httpServlet.doPost()」に置換されている。なお、ポイントカット名は、各ポイントカット定義間で一意性が保証され、かつ、プログラミング言語の仕様の範囲内において、任意の文字列が指定されてよい。本実施の形態では、Beforeルール要素のcメソッドに対するポイントカット名は、「call<カレントルール要素の変数名>−c」という命名規則に従って生成される。<カレントルール要素の変数名>は、カレントルール要素に対する変数名によって置換される。ルール要素R1の変数名は、「R1」であるため、「R1」に置換される。   In the point cut definition pc11, <point cut name> of the point cut definition template t2 is replaced with “callR1-c”. Also, <method name> in the pointcut definition template t2 is replaced with the method name “httpServlet.doPost ()” of the c method in the rule element R1. The pointcut name is guaranteed to be unique among the pointcut definitions, and an arbitrary character string may be designated within the scope of the programming language specification. In the present embodiment, the pointcut name for the c method of the Before rule element is generated according to a naming rule “call <variable name of current rule element> -c”. <Variable name of current rule element> is replaced by the variable name for the current rule element. Since the variable name of the rule element R1 is “R1”, it is replaced with “R1”.

続いて、履歴記録プログラム生成部131は、ポイントカット定義pc11に対するbeforeアドバイス定義ad11(図34参照)を、アスペクトコードac1に追加生成する(S302)。具体的には、履歴記録プログラム生成部131は、雛形データ記憶部14よりbeforeアドバイス定義雛形を取得し、beforeアドバイス定義雛形に基づいてbeforeアドバイス定義を生成する。   Subsequently, the history recording program generation unit 131 additionally generates before advice definition ad11 (see FIG. 34) for the point cut definition pc11 in the aspect code ac1 (S302). Specifically, the history recording program generation unit 131 acquires a before advice definition template from the template data storage unit 14, and generates a before advice definition based on the before advice definition template.

アドバイスとは、アスペクト指向プログラミング言語において、ジョイントポイントに対して実行される処理をいう。アドバイスのうち、beforeアドバイスは、「事前処理」を意味する。すなわち、beforeアドバイスは、ジョイントポイントの実行前に織り込まれる(組み込まれる)処理である。   Advice refers to processing executed on a joint point in an aspect-oriented programming language. Among advices, before advice means “pre-processing”. That is, the before advice is a process that is woven (incorporated) before the joint point is executed.

図16は、beforeアドバイス定義雛形の一例を示す図である。同図のbeforeアドバイス定義t5において、ポイントカット名は、<ポイントカット名>としてパラメタ化されている。   FIG. 16 is a diagram illustrating an example of a before advice definition template. In the before advice definition t5 in the figure, the point cut name is parameterized as <point cut name>.

また、beforeアドバイス定義雛形t5は、3つの処理ステップを含む。3つの処理ステップを含む。ステップs51は、現在のスレッドの識別子を取得する。ステップs52は、変数varTable(図11参照)より、現在のスレッドに対応する履歴テーブルを取得し、変数currentTableに代入する。ステップs53は、現在のスレッドに対応する履歴テーブルがまだ生成されていない場合は生成し、生成された履歴テーブルを変数currentTableに代入する。   Also, the before advice definition template t5 includes three processing steps. Includes three processing steps. Step s51 obtains the identifier of the current thread. In step s52, the history table corresponding to the current thread is acquired from the variable varTable (see FIG. 11), and is substituted into the variable currentTable. Step s53 generates a history table corresponding to the current thread if it has not yet been generated, and substitutes the generated history table into the variable currentTable.

ステップS302において、履歴記録プログラム生成部131は、beforeアドバイス定義雛形t5の<ポイントカット名>を、ステップS301において生成したポイントカット名(「callR1−c」)に置換することによりbeforeアドバイス定義を生成する。   In step S302, the history recording program generating unit 131 generates a before advice definition by replacing <point cut name> of the before advice definition template t5 with the point cut name ("callR1-c") generated in step S301. To do.

続いて、履歴記録プログラム生成部131は、カレントルール要素の要件が満たされたことを暫定的に履歴テーブル(変数currentTable)へ記録するためのステップをbeforeアドバイス定義に対して追加する(S303)。具体的には、履歴記録プログラム生成部131は、履歴記録雛形を雛形データ記憶部14より取得し、履歴記録雛形に基づいて、履歴テーブルへの記録処理に関するステップを追加する。   Subsequently, the history recording program generation unit 131 adds a step for temporarily recording in the history table (variable currentTable) that the requirements of the current rule element are satisfied to the before advice definition (S303). Specifically, the history recording program generation unit 131 acquires a history recording template from the template data storage unit 14, and adds a step related to recording processing to the history table based on the history recording template.

図17は、履歴記録雛形の一例を示す図である。同図の履歴記録雛形t4において、履歴テーブル(変数currentTable)に記録(設定)されるキー名と値とは、それぞれ<キー名>、<値>としてパラメタ化されている。ステップS303において、履歴記録プログラム生成部131は、<キー名>を、カレントルール要素(ルール要素R1)のcメソッドに対する変数名(R1)によって置換し、<値>をtrueによって置換した結果をbeforeアドバイス定義に追加する。なお、ステップs41及びs42の詳細については後述する。   FIG. 17 is a diagram illustrating an example of a history recording template. In the history record template t4 in the figure, the key name and the value recorded (set) in the history table (variable currentTable) are parameterized as <key name> and <value>, respectively. In step S303, the history recording program generating unit 131 replaces <key name> with the variable name (R1) for the c method of the current rule element (rule element R1), and replaces <value> with true before. Add to advice definition. Details of steps s41 and s42 will be described later.

続いて、履歴記録プログラム生成部131は、aメソッドは実行されていないことを履歴テーブル(変数currentTable)へ記録するためのステップをbeforeアドバイス定義に対して追加する(S304)。具体的には、履歴記録プログラム生成部131は、履歴記録雛形t4の<キー名>を、カレントルール要素(ルール要素R1)のaメソッドに対する変数名によって置換し、<値>をfalseによって置換した結果をbeforeアドバイス定義に追加する。当該aメソッドに対する変数名は、本実施の形態において、「<カレントルール要素の変数名>−pred」という命名規則に従って生成される。したがって、ルール要素R1のaメソッドに関して、<キー名>は、「R1−pred」という値によって置換される。   Subsequently, the history recording program generation unit 131 adds a step for recording in the history table (variable currentTable) that the a method has not been executed to the before advice definition (S304). Specifically, the history recording program generation unit 131 replaces <key name> of the history recording template t4 with the variable name for the a method of the current rule element (rule element R1), and replaces <value> with false. Add the result to the before advice definition. In the present embodiment, the variable name for the a method is generated according to the naming rule “<variable name of current rule element> -pred”. Therefore, for the a method of rule element R1, <key name> is replaced by the value "R1-pred".

ステップS304の実行により、ステップS301において生成されたポイントカット定義に対する具体的なbeforeアドバイス定義は完成する。図18は、具体的なbeforeアドバイス定義の第一の例を示す図である。   By executing step S304, a specific before advice definition for the pointcut definition generated in step S301 is completed. FIG. 18 is a diagram illustrating a first example of specific before advice definition.

同図のbeforeアドバイス定義ad11に含まれる各ステップについて、図16又は図17と同じステップには、同一ステップ番号を付している。   For each step included in the before advice definition ad11 in the same figure, the same step number is assigned to the same step as in FIG. 16 or FIG.

ステップs51〜s53については、図16において説明した通りである。ステップs41−1は、カレントルール要素の変数名「R1」のキー名に対して、trueを履歴テーブルに記録する。すなわち、cメソッドの実行前に、ルール要素R1の要件が満たされたことが、暫定的に当該履歴テーブルに記録される。同図のbeforeアドバイス定義ad11は、ポイントカット定義pc11の作用により、当該cメソッドの実行前に実行されるからである。ステップs42−1は、現在のスレッドの識別子に対応付けて当該履歴テーブルを変数varTableに格納する。その結果、現在のスレッドにおいて、ルール要素R1の要件が満たされたことが暫定的に変数varTableに記録されたことになる。   Steps s51 to s53 are as described in FIG. In step s41-1, true is recorded in the history table for the key name of the variable name “R1” of the current rule element. That is, it is temporarily recorded in the history table that the requirement of the rule element R1 is satisfied before the c method is executed. This is because the before advice definition ad11 shown in the figure is executed before the execution of the c method by the action of the pointcut definition pc11. Step s42-1 stores the history table in the variable varTable in association with the identifier of the current thread. As a result, the fact that the requirement of the rule element R1 is satisfied in the current thread is provisionally recorded in the variable varTable.

ステップs41−2は、履歴テーブル(currentTable)に、カレントルール要素のaメソッドに対する変数名(「R1−pred」)に対してfalseを記録する。すなわち、当該aメソッドは実行されていないことが当該履歴テーブルに記録される。ステップs42−2は、現在のスレッドの識別子に対応付けて当該履歴テーブルを変数varTableに格納する。その結果、現在のスレッドにおいて、当該aメソッドは実行されていないことが変数varTableに記録されたことになる。   Step s41-2 records false for the variable name ("R1-pred") for the a method of the current rule element in the history table (currentTable). That is, it is recorded in the history table that the a method has not been executed. In step s42-2, the history table is stored in the variable varTable in association with the identifier of the current thread. As a result, it is recorded in the variable varTable that the a method is not executed in the current thread.

続いて、履歴記録プログラム生成部131は、カレントルール要素のaメソッドの呼び出しをフックするためのポイントカット定義をアスペクトコードac1に追加生成する(S305)。具体的には、履歴記録プログラム生成部131は、ポイントカット定義雛形t2(図14)の<ポイントカット名>を適当な値に置換し、<メソッド名>をカレントルール要素のaメソッドのメソッド名に置換して、当該aメソッドに対するポイントカット定義を生成する。   Subsequently, the history recording program generation unit 131 additionally generates a pointcut definition for hooking the call of the a method of the current rule element in the aspect code ac1 (S305). Specifically, the history recording program generation unit 131 replaces <point cut name> in the point cut definition template t2 (FIG. 14) with an appropriate value, and replaces <method name> with the method name of the a method of the current rule element. To generate a pointcut definition for the a method.

図19は、履歴記録プログラムにおけるポイントカット定義の第二の具体例を示す図である。同図のポイントカット定義pc12は、図14のポイントカット定義雛形t2に対して、ルール要素R1(図8)のaメソッドが当てはめられた場合に生成されるポイントカット定義である。   FIG. 19 is a diagram showing a second specific example of the pointcut definition in the history recording program. The point cut definition pc12 in the figure is a point cut definition generated when the a method of the rule element R1 (FIG. 8) is applied to the point cut definition template t2 in FIG.

ポイントカット定義pc12において、ポイントカット定義雛形t2の<ポイントカット名>は、「callR1−pred」に置換されている。また、ポイントカット定義雛形t2の<メソッド名>は、ルール要素R1におけるaメソッドのメソッド名「X509TrustManager.checkServerTrusted()」に置換されている。なお、Beforeルール要素のaメソッドに対するポイントカット名は、「call<カレントルール要素の変数名>−pred」という命名規則に従って生成される。   In the point cut definition pc12, <point cut name> of the point cut definition template t2 is replaced with “callR1-pred”. Also, the <method name> of the pointcut definition template t2 is replaced with the method name “X509TrustManager.checkServerTrusted ()” of the a method in the rule element R1. Note that the point cut name for the a method of the Before rule element is generated according to a naming rule of “call <variable name of current rule element> -pred”.

続いて、履歴記録プログラム生成部131は、ステップS305において生成したポイントカット定義に対するafterアドバイス定義をアスペクトコードac1に追加生成する(S306)。具体的には、履歴記録プログラム生成部131は、雛形データ記憶部14よりafterアドバイス定義雛形を取得し、afterアドバイス定義雛形に基づいてafterアドバイス定義を生成する。   Subsequently, the history recording program generation unit 131 additionally generates an after advice definition for the point cut definition generated in step S305 in the aspect code ac1 (S306). Specifically, the history recording program generation unit 131 acquires an after advice definition template from the template data storage unit 14, and generates an after advice definition based on the after advice definition template.

afterアドバイスは、「事後処理」を意味する。すなわち、afterアドバイスは、ジョイントポイントの実行後に織り込まれる(組み込まれる)処理である。   After advice means “post processing”. That is, the after advice is a process to be incorporated (incorporated) after the joint point is executed.

図20は、afterアドバイス定義雛形の一例を示す図である。同図のafterアドバイス定義雛形t3において、ポイントカット名は、<ポイントカット名>としてパラメタ化されている。   FIG. 20 is a diagram illustrating an example of an after advice definition template. In the after advice definition template t3 in the figure, the point cut name is parameterized as <point cut name>.

また、afterアドバイス定義雛形t3は、3つの処理ステップを含む。ステップs31は、現在のスレッドの識別子を取得する。ステップs32は、変数varTable(図11参照)より、現在のスレッドに対応する履歴テーブルを取得し、変数currentTableに代入する。ステップs33は、現在のスレッドに対応する履歴テーブルがまだ生成されていない場合は生成し、生成された履歴テーブルを変数currentTableに代入する。   The after advice definition template t3 includes three processing steps. Step s31 obtains the identifier of the current thread. In step s32, the history table corresponding to the current thread is acquired from the variable varTable (see FIG. 11), and is substituted into the variable currentTable. A step s33 generates a history table corresponding to the current thread if it has not been generated yet, and substitutes the generated history table into a variable currentTable.

ステップS306において、履歴記録プログラム生成部131は、afterアドバイス定義雛形t3の<ポイントカット名>を、ステップS305において生成したポイントカット名(「callR1−pred」)に置換することによりafterアドバイス定義を生成する。   In step S306, the history recording program generation unit 131 generates an after advice definition by replacing <point cut name> of the after advice definition template t3 with the point cut name ("callR1-pred") generated in step S305. To do.

続いて、履歴記録プログラム生成部131は、aメソッドが呼び出されたことを履歴テーブル(変数currentTable)へ記録するためのステップを、ステップS306において生成されたafterアドバイス定義に対して追加する(S307)。具体的には、履歴記録プログラム生成部131は、履歴記録雛形t4(図17)を雛形データ記憶部14より取得し、履歴記録雛形t4に基づいて、履歴テーブルへの記録処理に関するステップを追加する。すなわち、履歴記録プログラム生成部131は、履歴記録雛形t4の<キー名>を、カレントルール要素(ルール要素R1)のaメソッドに対する変数名(R1−pred)によって置換し、<値>をtrueによって置換した結果をafterアドバイス定義に追加する。   Subsequently, the history recording program generation unit 131 adds a step for recording that the a method has been called to the history table (variable currentTable) to the after advice definition generated in step S306 (S307). . Specifically, the history recording program generation unit 131 acquires the history recording template t4 (FIG. 17) from the template data storage unit 14, and adds a step related to the recording process to the history table based on the history recording template t4. . That is, the history recording program generation unit 131 replaces <key name> of the history recording template t4 with the variable name (R1-pred) for the a method of the current rule element (rule element R1), and <value> by true. The replacement result is added to the after advice definition.

ステップS307の実行により、ステップS305において生成されたポイントカット定義に対する具体的なafterアドバイス定義は完成する。   By executing step S307, a specific after advice definition for the pointcut definition generated in step S305 is completed.

図21は、具体的なafterアドバイス定義の第一の例を示す図である。同図のafterアドバイス定義ad12に含まれる各ステップについて、図17又は図20と同じステップには、同一ステップ番号を付している。   FIG. 21 is a diagram illustrating a first example of a specific after advice definition. With respect to each step included in the after advice definition ad12 in the same figure, the same step number is assigned to the same step as in FIG. 17 or FIG.

ステップs31〜s33については、図20において説明した通りである。ステップs41は、変数varTableより取得された(s32)、又は新に生成された(s33)履歴テーブル(currentTable)に、カレントルール要素のaメソッド対する変数名(「R1−pred」)に対してtrueを記録する。すなわち、aメソッドが呼び出されたことが、当該履歴テーブルに記録される。ステップs42は、現在のスレッドの識別子に対応付けて当該履歴テーブルを変数varTableに格納する。その結果、現在のスレッドにおいて、aメソッドが呼び出されたことが変数varTableに記録されたことになる。   Steps s31 to s33 are as described in FIG. In step s41, true is obtained for the variable name (“R1-pred”) for the a method of the current rule element in the history table (currentTable) acquired from the variable varTable (s32) or newly generated (s33). Record. That is, the fact that the a method has been called is recorded in the history table. In step s42, the history table is stored in the variable varTable in association with the identifier of the current thread. As a result, the fact that the a method has been called in the current thread is recorded in the variable varTable.

続いて、履歴記録プログラム生成部131は、カレントルール要素のbメソッドの呼び出しをフックするためのポイントカット定義をアスペクトコードac1に追加生成する(S308)。具体的には、履歴記録プログラム生成部131は、雛形データ記憶部14よりポイントカット定義雛形t2(図14)を取得し、ポイントカット定義雛形t2にカレントルール要素のbメソッドを当てはめた結果をアスペクトコードac1に追加する。その結果、図22に示されるポイントカット定義がアスペクトコードac1に追加される。   Subsequently, the history recording program generation unit 131 additionally generates a point cut definition for hooking the call of the b method of the current rule element in the aspect code ac1 (S308). Specifically, the history recording program generation unit 131 acquires the pointcut definition template t2 (FIG. 14) from the template data storage unit 14, and applies the b method of the current rule element to the pointcut definition template t2. Add to code ac1. As a result, the point cut definition shown in FIG. 22 is added to the aspect code ac1.

図22は、履歴記録プログラムにおけるポイントカット定義の第三の具体例を示す図である。同図のポイントカット定義pc13は、図14のポイントカット定義雛形t2に対して、ルール要素R1のbメソッドが当てはめられた場合に生成されるポイントカット定義である。   FIG. 22 is a diagram showing a third specific example of the pointcut definition in the history recording program. The point cut definition pc13 in the figure is a point cut definition generated when the b method of the rule element R1 is applied to the point cut definition template t2 in FIG.

ポイントカット定義pc13において、ポイントカット定義雛形t2の<ポイントカット名>は、「callR1−succ」に置換されている。また、ポイントカット定義雛形t2の<メソッド名>は、ルール要素R1におけるbメソッドのメソッド名「SSLSocket.startHandshake ()」に置換されている。なお、本実施の形態では、Beforeルール要素のbメソッドに対するポイントカット名は、「call<カレントルール要素の変数名>−succ」という命名規則に従って生成される。   In the pointcut definition pc13, <pointcut name> of the pointcut definition template t2 is replaced with “callR1-succ”. Also, the <method name> of the pointcut definition template t2 is replaced with the method name “SSLSocket.startHandshake ()” of the b method in the rule element R1. In the present embodiment, the pointcut name for the b method of the Before rule element is generated according to a naming rule “call <variable name of current rule element> -succ”.

続いて、履歴記録プログラム生成部131は、ステップS308において生成したポイントカット定義に対するafterアドバイス定義をアスペクトコードac1に追加生成する(S309)。具体的には、履歴記録プログラム生成部131は、afterアドバイス定義雛形t3の<ポイントカット名>を、ステップS308において生成したポイントカット名(「callR1−succ」)に置換することによりafterアドバイス定義を生成する。   Subsequently, the history recording program generation unit 131 additionally generates an after advice definition for the point cut definition generated in step S308 in the aspect code ac1 (S309). Specifically, the history recording program generation unit 131 replaces the <point cut name> of the after advice definition template t3 with the point cut name (“callR1-suc”) generated in step S308, thereby changing the after advice definition. Generate.

続いて、プログラム生成部13は、bメソッドより前に呼ばれているべきaメソッドに関する呼び出し履歴(実行履歴)を参照するためのステップを、ステップS309において生成されたafterアドバイス定義に追加する(S310)。当該ステップは、雛形データ記憶部14より取得される履歴参照雛形に基づいて生成される。   Subsequently, the program generation unit 13 adds a step for referring to the call history (execution history) related to the a method that should be called before the b method to the after advice definition generated in step S309 (S310). ). This step is generated based on the history reference template acquired from the template data storage unit 14.

図23は、履歴参照雛形の一例を示す図である。同図の履歴参照雛形t6において、履歴テーブル(変数currentTable)より値を取得するキー名と、取得された値を格納する変数(参照用変数)の変数名とは、それぞれ<キー名>、<参照用変数名>としてパラメタ化されている。ステップS310において、履歴記録プログラム生成部131は、<参照用変数名>を適当な値によって置換し、<キー名>をaメソッドに対する変数名(ここでは、「R1−pred」)によって置換した結果をafterアドバイス定義に追加する。本実施の形態において、aメソッドの変数名に対応する値を参照するための変数名は、「r1」とされる。したがって、<参照用変数名>は、「r1」に置換される。なお、ステップs61及びs62の詳細については後述する。   FIG. 23 is a diagram illustrating an example of a history reference template. In the history reference template t6 in the figure, the key name for acquiring a value from the history table (variable currentTable) and the variable name of the variable for storing the acquired value (reference variable) are <key name> and < Parameterized as reference variable name>. In step S310, the history recording program generation unit 131 replaces <reference variable name> with an appropriate value, and replaces <key name> with a variable name for the a method (here, "R1-pred"). Is added to the after advice definition. In the present embodiment, the variable name for referring to the value corresponding to the variable name of the a method is “r1”. Therefore, <reference variable name> is replaced with “r1”. Details of steps s61 and s62 will be described later.

続いて、プログラム生成部13は、履歴記録雛形t4(図17)を用いて、カレントルール要素の評価値を変数varTableに記録するためのステップを、ステップS309において生成されたafterアドバイス定義に追加する(S311)。具体的には、履歴記録雛形t4の<キー名>がカレントルール要素の変数名(「R1」)によって置換され、<値>が、履歴記録雛形t4(図23)の<参照用変数名>の置換先と同じ変数名(「r1」)に置換された結果が、当該afterアドバイスに追加される。   Subsequently, the program generation unit 13 uses the history recording template t4 (FIG. 17) to add a step for recording the evaluation value of the current rule element in the variable varTable to the after advice definition generated in step S309. (S311). Specifically, the <key name> of the history record template t4 is replaced with the variable name (“R1”) of the current rule element, and the <value> is <reference variable name> of the history record template t4 (FIG. 23). The result of replacement with the same variable name (“r1”) as the replacement destination is added to the after advice.

ステップS311の実行により、ステップS308において生成されたポイントカット定義に対する具体的なafterアドバイス定義は完成する。   By executing step S311, a specific after advice definition for the pointcut definition generated in step S308 is completed.

図24は、具体的なafterアドバイス定義の第二の例を示す図である。同図のafterアドバイス定義ad13に含まれる各ステップについて、図16、図23、又は図17と同じステップには、同一ステップ番号を付している。   FIG. 24 is a diagram illustrating a second example of a specific after advice definition. For each step included in the after advice definition ad13 in the same figure, the same step number is assigned to the same step as in FIG. 16, FIG. 23, or FIG.

ステップs31〜s33については、図20において説明した通りである。ステップs61は、現在のスレッドに対応する履歴テーブル(変数currentTable)において、キー名「R1−pred」に対して記録されている値を取得し、変数r1に代入する。すなわち、カレントルール要素のaメソッドが実行されたか否かを示す真偽値が変数r1に代入される。   Steps s31 to s33 are as described in FIG. In step s61, a value recorded for the key name “R1-pred” in the history table (variable currentTable) corresponding to the current thread is acquired and substituted into the variable r1. That is, a true / false value indicating whether or not the a method of the current rule element has been executed is assigned to the variable r1.

ステップs62は、変数r1の値がnull(空)である場合(すなわち、beforeアドバイス定義ad11及びafterアドバイス定義ad12が実行されていない場合)、変数r1にfalseを代入する。したがって、aメソッドが実行された後にアドバイス定義ad13が実行されている場合は、変数r1はtrueが代入された状態となる。それ以外の場合は、変数r1はfalseが代入された状態となる。なお、afterアドバイス定義ad13は、bメソッドの実行後に実行される処理である。したがって、aメソッドが実行された後にアドバイス定義ad13が実行されている場合とは、aメソッドの実行後にbメソッドが実行されている場合に相当する。これは、Before要素であるカレントルール要素の要件が満たされていることを意味する。   Step s62 assigns false to the variable r1 when the value of the variable r1 is null (that is, when the before advice definition ad11 and the after advice definition ad12 are not executed). Therefore, when the advice definition ad13 is executed after the a method is executed, the variable r1 is in a state where true is substituted. In other cases, the variable r1 is in a state where false is substituted. The after advice definition ad13 is a process executed after the b method is executed. Therefore, the case where the advice definition ad13 is executed after the a method is executed corresponds to the case where the b method is executed after the a method is executed. This means that the requirement of the current rule element which is the Before element is satisfied.

ステップs41は、カレントルール要素の変数名「R1」のキー名に対して、変数r1の値を履歴テーブルに記録する。すなわち、変数r1の値が、カレントルール要素の評価値として履歴テーブルに記録される。上記したように、変数r1の値は、カレントルール要素の要件が満たされているか否かを示すからである。   In step s41, the value of the variable r1 is recorded in the history table for the key name of the variable name “R1” of the current rule element. That is, the value of the variable r1 is recorded in the history table as the evaluation value of the current rule element. This is because the value of the variable r1 indicates whether or not the requirement of the current rule element is satisfied as described above.

ステップs42は、現在のスレッドの識別子に対応付けて当該履歴テーブルを変数varTableに格納する。その結果、現在のスレッドにおいて、カレントルール要素の要件が満たされているか否かがが変数varTableに記録されたことになる。   In step s42, the history table is stored in the variable varTable in association with the identifier of the current thread. As a result, whether or not the requirements of the current rule element are satisfied in the current thread is recorded in the variable varTable.

以上で、カレントルール要素がBeforeルール要素である場合の処理手順は終了する。図8に示されるように、本実施の形態の場合、図8のルール要素一覧rL1において2番目のルール要素(ルール要素R2)もBeforeルール要素である。したがって、続けて、ルール要素R2に関しても図13に示される処理手順が実行される。その結果、ルール要素R2において、メソッドa、b、又はcに対応する各メソッドに関して、上述したようなソースコードが生成される。   This is the end of the processing procedure when the current rule element is the Before rule element. As shown in FIG. 8, in the case of the present embodiment, the second rule element (rule element R2) in the rule element list rL1 in FIG. 8 is also a Before rule element. Therefore, the processing procedure shown in FIG. 13 is also executed for rule element R2. As a result, in the rule element R2, the source code as described above is generated for each method corresponding to the method a, b, or c.

続いて、図8のルール要素一覧rL1に基づいて、図9のステップS207の検出プログラムPc生成処理について説明する。なお、カレント要素がAfterルール要素、Callルール要素、又は型指定Callルール要素である場合の履歴記録プログラムPrの生成処理の処理手順の説明は、便宜上、後回しにする。   Next, the detection program Pc generation process in step S207 in FIG. 9 will be described based on the rule element list rL1 in FIG. Note that the description of the processing procedure of the history recording program Pr generation process when the current element is an After rule element, a Call rule element, or a type designation Call rule element will be deferred for convenience.

図25は、検出プログラム生成処理の処理手順の一例を説明するためのフローチャートである。   FIG. 25 is a flowchart for explaining an example of the processing procedure of the detection program generation processing.

ステップS401において、検出プログラム生成部132は、ルール要素一覧rL1において、各ルール要素の最後の引数として指定されているメソッド(以下、「呼出元メソッド」という。)をフックするためのポイントカット定義を、アスペクトコードac1に追加する。Beforeルール要素についてはcメソッド、Afterルール要素についてはfメソッド、Callルール要素についてはhメソッド、型指定Callルール要素についてはjメソッドが、呼出元メソッドに相当する。なお、本実施の形態において、一つのルール(ルール記述)内の各ルール要素の呼出元メソッドは共通である必要がある。ルール違反の有無の検出は、当該呼出元メソッドの実行後の一箇所において行われる必要があるからである。   In step S401, the detection program generation unit 132 creates a pointcut definition for hooking a method (hereinafter referred to as “caller method”) specified as the last argument of each rule element in the rule element list rL1. To the aspect code ac1. The c rule for the Before rule element, the f method for the After rule element, the h method for the Call rule element, and the j method for the type-specified Call rule element correspond to the caller method. In the present embodiment, the caller method of each rule element in one rule (rule description) needs to be common. This is because it is necessary to detect whether there is a rule violation or not at one place after execution of the caller method.

ステップS401におけるポイントカット定義の生成には、ポイントカット定義雛形t2(図14)が用いられる。図26は、検出プログラムにおけるポイントカット定義の具体例を示す図である。   The point cut definition template t2 (FIG. 14) is used for generating the point cut definition in step S401. FIG. 26 is a diagram illustrating a specific example of the pointcut definition in the detection program.

同図のポイントカット定義pc17において、図14のポイントカット定義雛形t2の<ポイントカット名>は、「callLib」に置換されている。また、<メソッド名>は、ルール記述rd1の対象メソッド(すなわち、ルール記述rd1の各ルール要素の呼出元メソッド)のメソッド名(「httpServlet.doPost()」)によって置換されている。なお、対象メソッドに対するポイントカット定義におけるポイントカット名は、本実施の形態では固定的に「callLib」に置換される。但し、当該ポイントカット名は、プログラミング言語の仕様の範囲内において任意に決定されてよい。   In the point cut definition pc17 of FIG. 14, <point cut name> of the point cut definition template t2 of FIG. 14 is replaced with “callLib”. Also, <method name> is replaced by the method name (“httpServlet.doPost ()”) of the target method of the rule description rd1 (that is, the caller method of each rule element of the rule description rd1). Note that the pointcut name in the pointcut definition for the target method is fixedly replaced with “callLib” in the present embodiment. However, the point cut name may be arbitrarily determined within the specification range of the programming language.

続いて、検出プログラム生成部132は、afterアドバイス定義雛形t3を用いて、ステップS401において生成したポイントカット定義に対するafterアドバイス定義をアスペクトコードac1に追加生成する(S402)。具体的には、afterアドバイス定義雛形t3の<ポイントカット名>が、ステップS401において置換先とされたポイントカット名(「callLib」)に置換された結果が、アスペクトコードac1に追加される。   Subsequently, the detection program generation unit 132 additionally generates an after advice definition for the point cut definition generated in step S401, using the after advice definition template t3 (S402). Specifically, the result obtained by replacing the <point cut name> of the after advice definition template t3 with the point cut name (“callLib”) that is the replacement destination in step S401 is added to the aspect code ac1.

続いて、検出プログラム生成部132は、ルール記述rd1の式構造(!R1||R2)内に含まれる変数名ごとに、当該変数名に対する値を参照するためのステップを、アスペクトコードac1に追加する(S403)。具体的には、検出プログラム生成部132は、雛形データ記憶部14より履歴参照雛形t6(図23)を取得し、履歴参照雛形t6に当該変数名を当てはめた結果を当該変数名ごとにアスペクトコードac1に追加する。   Subsequently, the detection program generation unit 132 adds a step for referring to the value for the variable name for each variable name included in the expression structure (! R1 || R2) of the rule description rd1 to the aspect code ac1. (S403). Specifically, the detection program generation unit 132 acquires the history reference template t6 (FIG. 23) from the template data storage unit 14, and assigns the variable name to the history reference template t6 as an aspect code for each variable name. Add to ac1.

式構造(!R1||R2)には、変数名R1及び変数名R2が含まれている。したがって、履歴参照雛形t6の<参照変数名>が「r1」に置換され、<キー名>が「R1」に置換された結果が追加される。更に、履歴参照雛形t6の<参照変数名>が「r2」に置換され、<キー名>が「R2」に置換された結果が追加される。   The expression structure (! R1 || R2) includes a variable name R1 and a variable name R2. Therefore, the result obtained by replacing <reference variable name> in the history reference template t6 with “r1” and replacing <key name> with “R1” is added. Further, the result of replacing <reference variable name> with “r2” and replacing <key name> with “R2” in the history reference template t6 is added.

続いて、検出プログラム生成部132は、ルール違反の有無の検出結果(検出ログ)を記録するためのステップをアスペクトコードac1に追加する(S404)。当該ステップは、雛形データ記憶部14より取得される検出ログ記録雛形を用いて生成される。   Subsequently, the detection program generating unit 132 adds a step for recording the detection result (detection log) of the presence or absence of rule violation to the aspect code ac1 (S404). This step is generated using the detection log recording template acquired from the template data storage unit 14.

図27は、検出ログ記録雛形の一例を示す図である。同図の検出ログ記録雛形t7において、<式>は、式構造の各変数名が、当該変数名に対する値が代入された参照用変数の変数名によって置換された式によって置換される。ステップs71〜s74の詳細については後述する。   FIG. 27 is a diagram illustrating an example of a detection log recording template. In the detection log recording template t7 in the figure, <expression> is replaced by an expression in which each variable name in the expression structure is replaced by the variable name of the reference variable to which the value for the variable name is assigned. Details of steps s71 to s74 will be described later.

ステップS404の実行により、ステップS402において生成されたafterアドバイス定義は、図28に示されるように完成する。   By executing step S404, the after advice definition generated in step S402 is completed as shown in FIG.

図28は、検出プログラムにおけるafterアドバイス定義の具体例を示す図である。同図のafterアドバイス定義ad17に含まれる各ステップについて、図20、図23、又は図27と同じステップには、同一ステップ番号を付している。   FIG. 28 is a diagram illustrating a specific example of after advice definition in the detection program. For each step included in the after advice definition ad17 in the same figure, the same step number is assigned to the same step as in FIG. 20, FIG. 23, or FIG.

ステップs31〜s33については、図20において説明した通りであり、ステップS402において生成される。ステップs61−1〜s62−2は、ステップS403において生成される。ステップs61−1は、現在のスレッドに対応する履歴テーブル(変数currentTable)において、キー名「R1」に対して記録されている値を取得し、参照用変数r1に代入する。すなわち、ルール要素R1の評価値を示す真偽値が変数r1に代入される。ステップs62−1は、参照用変数r1の値がnull(空)である場合、参照用変数r1にfalseを代入する。したがって、ルール要素R1の要件が満たされている場合、参照用変数r1にはtrueが代入され、ルール要素R1の要件が満たされていない場合、参照用変数r1にはfalseが代入された状態となる。   Steps s31 to s33 are as described in FIG. 20, and are generated in step S402. Steps s61-1 to s62-2 are generated in step S403. In step s61-1, the value recorded for the key name “R1” in the history table (variable currentTable) corresponding to the current thread is acquired and substituted into the reference variable r1. That is, a true / false value indicating the evaluation value of the rule element R1 is substituted into the variable r1. Step s62-1 assigns false to the reference variable r1 when the value of the reference variable r1 is null (empty). Therefore, when the requirement of the rule element R1 is satisfied, true is assigned to the reference variable r1, and when the requirement of the rule element R1 is not satisfied, false is assigned to the reference variable r1. Become.

ステップs61−2は、現在のスレッドに対応する履歴テーブル(変数currentTable)において、キー名「R2」に対して記録されている値を取得し、参照用変数r2に代入する。すなわち、ルール要素R2の評価値を示す真偽値が参照用変数r2に代入される。ステップs62−2は、参照用変数r2の値がnull(空)である場合、参照用変数r2にfalseを代入する。したがって、ルール要素R2の要件が満たされている場合、参照用変数r2にはtrueが代入され、ルール要素R2の要件が満たされていない場合、参照用変数r2にはfalseが代入された状態となる。   In step s61-2, the value recorded for the key name “R2” in the history table (variable currentTable) corresponding to the current thread is acquired and substituted into the reference variable r2. That is, a true / false value indicating the evaluation value of the rule element R2 is substituted into the reference variable r2. Step s62-2 assigns false to the reference variable r2 when the value of the reference variable r2 is null (empty). Therefore, when the requirement of the rule element R2 is satisfied, true is assigned to the reference variable r2, and when the requirement of the rule element R2 is not satisfied, false is assigned to the reference variable r2. Become.

ステップs71〜s74は、1行分(1レコード分)の検出ログを検出ログ記憶部16に記録するための処理であり、ステップS404において生成される。本実施の形態において、一行分の検出ログは、図29に示されるような構成を有する。   Steps s71 to s74 are processes for recording the detection log for one line (for one record) in the detection log storage unit 16, and are generated in step S404. In the present embodiment, the detection log for one line has a configuration as shown in FIG.

図29は、一行分の検出ログの構成例を示す図である。同図に示されるように、本実施の形態において、検出ログは、ルール名、検出箇所、及び検出結果等の項目を有する。ルール名は、ルール違反の有無の検出に使用されたルールのルール名である。検出箇所は、違反の有無が検出された箇所である。本実施の形態では、呼出元メソッドのメソッド名によって検出箇所が示される。ルール違反の有無は、呼出元メソッドごとに検出されるからである。検出結果は、ルール違反の有無の検出結果であり、「positive」又は「negative」が記録される。「positive」は、ルール違反に対して陽性であること、すなあち、ルール違反の可能性が検出されたことを示す。「negative」は、ルール違反に対して陰性であること、すなわち、ルール違反の可能性は検出されなかったことを示す。   FIG. 29 is a diagram illustrating a configuration example of a detection log for one line. As shown in the figure, in the present embodiment, the detection log has items such as a rule name, a detection location, and a detection result. The rule name is the rule name of the rule used to detect whether there is a rule violation. The detected part is a part where the existence of violation is detected. In the present embodiment, the detection location is indicated by the method name of the caller method. This is because the presence or absence of rule violation is detected for each caller method. The detection result is a detection result of whether or not there is a rule violation, and “positive” or “negative” is recorded. “Positive” indicates that it is positive for a rule violation, that is, the possibility of a rule violation has been detected. “Negative” indicates that the rule violation is negative, that is, the possibility of the rule violation is not detected.

図28に戻る。ステップs71は、記録対象の1行分の検出ログのルール名を記録する。すなわち、ステップs71にける「log_rule()」は、検出ログの構成要素であるルール名を記録する関数である。また、「log_rule」の引数に指定されている「rule_name」は、図5又は図9の開始時に指定されたルール名が記憶されている変数である。ステップs72は、記録対象の1行分の検出ログの検出箇所として、ルール記述rd1の各ルール要素に共通の呼出元メソッドのメソッド名を記録する。すなわち、ステップs72にける「log_point()」は、検出ログの構成要素である検出箇所を記録する関数である。また、「log_point」の引数に指定されている「thisJoinPoint」は、当該呼出元メソッドのメソッド名が記憶されている変数である。   Returning to FIG. Step s71 records the rule name of the detection log for one line to be recorded. That is, “log_rule ()” in step s71 is a function for recording a rule name that is a constituent element of the detection log. Also, “rule_name” specified as an argument of “log_rule” is a variable in which the rule name specified at the start of FIG. 5 or FIG. 9 is stored. In step s72, the method name of the caller method common to each rule element of the rule description rd1 is recorded as a detection part of the detection log for one line to be recorded. That is, “log_point ()” in step s72 is a function for recording a detection location that is a constituent element of the detection log. Also, “thisJoinPoint” specified in the argument of “log_point” is a variable in which the method name of the caller method is stored.

ステップs73は、「!(!r1||r2)」の真偽値を判定し、「!(!r1||r2)」の値が真(true)である場合、すなわち、ルールが満たされない場合に、記録対象の1行分の検出ログの構成要素である検出結果に、「positive」を記録する。ステップs74は、「!(!r1||r2)」の値が偽(false)である場合、すなわち、ルールが満たされた場合に、記録対象の1行分の検出ログの構成要素である検出結果に、「negative」を記録する。すなわち、ステップs73及びs74における「log_result」は、引数に指定された値を、検出ログの構成要素である検出結果に記録する関数である。   Step s73 determines the true / false value of “! (! R1 || r2)”, and if the value of “! (! R1 || r2)” is true (ie, the rule is not satisfied). In addition, “positive” is recorded in the detection result which is a component of the detection log for one line to be recorded. In step s74, when the value of “! (! R1 || r2)” is false (ie, when the rule is satisfied), detection that is a constituent element of the detection log for one line to be recorded Record “negative” in the result. In other words, “log_result” in steps s73 and s74 is a function that records the value designated as an argument in the detection result that is a component of the detection log.

以上で、ルール記述rd1に対する履歴記録プログラムPr及び検出プログラムPcのソースコード(アスペクトコードac1)の生成は完了する。その結果、アスペクトコードac1は、図30及び図31に示されるようになる。   The generation of the source code (aspect code ac1) of the history recording program Pr and the detection program Pc for the rule description rd1 is thus completed. As a result, the aspect code ac1 is as shown in FIGS.

図30及び図31は、本実施の形態の第一のルール記述に関して生成される履歴記録プログラム及び検出プログラムのアスペクトコードの具体例を示す図である。図30及び図31は、一つのアスペクトコードac1を、便宜上、二つの図面に分割して示したものである。   FIGS. 30 and 31 are diagrams showing specific examples of the aspect code of the history recording program and the detection program generated with respect to the first rule description of the present embodiment. 30 and 31 show one aspect code ac1 divided into two drawings for convenience.

図30において、図15、図18、図19、図21、図22、又は図24と同一のポイントカット定義又はアドバイス定義には、同一符号を付している。すなわち、図30には、ルール記述rd1より抽出されたルール要素R1に関するポイントカット定義又はアドバイス定義が示されている。   In FIG. 30, the same reference numerals are assigned to the same pointcut definition or advice definition as in FIG. 15, FIG. 18, FIG. 19, FIG. 21, FIG. That is, FIG. 30 shows a point cut definition or an advice definition related to the rule element R1 extracted from the rule description rd1.

図31において、図26又は図28と同一のポイントカット定義又はアドバイス定義には、同一符号を付している。   In FIG. 31, the same reference numerals are assigned to the same pointcut definition or advice definition as in FIG.

また、図31において、ポイントカット定義pc14及びafterアドバイス定義ad14は、ルール要素R2に関して図13のステップS301〜S304が実行されることにより生成されるポイントカット定義又はアドバイス定義である。ポイントカット定義pc15及びafterアドバイス定義ad15は、ルール要素R2に関して図13のステップS305〜S307が実行されることにより生成されるポイントカット定義又はアドバイス定義である。ポイントカット定義pc16及びafterアドバイス定義ad16は、ルール要素R2に関して図13のステップS308〜S311が実行されることにより生成されるポイントカット定義又はアドバイス定義である。   In FIG. 31, the pointcut definition pc14 and the after advice definition ad14 are pointcut definitions or advice definitions generated by executing steps S301 to S304 of FIG. 13 for the rule element R2. The point cut definition pc15 and the after advice definition ad15 are point cut definitions or advice definitions generated by executing steps S305 to S307 in FIG. 13 with respect to the rule element R2. The pointcut definition pc16 and the after advice definition ad16 are pointcut definitions or advice definitions generated by executing steps S308 to S311 in FIG. 13 for the rule element R2.

続いて、図5のステップS205の履歴記録プログラムPrの生成処理に関して、便宜上、説明を後回しにした、カレントルール要素がAfterルール要素である場合について説明する。ここでは、図5のステップS101において、ルール解析部12によって、図32に示されるルール記述が読み込まれたこととする。   Next, the case where the current rule element is an after rule element, which is deferred for convenience, will be described with respect to the process of generating the history recording program Pr in step S205 of FIG. Here, it is assumed that the rule description shown in FIG. 32 is read by the rule analysis unit 12 in step S101 of FIG.

図32は、第二のルール記述の一例を示す図である。同図に示されるルール記述rd2に記述された式では、二つのAfterルール要素が「||」オペレータによって接続されている。第一項のAfterルール要素は、「@After(java.io.File.delete(), java.io.File.createTempFile(), httpServlet.doPost())」であり、第二項のAfterルール要素は、「@After(java.io.File.deleteOnExit(), java.io.File.createTempFile(), httpServlet.doPost())」である。   FIG. 32 is a diagram illustrating an example of the second rule description. In the expression described in the rule description rd2 shown in the figure, two After rule elements are connected by the “||” operator. The After rule element of the first term is "@After (java.io.File.delete (), java.io.File.createTempFile (), httpServlet.doPost ())", and the After rule element of the second term Is "@After (java.io.File.deleteOnExit (), java.io.File.createTempFile (), httpServlet.doPost ())".

したがって、ルール記述rd2に係る式は、「httpServlet.doPost()内でjava.io.File.createTempFile()が呼び出された場合は、java.io.File.createTempFile()の呼び出し後にjava.io.File.delete()が呼び出されなければならない。又は、httpServlet.doPost()内で、java.io.File.createTempFile()が呼び出された場合は、java.io.File.createTempFile()の呼び出し後に、java.io.File.deleteOnExit()が呼び出されなければならない。」というルールを示す。   Therefore, the expression related to the rule description rd2 is “if java.io.File.createTempFile () is called in httpServlet.doPost (), then java.io.File.createTempFile () will be called after java.io.File.createTempFile ()”. File.delete () must be called, or after calling java.io.File.createTempFile () if java.io.File.createTempFile () is called in httpServlet.doPost () , Java.io.File.deleteOnExit () must be called. "

アプリケーション内においてファイルが一時的に生成された場合、当該ファイルはアプリケーションの終了時に削除されないと、情報漏洩の虞がある。ファイルが適切に削除されるためには、Java.io.File#createTempFile()の実行後には、delete()又はdeleteOnExit()が実行される必要があるというルールが規定されればよい。当該ルールをルール要素及びオペレータを用いて表現したものが、ルール記述rd2である。   When a file is temporarily generated in an application, there is a risk of information leakage unless the file is deleted at the end of the application. In order for the file to be deleted appropriately, a rule that delete () or deleteOnExit () needs to be executed after execution of Java.io.File # createTempFile () may be defined. A rule description rd2 represents the rule using a rule element and an operator.

ルール記述rd2について、図5のステップS102〜S106が実行された結果、図33に示されるルール要素一覧が補助記憶装置102に記録(出力)される。   As a result of executing Steps S102 to S106 of FIG. 5 for the rule description rd2, the rule element list shown in FIG. 33 is recorded (output) in the auxiliary storage device 102.

図33は、第二のルール要素一覧の例を示す図である。同図では、第一項のAfterルール要素に対して、変数名「R3」が割り当てられ(生成され)、第二項のAfterルール要素に対して、変数名「R4」が割り当てられた(生成された)例が示されている。以下、第一項のAfterルール要素を「ルール要素R3」といい、第二項のAfterルール要素を「ルール要素R4」という。   FIG. 33 is a diagram illustrating an example of a second rule element list. In the figure, the variable name “R3” is assigned (generated) to the After rule element of the first term, and the variable name “R4” is assigned (generated) to the After rule element of the second term. Example) is shown. Hereinafter, the after rule element of the first term is referred to as “rule element R3”, and the after rule element of the second term is referred to as “rule element R4”.

続いてステップS107では、以下の式構造(2)が生成される。   Subsequently, in step S107, the following formula structure (2) is generated.

R3||R4 ・・・(2)
続いて、ルール記述rd2に関してプログラム生成部13によって図9において説明した処理が実行される。ステップS202では、ルール記述rd2に関するアスペクトコードの一部が生成される。
R3 || R4 (2)
Subsequently, the process described in FIG. 9 is executed by the program generation unit 13 with respect to the rule description rd2. In step S202, a part of the aspect code related to the rule description rd2 is generated.

図34及び図35は、本実施の形態の第二のルール記述に関して生成される履歴記録プログラム及び検出プログラムのアスペクトコードの具体例を示す図である。   FIG. 34 and FIG. 35 are diagrams showing specific examples of the aspect code of the history recording program and the detection program generated with respect to the second rule description of the present embodiment.

同図には、ルール記述rd2に関して生成されるアスペクトコードac2の完成形が示されているが、ステップS202において生成される部分は、アスペクトの定義とステップs11である。すなわち、図12に示されるアスペクトコードac1と同様の内容である。なお、ステップs11は、図12のアスペクトコードac1におけるステップs11と同じである。すなわち、履歴を記録するためのデータ構造(図11参照)は、ルール要素のタイプに拘わらず同じである。   In the drawing, the completed form of the aspect code ac2 generated for the rule description rd2 is shown. The part generated in step S202 is the definition of the aspect and step s11. That is, the content is the same as the aspect code ac1 shown in FIG. Step s11 is the same as step s11 in the aspect code ac1 of FIG. That is, the data structure for recording the history (see FIG. 11) is the same regardless of the type of rule element.

続いて、図9のステップS205について説明する。ルール要素一覧rL2(図33)に含まれているルール要素は、いずれもAfterルール要素である。したがって、履歴記録プログラム生成部131は、履歴記録プログラムPrの生成処理として、Afterルール要素に関する履歴記録プログラムPrを生成するための処理を実行する。当該生成処理では、要するに次のような処理を実行する履歴記録プログラムPrが生成される。以下の説明において、dメソッド、eメソッド、fメソッドとは、@After(d,e,f)における、dメソッド、eメソッド、又はfメソッドをいう。   Next, step S205 in FIG. 9 will be described. All rule elements included in the rule element list rL2 (FIG. 33) are After rule elements. Therefore, the history recording program generation unit 131 executes a process for generating the history recording program Pr related to the After rule element as the generation process of the history recording program Pr. In the generation process, a history recording program Pr for executing the following process is generated. In the following description, d method, e method, and f method refer to d method, e method, and f method in @After (d, e, f).

(1)fメソッドの実行をフックし、当該Afterルール要素の評価値をtrueとする。   (1) The execution of the f method is hooked, and the evaluation value of the After rule element is set to true.

(2)eメソッドの実行をフックし、当該評価値をfalseとする。   (2) The execution of the e method is hooked and the evaluation value is set to false.

(3)dメソッドの実行をフックし、当該評価値をtrueとする。   (3) The execution of the d method is hooked, and the evaluation value is set to true.

以上により、eメソッドが実行された場合、その後にdメソッドが実行されなければ、当該Afterルール要素の評価値をfalseとする履歴記録プログラムPrが生成される。   As described above, when the e method is executed, if the d method is not executed after that, the history recording program Pr having the evaluation value of the After rule element as false is generated.

以下、斯かる履歴記録プログラムPrの生成処理の詳細について説明する。   The details of the process of generating the history recording program Pr will be described below.

図36は、Afterルール要素に関する履歴記録プログラム生成処理の処理手順の一例を説明するためのフローチャートである。以下の説明において、ルール記述rd2に関して、図9のステップS202において生成されているアスペクトコードを、「アスペクトコードac2」という。図36の開始時点におけるアスペクトコードac2の状態は、図12に示されるアスペクトコードac1と同じである。   FIG. 36 is a flowchart for explaining an example of the processing procedure of the history recording program generation processing regarding the After rule element. In the following description, regarding the rule description rd2, the aspect code generated in step S202 of FIG. 9 is referred to as “aspect code ac2”. The state of the aspect code ac2 at the start time in FIG. 36 is the same as the aspect code ac1 shown in FIG.

ステップS501において、履歴記録プログラム生成部131は、ポイントカット定義雛形t2(図14)を用いて、カレントルール要素(ルール要素R3)のfメソッドの呼び出しをフックするためのポイントカット定義pc21をアスペクトコードac2に追加生成する。具体的には、履歴記録プログラム生成部131は、ポイントカット定義雛形t2の<ポイントカット名>を「callR3−f」に置換し、<メソッド名>をカレントルール要素のfメソッドのメソッド名(「httpServlet.doPost()」)に置換して、当該fメソッドに対するポイントカット定義pc21(図34参照)を生成する。なお、本実施の形態では、Afterルール要素のfメソッドに対するポイントカット名は、「call<カレントルール要素の変数名>−f」という命名規則に従って生成される。   In step S501, the history recording program generation unit 131 uses the pointcut definition template t2 (FIG. 14) to generate the aspect code of the pointcut definition pc21 for hooking the call of the f method of the current rule element (rule element R3). Generate additional to ac2. Specifically, the history recording program generation unit 131 replaces <pointcut name> of the pointcut definition template t2 with “callR3-f”, and replaces <method name> with the method name of the f method of the current rule element (“ httpServlet.doPost () "), and a pointcut definition pc21 (see FIG. 34) for the f method is generated. In the present embodiment, the pointcut name for the f method of the After rule element is generated according to the naming rule “call <variable name of current rule element> -f”.

続いて、履歴記録プログラム生成部131は、ポイントカット定義pc21に対するbeforeアドバイス定義ad21(図34参照)を、beforeアドバイス定義雛形t5(図16)を用いて生成し、アスペクトコードac2に追加する(S502)。ステップS502では、beforeアドバイス定義ad21のうち、ステップs51〜s53が生成される。当該ステップ番号は、図16に対応する。   Subsequently, the history recording program generation unit 131 generates a before advice definition ad21 (see FIG. 34) for the pointcut definition pc21 using the before advice definition template t5 (FIG. 16) and adds it to the aspect code ac2 (S502). ). In step S502, steps s51 to s53 are generated in the before advice definition ad21. The step number corresponds to FIG.

続いて、履歴記録プログラム生成部131は、カレントルール要素の要件が満たされたことを、暫定的に履歴テーブル(変数currentTable)へ記録するためのステップをbeforeアドバイス定義ad21に対して追加する(S503)。当該ステップの追加には、履歴記録雛形t4(図17)が使用される。追加されたステップは、アドバイス定義ad21内(図34)におけるs41及び42に相当する。   Subsequently, the history recording program generation unit 131 adds a step for temporarily recording in the history table (variable currentTable) that the requirement of the current rule element is satisfied to the before advice definition ad21 (S503). ). The history recording template t4 (FIG. 17) is used to add the step. The added steps correspond to s41 and 42 in the advice definition ad21 (FIG. 34).

アドバイス定義ad21内のステップs41は、変数varTableより取得された(s52)、又は新に生成された(s53)履歴テーブル(currentTable)に、カレントルール要素(ルール要素R3)の変数名(「R3」)に対してtrueを記録する。すなわち、fメソッドの実行前に、ルール要素R3の要件が満たされたことが、暫定的に当該履歴テーブルに記録される。ステップs42は、現在のスレッドの識別子に対応付けて当該履歴テーブルを変数varTableに格納する。その結果、現在のスレッドにおいて、ルール要素R3の要件が満たされたことが暫定的に変数varTableに記録されたことになる。   In step s41 in the advice definition ad21, the variable name (“R3”) of the current rule element (rule element R3) is added to the history table (currentTable) acquired from the variable varTable (s52) or newly generated (s53). ) For true. That is, the fact that the requirement of the rule element R3 is satisfied is temporarily recorded in the history table before the f method is executed. In step s42, the history table is stored in the variable varTable in association with the identifier of the current thread. As a result, the fact that the requirement of the rule element R3 is satisfied in the current thread is temporarily recorded in the variable varTable.

続いて、履歴記録プログラム生成部131は、ポイントカット定義雛形t2(図14)を用いて、カレントルール要素(ルール要素R3)のeメソッドの呼び出しをフックするためのポイントカット定義pc22をアスペクトコードac2に追加生成する(S504)。具体的には、履歴記録プログラム生成部131は、ポイントカット定義雛形t2の<ポイントカット名>を「R3−pred」に置換し、<メソッド名>をカレントルール要素のeメソッドのメソッド名(「java.io.File.createTempFile()」)に置換して、当該eメソッドに対するポイントカット定義pc22(図34参照)を生成する。なお、本実施の形態で、Afterルール要素のeメソッドに対するポイントカット名は、「call<カレントルール要素の変数名>−pred」という命名規則に従って生成される。   Subsequently, the history recording program generation unit 131 uses the pointcut definition template t2 (FIG. 14) to generate the pointcut definition pc22 for hooking the call of the e method of the current rule element (rule element R3) with the aspect code ac2 (S504). Specifically, the history recording program generation unit 131 replaces <point cut name> of the point cut definition template t2 with “R3-pred”, and replaces <method name> with the method name of the e method of the current rule element (“ java.io.File.createTempFile () ”) to generate a pointcut definition pc22 (see FIG. 34) for the e method. In the present embodiment, the pointcut name for the e method of the After rule element is generated according to a naming rule “call <variable name of current rule element> -pred”.

続いて、履歴記録プログラム生成部131は、ポイントカット定義pc22に対するafterアドバイス定義ad22(図34参照)を、afterアドバイス定義雛形t3(図20)を用いて生成し、アスペクトコードac2に追加する(S505)。ステップS505では、afterアドバイス定義ad22のうち、ステップs31〜s33が生成される。当該ステップ番号は、図20に対応する。   Subsequently, the history recording program generation unit 131 generates an after advice definition ad22 (see FIG. 34) for the pointcut definition pc22 using the after advice definition template t3 (FIG. 20) and adds it to the aspect code ac2 (S505). ). In step S505, steps s31 to s33 are generated in the after advice definition ad22. The step number corresponds to FIG.

続いて、履歴記録プログラム生成部131は、カレントルール要素は満たされていないことを、暫定的に履歴テーブル(変数currentTable)へ記録するためのステップをafterアドバイス定義ad22に対して追加する(S506)。当該ステップの追加には、履歴記録雛形t4(図17)が使用される。追加されたステップは、アドバイス定義ad22内(図34)におけるs41及びs42に相当する。   Subsequently, the history recording program generation unit 131 adds a step for temporarily recording in the history table (variable currentTable) that the current rule element is not satisfied to the after advice definition ad22 (S506). . The history recording template t4 (FIG. 17) is used to add the step. The added steps correspond to s41 and s42 in the advice definition ad22 (FIG. 34).

アドバイス定義ad22内のステップs41は、変数varTableより取得された(s32)、又は新に生成された(s33)履歴テーブル(currentTable)に、ルール要素R3の変数名(「R3」)に対してfalseを記録する。すなわち、eメソッドの実行後に、ルール要素R3の要件が満たされていないことが、暫定的に当該履歴テーブルに記録される。ステップs42は、現在のスレッドの識別子に対応付けて当該履歴テーブルを変数varTableに格納する。その結果、現在のスレッドにおいて、ルール要素R3の要件が満たされていないことが暫定的に変数varTableに記録されたことになる。   Step s41 in the advice definition ad22 is false for the variable name (“R3”) of the rule element R3 in the history table (currentTable) acquired from the variable varTable (s32) or newly generated (s33). Record. That is, after the e method is executed, the fact that the requirement of the rule element R3 is not satisfied is temporarily recorded in the history table. In step s42, the history table is stored in the variable varTable in association with the identifier of the current thread. As a result, it is temporarily recorded in the variable varTable that the requirement of the rule element R3 is not satisfied in the current thread.

続くステップS507及びS508において、履歴記録プログラム生成部131は、dメソッドに関して、ステップS504及びS505において説明した処理を実行する。その結果、ポイントカット定義pc23及びafterアドバイス定義ad23のs31〜s33までが生成される。なお、本実施の形態では、Afterルール要素のdメソッドに対するポイントカット名は、「call<カレントルール要素の変数名>−succ」という命名規則に従って生成される。   In subsequent steps S507 and S508, the history recording program generation unit 131 executes the processing described in steps S504 and S505 for the d method. As a result, the point cut definition pc23 and the after advice definition ad23 from s31 to s33 are generated. In the present embodiment, the pointcut name for the d method of the After rule element is generated according to the naming rule “call <variable name of current rule element> -succ”.

続いて、履歴記録プログラム生成部131は、カレントルール要素は満たされていることを履歴テーブル(変数currentTable)へ記録するためのステップをafterアドバイス定義ad23に対して追加する(S509)。当該ステップの追加には、履歴記録雛形t4(図17)が使用される。追加されたステップは、アドバイス定義ad23内(図34)におけるs41及びs42に相当する。   Subsequently, the history recording program generation unit 131 adds a step for recording in the history table (variable currentTable) that the current rule element is satisfied to the after advice definition ad23 (S509). The history recording template t4 (FIG. 17) is used to add the step. The added steps correspond to s41 and s42 in the advice definition ad23 (FIG. 34).

以上で、カレントルール要素がAfterルール要素である場合の処理手順は終了する。図33に示されるように、本実施の形態の場合、図8のルール要素一覧rL2において2番目のルール要素(ルール要素R4)もAfterルール要素である。したがって、続けて、ルール要素R4に関しても図36に示される処理手順が実行される。その結果、ルール要素R4において、メソッドd、e、又はfに対応する各メソッドに関して、上述したようなソースコードが生成される。なお、当該処理手順の内容の説明は、上記より自明であるため省略する。   This is the end of the processing procedure when the current rule element is an After rule element. As shown in FIG. 33, in the case of the present embodiment, the second rule element (rule element R4) in the rule element list rL2 of FIG. 8 is also an After rule element. Therefore, the processing procedure shown in FIG. 36 is also executed for rule element R4. As a result, in the rule element R4, the source code as described above is generated for each method corresponding to the method d, e, or f. The description of the processing procedure is omitted because it is self-evident from the above.

続いて、図5のステップS205の履歴記録プログラムPrの生成処理に関して、カレントルール要素がCallルール要素である場合について説明する。   Next, regarding the generation process of the history recording program Pr in step S205 of FIG. 5, a case where the current rule element is a Call rule element will be described.

図37は、Callルール要素に関する履歴記録プログラム生成処理の処理手順の一例を説明するためのフローチャートである。以下の説明において、gメソッド、hメソッドとは、@Call(g,h)におけるgメソッド又はhメソッドをいう。   FIG. 37 is a flowchart for explaining an example of the processing procedure of the history recording program generation processing regarding the Call rule element. In the following description, the g method and h method refer to the g method or h method in @Call (g, h).

ステップS601において、履歴記録プログラム生成部131は、ポイントカット定義雛形t2(図14)を用いて、カレントルール要素のhメソッドの呼び出しをフックするためのポイントカット定義を作成中のアスペクトコードに追加生成する。   In step S601, the history recording program generation unit 131 additionally generates a pointcut definition for hooking the call to the h method of the current rule element using the pointcut definition template t2 (FIG. 14). To do.

続いて、履歴記録プログラム生成部131は、ポイントカット定義に対するbeforeアドバイス定義を、beforeアドバイス定義雛形t5(図16)を用いて生成し、アスペクトコードに追加する(S602)。   Subsequently, the history recording program generation unit 131 generates a before advice definition for the pointcut definition using the before advice definition template t5 (FIG. 16) and adds it to the aspect code (S602).

続いて、履歴記録プログラム生成部131は、カレントルール要素の要件が満たされていないこと示す評価値を、暫定的に履歴テーブル(変数currentTable)へ記録するためのステップをbeforeアドバイス定義に対して追加する(S603)。   Subsequently, the history recording program generation unit 131 adds a step for temporarily recording an evaluation value indicating that the requirement of the current rule element is not satisfied to the history table (variable currentTable) to the before advice definition. (S603).

続いて、履歴記録プログラム生成部131は、ポイントカット定義雛形t2(図14)を用いて、カレントルール要素(ルール要素R3)のgメソッドの呼び出しをフックするためのポイントカット定義をアスペクトコードに追加生成する(S604)。   Subsequently, the history recording program generation unit 131 uses the pointcut definition template t2 (FIG. 14) to add a pointcut definition for hooking the g method call of the current rule element (rule element R3) to the aspect code. Generate (S604).

続いて、履歴記録プログラム生成部131は、ポイントカット定義に対するafterアドバイス定義を、afterアドバイス定義雛形t3(図20)を用いて生成し、アスペクトコードに追加する(S605)。   Subsequently, the history recording program generation unit 131 generates an after advice definition for the pointcut definition using the after advice definition template t3 (FIG. 20) and adds it to the aspect code (S605).

続いて、履歴記録プログラム生成部131は、カレントルール要素は満たされたことを示す評価値を履歴テーブル(変数currentTable)へ記録するためのステップをafterアドバイス定義に対して追加する(S606)。当該ステップの追加には、履歴記録雛形t4(図17)が使用される。   Subsequently, the history recording program generation unit 131 adds a step for recording an evaluation value indicating that the current rule element is satisfied in the history table (variable currentTable) to the after advice definition (S606). The history recording template t4 (FIG. 17) is used to add the step.

このように、Callルール要素については、hメソッドの実行の検知に応じて評価値がfalseとされ、gメソッドの実行の検知に応じて評価値がtrueとされる。したがって、当該評価値は、gメソッドが呼ばれたときに限ってtrueとなる。   Thus, for the Call rule element, the evaluation value is set to false in response to detection of execution of the h method, and the evaluation value is set to true in response to detection of execution of the g method. Therefore, the evaluation value is true only when the g method is called.

なお、型指定Callルール要素に関する履歴記録プログラムPrの生成処理は、例えば、図37のhメソッドがjメソッドに置換され、gメソッドがiメソッドに置換された処理が実行されたものであればよい。   The generation process of the history recording program Pr related to the type designation Call rule element may be, for example, a process in which the h method in FIG. 37 is replaced with the j method and the g method is replaced with the i method. .

続いて、履歴記録プログラムPr及び検出プログラムPc、具体的には、アスペクトコードac1(図30及び図31)又はアスペクトコードac2(図35及び図36)等の実行時の処理手順について説明する。   Next, the processing procedure at the time of executing the history recording program Pr and the detection program Pc, specifically the aspect code ac1 (FIGS. 30 and 31) or the aspect code ac2 (FIGS. 35 and 36) will be described.

図38は、履歴記録プログラム及び検出プログラムの実行時の処理手順の一例を説明するためのフローチャートである。同図の処理手順の実行前に、アスペクトコードac1又はac2等は、コンパイルされる。コンパイル後のプログラムは、履歴記録プログラムPr及び検出プログラムPcとして機能するプログラムである。   FIG. 38 is a flowchart for explaining an example of a processing procedure when the history recording program and the detection program are executed. Prior to the execution of the processing procedure of the figure, the aspect code ac1 or ac2 is compiled. The compiled program is a program that functions as the history recording program Pr and the detection program Pc.

ステップS701において、履歴記録プログラムPr及び検出プログラムPc(すなわち、アスペクトコード)がアプリケーションに適用された状態で起動される。なお、同図では、便宜上、アプリケーションは、テストプログラム生成装置10において起動されることとする。但し、他のコンピュータにおいて図38の処理が実行されてもよい。また、アスペクトコードの適用に関しては公知技術であるため、その説明は省略する。   In step S701, the history recording program Pr and the detection program Pc (that is, the aspect code) are activated in a state where they are applied to the application. In the figure, for the sake of convenience, the application is started in the test program generation device 10. However, the processing of FIG. 38 may be executed in another computer. Further, since application of the aspect code is a known technique, description thereof is omitted.

起動されたアプリケーションの処理の進行に応じて、ライブラリのメソッドが実行される(呼び出される)。メソッドの実行に応じ、履歴記録プログラムPrは、メソッドの実行履歴の記録をCPU104に実行させる(S702)。具体的には、履歴記録プログラムPrにおけるポイントカット定義により、アプリケーションによるライブラリのメソッドの呼び出しがフックされる。当該呼び出しのフックに応じ、履歴記録プログラムPrにおけるアドバイス定義が実行され、当該呼び出しに関する履歴が変数varTableに記録される。   A library method is executed (called) in accordance with the progress of processing of the started application. In response to the method execution, the history recording program Pr causes the CPU 104 to record the method execution history (S702). Specifically, the library method call is hooked by the application by the pointcut definition in the history recording program Pr. The advice definition in the history recording program Pr is executed according to the hook of the call, and the history regarding the call is recorded in the variable varTable.

続いて、アプリケーションによる呼出元メソッドの実行が終了すると、検出プログラムPcは、ステップS702において記録された履歴に基づくルール違反の有無の検出及び検出結果(検出ログ(図29))の検出ログ記憶部16への記録をCPU104に実行させる(S703)。具体的には、当該呼出元メソッドの実行後に、検出プログラムPcにおけるアドバイス定義が実行され、ルール記述rd1又はrd2等の要件の充足の有無が検出される。検出結果は、検出ログ(図29)の形式で検出ログ記憶部16に記録される。   Subsequently, when the execution of the caller method by the application is completed, the detection program Pc detects whether there is a rule violation based on the history recorded in step S702 and a detection log storage unit for detection results (detection log (FIG. 29)). 16 is executed by the CPU 104 (S703). Specifically, after the caller method is executed, the advice definition in the detection program Pc is executed to detect whether the requirements such as the rule description rd1 or rd2 are satisfied. The detection result is recorded in the detection log storage unit 16 in the form of a detection log (FIG. 29).

続いて、ブラックボックステスト用のテストプログラムTpの生成処理について説明する。図39は、ブラックボックステスト用のテストプログラムの生成処理の処理手順の一例を説明するためのフローチャートである。同図の処理が実行される前に、履歴記録プログラムPr及びルール検証プログラムPcの実行(検査対象のアプリケーションへの適用)により、少なくとも一つ(一行)の検出ログが、検出ログ記憶部16に記憶されていることとする。   Next, a process for generating the test program Tp for the black box test will be described. FIG. 39 is a flowchart for explaining an example of a processing procedure for generating a test program for a black box test. Before the processing of FIG. 10 is executed, at least one (one line) detection log is stored in the detection log storage unit 16 by executing the history recording program Pr and the rule verification program Pc (applied to the application to be inspected). It shall be remembered.

ステップS801において、テストプログラム生成部15は、検出ログ記憶部16からの未処理の一つ(一行分)の検出ログの取得(読み込み)を試みる。未処理とは、ステップS803以降に関して処理対象とされていないことをいう。取得(読み込み)に成功した場合(S802でYes)、テストプログラム生成部15は、取得された検出ログ(以下、「対象ログ」という。)のルール名及び検出結果に対応するテストポリシーを、テストポリシーリスト記憶部17より抽出(検索)する(S803)。   In step S <b> 801, the test program generation unit 15 attempts to acquire (read) one unprocessed (one line) detection log from the detection log storage unit 16. “Unprocessed” means that it is not set as a processing target for step S803 and subsequent steps. When the acquisition (reading) is successful (Yes in S802), the test program generation unit 15 tests the test policy corresponding to the rule name and the detection result of the acquired detection log (hereinafter referred to as “target log”). Extracted (searched) from the policy list storage unit 17 (S803).

図40は、テストポリシーリスト記憶部の構成例を示す図である。同図において、テストポリシーリスト記憶部17は、テストポリシーの一覧(テストポリシーリスト)を記憶する。一つのテストポリシーは、ルール名、検出結果、及びテストシナリオ名等の情報を含む。   FIG. 40 is a diagram illustrating a configuration example of the test policy list storage unit. In the figure, a test policy list storage unit 17 stores a list of test policies (test policy list). One test policy includes information such as a rule name, a detection result, and a test scenario name.

ルール名は及び検出結果は、当該テストポリシーが対応するルール名及び検出結果である。すなわち、当該ルール名に係るルールに関して、当該検出結果が検出された場合に、当該テストポリシーが有効である(適用される)ことを示す。したがって、テストポリシーにおけるルール名及び検出結果は、当該テストポリシーの適用条件であるといえる。テストシナリオ名は、テストポリシーが適用される場合に、テストプログラムTpの生成に使用すべきシナリオコードの識別名である。   The rule name and the detection result are the rule name and the detection result corresponding to the test policy. That is, regarding the rule relating to the rule name, when the detection result is detected, it indicates that the test policy is valid (applied). Therefore, it can be said that the rule name and the detection result in the test policy are the application conditions of the test policy. The test scenario name is an identification name of a scenario code to be used for generating the test program Tp when the test policy is applied.

例えば、同図において、一つ目のテストポリシーでは、ルール名が「SQL−inj」であるルール(ルール記述)に関して、検出結果が「positive」であった場合に、「checkSQLinj1」という名前のシナリオコードを使用すべきことが示されている。また、二つ目のテストポリシーでは、ルール名が「SQL−inj」であるルール(ルール記述)に関して、検出結果が「positive」であった場合、「checkSQLinj2」という名前のシナリオコードを使用すべきことが示されている。ここで、一つ名のテストポリシーと二つ目のテストポリシーとのルール名及び検出結果は一致する。このように、同一の適用条件に対して複数のテストシナリオ名(すなわち、シナリオコード)が関連付けられてもよい。また、同一のテストシナリオ名(すなわち、シナリオコード)が複数の適用条件(ルール名及び検出結果)に関連付けられてもよい。   For example, in the first test policy, in the first test policy, when the detection result is “positive” for the rule (rule description) whose rule name is “SQL-inj”, the scenario named “checkSQLLinj1” The code is shown to be used. In the second test policy, for a rule (rule description) whose rule name is “SQL-inj”, if the detection result is “positive”, a scenario code named “checkSQLLinj2” should be used. It has been shown. Here, the rule names and detection results of the first test policy and the second test policy match. Thus, a plurality of test scenario names (that is, scenario codes) may be associated with the same application condition. Further, the same test scenario name (that is, scenario code) may be associated with a plurality of application conditions (rule name and detection result).

ステップS803では、対象ログとルール名及び検出結果が一致するテストポリシーが抽出される。続いて、テストプログラム生成部15は、抽出されたテストポリシーにおいて指定されているテストシナリオ名に係るシナリオコードのコピー(複製)を、シナリオコード記憶部18より取得する(S804)。複数のテストポリシーが抽出されている場合は、複数のシナリオコードのコピーが取得される。なお、ここで、「コピー」が取得されるのは、後述されるようにシナリオコードは書き換えが行われるところ、シナリオコードのオリジナル版が書き換えの対象とされないようにするためである。したがって、以下のステップでは、シナリオコードのコピーが処理対象とされるが、単に、「シナリオコード」という。   In step S803, a test policy whose target log matches the rule name and the detection result is extracted. Subsequently, the test program generation unit 15 obtains a copy (duplication) of the scenario code related to the test scenario name specified in the extracted test policy from the scenario code storage unit 18 (S804). When a plurality of test policies are extracted, copies of a plurality of scenario codes are acquired. Here, “copy” is acquired in order to prevent the original version of the scenario code from being rewritten, as will be described later. Accordingly, in the following steps, a copy of the scenario code is the processing target, but is simply referred to as “scenario code”.

図41は、シナリオコードの第一の例を示す図である。また、図42は、シナリオコードの第二の例を示す図である。   FIG. 41 is a diagram illustrating a first example of a scenario code. FIG. 42 is a diagram illustrating a second example of the scenario code.

図41のシナリオコードsc1は、テストシナリオ名が「checkSQLinj1」であるシナリオコードである。また、図42のシナリオコードsc2は、テストシナリオ名が「checkSQLinj2」であるシナリオコードである。各シナリオコードは、それぞれ単独で、アスペクト指向プログラミング言語(AspectJ)における一つのアスペクトを構成し、基本的に、ポイントカット定義とアドバイス定義とを含む。   The scenario code sc1 in FIG. 41 is a scenario code whose test scenario name is “checkSQLLinj1”. The scenario code sc2 in FIG. 42 is a scenario code whose test scenario name is “checkSQLLinj2”. Each scenario code independently constitutes one aspect in the aspect-oriented programming language (AspectJ), and basically includes a pointcut definition and an advice definition.

例えば、シナリオコードsc1は、ポイントカット定義pc31とaroundアドバイス定義ad31とを含む。また、シナリオコードsc2は、ポイントカット定義pc32とaroundアドバイス定義ad32とを含む。aroundアドバイスとは、本来実行されるはずの処理の代わりに、当該aroundアドバイスに定義された処理を実行させるアドバイスである。なお、アドバイスは、必ずしもaroundアドバイスでなくてもよい。   For example, the scenario code sc1 includes a point cut definition pc31 and an around advice definition ad31. The scenario code sc2 includes a point cut definition pc32 and an around advice definition ad32. The “round advice” is advice that causes a process defined in the “round advice” to be executed instead of the process that should be executed. Note that the advice does not necessarily have to be around advice.

各シナリオコードの、ポイントカット定義において、ジョインポイントとされるメソッド名は、空欄(ブランク)又はパラメタ化されており、同図では、<検出箇所>として表現されている。<検出箇所>は、検出ログの検出箇所に係るメソッド名によって置換されることを意味する。すなわち、シナリオコードは、検出ログにおける検出箇所をフックして、当該検出箇所に関してアドバイス定義において定義された処理を実行させるといった内容になっている。アドバイス定義には、ルール名及び検出結果に応じた、ブラックボックステスト用の処理(テストシナリオ)が定義される。したがって、シナリオコードには、特定の箇所(メソッド)において、特定のルールに関して違反又は準拠が検出された場合に有効であると考えられるテストシナリオが実装される。   In the point cut definition of each scenario code, the method name used as a join point is blank (blank) or parameterized, and is represented as <detection location> in FIG. <Detection location> means being replaced by the method name related to the detection location of the detection log. That is, the scenario code has a content that hooks a detection location in the detection log and executes the process defined in the advice definition for the detection location. In the advice definition, a black box test process (test scenario) is defined according to the rule name and the detection result. Therefore, a test scenario that is considered to be effective when a violation or compliance with a specific rule is detected at a specific location (method) is installed in the scenario code.

なお、本実施の形態では、各シナリオコードのアスペクト名が、当該シナリオコードのテストシナリオ名として用いられている。但し、各シナリオコードのファイル名等、他の識別情報が、テストシナリオ名として用いられてもよい。   In the present embodiment, the aspect name of each scenario code is used as the test scenario name of the scenario code. However, other identification information such as the file name of each scenario code may be used as the test scenario name.

続いて、テストプログラム生成部15は、取得された各シナリオコードの空欄部分(<検出箇所>の部分)に、対象ログの検出箇所の値(メソッド名)を書き込む(S805)。又は、取得されたシナリオコードの空欄部分が、対象ログの検出箇所の値(メソッド名)によって置換される。   Subsequently, the test program generation unit 15 writes the value (method name) of the detection location of the target log in the blank portion (<detection location> portion) of each acquired scenario code (S805). Alternatively, the blank part of the acquired scenario code is replaced with the value (method name) of the detected part of the target log.

続いて、テストプログラム生成部15は、メソッド名が書き込まれた各シナリオコードを、テストプログラムTpとして出力(例えば、補助記憶装置102に保存)する(S806)。複数のシナリオコードが取得されている場合、複数のテストプログラムTpが出力される。   Subsequently, the test program generation unit 15 outputs (for example, stores in the auxiliary storage device 102) each scenario code in which the method name is written as the test program Tp (S806). When a plurality of scenario codes are acquired, a plurality of test programs Tp are output.

以降、テストプログラム生成部15は、検出ログ記憶部16における全ての検出ログに関してステップS803〜S806を実行した後(S802でNo)、図39の処理を終了させる。   Thereafter, the test program generation unit 15 executes steps S803 to S806 for all the detection logs in the detection log storage unit 16 (No in S802), and then ends the process of FIG.

以上のように生成されたテストプログラムTpは、コンパイルされ、ライブラリを使用するアプリケーションに適用されることにより、ブラックボックステストを実行する。   The test program Tp generated as described above is compiled and applied to an application that uses a library, thereby executing a black box test.

続いて、図43に示される具体的なルール記述の例に基づいて、ブラックボックステスト用のテストプログラムTpの生成、及びブラックボックステストの実行に関して説明する。   Next, generation of the test program Tp for the black box test and execution of the black box test will be described based on a specific example of rule description shown in FIG.

図43は、第三のルール記述の一例を示す図である。同図に示されるルール記述rd3に記述された式では、一つのCallルール要素と二つのAfterルール要素が「&&」オペレータによって接続されている。第一項のCallルール要素は、AdminLoginServlet.login()内で、PreparedStatement.set*()の呼出が必須であることを示す(図3参照)。なお、「set*」における「*(アスタリスク)」は、正規表現である。したがって、PreparedStatement.set*()は、PreparedStatement.set*()という正規表現に合致するいずれかのメソッドを示す。   FIG. 43 is a diagram illustrating an example of the third rule description. In the expression described in the rule description rd3 shown in the figure, one Call rule element and two After rule elements are connected by an “&&” operator. The Call rule element of the first term indicates that it is necessary to call PreparedStatement.set * () in AdminLoginServlet.login () (see FIG. 3). Note that “* (asterisk)” in “set *” is a regular expression. Therefore, PreparedStatement.set * () indicates any method that matches the regular expression PreparedStatement.set * ().

第二項のAfterルール要素は、AdminLoginServlet.login()内で、PreparedStatement.set*()の実行がConnection.prepareStatement()の実行後に必須であることを示す(図3参照)。第三項のAfterルール要素は、AdminLoginServlet.login()内で、PreparedStatement.set.executeQuery(),の実行がPreparedStatement.set*()の実行後に必須であることを示す(図3参照)。   The After rule element in the second term indicates that the execution of PreparedStatement.set * () is essential after the execution of Connection.prepareStatement () in AdminLoginServlet.login () (see FIG. 3). The After rule element of the third term indicates that the execution of PreparedStatement.set.executeQuery () is essential after the execution of PreparedStatement.set * () in AdminLoginServlet.login () (see FIG. 3).

したがって、ルール記述rd3は、AdminLoginServlet.login()内において、以下の(a)、(b)、(c)の順で、各メソッドが呼び出される必要があるというルールを規定する。
(a)Connection.prepareStatement()
(b)PreparedStatement.set*()
(c)PreparedStatement.set.executeQuery()
当該ルールは、SQLインジェクション対策の文脈上のルールである。SQLインジェクションを防ぐためには、(a)、(b)、(c)の順で、各メソッドが呼び出される必要があるからである。便宜上、以下において、各メソッドを、メソッド(a)、メソッド(b)、又はメソッド(c)という。また、ルール記述rd3に係るルール名は、「SQL−inj」であるとする。
Accordingly, the rule description rd3 defines a rule that each method needs to be called in the following order (a), (b), (c) in AdminLoginServlet.login ().
(A) Connection.prepareStatement ()
(B) PreparedStatement.set * ()
(C) PreparedStatement.set.executeQuery ()
This rule is a contextual rule for countermeasures against SQL injection. This is because it is necessary to call each method in the order of (a), (b), and (c) in order to prevent SQL injection. For convenience, each method is hereinafter referred to as a method (a), a method (b), or a method (c). Further, it is assumed that the rule name related to the rule description rd3 is “SQL-inj”.

ルール記述rd3について、図5のステップS102〜S106が実行された結果、図44に示されるルール要素一覧が補助記憶装置102に記録(出力)される。   As a result of executing steps S102 to S106 in FIG. 5 for the rule description rd3, the rule element list shown in FIG. 44 is recorded (output) in the auxiliary storage device 102.

図33は、第三のルール要素一覧の例を示す図である。同図では、第一項のCallルール要素に対して、変数名「R5」が割り当てられ(生成され)、第二項のAfterルール要素に対して、変数名「R6」が割り当てられ(生成され)、第三項のAfterルール要素に対して、変数名「R7」が割り当てられた(生成された)例が示されている。以下、第一項のCallルール要素を「ルール要素R5」といい、第二項のAfterルール要素を「ルール要素R6」といい、第三項のAfterルール要素を「ルール要素R7」という。   FIG. 33 is a diagram illustrating an example of a third rule element list. In the figure, the variable name “R5” is assigned (generated) to the Call rule element of the first term, and the variable name “R6” is assigned (generated) to the After rule element of the second term. ), An example in which the variable name “R7” is assigned (generated) to the after rule element of the third term is shown. Hereinafter, the Call rule element of the first term is referred to as “rule element R5”, the After rule element of the second term is referred to as “rule element R6”, and the After rule element of the third term is referred to as “rule element R7”.

続いてステップS107では、以下の式構造(3)が生成される。   Subsequently, in step S107, the following formula structure (3) is generated.

R5&&R6&&R7 ・・・(3)
続いて、図43に示されるルール一覧及び式構造(3)等に関して、図9等を用いて説明した処理が実行され、ルール記述rd3に関する履歴記録プログラムPr及び検出プログラムPcが生成される。当該履歴記録プログラムPr及び当該検出プログラムPcの生成処理、及び当該生成処理によって生成されるアスペクトコードの内容は、ルール記述rd1及びルール記述rd2に関する説明より自明であるため、省略する。
R5 && R6 && R7 (3)
Subsequently, with respect to the rule list and formula structure (3) shown in FIG. 43, the processing described with reference to FIG. 9 and the like is executed, and the history recording program Pr and the detection program Pc related to the rule description rd3 are generated. Since the generation process of the history recording program Pr and the detection program Pc and the contents of the aspect code generated by the generation process are obvious from the description of the rule description rd1 and the rule description rd2, they are omitted.

ルール記述rd3に関する履歴記録プログラムPr及び検出プログラムPcが、図45に示される実装を有するアプリケーションに適用された場合を考える。   Consider a case where the history recording program Pr and the detection program Pc related to the rule description rd3 are applied to an application having the implementation shown in FIG.

図45は、検査対象のアプリケーションの実装例を示す図である。同図の実装例(ソースコード)は、アプリケーションap1におけるAdminServlet.loginメソッドの実装例を示す。当該loginメソッド内では、(a)に示される部分においてメソッド(a)が呼び出されている。また、(c)に示される部分においてメソッド(c)が呼び出されている。   FIG. 45 is a diagram illustrating an implementation example of an application to be inspected. An implementation example (source code) of FIG. An implementation example of the login method is shown. In the login method, the method (a) is called at the portion indicated by (a). Also, the method (c) is called in the part shown in (c).

図45に示されるアプリケーションap1に対して、ルール記述rd3に基づく履歴記録プログラムPr及び検出プログラムPcが適用されると、例えば、図46に示されるような検出ログが検出ログ記憶部16に記録される。   When the history recording program Pr and the detection program Pc based on the rule description rd3 are applied to the application ap1 shown in FIG. 45, for example, a detection log as shown in FIG. 46 is recorded in the detection log storage unit 16. The

図46は、検出ログの具体例を示す図である。同図の検出ログL1では、SQL−injというルール名のルール(ルール記述rd3)に関して、AdminLoginServlet.loginメソッド内において、ルール違反(positive)が検出されたことが示されている。アプリケーションap1では、メソッド(b)が呼び出されていないことが検出プログラムPcによって検出されるからである。   FIG. 46 is a diagram showing a specific example of the detection log. In the detection log L1 in the figure, it is indicated that a rule violation (positive) is detected in the AdminLoginServlet.login method for the rule with the rule name SQL-inj (rule description rd3). This is because in the application ap1, the detection program Pc detects that the method (b) has not been called.

この時点で、アプリケーションap1は、以下の4つのケースのうち、ケース(B)又はケース(D)に該当することが分かる。
(A)正しい実装で、かつ、結果もOK
(B)誤った実装の可能性が有り、結果はOK
(C)正しい実装であるにも拘わらず、結果はNG
(D)誤った実装の可能性が有り、結果はNG
検出ログL1及び図40に示したテストポリシーリストに基づいて、図39の処理が実行されると、図40の1行目及び2行目のテストポリシーが抽出される。したがって、図41に示したシナリオコードsc1、及び図42に示したシナリオコードsc2のそれぞれに対して、検出ログL1における検出箇所(AdminLoginServlet.login)が書き込まれる。その結果、図47及び図48に示されるようなテストプログラムTpが生成される。
At this point, it can be seen that the application ap1 corresponds to the case (B) or the case (D) among the following four cases.
(A) Correct implementation and result is OK
(B) There is a possibility of incorrect mounting, and the result is OK.
(C) Despite the correct implementation, the result is NG
(D) There is a possibility of incorrect mounting, the result is NG
When the process of FIG. 39 is executed based on the detection log L1 and the test policy list shown in FIG. 40, the test policies of the first and second lines in FIG. 40 are extracted. Therefore, the detection location (AdminLoginServlet.login) in the detection log L1 is written to each of the scenario code sc1 shown in FIG. 41 and the scenario code sc2 shown in FIG. As a result, a test program Tp as shown in FIGS. 47 and 48 is generated.

図47は、テストプログラムの第一の例を示す図である。また、図48は、テストプログラムの第二の例を示す図である。図47及び図48において、図41又は図42と同一又は対応する部分には同一符号を付している。   FIG. 47 is a diagram illustrating a first example of a test program. FIG. 48 is a diagram showing a second example of the test program. 47 and 48, the same or corresponding parts as those in FIG. 41 or 42 are denoted by the same reference numerals.

図47のテストプログラムTp1及び図48のテストプログラムTp2では、それぞれ空欄部分(図中における<検出箇所>)が、「AdminLoginServlet.login」によって置換されている。したがって、テストプログラムTp1及びTp2は、それぞれ、アプリケーションによるAdminLoginServlet.loginメソッドの呼び出し(実行)をフックし、aroundアドバイスad31又はad32を実行するプログラムである。   In the test program Tp1 of FIG. 47 and the test program Tp2 of FIG. 48, the blank portions (<detection location> in the figure) are respectively replaced by “AdminLoginServlet.login”. Therefore, the test programs Tp1 and Tp2 are programs that hook the call (execution) of the AdminLoginServlet.login method by the application and execute the around advice ad31 or ad32.

図47のaroundアドバイスad31において、ステップs81は、AdminLoginServlet.loginメソッドの第一引数であるidに対して文字列「dummy」を代入する。ステップs82aは、AdminLoginServlet.loginメソッドの第二引数であるpassに対して文字列「¥”or ¥”A¥”=¥”A」を代入する。   47, in step s81, the character string “dummy” is substituted for id which is the first argument of the AdminLoginServlet.login method. In step s82a, the character string "\" or \ "A \" = \ "A" is substituted for pass, which is the second argument of the AdminLoginServlet.login method.

ステップs83は、本来実行すべき処理(図45のAdminLoginServlet.loginメソッド)を実行し、その戻り値をresultに格納する。したがって、ステップs83では、第一引数及び第二引数に関して、ステップs81及びs82aにおいて強制的に代入された値に基づいて、AdminLoginServlet.loginメソッドが実行される。なお、AdminLoginServlet.loginメソッドは、認証に成功した場合「true」を返却し、認証に失敗した場合「false」を返却する。したがって、ステップs83のresultには、認証結果が格納される。ステップs84aは、認証結果を出力する。   In step s83, a process to be originally executed (AdminLoginServlet.login method in FIG. 45) is executed, and the return value is stored in the result. Therefore, in step s83, the AdminLoginServlet.login method is executed based on the values forcibly substituted in steps s81 and s82a for the first argument and the second argument. Note that the AdminLoginServlet.login method returns “true” when authentication is successful, and returns “false” when authentication fails. Therefore, the authentication result is stored in the result of step s83. Step s84a outputs the authentication result.

一方、図48のaroundアドバイスad32において、図47のaroundアドバイスad31と同一ステップには同一ステップ番号を付している。ここでは、ステップ番号が異なる部分について説明する。ステップs82bは、AdminLoginServlet.loginメソッドの第二引数であるpassに対して文字列「¥’or ¥’A¥’=¥’A」を代入する。当該文字列は、図47のステップs82aの文字列「¥”or ¥”A¥”=¥”A」の二重引用符(”)が、一重引用符(’)に置き換えられたものである。また、ステップs83bは、AdminLoginServlet.loginメソッドの戻り値(すなわち、認証結果)を出力する。ステップs83bは、認証結果とともに出力される文字列(「SQL−inj_single_quot result=」)が、図47のステップs83aにおける文字列(「SQL−inj_double_quot result=」)と異なる。図47のテストプログラムTp1の実行結果と、図48のテストプログラムTp2の実行結果とを識別可能とするためである。   On the other hand, in the around advice ad32 in FIG. 48, the same step number is assigned to the same step as the around advice ad31 in FIG. Here, the parts with different step numbers will be described. In step s82b, the character string "\ 'or \' A \ '= \' A" is substituted for pass, which is the second argument of the AdminLoginServlet.login method. The character string is obtained by replacing the double quotation mark (") of the character string" \ "or \" A \ "= \" A "in step s82a of FIG. 47 with a single quotation mark ('). Step s83b outputs the return value (that is, the authentication result) of the AdminLoginServlet.login method, and step s83b outputs a character string ("SQL-inj_single_quot result =") that is output together with the authentication result as shown in FIG. It is different from the character string (“SQL-inj_double_quote result =”) in step s83a. This is because the execution result of the test program Tp1 in FIG. 47 and the execution result of the test program Tp2 in FIG. 48 can be identified.

なお、テストプログラムTp1及びテストプログラムTp2は、いずれも、SQLインジェクションを試みるためのテストプログラムTpである。すなわち、本来であれば、テストプログラムTp1及びテストプログラムTp2の双方のケースにおいて、認証は失敗しなければならない。テストプログラムTp1及びテストプログラムTp2において指定される、id及びpassは、正当なid又はpassでないからである。   Note that the test program Tp1 and the test program Tp2 are both test programs Tp for attempting SQL injection. That is, originally, authentication must fail in both cases of the test program Tp1 and the test program Tp2. This is because the id and pass specified in the test program Tp1 and the test program Tp2 are not valid id or pass.

しかし、アプリケーションap1では、メソッド(b)が呼び出されていない、したがって、テストプログラムTp1がアプリケーションap1に適用された場合は、認証は失敗するが、テストプログラムTp2がアプリケーションap1に適用された場合は、認証は成功してしまう。すなわち、テストプログラムTp2のケースでは、SQLインジェクションに成功してしまう。   However, in the application ap1, the method (b) is not called. Therefore, when the test program Tp1 is applied to the application ap1, the authentication fails, but when the test program Tp2 is applied to the application ap1, Authentication succeeds. That is, in the case of the test program Tp2, SQL injection is successful.

その結果、テストプログラムTp2によって、アプリケーションap1に関して、セキュリティの脆弱性を検出することができる。すなわち、以下の二つのケースのうち、アプリケーションap1は、ケースDに該当することが分かる。
(B)誤った実装の可能性が有り、結果はOK
(D)誤った実装の可能性が有り、結果はNG
したがって、テスト実施者は、メソッド(b)を呼び出すように、アプリケーションap1の修正が必要であることを認識することができる。
As a result, it is possible to detect security vulnerabilities for the application ap1 by the test program Tp2. That is, it can be seen that the application ap1 corresponds to the case D among the following two cases.
(B) There is a possibility of incorrect mounting, and the result is OK.
(D) There is a possibility of incorrect mounting, the result is NG
Therefore, the tester can recognize that the application ap1 needs to be corrected so as to call the method (b).

なお、仮に、履歴記録プログラムPr及び検出プログラムPcによる検出ログによる検出ログに基づくテストプログラムTpによるブラックボックステストではなく、一般的なブラックボックステストのみが実行された場合を考える。この場合、たまたまテストプログラムTp1に相当するブラックボックステストが実行されれば、アプリケーションap1に関してAdminLoginServlet.loginメソッドにおける認証は失敗する。したがって、テスト実施者は、以下のケースA又はケースBのいずれかに該当することまでは認識することはできる。
(A)正しい実装で、かつ、結果もOK
(B)誤った実装の可能性が有り、結果はOK
しかし、ケースAとケースBとのいずれに該当するのかに関して、即座に区別するのは困難である。
It is assumed that only a general black box test is executed instead of a black box test by the test program Tp based on the detection log by the detection log by the history recording program Pr and the detection program Pc. In this case, if a black box test corresponding to the test program Tp1 happens to be executed, authentication in the AdminLoginServlet.login method for the application ap1 fails. Therefore, the tester can recognize that the case falls under either case A or case B below.
(A) Correct implementation and result is OK
(B) There is a possibility of incorrect mounting, and the result is OK.
However, it is difficult to immediately distinguish whether it corresponds to case A or case B.

また、たまたまテストプログラムTp2に相当するブラックボックステストが実行されれば、アプリケーションap1に関してAdminLoginServlet.loginメソッドにおける認証は成功する。したがって、テスト実施者は、以下のケースC又はケースDのいずれかに該当することまでは認識することはできる。
(C)正しい実装であるにも拘わらず、結果はNG
(D)誤った実装の可能性が有り、結果はNG
しかし、ケースCとケースBとのいずれに該当するのかに関して、即座に区別するのは困難である。
If a black box test corresponding to the test program Tp2 happens to be executed, authentication in the AdminLoginServlet.login method is successful for the application ap1. Therefore, the tester can recognize that it corresponds to one of the following cases C or D.
(C) Despite the correct implementation, the result is NG
(D) There is a possibility of incorrect mounting, the result is NG
However, it is difficult to immediately distinguish whether it corresponds to case C or case B.

上述したように、本実施の形態によれば、まず、文脈上のルール違反の有無の検出が行われ、検出結果に基づいて、ブラックボックステストを実施する箇所が絞り込まれる。また、当該検出結果に基づいて、ブラックボックステスト用のテストプログラムTpが自動生成される。   As described above, according to the present embodiment, first, the presence / absence of a rule violation in context is detected, and the locations where the black box test is performed are narrowed down based on the detection result. Also, a test program Tp for black box test is automatically generated based on the detection result.

したがって、絞り込まれた箇所に関して、ブラックボックステストを詳細に実施することができる。その結果、当初からブラックボックステストのみを実施する場合に比べて、バグの検出精度を向上させることができる。また、ブラックボックステストを詳細に実施する箇所は絞り込まれているため、テスト作業の効率化を期待することができる。   Therefore, the black box test can be carried out in detail with respect to the narrowed portions. As a result, the bug detection accuracy can be improved as compared with the case where only the black box test is performed from the beginning. In addition, since the locations where the black box test is carried out in detail are narrowed down, it is possible to expect an increase in the efficiency of the test work.

なお、上記ケースA〜Dのうち、ケースA及びケースCと、ケースB及びケースDとについては、ブラックボックスの実施以前に、ルールに基づく検出ログによって判別することができる。また、ケースAとケースCとの判別、及びケースBとケースDとについては、検出ログ、テストポリシー、及びシナリオコードに基づいて自動生成されるテストプログラムTpによるブラックボックスに基づいて、判別することができる。   Of the cases A to D, the case A and the case C, and the case B and the case D can be determined by a detection log based on a rule before the black box is executed. In addition, the case A and the case C are discriminated, and the case B and the case D are discriminated based on a black box by the test program Tp automatically generated based on the detection log, the test policy, and the scenario code. Can do.

また、検査対象のプログラムが様々な処理フローを含んでいる場合、ブラックボックステストが本来想定している処理フローのカバレッジ(網羅性)を満たしているか否かを、ブラックボックステストの結果と検出ログとを合わせて閲覧することで、検証することができる。その結果、テストの網羅性の向上を期待できる。   In addition, if the program to be inspected contains various processing flows, the black box test results and the detection log indicate whether the black box test satisfies the processing flow coverage originally assumed. It is possible to verify by browsing together. As a result, it can be expected that test coverage will be improved.

また、ルール違反の有無の検出結果とシナリオコードとは、テストポリシーによって関連付けることができる。テストポリシーは、テスト実施者が有するブラックボックステストに関する方針又は意図等に基づいて作成することができる。したがって、テスト実施者の方針又は意図等に応じて、当該検出結果とシナリオコードとを自由に関連付けることができる。   Further, the detection result of rule violation and the scenario code can be associated with each other by a test policy. The test policy can be created based on a policy or intention regarding the black box test owned by the tester. Therefore, the detection result and the scenario code can be freely associated according to the policy or intention of the tester.

また、テストポリシーは、ルール名とルール違反の有無の検出箇所との組み合わせに応じてシナリオコードを関連付ける。換言すれば、検出箇所に応じて異なるシナリオコードを関連付けることができる。その結果、検出箇所に適したシナリオコードに基づくテストプログラムTpを生成することができる。   The test policy associates a scenario code according to a combination of a rule name and a location where a rule violation is detected. In other words, different scenario codes can be associated depending on the detected location. As a result, the test program Tp based on the scenario code suitable for the detected location can be generated.

また、本実施の形態によれば、ルール記述を作成することにより、当該ルール記述に基づいて、履歴記録プログラムPr及び検出プログラムPcが自動生成される。当該履歴記録プログラムPr及び検出プログラムPcを、ライブラリを利用するアプリケーションに適用することにより、当該アプリケーションによる当該ライブラリの利用の適否を検査することができる。したがって、テストプログラム生成装置10は、ライブラリの文脈上のルールに対する違反の検出を適切に支援することができる。   Further, according to the present embodiment, by creating a rule description, the history recording program Pr and the detection program Pc are automatically generated based on the rule description. By applying the history recording program Pr and the detection program Pc to an application that uses a library, it is possible to check whether or not the library is used by the application. Therefore, the test program generation device 10 can appropriately support detection of violations of rules in the context of the library.

より詳しくは、履歴記録プログラムPrは、ライブラリのメソッドの呼び出し履歴を採取し、記録しておく。検出プログラムPcは、履歴の内容が、ライブラリの文脈上のルールに適合しているか否かを判定する。したがって、デバッガのようにコールスタック(呼び出しの親子関係)だけではない、呼出の有無又は前後関係に関するルール違反の検出が可能になる。   More specifically, the history recording program Pr collects and records a library method call history. The detection program Pc determines whether or not the history contents conform to the contextual rules of the library. Therefore, it is possible to detect not only the call stack (call parent-child relationship) but also a rule violation related to the presence or absence of the call or the context as in the debugger.

また、本実施の形態では、メソッドの呼び出しに対して動的なフック機構が採用されて、アプリケーションによるライブラリの呼出が検知される。したがって、ライブラリ又はアプリケーションのソースコード等に修正を加える必要はない。その結果、例えば、ライブラリの作成後に、後付けでルールを作成し、ライブラリと一体化して提供することもできる。そうすることにより、検査ツールを別途提供されなくても、アプリケーションのテストの過程で、文脈上のルール違反を自動的に検出することができる。   In the present embodiment, a dynamic hook mechanism is employed for method invocation, and library invocation by an application is detected. Therefore, there is no need to modify the library or application source code. As a result, for example, after the library is created, a rule can be created later and can be provided integrally with the library. By doing so, it is possible to automatically detect contextual rule violations in the course of application testing without providing a separate inspection tool.

なお、本実施の形態において、履歴記録プログラムPrは、履歴記録部の一例である。検出プログラムPcは、検出部の一例である。テストプログラム生成部15は、生成部の一例である。   In the present embodiment, the history recording program Pr is an example of a history recording unit. The detection program Pc is an example of a detection unit. The test program generation unit 15 is an example of a generation unit.

以上、本発明の実施例について詳述したが、本発明は斯かる特定の実施形態に限定されるものではなく、特許請求の範囲に記載された本発明の要旨の範囲内において、種々の変形・変更が可能である。   As mentioned above, although the Example of this invention was explained in full detail, this invention is not limited to such specific embodiment, In the range of the summary of this invention described in the claim, various deformation | transformation・ Change is possible.

以上の説明に関し、更に以下の項を開示する。
(付記1)
メソッドの集合を利用する利用プログラムによる前記メソッドの実行の検知に応じて該実行の履歴を記録し、
前記履歴を、記憶部が記憶する、前記メソッドの集合に関する文脈上の規則情報と照合して、前記利用プログラムによる前記メソッドの実行に関して前記規則情報に対する違反を検出し、検出結果を前記記憶部に記録し、
前記規則情報と前記検出結果との組み合わせに対応付けて前記記憶部が記憶するテストコードを実行させるテストプログラムを生成する処理をコンピュータが実行するテストプログラム生成方法。
(付記2)
前記検出結果は、前記違反が検出された前記メソッドのメソッド名を含み、
前記生成する処理は、前記メソッド名に係る前記メソッドの実行の検出に応じて前記テストプコードを実行させる前記テストプログラムを生成する付記1記載のテストプログラム生成方法。
(付記3)
前記規則情報に係る前記メソッドの実行の検知に応じて該実行の履歴を記録する履歴記録プログラムを生成する処理と、
前記履歴を前記規則情報と照合して前記利用プログラムによる前記メソッドの実行に関して前記規則情報に対する違反を検出する検出プログラムを生成する処理とを前記コンピュータが実行し、
前記履歴プログラムは、前記履歴を記録する処理を前記コンピュータに実行させ、
前記検出プログラムは、前記検出手順を前記コンピュータに実行させる付記1又は2記載のテストプログラム生成方法。
(付記4)
前記規則情報は、cメソッド内において、bメソッドが実行される場合はbメソッドの実行前にaメソッドが実行されなければならないことを規定し、
前記履歴を記録する処理は、cメソッドの実行の検知に応じ、aメソッドが呼び出されていないことを記録し、aメソッドの実行の検知に応じ、aメソッドが実行されたことを記録し、bメソッドの実行の検知に応じ、aメソッドが実行されたか否かに基づいて当該規則情報に規定された要件が満たされたか否かを検出する付記1乃至3いずれか一項記載のテストプログラム生成方法。
(付記5)
前記規則情報は、fメソッド内において、eメソッドが実行される場合はeメソッドの実行後にdメソッドが実行されなければならないことを規定し、
前記履歴を記録する処理は、fメソッドの実行の検知に応じ、当該規則情報に規定された要件が満たされていることを記録し、eメソッドの実行の検知に応じ、当該要件が満たされていないことを記録し、dメソッドの実行の検知に応じ、当該要件が満たされていることを検出する付記1乃至4いずれか一項記載のテストプログラム生成方法。
(付記6)
前記規則情報は、hメソッド内において、gメソッドが実行されなければならないことを規定し、
前記履歴を記録する処理は、hメソッドの実行の検知に応じ、当該規則情報に規定された要件が満たされていないことを記録し、gメソッドの実行の検知に応じ、当該要件が満たされていることを検出する付記1乃至5いずれか一項記載のテストプログラム生成方法。
(付記7)
メソッドの集合を利用する利用プログラムによる前記メソッドの実行の検知に応じて該実行の履歴を記録する履歴記録部と、
前記履歴を、記憶部が記憶する、前記メソッドの集合に関する文脈上の規則情報と照合して、前記利用プログラムによる前記メソッドの実行に関して前記規則情報に対する違反を検出し、検出結果を前記記憶部に記録する検出部と、
前記規則情報と前記検出結果との組み合わせに対応付けて前記記憶部が記憶するテストコードを実行させるテストプログラムを生成する生成部とを有するテストプログラム生成装置。
(付記8)
前記検出結果は、前記違反が検出された前記メソッドのメソッド名を含み、
前記生成部は、前記メソッド名に係る前記メソッドの実行の検出に応じて前記テストプコードを実行させる前記テストプログラムを生成する付記7記載のテストプログラム生成装置。
(付記9)
前記規則情報に係る前記メソッドの実行の検知に応じて該実行の履歴を記録する履歴記録プログラムを生成する履歴記録プログラム生成部と、
前記履歴を前記規則情報と照合して前記利用プログラムによる前記メソッドの実行に関して前記規則情報に対する違反を検出する検出プログラムを生成する検出プログラム生成部とを有し、
前記履歴プログラムは、前記履歴記録部として前記テストプログラム生成装置を機能させ、
前記検出プログラムは、前記検出部として前記テストプログラム生成装置を機能させる付記7又は8記載のテストプログラム生成装置。
(付記10)
前記規則情報は、cメソッド内において、bメソッドが実行される場合はbメソッドの実行前にaメソッドが実行されなければならないことを規定し、
前記履歴記録部は、cメソッドの実行の検知に応じ、aメソッドが呼び出されていないことを記録し、aメソッドの実行の検知に応じ、aメソッドが実行されたことを記録し、bメソッドの実行の検知に応じ、aメソッドが実行されたか否かに基づいて当該規則情報に規定された要件が満たされたか否かを検出する付記7乃至9いずれか一項記載のテストプログラム生成装置。
(付記11)
前記規則情報は、fメソッド内において、eメソッドが実行される場合はeメソッドの実行後にdメソッドが実行されなければならないことを規定し、
前記履歴記録部は、fメソッドの実行の検知に応じ、当該規則情報に規定された要件が満たされていることを記録し、eメソッドの実行の検知に応じ、当該要件が満たされていないことを記録し、dメソッドの実行の検知に応じ、当該要件が満たされていることを検出する付記7乃至10いずれか一項記載のテストプログラム生成装置。
(付記12)
前記規則情報は、hメソッド内において、gメソッドが実行されなければならないことを規定し、
前記履歴記録部は、hメソッドの実行の検知に応じ、当該規則情報に規定された要件が満たされていないことを記録し、gメソッドの実行の検知に応じ、当該要件が満たされていることを検出する付記7乃至11いずれか一項記載のテストプログラム生成装置。
(付記13)
メソッドの集合を利用する利用プログラムによる前記メソッドの実行の検知に応じて該実行の履歴を記録し、
前記履歴を、記憶部が記憶する、前記メソッドの集合に関する文脈上の規則情報と照合して、前記利用プログラムによる前記メソッドの実行に関して前記規則情報に対する違反を検出し、検出結果を前記記憶部に記録し、
前記規則情報と前記検出結果との組み合わせに対応付けて前記記憶部が記憶するテストコードを実行させるテストプログラムを生成する処理をコンピュータに実行させるテストプログラム生成プログラム。
(付記14)
前記検出結果は、前記違反が検出された前記メソッドのメソッド名を含み、
前記生成する処理は、前記メソッド名に係る前記メソッドの実行の検出に応じて前記テストプコードを実行させる前記テストプログラムを生成する付記13記載のテストプログラム生成プログラム。
(付記15)
記規則情報に係る前記メソッドの実行の検知に応じて該実行の履歴を記録する履歴記録プログラムを生成する履歴記録プログラム生成する処理と、
前記履歴を前記規則情報と照合して前記利用プログラムによる前記メソッドの実行に関して前記規則情報に対する違反を検出する検出プログラムを生成する検出プログラム生成する処理とを前記コンピュータに実行させ、
前記履歴プログラムは、前記履歴を記録する処理を前記コンピュータに実行させ、
前記検出プログラムは、前記検出手順を前記コンピュータに実行させる付記13又は14記載のテストプログラム生成プログラム。
(付記16)
前記規則情報は、cメソッド内において、bメソッドが実行される場合はbメソッドの実行前にaメソッドが実行されなければならないことを規定し、
前記履歴を記録する処理は、cメソッドの実行の検知に応じ、aメソッドが呼び出されていないことを記録し、aメソッドの実行の検知に応じ、aメソッドが実行されたことを記録し、bメソッドの実行の検知に応じ、aメソッドが実行されたか否かに基づいて当該規則情報に規定された要件が満たされたか否かを検出する付記13乃至15いずれか一項記載のテストプログラム生成プログラム。
(付記17)
前記規則情報は、fメソッド内において、eメソッドが実行される場合はeメソッドの実行後にdメソッドが実行されなければならないことを規定し、
前記履歴を記録する処理は、fメソッドの実行の検知に応じ、当該規則情報に規定された要件が満たされていることを記録し、eメソッドの実行の検知に応じ、当該要件が満たされていないことを記録し、dメソッドの実行の検知に応じ、当該要件が満たされていることを検出する付記13乃至16いずれか一項記載のテストプログラム生成プログラム。
(付記18)
前記規則情報は、hメソッド内において、gメソッドが実行されなければならないことを規定し、
前記履歴を記録する処理は、hメソッドの実行の検知に応じ、当該規則情報に規定された要件が満たされていないことを記録し、gメソッドの実行の検知に応じ、当該要件が満たされていることを検出する付記13乃至17いずれか一項記載のテストプログラム生成プログラム。
Regarding the above description, the following items are further disclosed.
(Appendix 1)
Record the execution history according to the detection of the execution of the method by the using program that uses the set of methods,
The history is collated with contextual rule information regarding the set of methods stored in the storage unit, a violation of the rule information regarding execution of the method by the use program is detected, and a detection result is stored in the storage unit. Record,
A test program generation method in which a computer executes a process of generating a test program for executing a test code stored in the storage unit in association with a combination of the rule information and the detection result.
(Appendix 2)
The detection result includes a method name of the method in which the violation is detected,
The test program generation method according to appendix 1, wherein the generation process generates the test program for executing the test precode in response to detection of execution of the method relating to the method name.
(Appendix 3)
A process of generating a history recording program for recording a history of the execution in response to detection of the execution of the method according to the rule information;
The computer executes a process of collating the history with the rule information and generating a detection program for detecting violations of the rule information with respect to the execution of the method by the utilization program,
The history program causes the computer to execute processing for recording the history,
The test program generation method according to appendix 1 or 2, wherein the detection program causes the computer to execute the detection procedure.
(Appendix 4)
The rule information specifies that in the c method, if the b method is executed, the a method must be executed before the b method is executed.
The process of recording the history records that the a method has not been called in response to detection of execution of the c method, records that the a method has been executed in response to detection of execution of the a method, and b The test program generation method according to any one of appendices 1 to 3, wherein the test program generation method detects whether or not the requirement defined in the rule information is satisfied based on whether or not the method a is executed in response to detection of the execution of the method. .
(Appendix 5)
The rule information specifies that, in the f method, if the e method is executed, the d method must be executed after the e method is executed.
The process of recording the history records that the requirement specified in the rule information is satisfied according to the detection of the execution of the f method, and the requirement is satisfied according to the detection of the execution of the e method. 5. The test program generation method according to any one of appendices 1 to 4, wherein the test program generation method records that there is no data and detects that the requirement is satisfied in response to detection of execution of the d method.
(Appendix 6)
The rule information specifies that the g method must be executed in the h method,
The process of recording the history records that the requirement specified in the rule information is not satisfied according to the detection of the execution of the h method, and the requirement is satisfied according to the detection of the execution of the g method. The test program generation method according to any one of appendices 1 to 5, wherein the test program is detected.
(Appendix 7)
A history recording unit that records a history of the execution in response to detection of the execution of the method by a use program that uses a set of methods;
The history is collated with contextual rule information regarding the set of methods stored in the storage unit, a violation of the rule information regarding execution of the method by the use program is detected, and a detection result is stored in the storage unit. A detector for recording;
A test program generation apparatus comprising: a generation unit that generates a test program that executes a test code stored in the storage unit in association with a combination of the rule information and the detection result.
(Appendix 8)
The detection result includes a method name of the method in which the violation is detected,
The test program generation device according to appendix 7, wherein the generation unit generates the test program for executing the test precode in response to detection of execution of the method relating to the method name.
(Appendix 9)
A history recording program generating unit that generates a history recording program for recording the history of the execution in response to detection of the execution of the method according to the rule information;
A detection program generating unit that generates a detection program for detecting violations of the rule information with respect to execution of the method by the use program by comparing the history with the rule information;
The history program causes the test program generation device to function as the history recording unit,
The test program generation device according to appendix 7 or 8, wherein the detection program causes the test program generation device to function as the detection unit.
(Appendix 10)
The rule information specifies that in the c method, if the b method is executed, the a method must be executed before the b method is executed.
The history recording unit records that the a method has not been called in response to detection of execution of the c method, records that the a method has been executed in response to detection of execution of the a method, 10. The test program generation device according to any one of appendices 7 to 9, which detects whether or not a requirement defined in the rule information is satisfied based on whether or not the a method has been executed in response to detection of execution.
(Appendix 11)
The rule information specifies that, in the f method, if the e method is executed, the d method must be executed after the e method is executed.
The history recording unit records that the requirement specified in the rule information is satisfied according to the detection of the execution of the f method, and the requirement is not satisfied according to the detection of the execution of the e method. The test program generation device according to any one of appendices 7 to 10, wherein the test program generation device detects that the requirement is satisfied in response to detection of execution of the d method.
(Appendix 12)
The rule information specifies that the g method must be executed in the h method,
The history recording unit records that the requirement specified in the rule information is not satisfied in response to detection of execution of the h method, and that the requirement is satisfied in response to detection of execution of the g method. 12. The test program generation device according to any one of appendices 7 to 11 for detecting the error
(Appendix 13)
Record the execution history according to the detection of the execution of the method by the using program that uses the set of methods,
The history is collated with contextual rule information regarding the set of methods stored in the storage unit, a violation of the rule information regarding execution of the method by the use program is detected, and a detection result is stored in the storage unit. Record,
A test program generation program for causing a computer to execute a process for generating a test program for executing a test code stored in the storage unit in association with a combination of the rule information and the detection result.
(Appendix 14)
The detection result includes a method name of the method in which the violation is detected,
14. The test program generation program according to appendix 13, wherein the generation process generates the test program for executing the test precode in response to detection of execution of the method relating to the method name.
(Appendix 15)
Processing for generating a history recording program for generating a history recording program for recording the history of the execution in response to detection of execution of the method according to the rule information;
Causing the computer to execute a process for generating a detection program for generating a detection program for detecting violations of the rule information with respect to the execution of the method by the usage program by comparing the history with the rule information;
The history program causes the computer to execute processing for recording the history,
15. The test program generation program according to appendix 13 or 14, wherein the detection program causes the computer to execute the detection procedure.
(Appendix 16)
The rule information specifies that in the c method, if the b method is executed, the a method must be executed before the b method is executed.
The process of recording the history records that the a method has not been called in response to detection of execution of the c method, records that the a method has been executed in response to detection of execution of the a method, and b The test program generation program according to any one of appendices 13 to 15, which detects whether or not a requirement defined in the rule information is satisfied based on whether or not the method a has been executed in response to detection of method execution. .
(Appendix 17)
The rule information specifies that, in the f method, if the e method is executed, the d method must be executed after the e method is executed.
The process of recording the history records that the requirement specified in the rule information is satisfied according to the detection of the execution of the f method, and the requirement is satisfied according to the detection of the execution of the e method. 17. The test program generation program according to any one of appendices 13 to 16, wherein the test program generation program records that the requirement is satisfied in response to detection of the execution of the d method.
(Appendix 18)
The rule information specifies that the g method must be executed in the h method,
The process of recording the history records that the requirement specified in the rule information is not satisfied according to the detection of the execution of the h method, and the requirement is satisfied according to the detection of the execution of the g method. 18. The test program generation program according to any one of supplementary notes 13 to 17, which detects that the

10 テストプログラム生成装置
11 ルール記述記憶部
12 ルール解析部
13 プログラム生成部
14 雛形データ記憶部
15 テストプログラム生成部
16 検出ログ記憶部
17 テストポリシーリスト記憶部
18 シナリオコード記憶部
100 ドライブ装置
101 記録媒体
102 補助記憶装置
103 メモリ装置
104 CPU
105 インタフェース装置
106 表示装置
107 入力装置
131 履歴記録プログラム生成部
132 検出プログラム生成部
B バス
Pr 履歴記録プログラム
Pc 検出プログラム
Tp テストプログラム
DESCRIPTION OF SYMBOLS 10 Test program generation apparatus 11 Rule description storage part 12 Rule analysis part 13 Program generation part 14 Model data storage part 15 Test program generation part 16 Detection log storage part 17 Test policy list storage part 18 Scenario code storage part 100 Drive apparatus 101 Recording medium 102 Auxiliary storage device 103 Memory device 104 CPU
105 Interface Device 106 Display Device 107 Input Device 131 History Recording Program Generation Unit 132 Detection Program Generation Unit B Bus Pr History Recording Program Pc Detection Program Tp Test Program

Claims (5)

メソッドの集合を利用する利用プログラムによる前記メソッドの実行の検知に応じて該実行の履歴を記録し、
前記履歴を、記憶部が記憶する、前記メソッドの集合に関する文脈上の規則情報と照合して、前記利用プログラムによる前記メソッドの実行に関して前記規則情報に対する違反を検出し、検出結果を前記記憶部に記録し、
前記規則情報と前記検出結果との組み合わせに対応付けて前記記憶部が記憶するテストコードを実行させるテストプログラムを生成する処理をコンピュータが実行するテストプログラム生成方法。
Record the execution history according to the detection of the execution of the method by the using program that uses the set of methods,
The history is collated with contextual rule information regarding the set of methods stored in the storage unit, a violation of the rule information regarding execution of the method by the use program is detected, and a detection result is stored in the storage unit. Record,
A test program generation method in which a computer executes a process of generating a test program for executing a test code stored in the storage unit in association with a combination of the rule information and the detection result.
前記検出結果は、前記違反が検出された前記メソッドのメソッド名を含み、
前記生成する処理は、前記メソッド名に係る前記メソッドの実行の検出に応じて前記テストプコードを実行させる前記テストプログラムを生成する請求項1記載のテストプログラム生成方法。
The detection result includes a method name of the method in which the violation is detected,
The test program generation method according to claim 1, wherein the generating process generates the test program for executing the test precode in response to detection of execution of the method related to the method name.
前記規則情報に係る前記メソッドの実行の検知に応じて該実行の履歴を記録する履歴記録プログラムを生成する処理と、
前記履歴を前記規則情報と照合して前記利用プログラムによる前記メソッドの実行に関して前記規則情報に対する違反を検出する検出プログラムを生成する処理とを前記コンピュータが実行し、
前記履歴プログラムは、前記履歴を記録する処理を前記コンピュータに実行させ、
前記検出プログラムは、前記検出手順を前記コンピュータに実行させる請求項1又は2記載のテストプログラム生成方法。
A process of generating a history recording program for recording a history of the execution in response to detection of the execution of the method according to the rule information;
The computer executes a process of collating the history with the rule information and generating a detection program for detecting violations of the rule information with respect to the execution of the method by the utilization program,
The history program causes the computer to execute processing for recording the history,
The test program generation method according to claim 1, wherein the detection program causes the computer to execute the detection procedure.
メソッドの集合を利用する利用プログラムによる前記メソッドの実行の検知に応じて該実行の履歴を記録する履歴記録部と、
前記履歴を、記憶部が記憶する、前記メソッドの集合に関する文脈上の規則情報と照合して、前記利用プログラムによる前記メソッドの実行に関して前記規則情報に対する違反を検出し、検出結果を前記記憶部に記録する検出部と、
前記規則情報と前記検出結果との組み合わせに対応付けて前記記憶部が記憶するテストコードを実行させるテストプログラムを生成する生成部とを有するテストプログラム生成装置。
A history recording unit that records a history of the execution in response to detection of the execution of the method by a use program that uses a set of methods;
The history is collated with contextual rule information regarding the set of methods stored in the storage unit, a violation of the rule information regarding execution of the method by the use program is detected, and a detection result is stored in the storage unit. A detector for recording;
A test program generation apparatus comprising: a generation unit that generates a test program that executes a test code stored in the storage unit in association with a combination of the rule information and the detection result.
メソッドの集合を利用する利用プログラムによる前記メソッドの実行の検知に応じて該実行の履歴を記録し、
前記履歴を、記憶部が記憶する、前記メソッドの集合に関する文脈上の規則情報と照合して、前記利用プログラムによる前記メソッドの実行に関して前記規則情報に対する違反を検出し、検出結果を前記記憶部に記録し、
前記規則情報と前記検出結果との組み合わせに対応付けて前記記憶部が記憶するテストコードを実行させるテストプログラムを生成する処理をコンピュータに実行させるテストプログラム生成プログラム。
Record the execution history according to the detection of the execution of the method by the using program that uses the set of methods,
The history is collated with contextual rule information regarding the set of methods stored in the storage unit, a violation of the rule information regarding execution of the method by the use program is detected, and a detection result is stored in the storage unit. Record,
A test program generation program for causing a computer to execute a process for generating a test program for executing a test code stored in the storage unit in association with a combination of the rule information and the detection result.
JP2011165947A 2011-07-28 2011-07-28 Method, device, and program for generating test program Withdrawn JP2013030017A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011165947A JP2013030017A (en) 2011-07-28 2011-07-28 Method, device, and program for generating test program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011165947A JP2013030017A (en) 2011-07-28 2011-07-28 Method, device, and program for generating test program

Publications (1)

Publication Number Publication Date
JP2013030017A true JP2013030017A (en) 2013-02-07

Family

ID=47786997

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011165947A Withdrawn JP2013030017A (en) 2011-07-28 2011-07-28 Method, device, and program for generating test program

Country Status (1)

Country Link
JP (1) JP2013030017A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5863973B2 (en) * 2012-08-01 2016-02-17 三菱電機株式会社 Program execution device and program analysis device
JP2016081400A (en) * 2014-10-21 2016-05-16 日本電信電話株式会社 Rule deviation application discovery device, rule deviation application discovery system, and rule deviation application discovery method
CN111198787A (en) * 2018-11-16 2020-05-26 长鑫存储技术有限公司 Test program generation method, test program generation device, storage medium and electronic equipment

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5863973B2 (en) * 2012-08-01 2016-02-17 三菱電機株式会社 Program execution device and program analysis device
JP2016081400A (en) * 2014-10-21 2016-05-16 日本電信電話株式会社 Rule deviation application discovery device, rule deviation application discovery system, and rule deviation application discovery method
CN111198787A (en) * 2018-11-16 2020-05-26 长鑫存储技术有限公司 Test program generation method, test program generation device, storage medium and electronic equipment
CN111198787B (en) * 2018-11-16 2021-11-02 长鑫存储技术有限公司 Test program generation method, test program generation device, storage medium and electronic equipment
US11960751B2 (en) 2018-11-16 2024-04-16 Changxin Memory Technologies, Inc. Test program generation method, device, memory medium and electronic equipment

Similar Documents

Publication Publication Date Title
US11514172B2 (en) System and method for information flow analysis of application code
CN109992970B (en) JAVA deserialization vulnerability detection system and method
US7797245B2 (en) Methods and systems for identifying an area of interest in protectable content
Martin-Lopez et al. Specification and automated analysis of inter-parameter dependencies in web APIs
Huang et al. Detecting sensitive data disclosure via bi-directional text correlation analysis
US10084819B1 (en) System for detecting source code security flaws through analysis of code history
De Lucia et al. Behavioral pattern identification through visual language parsing and code instrumentation
Pinheiro et al. Mutating code annotations: An empirical evaluation on Java and C# programs
Hildebrandt et al. Automatic conformance testing of optimized triple graph grammar implementations
Amankwah et al. Bug detection in Java code: An extensive evaluation of static analysis tools using Juliet Test Suites
JP2010267266A (en) Test support device and test support method
Pfeiffer et al. Taming the confusion of languages
JP2013030017A (en) Method, device, and program for generating test program
US8359579B2 (en) Monitoring dynamic aspect oriented applications at execution time
Grent et al. Automatically identifying parameter constraints in complex web APIs: A case study at adyen
Kirschner et al. Automatic derivation of vulnerability models for software architectures
Hammami et al. Towards a dynamic testing approach for checking the correctness of ethereum smart contracts
Corradini et al. Automated black-box testing of mass assignment vulnerabilities in RESTful APIs
Xie et al. Idea: interactive support for secure software development
JP5556480B2 (en) Context Violation Detection Support Method, Context Violation Detection Support Device, and Context Violation Detection Support Program
Agarwal et al. Copilot Evaluation Harness: Evaluating LLM-Guided Software Programming
Furda et al. A practical approach for detecting multi-tenancy data interference
Gao et al. Generating open api usage rule from error descriptions
Zhang et al. Aspect interference and composition in the motorola aspect-oriented modeling weaver
White et al. An early detection tool in Eclipse to support secure coding practices

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20141007