JP2024031735A - Source code modification support device and source code modification support method - Google Patents

Source code modification support device and source code modification support method Download PDF

Info

Publication number
JP2024031735A
JP2024031735A JP2022193242A JP2022193242A JP2024031735A JP 2024031735 A JP2024031735 A JP 2024031735A JP 2022193242 A JP2022193242 A JP 2022193242A JP 2022193242 A JP2022193242 A JP 2022193242A JP 2024031735 A JP2024031735 A JP 2024031735A
Authority
JP
Japan
Prior art keywords
source code
metrics
language
program module
list
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.)
Pending
Application number
JP2022193242A
Other languages
Japanese (ja)
Inventor
孝雄 澤田
祐司 菊田
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.)
Fuji Electric Co Ltd
Original Assignee
Fuji Electric Co 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 Fuji Electric Co Ltd filed Critical Fuji Electric Co Ltd
Publication of JP2024031735A publication Critical patent/JP2024031735A/en
Pending legal-status Critical Current

Links

Images

Abstract

【課題】ソースコードの一部を他の言語の記述に置き替える作業の労力を軽減する。【解決手段】ソースコード修正支援装置は、取得部、構造解析部、及び判定部を備える。取得部は、ソースコードの構造の分析に係わる複数のメトリクス項目それぞれに対してプログラムの複雑さを判断するための基準値およびプログラムの複雑さに対応する評価値を付与することで作成されるメトリクスルールリストを取得する。構造解析部は、第1の言語で記述されたソースコード中の各プログラムモジュールについて、各メトリクス項目に対応する基準値に違反しているか否かをそれぞれ判定し、基準値に違反しているメトリクス項目に対応する評価値の和を表す評価点数を計算する。判定部は、構造解析部により計算された評価点数に基づいて、各プログラムモジュールに対して、第2の言語への置換えの要否を判定する。【選択図】図1An object of the present invention is to reduce the labor involved in replacing part of a source code with a description in another language. A source code modification support device includes an acquisition section, a structure analysis section, and a determination section. The acquisition unit generates metrics by assigning a reference value for determining program complexity and an evaluation value corresponding to the program complexity to each of multiple metrics items related to analysis of source code structure. Get the rule list. The structure analysis unit determines whether or not each program module in the source code written in the first language violates the standard value corresponding to each metrics item, and identifies metrics that violate the standard value. Calculate the evaluation score representing the sum of evaluation values corresponding to the item. The determination unit determines whether or not each program module needs to be replaced with a second language based on the evaluation score calculated by the structure analysis unit. [Selection diagram] Figure 1

Description

本発明は、ソースコード内の記述を他の言語の記述に置き替える作業を支援する装置および方法に係わる。 The present invention relates to an apparatus and method for supporting the task of replacing a description in a source code with a description in another language.

ネットワークに接続する機会が増加したことに伴い、悪意ある第三者によりソフトウェアの脆弱性が狙われて不具合が発生するケースも増加してきている。このため、開発段階で、所定のセキュアコーディングルールに基づいてソースコードを解析することで、ソフトウェアの脆弱性を発見する作業が行われている。これにより、ソフトウェアの安全性が担保される。例えば、車載機器、産業機器、医療機器などの分野では、CERT(Computer Emergency Response Team)、MISRA(The Motor Industry Software Reliability Association)、AUTOSAR(Automotive Open System Architecture)などのセキュアコーディングルールが使用されている。 As opportunities for connecting to networks have increased, there has also been an increase in the number of cases in which malicious third parties are targeting software vulnerabilities and causing problems. For this reason, work is being done to discover software vulnerabilities during the development stage by analyzing source code based on predetermined secure coding rules. This ensures the safety of the software. For example, secure coding rules such as CERT (Computer Emergency Response Team), MISRA (The Motor Industry Software Reliability Association), and AUTOSAR (Automotive Open System Architecture) are used in fields such as automotive equipment, industrial equipment, and medical equipment. .

加えて、ソフトウェアの脆弱性を小さくするプログラミング言語が普及してきている。例えば、Rustは、メモリの安全性を保証する言語であり、C言語またはC++に代わる言語の1つとして注目されている。 In addition, programming languages that reduce software vulnerabilities are becoming popular. For example, Rust is a language that guarantees memory safety, and is attracting attention as one of the languages that can replace the C language or C++.

なお、ソースプログラムの実行処理順序の誤りを指摘するソースプログラム解析装置が提案されている(例えば、特許文献1)。また、あるプログラミング言語で記述されたソースコードを別のプログラミング言語によるソースコードに変換するソースコード変換装置が提案されている(例えば、特許文献2)。さらに、プログラムの修正またはデバッグを支援する装置が提案されている(例えば、特許文献3~4)。 Note that a source program analysis device that points out errors in the execution processing order of a source program has been proposed (for example, Patent Document 1). Furthermore, a source code conversion device has been proposed that converts source code written in one programming language to source code written in another programming language (for example, Patent Document 2). Furthermore, devices that support program modification or debugging have been proposed (for example, Patent Documents 3 and 4).

特開2006-236042号公報Japanese Patent Application Publication No. 2006-236042 特開2010-140408号公報Japanese Patent Application Publication No. 2010-140408 特開2021-192201号公報Japanese Patent Application Publication No. 2021-192201 特開2009-104252号公報JP2009-104252A

上述したように、Rust等の信頼性の高いプログラミング言語が普及してきている。他方、プログラム開発に要するコストおよび時間を抑制するために、可能な限り既存のソフトウェア製品を使い続けたいという要求がある。このため、既存のソフトウェアの脆弱性に対処するために、静的解析装置を利用して脆弱性を含む箇所を特定し、特定した箇所のみを信頼性の高い言語の記述で書き換えることがある。 As mentioned above, highly reliable programming languages such as Rust are becoming popular. On the other hand, there is a desire to continue using existing software products as much as possible in order to reduce the cost and time required for program development. Therefore, in order to deal with vulnerabilities in existing software, static analysis equipment may be used to identify locations that contain vulnerabilities, and only the identified locations may be rewritten with a description in a highly reliable language.

ただし、大規模なプログラムにおいては、脆弱性を含む箇所の個数も多くなる。このため、脆弱性を含む箇所すべてを信頼性の高い言語の記述で書き換える場合、作業時間が長くなってしまう。 However, in large-scale programs, the number of locations containing vulnerabilities increases. For this reason, it takes a long time to rewrite all parts that contain vulnerabilities with descriptions in a highly reliable language.

本発明の1つの側面に係わる目的は、ある言語で記述されたソースコードの一部を他の言語の記述に置き替える作業の労力を軽減することである。 An object of one aspect of the present invention is to reduce the labor involved in replacing part of a source code written in one language with one written in another language.

本発明の1つの態様のソースコード修正支援装置は、ソースコードの構造の分析に係わる複数のメトリクス項目それぞれに対してプログラムの複雑さを判断するための基準値およびプログラムの複雑さに対応する評価値を付与することで作成されるメトリクスルールリストを取得するメトリクスルールリスト取得部と、第1の言語で記述されたソースコード中の各プログラムモジュールについて、前記メトリクスルールリストに登録されている各メトリクス項目に対応する基準値に違反しているか否かをそれぞれ判定し、基準値に違反しているメトリクス項目に対応する評価値の和を表す評価点数を計算する構造解析部と、前記構造解析部により計算された評価点数に基づいて、各プログラムモジュールに対する対処方針を判定する判定部と、を備える。 A source code modification support device according to one aspect of the present invention provides a reference value for determining the complexity of a program for each of a plurality of metrics items related to analysis of the structure of a source code, and an evaluation corresponding to the complexity of the program. A metrics rule list acquisition unit that acquires a metrics rule list created by assigning values, and each metric registered in the metrics rule list for each program module in the source code written in the first language. a structural analysis unit that determines whether or not a standard value corresponding to each item is violated, and calculates an evaluation score representing the sum of evaluation values corresponding to metrics items that violate the standard value; and the structural analysis unit and a determination unit that determines a response policy for each program module based on the evaluation score calculated by.

上述の態様によれば、ある言語で記述されたソースコードの一部を他の言語の記述に置き替える作業の労力を軽減できる。 According to the above aspect, it is possible to reduce the labor involved in replacing part of a source code written in a certain language with a description in another language.

本発明の実施形態に係わるソースコード修正支援装置の一例を示す図である。FIG. 1 is a diagram showing an example of a source code modification support device according to an embodiment of the present invention. メトリクスリストの一例を示す図である。FIG. 3 is a diagram showing an example of a metrics list. メトリクスルール作成部の処理の一例を示すフローチャートである。3 is a flowchart illustrating an example of processing by a metrics rule creation unit. 評価値リストおよびメトリクスルールリストの一例を示す図である。It is a figure showing an example of an evaluation value list and a metrics rule list. 構造解析部の処理の一例を示すフローチャートである。5 is a flowchart illustrating an example of processing by a structure analysis unit. 構造解析部による分析結果を表す分析結果リストの一例を示す図である。It is a figure which shows an example of the analysis result list showing the analysis result by a structure analysis part. 判定部の処理の一例を示すフローチャートである。7 is a flowchart illustrating an example of processing by a determination unit. 他言語置換えリストおよび他処理リストの一例を示す図である。It is a figure showing an example of a foreign language substitution list and a foreign processing list. ソースコード修正装置および試験装置による処理の一例を示すフローチャートである。3 is a flowchart illustrating an example of processing by a source code modification device and a testing device. 本発明の第2の実施形態に係わるソースコード修正支援装置の一例を示す図である。FIG. 7 is a diagram showing an example of a source code modification support device according to a second embodiment of the present invention. セキュアコーディングルールの一例を示す図である。It is a figure which shows an example of a secure coding rule. 優先度リストおよびセキュリティルールリストの一例を示す図である。FIG. 3 is a diagram showing an example of a priority list and a security rule list. 静的解析部の処理の一例を示すフローチャートである。3 is a flowchart illustrating an example of processing by a static analysis unit. 静的解析部の検索結果を表す検索結果リストの一例を示す図である。FIG. 3 is a diagram illustrating an example of a search result list representing search results of a static analysis unit. 本発明の第2の実施形態における判定部の処理の一例を示すフローチャートである。It is a flowchart which shows an example of the process of the determination part in the 2nd Embodiment of this invention. 本発明の第2の実施形態における他言語置換えリストおよび他処理リストの一例を示す図である。It is a figure showing an example of the other language substitution list and the other processing list in the 2nd embodiment of the present invention. 本発明の第3の実施形態に係わるソースコード修正支援装置の一例を示す図である。It is a figure showing an example of a source code modification support device concerning a 3rd embodiment of the present invention. テンプレートの一例を示す図である。It is a figure showing an example of a template. テンプレート検索部の処理の一例を示すフローチャートである。7 is a flowchart illustrating an example of processing by a template search unit. テンプレート検索部による検索結果を表す検索結果リストの一例を示す図(その1)である。FIG. 2 is a diagram (part 1) showing an example of a search result list representing search results by a template search unit. テンプレート検索部による検索結果を表す検索結果リストの一例を示す図(その2)である。FIG. 7 is a diagram (part 2) illustrating an example of a search result list representing search results by the template search unit. 本発明の第3の実施形態における判定部の処理の一例を示すフローチャートである。It is a flowchart which shows an example of the process of the determination part in the 3rd Embodiment of this invention. 図20に示す検索結果リストに登録されている各プログラムモジュールに対して優先度を付与した状態を示す図である。21 is a diagram showing a state in which priorities are assigned to each program module registered in the search result list shown in FIG. 20. FIG. 図21に示す検索結果リストに登録されている各プログラムモジュールに対して優先度を付与した状態を示す図である。22 is a diagram showing a state in which priorities are assigned to each program module registered in the search result list shown in FIG. 21. FIG. 本発明の実施形態のバリエーションを示す図である。FIG. 6 is a diagram showing a variation of the embodiment of the present invention. ソースコード修正支援装置のハードウェア構成の一例を示す図である。FIG. 2 is a diagram illustrating an example of the hardware configuration of a source code modification support device.

図1は、本発明の実施形態に係わるソースコード修正支援装置の一例を示す。本発明の実施形態に係わるソースコード修正支援装置1は、メトリクス分析に基づいてソースコード2の中からリスクの高いプログラムモジュールを抽出し、抽出した各プログラムモジュールに対して対処方針を表す情報を出力する。なお、プログラムモジュールは、特に限定されるものではないが、例えば、1個の関数に対応する1まとまりの記述または処理を意味する。この場合、関数は、メソッドを含むものとする。 FIG. 1 shows an example of a source code modification support device according to an embodiment of the present invention. The source code modification support device 1 according to the embodiment of the present invention extracts high-risk program modules from the source code 2 based on metrics analysis, and outputs information representing a countermeasure for each extracted program module. do. Note that a program module is not particularly limited, but means, for example, a set of descriptions or processes corresponding to one function. In this case, the function shall include a method.

ソースコード2は、所定のプログラミング言語で記述された、コンパイル前のプログラムコードである。特に限定されるものではないが、この実施例では、ソースコード2は、C言語またはC++で記述されているものとする。また、ソースコード2は、既存のソフトウェア製品として使用されているプログラムコードであってもよい。さらに、ソースコード2は、複数のプログラムモジュールを含む。 Source code 2 is a pre-compiled program code written in a predetermined programming language. Although not particularly limited, it is assumed in this embodiment that the source code 2 is written in C language or C++. Further, the source code 2 may be a program code used as an existing software product. Furthermore, source code 2 includes multiple program modules.

メトリクスリスト3には、図2に示すように、ソースコードの複雑さ(規模、保守性などを含む)を定量的に示すための指標(すなわち、メトリクス)が登録されている。例えば、サイクロマティック複雑度(Cyclomatic)は、ソースコード中で使用される分岐条件の経路の数に1を加えた値を検出する。分岐条件としては、「if~then」「For~Next」「Case」「Catch」「While」などが想定される。また、最大ネスト数(MaxNesting)は、ソースコード中で使用される関数のネストの深さ(または、入れ子構造の段数)を表す。 As shown in FIG. 2, the metrics list 3 has registered therein indicators (that is, metrics) for quantitatively indicating the complexity (including scale, maintainability, etc.) of the source code. For example, cyclomatic complexity detects the value obtained by adding 1 to the number of branch condition paths used in the source code. Possible branch conditions include "if-then," "for-next," "case," "catch," and "while." Further, the maximum nesting number (MaxNesting) represents the nesting depth (or the number of stages of nested structure) of functions used in the source code.

ソースコード修正支援装置1は、図1に示すように、メトリクスルールリスト作成部11、メトリクスルールリスト取得部12、構造解析部13、および判定部14を備える。なお、ソースコード修正支援装置1は、図1に示していない他の機能またはデバイスを備えてもよい。 As shown in FIG. 1, the source code modification support device 1 includes a metrics rule list creation section 11, a metrics rule list acquisition section 12, a structure analysis section 13, and a determination section 14. Note that the source code modification support device 1 may include other functions or devices not shown in FIG.

メトリクスルールリスト作成部11には、メトリクスリスト3が与えられる。ここで、メトリクスリスト3には、上述したように、1以上のメトリクス項目が登録されている。そして、メトリクスルールリスト作成部11は、各メトリクス項目に対して基準値および評価値を付与することでメトリクスルールリストを作成する。なお、メトリクスルールリスト作成部11は、例えば、ソースコード2を修正する作業者がコンピュータを操作することで実現される。 The metrics list 3 is provided to the metrics rule list creation unit 11 . Here, as described above, one or more metrics items are registered in the metrics list 3. Then, the metrics rule list creation unit 11 creates a metrics rule list by assigning a reference value and an evaluation value to each metrics item. Note that the metrics rule list creation unit 11 is realized, for example, by an operator who modifies the source code 2 operating a computer.

図3は、メトリクスルールリスト作成部11の処理の一例を示すフローチャートである。このフローチャートの処理は、例えば、ソースコード修正支援装置1にソースコード2が与えられたときに実行される。ただし、メトリクスルールリスト作成部11は、ソースコード修正支援装置1にソースコード2が与えられる前に図3に示すフローチャートの処理を実行してもよい。 FIG. 3 is a flowchart showing an example of the processing of the metrics rule list creation unit 11. The processing in this flowchart is executed, for example, when the source code 2 is provided to the source code modification support device 1. However, the metrics rule list creation unit 11 may execute the process of the flowchart shown in FIG. 3 before the source code 2 is provided to the source code modification support device 1.

S1において、メトリクスルールリスト作成部11は、ソースコード2を修正する際の対処方針に係わる評価値リストを作成する。評価値リスト21は、図4(a)に示すように、メトリクスリスト3に登録されている各メトリクス項目に付与すべき評価値の定義を表す。評価値は、例えば、当該メトリクス項目の基準値を超えたときのセキュリティ上のリスクの深刻度に基づいて決定される。この実施例では、3段階の評価値が設定されているが、2段階または4段階以上の評価値を設定してもよい。 In S1, the metrics rule list creation unit 11 creates an evaluation value list related to a countermeasure when modifying the source code 2. As shown in FIG. 4(a), the evaluation value list 21 represents the definition of evaluation values to be given to each metrics item registered in the metrics list 3. The evaluation value is determined, for example, based on the severity of the security risk when the standard value of the metric item is exceeded. In this embodiment, evaluation values are set in three stages, but evaluation values in two stages, four stages or more may be set.

対処方針は、当該メトリクス項目の基準値を超えるプログラムモジュールに対してどのように対処するのかを表す。この実施例では、評価値に応じて図4(a)に示す方針が設定されている。すなわち、最もリスクが高い評価値「3」が付与されるメトリクス項目の基準を超えるプログラムモジュールに対しては「他の言語の記述に置き替える」が設定されている。2番目にリスクが高い評価値「2」が付与されるメトリクス項目の基準を超えるプログラムモジュールに対しては「他の言語の記述に置き替えることを推奨する」が設定されている。最もリスクが低い評価値「1」が付与されるメトリクス項目の基準を超えるプログラムモジュールに対しては「所定のポリシに基づいて修正する」が設定されている。 The response policy represents how to handle a program module that exceeds the standard value of the relevant metrics item. In this embodiment, the policy shown in FIG. 4(a) is set depending on the evaluation value. That is, "replace with description in another language" is set for a program module that exceeds the standard of the metrics item to which the evaluation value "3" with the highest risk is assigned. For program modules that exceed the standards of metrics items that are given the second highest risk evaluation value of "2," "recommended to be replaced with description in another language" is set. "Modify based on a predetermined policy" is set for a program module that exceeds the standard of the metrics item to which the lowest risk evaluation value "1" is assigned.

S2において、メトリクスルールリスト作成部11は、ソースコード修正支援装置1に与えられたメトリクスリスト3を取得する。S3において、メトリクスルールリスト作成部11は、各メトリクス項目に対応する基準値を取得する。この基準値は、例えば、プログラムモジュールが複雑であるか否かを判定する閾値に相当する。また、この基準値は、予め決められているものとする。S4において、メトリクスルールリスト作成部11は、メトリクスリスト3において各メトリクス項目に対応する基準値および評価値を付与することでメトリクスルールリストを作成する。この実施例では、図2に示す各メトリクス項目に対して所定の基準値および図4(a)に示す評価値を付与することで、図4(b)に示すメトリクスルールリスト22が得られる。 In S2, the metrics rule list creation unit 11 obtains the metrics list 3 given to the source code modification support device 1. In S3, the metrics rule list creation unit 11 acquires a reference value corresponding to each metrics item. This reference value corresponds to, for example, a threshold value for determining whether a program module is complicated. Further, it is assumed that this reference value is determined in advance. In S4, the metrics rule list creation unit 11 creates a metrics rule list by assigning a reference value and an evaluation value corresponding to each metrics item in the metrics list 3. In this embodiment, the metrics rule list 22 shown in FIG. 4(b) is obtained by assigning a predetermined reference value and the evaluation value shown in FIG. 4(a) to each metrics item shown in FIG. 2.

例えば、ソースコードが、インパクトスケール(ImpactScale)の基準値を超えるプログラムモジュールを含むときは、重大な障害が発生する可能性があると考えられる。したがって、このメトリクス項目に対して大きな評価値「3」が付与される。また、ソースコードが、凝縮度の欠如(PercentLackOfCohesion)の基準値を超えるプログラムモジュールを含むときは、何らかの障害が発生する可能性があるものの、重大な障害が発生する可能性は高くないと考えられる。したがって、このメトリクス項目に対しては、中間レベルの評価値「2」が付与される。なお、サイクロマティック複雑度(Cyclomatic)、最大ネスト数(MaxNesting)、入力数(CountInput)の基準値を超えるプログラムモジュールを含む場合であっても、重大な障害が発生する可能性は低いと考えられる。したがって、これらのメトリック項目に対しては、小さい評価値「1」が付与される。 For example, if the source code includes a program module that exceeds the impact scale (ImpactScale) standard value, it is considered that a serious failure may occur. Therefore, a large evaluation value of "3" is assigned to this metrics item. In addition, when the source code includes a program module that exceeds the standard value of lack of condensation (PercentLackOfCohesion), although some failures may occur, it is considered that the possibility of serious failures is not high. . Therefore, this metrics item is given an intermediate evaluation value of "2". Furthermore, even if a program module includes a program module that exceeds the standard values for cyclomatic complexity (Cyclomatic), maximum number of nests (MaxNesting), and number of inputs (CountInput), it is considered that the possibility of serious failures occurring is low. . Therefore, a small evaluation value of "1" is assigned to these metric items.

各メトリクス項目に対して付与する基準値および/または評価値は、例えば、ソースコード2を修正する作業者が決定してもよい。この場合、この作業者がコンピュータを操作することで、図4(b)に示すメトリクスルールリスト22が作成される。作成されたメトリクスルールリスト22は、ソースコード修正支援装置1が備える不図示のメモリに保存される。 The reference value and/or evaluation value given to each metrics item may be determined, for example, by a worker who modifies the source code 2. In this case, the worker operates the computer to create the metrics rule list 22 shown in FIG. 4(b). The created metrics rule list 22 is stored in a memory (not shown) included in the source code modification support device 1.

メトリクスルールリスト取得部12は、図3に示す手順で作成されたメトリクスルールリスト22を取得する。この実施例では、メトリクスルールリスト取得部12は、ソースコード修正支援装置1が備えるメモリから図4(b)に示すメトリクスルールリスト22を読み出す。 The metrics rule list acquisition unit 12 acquires the metrics rule list 22 created by the procedure shown in FIG. In this embodiment, the metrics rule list acquisition unit 12 reads the metrics rule list 22 shown in FIG. 4(b) from the memory included in the source code modification support device 1.

構造解析部13は、メトリクスルールリスト取得部12が取得したメトリクスルールリスト22に基づいて、ソースコード2において、リスクの高い複雑なプログラムモジュールを検索する。すなわち、構造解析部13は、ソースコード2において、各メトリクス項目の基準値に違反するプログラムモジュールを検索する。「基準値に違反」は、この実施例では、基準値を超えることを意味する。 The structure analysis unit 13 searches the source code 2 for a complex program module with a high risk based on the metrics rule list 22 acquired by the metrics rule list acquisition unit 12. That is, the structure analysis unit 13 searches the source code 2 for a program module that violates the standard value of each metrics item. In this embodiment, "violating the standard value" means exceeding the standard value.

図5は、構造解析部13の処理の一例を示すフローチャートである。このフローチャートの処理は、ソースコード修正支援装置1にソースコード2が与えられたときに実行される。ただし、このフローチャートの処理が実行される前に、図4(b)に示すメトリクスルールリスト22が作成されているものとする。 FIG. 5 is a flowchart showing an example of processing by the structure analysis unit 13. The process of this flowchart is executed when the source code 2 is given to the source code modification support device 1. However, it is assumed that the metrics rule list 22 shown in FIG. 4(b) has been created before the processing in this flowchart is executed.

S11において、構造解析部13は、ソースコード2を取得する。S12において、構造解析部13は、図3に示す手順で作成されたメトリクスルールリスト22に従って、ソースコード2内の違反モジュールを検索する。このとき、構造解析部13は、ソースコード2内の各プログラムモジュールについて、記述内容がメトリクス項目の基準値を超えているか否かを判定する。そして、S13において、構造解析部13は、分析結果を表す分析結果リストを出力する。 In S11, the structure analysis unit 13 obtains the source code 2. In S12, the structure analysis unit 13 searches for a violating module in the source code 2 according to the metrics rule list 22 created in the procedure shown in FIG. At this time, the structure analysis unit 13 determines whether the description content of each program module in the source code 2 exceeds the reference value of the metrics item. Then, in S13, the structure analysis unit 13 outputs an analysis result list representing the analysis results.

図6は、構造解析部13による分析結果を表す分析結果リストの一例を示す。この実施例では、ソースコード2は、ファイル名が「main.c」であるメインプログラムおよびファイル名が「sub.c」であるサブプログラムを含む。 FIG. 6 shows an example of an analysis result list representing the analysis results by the structure analysis unit 13. In this embodiment, the source code 2 includes a main program whose file name is "main.c" and a subprogram whose file name is "sub.c."

分析結果リスト23は、図6(a)に示すように、各プログラムモジュールの記述内容が、メトリクスルールリスト22に登録されている各メトリクス項目に対して違反しているか否かを表す。すなわち、「〇」印は、当該プログラムモジュールがメトリック項目の基準値に違反していないことを表し、「×」印は、当該プログラムモジュールがメトリック項目の基準値に違反していることを表す。なお、この実施例では、ソースコード2内の各プログラムモジュールは、「ファイル名」および「関数名」に組合せで識別されるものとする。また、「位置」は、各プログラムモジュールの関数が記述されている位置(行番号)を表す。 As shown in FIG. 6A, the analysis result list 23 indicates whether the written content of each program module violates each metrics item registered in the metrics rule list 22. That is, an "O" mark indicates that the program module does not violate the standard value of the metric item, and an "x" mark indicates that the program module violates the standard value of the metric item. In this embodiment, it is assumed that each program module in the source code 2 is identified by a combination of a "file name" and a "function name." Moreover, "position" represents the position (line number) where the function of each program module is described.

例えば、「ファイル名:main.c」および「関数名:main()」で識別されるプログラムモジュールに対する分析結果は以下の通りである。
(1)Cyclomatic=10、基準値=10 → 基準値以下(違反なし)
(2)MaxNesting=5、基準値=7 → 基準値以下(違反なし)
(3)PercentLackOfCohesion=15、基準値=20 → 基準値以下(違反なし)
(4)ImpactScale=10、基準値=8 → 基準値超え(違反あり)
(5)CountInput=8、基準値=15 → 基準値以下(違反なし)
構造解析部13は、違反が発生しているメトリクス項目に対応する評価点を足し合わせることで評価点数を計算する。この例では、「ImpactScale」のみに対して違反が発生している。そして、「ImpactScale」に対応する評価値は「3」である。よって、このプログラムモジュールの評価点数は「3」である。
For example, the analysis results for a program module identified by "file name: main.c" and "function name: main()" are as follows.
(1) Cyclomatic = 10, standard value = 10 → below standard value (no violation)
(2) MaxNesting = 5, standard value = 7 → below standard value (no violation)
(3) PercentLackOfCohesion = 15, standard value = 20 → below standard value (no violation)
(4) ImpactScale = 10, standard value = 8 → exceeds standard value (violation)
(5) CountInput = 8, standard value = 15 → below standard value (no violation)
The structure analysis unit 13 calculates the evaluation score by adding up the evaluation points corresponding to the metrics items in which the violation has occurred. In this example, a violation occurs only for "ImpactScale". The evaluation value corresponding to "ImpactScale" is "3". Therefore, the evaluation score for this program module is "3".

また、「ファイル名:main.c」および「関数名:func()」で識別されるプログラムモジュールに対する分析結果は以下の通りである。
(1)Cyclomatic=15、基準値=10 → 基準値超え(違反あり)
(2)MaxNesting=6、基準値=7 → 基準値以下(違反なし)
(3)PercentLackOfCohesion=25、基準値=20 → 基準値超え(違反あり)
(4)ImpactScale=3、基準値=8 → 基準値以下(違反なし)
(5)CountInput=10、基準値=15 → 基準値以下(違反なし)
この例では、「Cyclomatic」および「PercentLackOfCohesion」に対して違反が発生している。そして、「Cyclomatic」および「PercentLackOfCohesion」に対応する評価値はそれぞれ「1」および「2」である。よって、このプログラムモジュールの評価点数は「3」である。
Furthermore, the analysis results for the program module identified by "File name: main.c" and "Function name: func()" are as follows.
(1) Cyclomatic = 15, standard value = 10 → exceeds standard value (violation)
(2) MaxNesting = 6, standard value = 7 → below standard value (no violation)
(3) PercentLackOfCohesion = 25, standard value = 20 → exceeds standard value (violation)
(4) ImpactScale=3, standard value=8 → below standard value (no violation)
(5) CountInput = 10, standard value = 15 → below standard value (no violation)
In this example, violations occur for "Cyclomatic" and "PercentLackOfCohesion." The evaluation values corresponding to "Cyclomatic" and "PercentLackOfCohesion" are "1" and "2", respectively. Therefore, the evaluation score for this program module is "3".

このように、構造解析部13は、各プログラムモジュールの評価点数を計算する。これにより、分析結果リスト23が作成される。 In this way, the structure analysis unit 13 calculates the evaluation score of each program module. As a result, an analysis result list 23 is created.

構造解析部13は、図6(b)に示すように、分析結果の概要を表す分析結果リスト24を作成してもよい。分析結果リスト24は、ファイル毎に、分析を実行したソースコードの行数、違反が検出されたプログラムモジュールの総数、および評価値ごとに違反が検出されたプログラムモジュールの個数、およびファイル毎の評価点数の合計値を表す。例えば、メインプログラムに対する検索結果として、評価値が「3」「2」「1」であるメトリクス項目に対する違反がそれぞれ3個、2個、8個検出されたことを表している。 The structure analysis unit 13 may create an analysis result list 24 showing an overview of the analysis results, as shown in FIG. 6(b). The analysis result list 24 includes, for each file, the number of lines of source code that was analyzed, the total number of program modules in which violations were detected, the number of program modules in which violations were detected for each evaluation value, and the evaluation for each file. Represents the total value of points. For example, the search results for the main program indicate that 3, 2, and 8 violations of metrics items with evaluation values of "3," "2," and "1" were detected, respectively.

判定部14は、構造解析部13による分析結果に基づいて、各プログラムモジュールについての対処方針を判定する。具体的には、判定部14は、各プログラムモジュールについて、構造解析部13により計算された評価点数に基づいて対処方針を判定する。 The determining unit 14 determines the handling policy for each program module based on the analysis result by the structure analyzing unit 13. Specifically, the determination unit 14 determines the handling policy for each program module based on the evaluation score calculated by the structure analysis unit 13.

図7は、判定部14の処理の一例を示すフローチャートである。なお、このフローチャートの処理を実行する前に、構造解析部13により分析結果リスト23が作成されているものとする。 FIG. 7 is a flowchart illustrating an example of the processing of the determination unit 14. It is assumed that the analysis result list 23 has been created by the structure analysis section 13 before executing the processing in this flowchart.

S21において、判定部14は、構造解析部13により作成された分析結果リストを取得する。このとき、判定部14は、プログラムモジュールごとに評価点数が計算された分析果リスト(例えば、図6(a)に示す分析結果リスト23)を取得する。S22において、判定部14は、分析結果リストからプログラムモジュールを選択する。図6(a)に示す実施例では、各プログラムモジュールは、ファイル名および関数名の組合せで識別される。S23~S24において、判定部14は、選択したプログラムモジュールの評価点数を確認する。 In S21, the determination unit 14 obtains the analysis result list created by the structure analysis unit 13. At this time, the determination unit 14 obtains an analysis result list (for example, the analysis result list 23 shown in FIG. 6A) in which evaluation scores are calculated for each program module. In S22, the determination unit 14 selects a program module from the analysis result list. In the embodiment shown in FIG. 6(a), each program module is identified by a combination of a file name and a function name. In S23 and S24, the determining unit 14 checks the evaluation score of the selected program module.

選択したプログラムモジュールの評価点数がゼロであるときは、判定部14は、そのプログラムモジュールには問題が無いと判定する。この場合、判定部14は、S25において、選択したプログラムモジュールを無処理リストに追加する。無処理リストは、記述内容を変更する必要がないプログラムモジュールを登録するためのリストである。ただし、判定部14は、必ずしもS25の処理を実行する必要はない。 When the evaluation score of the selected program module is zero, the determination unit 14 determines that there is no problem with the program module. In this case, the determination unit 14 adds the selected program module to the unprocessed list in S25. The unprocessed list is a list for registering program modules whose descriptions do not need to be changed. However, the determination unit 14 does not necessarily need to execute the process of S25.

選択したプログラムモジュールの評価点数が所定の閾値より大きいときは、判定部14は、そのプログラムモジュールに係わるリスクが高いと判定する。この場合、判定部14は、S26において、選択したプログラムモジュールを図8(a)に示す他言語置換えリスト25に追加する。他言語置換えリスト25は、信頼性の高い他の言語に置き換えることが必要なプログラムモジュールを登録するためのリストである。なお、この例では、S24の閾値は「2」である。すなわち、評価点数が3以上であるプログラムモジュールが他言語置換えリスト25に登録される。 When the evaluation score of the selected program module is greater than a predetermined threshold, the determination unit 14 determines that the risk associated with the program module is high. In this case, the determination unit 14 adds the selected program module to the other language replacement list 25 shown in FIG. 8(a) in S26. The other language replacement list 25 is a list for registering program modules that need to be replaced with other languages with high reliability. Note that in this example, the threshold value in S24 is "2". That is, program modules with evaluation scores of 3 or more are registered in the other language replacement list 25.

選択したプログラムモジュールの評価点数がゼロではないが上述の閾値以下であるときには、判定部14は、そのプログラムモジュールがリスクを有するが、さほど重大なリスクではないと判定する。この場合、判定部14は、S27において、選択したプログラムモジュールを図8(b)に示す他処理リスト26に追加する。他処理リスト26は、他の言語に置き換える処理以外の処理を実行すべきプログラムモジュールを登録するためのリストである。 When the evaluation score of the selected program module is not zero but is equal to or less than the above-mentioned threshold, the determination unit 14 determines that the program module has a risk, but the risk is not very serious. In this case, the determination unit 14 adds the selected program module to the other processing list 26 shown in FIG. 8(b) in S27. The other processing list 26 is a list for registering program modules that should execute processing other than processing for replacing the language with another language.

S28において、判定部14は、S23~S27の処理を実行していないプログラムモジュールが分析結果リストに残っているかチェックする。S23~S27の処理を実行していないプログラムモジュールが分析結果リストに残っているときには、判定部14の処理はS22に戻る。すなわち、分析結果リストから次のプログラムモジュールが選択される。この後、新たに選択されたプログラムモジュールに対してS23~S27の処理が実行される。そして、分析結果リストに登録されているすべてのプログラムモジュールに対してS23~27の処理が実行されると、判定部14の処理は終了する。この結果、他言語置換えリスト25および他処理リスト26が作成される。 In S28, the determination unit 14 checks whether any program modules that have not undergone the processes in S23 to S27 remain in the analysis result list. If a program module that has not undergone the processes of S23 to S27 remains in the analysis result list, the process of the determination unit 14 returns to S22. That is, the next program module is selected from the analysis result list. Thereafter, the processes of S23 to S27 are executed for the newly selected program module. Then, when the processes of S23 to S27 are executed for all program modules registered in the analysis result list, the process of the determination unit 14 ends. As a result, the other language replacement list 25 and the other processing list 26 are created.

例えば、図6(a)に示す分析結果リスト23が判定部14に与えられるものとする。そして、判定部14は、分析結果リスト23に登録されている各プログラムモジュールに対してS23~S27の処理を実行する。ここで、S24で使用される閾値は「2」であるものとする。この場合、「ファイル名:main.c」および「関数名:main()」で識別されるプログラムモジュールの評価点数は「3」である。そうすると、判定部14は、このモジュールを他言語置換えリスト25に追加する。また、「ファイル名:main.c」および「関数名:func()」で識別されるプログラムモジュールも、他言語置換えリスト25に追加される。「ファイル名:main.c」および「関数名:aaa()」で識別されるプログラムモジュールの評価点数は「1」である。そうすると、判定部14は、このモジュールを他処理リスト26に追加する。また、「ファイル名:sub.c」および「関数名:sub_com2()」で識別されるプログラムモジュールも他処理リスト26に追加される。これにより、図8(a)に示す他言語置換えリスト25および図8(b)に示す他処理リスト26が得られる。 For example, it is assumed that the analysis result list 23 shown in FIG. 6(a) is given to the determination unit 14. Then, the determination unit 14 executes the processes of S23 to S27 for each program module registered in the analysis result list 23. Here, it is assumed that the threshold value used in S24 is "2". In this case, the evaluation score of the program module identified by "file name: main.c" and "function name: main()" is "3". Then, the determination unit 14 adds this module to the other language replacement list 25. Furthermore, the program module identified by “file name: main.c” and “function name: func()” is also added to the other language replacement list 25. The evaluation score of the program module identified by "file name: main.c" and "function name: aaa()" is "1". Then, the determination unit 14 adds this module to the other processing list 26. Furthermore, a program module identified by “file name: sub.c” and “function name: sub_com2()” is also added to the other processing list 26. As a result, the other language replacement list 25 shown in FIG. 8(a) and the other processing list 26 shown in FIG. 8(b) are obtained.

なお、他言語置換えリスト25は、評価点数が閾値を超えるプログラムモジュールへの対処方針として、第1の言語(C/C++)よりも信頼性の高い第2の言語(Rust)に置き換えることを指示する情報の一例である。また、図7に示す手順は1つの実施例であり、本発明の実施形態はこの手順に限定されるものではない。 Note that the other language replacement list 25 instructs to replace the first language (C/C++) with a second language (Rust) that is more reliable than the first language (C/C++) as a policy for dealing with program modules whose evaluation scores exceed a threshold value. This is an example of information. Further, the procedure shown in FIG. 7 is one example, and the embodiments of the present invention are not limited to this procedure.

このように、ソースコード修正支援装置1は、メトリクスリスト3に基づいてソースコード2中の各プログラムモジュールを分析する。このとき、各プログラムモジュールに対して、セキュリティ上のリスクの深刻度(または、信頼性の高いプログラミング言語に置き換える必要性の程度)を表す評価点数が付与される。そして、ソースコード修正支援装置1は、この評価点数を用いて各プログラムモジュールをグループ化することにより、他言語置換えリスト25および他処理リスト26を作成する。この後、他言語置換えリスト25および他処理リスト26は、図1に示すソースコード修正装置4に与えられる。 In this way, the source code modification support device 1 analyzes each program module in the source code 2 based on the metrics list 3. At this time, each program module is given an evaluation score that indicates the severity of the security risk (or the degree of necessity of replacing it with a highly reliable programming language). Then, the source code modification support device 1 creates the other language replacement list 25 and other processing list 26 by grouping each program module using this evaluation score. Thereafter, the other language replacement list 25 and other processing list 26 are provided to the source code modification device 4 shown in FIG.

ソースコード修正装置4は、ソースコード修正支援装置1により作成された他言語置換えリスト25および他処理リスト26に基づいてソースコード2を修正する。そして、試験装置5は、ソースコード修正装置4により修正されたソースコード2を実行することで動作確認を行う。なお、ソースコード修正装置4および試験装置5は、例えば、ソースコード2を修正する作業者がコンピュータを操作することで実現される。 The source code modification device 4 modifies the source code 2 based on the other language replacement list 25 and the other processing list 26 created by the source code modification support device 1. The test device 5 then executes the source code 2 modified by the source code modification device 4 to check the operation. Note that the source code modification device 4 and the testing device 5 are realized, for example, by an operator who modifies the source code 2 operating a computer.

図9は、ソースコード修正装置4および試験装置5による処理の一例を示すフローチャートである。この実施例では、S41において、ソースコード修正装置4は、ソースコード2を取得する。また、ソースコード修正装置4は、S42およびS45において、ソースコード修正支援装置1により作成された他言語置換えリスト25および他処理リスト26をそれぞれ取得する。 FIG. 9 is a flowchart showing an example of processing by the source code modification device 4 and the testing device 5. In this embodiment, the source code modification device 4 obtains the source code 2 in S41. Further, the source code modification device 4 obtains the other language replacement list 25 and the other processing list 26 created by the source code modification support device 1 in S42 and S45, respectively.

S43~S44の処理は、他言語置換えリスト25に登録されている各違反モジュールに対して実行される。すなわち、S43において、ソースコード修正装置4は、違反モジュールを他の言語の記述に置き換える。例えば、ソースコード2がC言語で記述されているときに、違反モジュールはRust言語の記述に置き換えられる。このとき、ソースコード2を修正する作業者が、ソースコード修正装置4を実現するコンピュータを用いて手作業でコードを書き換えてもよい。あるいは、ソースコード修正装置4がC言語からRust言語への変換機能を有するときは、ソースコード修正装置4により違反モジュールがRust言語の記述に置き換えられる。この場合、ソースコード修正装置4は、判定部14により他の言語の記述に置き換えるべきと判定された違反モジュールを、Rustの記述に変換する変換部として動作する。なお、プログラムコード全体をソフトウェア処理で他の言語に変換することは容易ではないが、一部の記述を他の言語に変換することは既存の技術で可能である。 The processes of S43 to S44 are executed for each violating module registered in the other language replacement list 25. That is, in S43, the source code correction device 4 replaces the violating module with a description in another language. For example, when the source code 2 is written in the C language, the violating module is replaced with a description in the Rust language. At this time, a worker who modifies the source code 2 may manually rewrite the code using a computer that implements the source code modification device 4. Alternatively, when the source code modification device 4 has a conversion function from the C language to the Rust language, the source code modification device 4 replaces the violating module with a description in the Rust language. In this case, the source code modification device 4 operates as a conversion unit that converts the violating module, which has been determined by the determination unit 14 to be replaced with a description in another language, into a Rust description. Note that although it is not easy to convert the entire program code into another language through software processing, it is possible to convert part of the description into another language using existing technology.

S44において、試験装置5は、他の言語に置き換えられた記述をコンパイルして実行する。すなわち、違反モジュールが正しく他の言語に置き換えられたか否かについての試験が行われる。そして、試験結果は、ソースコード修正装置4にフィードバックされる。このとき、違反モジュールが正しく他の言語に置き換えられていなければ、ソースコード修正装置4においてその記述がさらに修正される。これにより、他言語置換えリスト25に登録されている各違反モジュールが正しく他の言語に置き換えられる。 In S44, the test device 5 compiles and executes the description replaced with another language. That is, a test is performed as to whether the violating module has been correctly replaced with another language. The test results are then fed back to the source code modification device 4. At this time, if the violating module has not been correctly replaced with another language, the source code modification device 4 further modifies its description. As a result, each violating module registered in the other language replacement list 25 is correctly replaced with another language.

S46~S47の処理は、他処理リスト26に登録されている各違反モジュールに対して実行される。すなわち、S46において、ソースコード修正装置4は、ソースコードの言語のまま違反モジュールを修正する。例えば、ソースコード2がC言語で記述されているときは、違反モジュールは、C言語のままその内容が修正される。このとき、ソースコード2を修正する作業者が、ソースコード修正装置4を実現するコンピュータを用いて手作業でコードを修正してもよい。或いは、ソースコード修正装置4は、違反モジュールを修正することなく、違反モジュールが修正されてないことを表すレポートを出力してもよい。 The processes in S46 and S47 are executed for each violating module registered in the other process list 26. That is, in S46, the source code modification device 4 modifies the violating module without changing the language of the source code. For example, when the source code 2 is written in C language, the content of the violating module is modified while remaining in C language. At this time, the operator who modifies the source code 2 may manually modify the code using a computer that implements the source code modification device 4. Alternatively, the source code modification device 4 may output a report indicating that the violating module has not been modified, without modifying the violating module.

S47において、試験装置5は、修正後の記述をコンパイルして実行する。すなわち、違反モジュールが正しく修正されたか否かについて試験が行われる。そして、この試験結果は、ソースコード修正装置4にフィードバックされる。このとき、違反モジュールが正しく修正されていなければ、ソースコード修正装置4においてその記述がさらに修正される。これにより、他処理リスト26に登録されている各違反モジュールが正しく修正される。なお、S46において違反モジュールを修正しないときは、S47の処理を実行しなくてもよい。 In S47, the test device 5 compiles and executes the modified description. That is, a test is performed to determine whether the violating module has been correctly corrected. This test result is then fed back to the source code modification device 4. At this time, if the violating module has not been corrected correctly, the source code correction device 4 further corrects its description. As a result, each violating module registered in the other processing list 26 is corrected correctly. Note that if the violating module is not corrected in S46, it is not necessary to execute the process in S47.

S48において、試験装置5は、他の言語に置き換えられた記述および修正された記述をソースコード2に結合する。そして、試験装置5は、他の言語に置き換えられた記述および修正された記述を含むプログラムを試験する。 In S48, the testing device 5 combines the description replaced with another language and the modified description into the source code 2. Then, the test device 5 tests the program including the description replaced with another language and the modified description.

このように、ソースコード修正支援装置1は、ソースコードの構造を解析するためのメトリクスに基づいて、ソースコード中の各プログラムモジュールに対して、セキュリティ上のリスクの深刻度(または、信頼性の高いプログラミング言語に置き換える必要性の程度)を表す評価点数を付与する。したがって、ソースコード2を修正する作業者は、ソースコードのサイズが大きい場合であっても、セキュリティ上のリスクの深刻度が高いプログラムモジュールを容易に認識できる。すなわち、コストまたは作業量の観点でソースコード全体を他の言語で書き換えることが困難なケースであっても、セキュリティ上のリスクの深刻度が高いプログラムモジュールを確実に信頼性の高いプログラミング言語の記述に置き換えることができる。これにより、コストまたは作業量の制限がある場合であっても、信頼性が低い既存のプログラムのリスクを小さくできる。 In this way, the source code modification support device 1 determines the severity of security risks (or reliability) for each program module in the source code based on metrics for analyzing the structure of the source code. An evaluation score representing the degree of necessity of replacing the program with a higher-level programming language is assigned. Therefore, a worker who modifies the source code 2 can easily recognize program modules that pose a high degree of security risk even if the size of the source code is large. In other words, even in cases where it is difficult to rewrite the entire source code in another language due to cost or workload considerations, program modules with high security risks can be reliably written in a highly reliable programming language. can be replaced with This reduces the risk of existing unreliable programs even when cost or effort constraints exist.

<第2の実施形態>
図1~図8に示す実施形態では、ソースコードの構造を解析するメトリクスを利用してリスクが高いプログラムモジュールが抽出される。これに対して、本発明の第2の実施形態においては、メトリクスに加えて、セキュアコーディングルールも利用してリスクが高いプログラムモジュールが抽出される。セキュアコーディングルールは、ソースコードを記述する際に守らなければならないルールの一例である。
<Second embodiment>
In the embodiments shown in FIGS. 1 to 8, high-risk program modules are extracted using metrics that analyze the structure of source code. In contrast, in the second embodiment of the present invention, in addition to metrics, secure coding rules are also used to extract high-risk program modules. Secure coding rules are an example of rules that must be followed when writing source code.

図10は、本発明の第2の実施形態に係わるソースコード修正支援装置の一例を示す。本発明の第2の実施形態においては、ソースコード修正支援装置1Bは、セキュアコーディングルール30に基づいてソースコード2の中から違反記述を検索する機能を備える。なお、ソースコード2は、図1および図10において実質的に同じであり、所定のプログラミング言語で記述された、コンパイル前のプログラムコードである。 FIG. 10 shows an example of a source code modification support device according to the second embodiment of the present invention. In the second embodiment of the present invention, the source code modification support device 1B has a function of searching the source code 2 for a violation description based on the secure coding rule 30. Note that the source code 2 is substantially the same in FIGS. 1 and 10, and is a pre-compiled program code written in a predetermined programming language.

セキュアコーディングルール30は、ソースコードを記述する際に守らなければならないルールがリスト化された情報であり、ソースコード修正支援装置1Bがソースコード2を解析する際に使用される。この実施例では、ソースコード修正支援装置1Bは、セキュアコーディングルール30として既存のコーディングルールを使用する。例えば、セキュアコーディングルール30として、CERT、MISRA、またはAUTOSARが使用される。一例として、C/C++で記述されたコードの解析において使用されるCERT-C/C++コーディングスタンダード規約の一部を図11に示す。 The secure coding rules 30 are information that lists rules that must be followed when writing source code, and are used when the source code modification support device 1B analyzes the source code 2. In this embodiment, the source code modification support device 1B uses an existing coding rule as the secure coding rule 30. For example, CERT, MISRA, or AUTOSAR is used as the secure coding rule 30. As an example, FIG. 11 shows a part of the CERT-C/C++ coding standard convention used in analyzing code written in C/C++.

ソースコード修正支援装置1Bは、図10に示すように、メトリクスルールリスト作成部11、メトリクスルールリスト取得部12、構造解析部13、セキュリティルールリスト作成部31、セキュリティルールリスト取得部32、静的解析部33、および判定部14Bを備える。尚、メトリクスルールリスト作成部11、メトリクスルールリスト取得部12、および構造解析部13は、図1および図10において実質的に同じである。また、ソースコード修正支援装置1Bは、図10に示していない他の機能またはデバイスを備えてもよい。 As shown in FIG. 10, the source code modification support device 1B includes a metrics rule list creation unit 11, a metrics rule list acquisition unit 12, a structure analysis unit 13, a security rule list creation unit 31, a security rule list acquisition unit 32, a static It includes an analysis section 33 and a determination section 14B. Note that the metrics rule list creation section 11, the metrics rule list acquisition section 12, and the structure analysis section 13 are substantially the same in FIGS. 1 and 10. Further, the source code modification support device 1B may include other functions or devices not shown in FIG.

セキュリティルールリスト作成部31には、セキュアコーディングルール30が与えられる。セキュアコーディングルール30は、上述したように、ソースコードを記述する際に守らなければならない1または複数のルールを表す。そして、セキュリティルールリスト作成部31は、セキュアコーディングルール30としてリスト化されている各ルールに優先度を付与することでセキュリティルールリストを作成する。なお、セキュリティルールリスト作成部31は、例えば、ソースコード2を修正する作業者がコンピュータを操作することで実現される。 A secure coding rule 30 is provided to the security rule list creation unit 31. The secure coding rules 30 represent one or more rules that must be followed when writing source code, as described above. Then, the security rule list creation unit 31 creates a security rule list by assigning a priority to each rule listed as the secure coding rules 30. Note that the security rule list creation section 31 is realized, for example, by an operator who modifies the source code 2 operating a computer.

セキュリティルールリスト作成部31は、ソースコード2を修正する際の対処方針に係わる優先度リストを作成する。優先度リスト41は、図12(a)に示すように、セキュアコーディングルール30として用意されている各ルールに付与する優先度を定義する。優先度は、例えば、当該ルールに対する違反が発生したときのセキュリティ上のリスクの深刻度に基づいて決定される。この実施例では、3段階の優先度が設定されるが、2段階または4段階以上の優先度を設定してもよい。 The security rule list creation unit 31 creates a priority list related to the policy when modifying the source code 2. The priority list 41 defines the priority given to each rule prepared as the secure coding rule 30, as shown in FIG. 12(a). The priority is determined, for example, based on the severity of the security risk when a violation of the rule occurs. In this embodiment, three levels of priority are set, but two, four or more levels of priority may be set.

対処方針は、当該ルールに違反する記述に対してどのように対処するのかを表す。この実施例では、優先度に応じて図12(a)に示す方針が設定されている。即ち、最も優先度が高いレベル3が付与されるルールに違反する記述に対しては「他の言語の記述に置き替える」が設定されている。2番目に優先度が高いレベル2が付与されるルールに違反する記述に対しては「他の言語の記述に置き替えることを推奨する」が設定されている。最も優先度が低いレベル1が付与されるルールに違反する記述に対しては「所定のポリシに基づいて修正する」が設定されている。 The handling policy indicates how to deal with a description that violates the rule. In this embodiment, the policy shown in FIG. 12(a) is set according to the priority. That is, "replace with description in another language" is set for a description that violates the rule to which level 3, which has the highest priority, is assigned. For descriptions that violate the rules that are given level 2, which has the second highest priority, "recommended to replace with descriptions in other languages" is set. "Modify based on a predetermined policy" is set for a description that violates a rule to which level 1, which has the lowest priority, is assigned.

セキュリティルールリスト作成部31は、ソースコード修正支援装置1Bに与えられたセキュアコーディングルール30を取得する。そして、セキュリティルールリスト作成部31は、ソースコードを記述する際に守らなければならない各ルールに優先度を付与することでセキュリティルールリストを作成する。この実施例では、図11に示す各ルールに対して図12(a)に示す優先度を付与することで、図12(b)に示すセキュリティルールリスト42が得られる。 The security rule list creation unit 31 acquires the secure coding rules 30 given to the source code modification support device 1B. Then, the security rule list creation unit 31 creates a security rule list by assigning a priority to each rule that must be followed when writing source code. In this embodiment, the security rule list 42 shown in FIG. 12(b) is obtained by assigning the priority shown in FIG. 12(a) to each rule shown in FIG. 11.

例えば、ソースコードが、「INT32-C」で識別されるルール「符号付き整数演算がオーバフローを引き起こさないことを保証する」に違反する記述を含むときは、重大な障害が発生する可能性があると考えられる。したがって、このルールに対して高い優先度「3」が付与される。「INT33-C」および「EXP33-C」で識別されるルールについても同様である。また、ソースコードが、「ARR32-C」で識別されるルール「可変長配列のサイズ引数が適切な範囲内にあることを保証する」に違反する記述を含むときは、何らかの障害が発生する可能性があるものの、重大な障害が発生する可能性は高くないと考えられる。したがって、このルールに対しては、中間レベルの優先度「2」が付与される。他方、ソースコードが、「MSC05-C」で識別されるルール「time_t型の値を直接操作しない」に違反する記述を含む場合であっても、重大な障害が発生する可能性は低いと考えられる。したがって、このルールに対しては、低い優先度「1」が付与される。 For example, if the source code contains a statement that violates the rule ``Ensure that signed integer operations do not cause overflow'' identified in ``INT32-C,'' a serious failure may occur. it is conceivable that. Therefore, a high priority of "3" is given to this rule. The same applies to the rules identified by "INT33-C" and "EXP33-C". Additionally, if the source code contains a statement that violates the rule ``Ensure that the size argument of variable-length arrays is within an appropriate range'' identified in ``ARR32-C,'' some kind of failure may occur. However, it is considered that the possibility of serious failure occurring is not high. Therefore, this rule is given an intermediate level of priority "2". On the other hand, even if the source code contains a statement that violates the rule "Do not directly manipulate time_t type values" identified in "MSC05-C", we believe that there is a low possibility that a serious failure will occur. It will be done. Therefore, this rule is given a low priority of "1".

各ルールに対して付与する優先度は、例えば、ソースコード2を修正する作業者が決定してもよい。この場合、この作業者がコンピュータを操作することで、図12(b)に示すセキュリティルールリスト42が作成される。作成されたセキュリティルールリスト42は、ソースコード修正支援装置1Bが備える不図示のメモリに保存される。 The priority given to each rule may be determined, for example, by a worker who modifies the source code 2. In this case, the operator operates the computer to create the security rule list 42 shown in FIG. 12(b). The created security rule list 42 is stored in a memory (not shown) included in the source code modification support device 1B.

セキュリティルールリスト取得部32は、上述の手順で作成されたセキュリティルールリスト42を取得する。この例では、セキュリティルールリスト取得部32は、ソースコード修正支援装置1Bが備えるメモリから図12(b)に示すセキュリティルールリスト42を読み出す。 The security rule list acquisition unit 32 acquires the security rule list 42 created in the above-described procedure. In this example, the security rule list acquisition unit 32 reads the security rule list 42 shown in FIG. 12(b) from the memory included in the source code modification support device 1B.

静的解析部33は、セキュリティルールリスト取得部32が取得したセキュリティルールリスト42に基づいて、ソースコード2において違反記述を検索する。すなわち、静的解析部33は、ソースコード2において、セキュリティルールリスト42に記載されているルールに違反する違反記述を検索する。 The static analysis unit 33 searches the source code 2 for violation descriptions based on the security rule list 42 acquired by the security rule list acquisition unit 32. That is, the static analysis unit 33 searches the source code 2 for a violation description that violates the rules listed in the security rule list 42.

図13は、静的解析部33の処理の一例を示すフローチャートである。このフローチャートの処理は、ソースコード修正支援装置1Bにソースコード2が与えられたときに実行される。ただし、このフローチャートの処理が実行される前に、図12(b)に示すセキュリティルールリスト42が作成されているものとする。 FIG. 13 is a flowchart illustrating an example of processing by the static analysis unit 33. The processing in this flowchart is executed when source code 2 is provided to source code modification support device 1B. However, it is assumed that the security rule list 42 shown in FIG. 12(b) has been created before the processing in this flowchart is executed.

S51において、静的解析部33は、ソースコード2を取得する。S52において、静的解析部33は、セキュリティルールリスト42に従って、ソースコード2内の違反記述を検索する。なお、予め決められたルールに違反する記述を検索する方法は、公知に技術により実現される。そして、S53において、静的解析部33は、検索結果を表す検索結果リストを出力する。 In S51, the static analysis unit 33 obtains the source code 2. In S52, the static analysis unit 33 searches for violation descriptions in the source code 2 according to the security rule list 42. Note that a method of searching for a description that violates a predetermined rule can be realized by a publicly known technique. Then, in S53, the static analysis unit 33 outputs a search result list representing the search results.

図14は、静的解析部33の検索結果を表す検索結果リストの一例を示す。この実施例では、ソースコード2は、ファイル名が「main.c」であるメインプログラムおよびファイル名が「sub.c」であるサブプログラムを含む。 FIG. 14 shows an example of a search result list representing the search results of the static analysis unit 33. In this embodiment, the source code 2 includes a main program whose file name is "main.c" and a subprogram whose file name is "sub.c."

検索結果リスト43は、図14(a)に示すように、検出された違反記述ごとに、違反が検出されたファイル名、違反が検出された位置、違反に係わる記述、違反が検出されたルールを識別するルール番号、検出された違反の内容、および違反が検出されたルールの優先度を表す。優先度は、図12(b)に示すセキュリティルールリスト42を参照して設定される。たとえば、メインプログラムの12行目において、除算の分母がゼロとなる違反が検出されている。この違反は、図12(b)に示すように、最も優先度が高い違反(即ち、レベル3の違反)に該当する。よって、静的解析部33は、この違反記述に対して「レベル3」を対応づける。このように、静的解析部33は、ソースコード2から違反記述を検出すると共に、検出した各違反記述に対して、セキュリティ上のリスクの深刻度を表す優先度を対応づける。これにより、検索結果リスト43が得られる。 As shown in FIG. 14(a), the search result list 43 includes, for each detected violation description, the file name where the violation was detected, the location where the violation was detected, the description related to the violation, and the rule where the violation was detected. represents the rule number that identifies the rule, the content of the detected violation, and the priority of the rule in which the violation was detected. The priority is set with reference to the security rule list 42 shown in FIG. 12(b). For example, in line 12 of the main program, a violation in which the denominator of division becomes zero is detected. This violation corresponds to the violation with the highest priority (ie, level 3 violation), as shown in FIG. 12(b). Therefore, the static analysis unit 33 associates "level 3" with this violation description. In this way, the static analysis unit 33 detects violation descriptions from the source code 2, and associates each detected violation description with a priority indicating the severity of the security risk. As a result, a search result list 43 is obtained.

静的解析部33は、図14(b)に示すように、検索結果の概要を表す検索結果リスト44を作成してもよい。検索結果リスト44は、ファイル毎に、検索を実行したソースコードの行数、違反が検出された記述の総個数、および優先度ごとに違反が検出された記述の個数を表す。例えば、ファイル名が「main.c」であるメインプログラムに対する検索結果として、レベル3、レベル2、レベル1の違反がそれぞれ3個、2個、15個検出されたことを表している。 The static analysis unit 33 may create a search result list 44 showing an overview of search results, as shown in FIG. 14(b). The search result list 44 indicates, for each file, the number of lines of source code searched, the total number of descriptions in which violations were detected, and the number of descriptions in which violations were detected for each priority. For example, the search results for the main program with the file name "main.c" indicate that 3, 2, and 15 level 3, level 2, and level 1 violations were detected, respectively.

判定部14Bは、構造解析部13による分析結果および静的解析部33による検索結果に基づいて、ソースコード内のリスクの高い記述についての対処方針を決定する。すなわち、判定部14Bは、構造解析部13により計算される評価点数および静的解析部33により使用される優先度の組合せに基づいて対処方針を判定する。 The determination unit 14B determines a policy for dealing with high-risk descriptions in the source code, based on the analysis results by the structure analysis unit 13 and the search results by the static analysis unit 33. In other words, the determination unit 14B determines the response plan based on the combination of the evaluation score calculated by the structural analysis unit 13 and the priority used by the static analysis unit 33.

図15は、判定部14Bの処理の一例を示すフローチャートである。なお、このフローチャートの処理を実行する前に、構造解析部13により分析結果リスト23が作成され、静的解析部33により検索結果リスト43が作成されているものとする。 FIG. 15 is a flowchart illustrating an example of processing by the determination unit 14B. It is assumed that before executing the processing in this flowchart, the analysis result list 23 has been created by the structure analysis section 13 and the search result list 43 has been created by the static analysis section 33.

S61において、判定部14Bは、構造解析部13により作成された分析結果リストを取得する。このとき、判定部14Bは、各プログラムモジュールに対して評価点数が付与された分析結果リスト(例えば、図6(a)に示す分析結果リスト23)を取得する。S62において、判定部14Bは、静的解析部33により作成された検索結果リストを取得する。このとき、判定部14Bは、違反記述ごとに優先度が設定されている検索結果リスト(例えば、図14(a)に示す検索結果リスト43)を取得する。S63において、判定部14Bは、検索結果リストから違反記述を選択する。 In S61, the determination unit 14B obtains the analysis result list created by the structure analysis unit 13. At this time, the determination unit 14B obtains an analysis result list (for example, the analysis result list 23 shown in FIG. 6A) in which evaluation points are assigned to each program module. In S62, the determination unit 14B obtains the search result list created by the static analysis unit 33. At this time, the determination unit 14B obtains a search result list (for example, the search result list 43 shown in FIG. 14A) in which a priority is set for each violation description. In S63, the determination unit 14B selects a violation description from the search result list.

S64において、判定部14Bは、S63で選択した違反記述を含むプログラムモジュールを特定し、そのプログラムモジュールに付与されている評価点数を確認する。違反記述とプログラムモジュールとの対応関係は、ソースコード内の位置に基づいて検出してもよい。例えば、図14(a)に示す1番目の違反記述は、ソースコードの12行目に位置している。他方、図6(a)に示す1番目の関数「main()」は、ソースコードの10行目に位置している。したがって、この関数は、図14(a)に示す1番目の違反記述に対応していると判定される。 In S64, the determination unit 14B identifies the program module that includes the violation description selected in S63, and checks the evaluation score assigned to that program module. The correspondence between the violation description and the program module may be detected based on the position within the source code. For example, the first violation description shown in FIG. 14(a) is located on the 12th line of the source code. On the other hand, the first function "main()" shown in FIG. 6(a) is located on the 10th line of the source code. Therefore, it is determined that this function corresponds to the first violation description shown in FIG. 14(a).

S65において、判定部14Bは、S63で選択した違反記述の優先度が「レベル3:高優先」であり、且つ、その違反記述を含むプログラムモジュールの評価点数が「2」を超えているか否かを判定する。そして、優先度が「レベル3:高優先」であり、評価点数が「2」を超えているときは、判定部14Bは、S66において、その違反記述/プログラムモジュールを図16(a)に示す他言語置換えリスト45に追加する。他言語置換えリスト45は、他の言語に置き換えることが必要な違反記述/プログラムモジュールを登録するためのリストである。これに対して、選択した違反記述の優先度が「レベル2:中優先」または「レベル1:低優先」であるとき、或いは、その違反記述を含むプログラムモジュールの評価点数が「2」以下であるときは、判定部14Bは、S67において、その違反記述/プログラムモジュールを図16(b)に示す他処理リスト46に追加する。他処理リスト46は、他の言語に置き換える処理以外の処理を実行すべき違反記述/プログラムモジュールを登録するためのリストである。 In S65, the determination unit 14B determines whether the priority of the violation description selected in S63 is "Level 3: High priority" and the evaluation score of the program module including the violation description exceeds "2". Determine. Then, when the priority is "Level 3: High Priority" and the evaluation score exceeds "2", the determination unit 14B, in S66, displays the violation description/program module as shown in FIG. 16(a). Add to other language replacement list 45. The other language replacement list 45 is a list for registering violation descriptions/program modules that need to be replaced with other languages. On the other hand, when the priority of the selected violation description is "Level 2: Medium priority" or "Level 1: Low priority", or the evaluation score of the program module containing the violation description is "2" or less. If so, the determination unit 14B adds the violation description/program module to the other processing list 46 shown in FIG. 16(b) in S67. The other processing list 46 is a list for registering violation descriptions/program modules that should execute processing other than processing for replacing with another language.

S68において、判定部14Bは、S64~S67の処理を実行していない違反記述が検索結果リストに残っているかチェックする。S64~S67の処理を実行していない違反記述が検索結果リストに残っているときには、判定部14Bの処理はS63に戻る。すなわち、検索結果リストから次の違反記述が選択される。この後、新たに選択された違反記述に対してS64~S67の処理が実行される。そして、検索結果リストに登録されているすべての違反記述に対してS64~S67の処理が実行されると、判定部14Bの処理は終了する。このようにして、他言語置換えリスト45および他処理リスト46が作成される。 In S68, the determining unit 14B checks whether any violation descriptions for which the processes of S64 to S67 have not been executed remain in the search result list. If there are violation descriptions that have not been processed in S64 to S67 remaining in the search result list, the process of the determination unit 14B returns to S63. That is, the next violation description is selected from the search result list. Thereafter, the processes of S64 to S67 are executed for the newly selected violation description. Then, when the processes of S64 to S67 are executed for all violation descriptions registered in the search result list, the process of the determination unit 14B ends. In this way, the other language replacement list 45 and the other processing list 46 are created.

例えば、図6(a)に示す分析結果リスト23および図14(a)に示す検索結果リスト43が判定部14Bに与えられるものとする。そして、判定部14Bは、検索結果リスト43に登録されている各違反記述に対してS64~S67の処理を実行する。 For example, it is assumed that the analysis result list 23 shown in FIG. 6(a) and the search result list 43 shown in FIG. 14(a) are provided to the determination unit 14B. Then, the determination unit 14B executes the processes of S64 to S67 for each violation description registered in the search result list 43.

この場合、例えば、12行目の違反記述の優先度はレベル3であり、その違反記述を含むプログラムモジュール(関数:main())の評価点数は「3」である。したがって、この違反記述/プログラムモジュールは、図16(a)に示すように、他言語置換えリスト45に追加される。また、203行目の違反記述の優先度はレベル2であり、その違反記述を含むプログラムモジュール(関数:aaa())の評価点数は「1」である。したがって、この違反記述/プログラムモジュールは、図16(b)に示すように、他処理リスト46に追加される。なお、他言語置換えリスト45は、プログラムの構造が複雑であり、且つ、セキュリティ上のリスクの観点で最も高い優先度(レベル3)が対応づけられている違反記述/プログラムモジュールへの対処方針として、第1の言語(C/C++)よりも信頼性の高い第2の言語(Rust)に置き換えることを指示する情報の一例である。 In this case, for example, the priority of the violation description on the 12th line is level 3, and the evaluation score of the program module (function: main()) that includes the violation description is "3". Therefore, this violating description/program module is added to the other language replacement list 45, as shown in FIG. 16(a). Furthermore, the priority of the violation description on the 203rd line is level 2, and the evaluation score of the program module (function: aaa()) that includes the violation description is "1". Therefore, this violation description/program module is added to the other processing list 46, as shown in FIG. 16(b). Note that the other language replacement list 45 is used as a policy for dealing with violation descriptions/program modules that have complex program structures and are associated with the highest priority (level 3) from the perspective of security risks. , is an example of information instructing to replace the first language (C/C++) with a second language (Rust) that is more reliable.

ソースコード修正装置4および試験装置5の動作は、図1に示す実施形態および図10に示す第2の実施形態において実質的に同じである。即ち、ソースコード修正装置4は、ソースコード修正支援装置1Bから出力される情報に基づいてソースコードを修正し、試験装置5は、修正後のソースコードの試験を実行する。 The operations of the source code modification device 4 and the testing device 5 are substantially the same in the embodiment shown in FIG. 1 and the second embodiment shown in FIG. That is, the source code modification device 4 modifies the source code based on the information output from the source code modification support device 1B, and the testing device 5 tests the modified source code.

このように、本発明の第2の実施形態においては、コーディングルールに違反し、且つ、メトリクスの観点でリスクが高いと判定された記述(或いは、プログラムモジュール)が抽出される。したがって、図1に示す実施形態と比較して、より重要度の高い記述またはプログラムモジュールを効率よく修正できる。 In this manner, in the second embodiment of the present invention, descriptions (or program modules) that violate coding rules and are determined to have a high risk from the metrics perspective are extracted. Therefore, compared to the embodiment shown in FIG. 1, more important descriptions or program modules can be modified more efficiently.

<第3の実施形態>
図1~図8に示す実施形態では、ソースコードの構造を解析するメトリクスを利用してリスクが高いプログラムモジュールが抽出される。また、図10~図16に示す第2の実施形態では、メトリクスに加えて、セキュアコーディングルールも利用してリスクが高いプログラムモジュールが抽出される。そして、抽出したプログラムモジュールは、信頼性の高い言語(例えば、Rust)に置き換えられる。
<Third embodiment>
In the embodiments shown in FIGS. 1 to 8, high-risk program modules are extracted using metrics that analyze the structure of source code. Furthermore, in the second embodiment shown in FIGS. 10 to 16, program modules with high risk are extracted using secure coding rules in addition to metrics. The extracted program module is then replaced with a highly reliable language (for example, Rust).

ただし、セキュアコーディングルールに違反していない記述、或いは、メトリクスの観点で問題がない記述であっても、信頼性の高い言語に置き換えることが好ましい記述もある。そこで、第3の実施形態では、脆弱性が発生し得るコードスタイルおよび脆弱性の対策が行われているコードスタイルに係わるテンプレートが作成される。そして、ソースコード修正支援装置は、このテンプレートを利用して、信頼性の高い言語に置き換えることが好ましい記述をソースコードから抽出する。 However, even if the description does not violate the secure coding rules or has no problem from the perspective of metrics, there are some descriptions that are preferably replaced with a highly reliable language. Therefore, in the third embodiment, templates are created for code styles in which vulnerabilities may occur and code styles in which countermeasures for vulnerabilities have been taken. Then, the source code modification support device uses this template to extract from the source code a description that is preferably replaced with a highly reliable language.

図17は、本発明の第3の実施形態に係わるソースコード修正支援装置の一例を示す。第3の実施形態に係わるソースコード修正支援装置1Cは、テンプレート作成部51、テンプレート52、テンプレート検索部53、および判定部54を備える。そして、ソースコード修正支援装置1Cには、ソースコード2が与えられる。ソースコード2は、所定のプログラミング言語で記述された、コンパイル前のプログラムコードである。この実施例では、ソースコード2は、C言語(またはC++)で記述されているものとする。 FIG. 17 shows an example of a source code modification support device according to the third embodiment of the present invention. A source code modification support device 1C according to the third embodiment includes a template creation section 51, a template 52, a template search section 53, and a determination section 54. The source code 2 is then given to the source code modification support device 1C. Source code 2 is a pre-compiled program code written in a predetermined programming language. In this embodiment, it is assumed that the source code 2 is written in C language (or C++).

テンプレート52には、C/C++で記述されたソースコードにおいて脆弱性が発生し得るコードスタイルおよびC/C++でセキュリティ対策が行われているコードスタイルが登録されている。この実施例では、図18に示すように、外部関数、特定関数、ループ+配列操作、ループ+ポインタ操作などがテンプレート52に登録されている。外部関数は、ユーザが作成した関数を表す。ユーザが作成した関数は、脆弱性が発生し得るので、テンプレート52に登録されることが好ましい。特定関数は、セキュアコーディングルール(CERT-Cなど)に規定される、C/C++言語を安全に利用できるように設計された関数を表す。一例としては、特定関数は、バッファオーバフロー対策が施されたC/C++の標準関数に相当する。ループ+配列操作は、例えば、配列に文字データを1バイトずつコピーする処理などが相当する。ループ+ポインタ操作は、例えば、アドレスが示す領域に文字データを1バイトずつコピーする処理などが相当する。なお、「C/C++で記述されたソースコードにおいて脆弱性が発生し得るコードスタイル」は、例えば、過去の経験または実績等に基づいて、ソースコード2を修正する作業者により列挙れてもよい。 Registered in the template 52 are code styles in which vulnerabilities may occur in source code written in C/C++ and code styles in which security measures are taken in C/C++. In this embodiment, as shown in FIG. 18, an external function, a specific function, a loop+array operation, a loop+pointer operation, etc. are registered in the template 52. External functions represent functions created by the user. Since functions created by users may be vulnerable, they are preferably registered in the template 52. The specific function represents a function defined in secure coding rules (such as CERT-C) and designed to allow safe use of the C/C++ language. As an example, the specific function corresponds to a C/C++ standard function that is protected against buffer overflows. The loop+array operation corresponds to, for example, the process of copying character data one byte at a time to an array. The loop+pointer operation corresponds to, for example, a process of copying character data one byte at a time to an area indicated by an address. Note that "code styles in which vulnerabilities may occur in source code written in C/C++" may be listed by the worker who modifies the source code 2, for example, based on past experience or track record. .

テンプレート作成部51は、上述したテンプレート52を作成する。なお、テンプレート作成部51は、例えば、ソースコード2を修正する作業者がコンピュータを操作することで実現される。 The template creation unit 51 creates the template 52 described above. Note that the template creation unit 51 is realized, for example, by an operator who modifies the source code 2 operating a computer.

テンプレート検索部53は、テンプレート52を用いてソースコード2を検索する。具体的には、テンプレート検索部53は、テンプレート52に登録されているコードスタイルを含むプログラムモジュールをソースコード2から抽出する。 The template search unit 53 searches the source code 2 using the template 52. Specifically, the template search unit 53 extracts a program module including the code style registered in the template 52 from the source code 2.

図19は、テンプレート検索部53の処理の一例を示すフローチャートである。このフローチャートの処理は、ソースコード修正支援装置1Cにソースコード2が与えられたときに実行される。ただし、このフローチャートの処理が実行される前に、図18に示すテンプレート52が作成されているものとする。 FIG. 19 is a flowchart showing an example of the processing of the template search unit 53. The processing in this flowchart is executed when the source code 2 is given to the source code modification support device 1C. However, it is assumed that the template 52 shown in FIG. 18 has been created before the processing in this flowchart is executed.

S71において、テンプレート検索部53は、ソースコード2を取得する。S72において、テンプレート検索部53は、ソースコード2から、テンプレート52と一致するコードスタイルを含むプログラムモジュールを抽出する。このとき、テンプレート検索部53は、好ましくは、抽出したプログラムモジュールが記述されている位置(行番号)を検出する。そして、S73において、テンプレート検索部53は、検索結果を表す検索結果リストを出力する。 In S71, the template search unit 53 obtains the source code 2. In S72, the template search unit 53 extracts a program module that includes a code style that matches the template 52 from the source code 2. At this time, the template search unit 53 preferably detects the position (line number) where the extracted program module is written. Then, in S73, the template search unit 53 outputs a search result list representing the search results.

図20~図21は、テンプレート検索部53による検索結果を表す検索結果リストの一例を示す。なお、図20~図21では省略しているが、検索結果リストは、図6または図14に示すように、抽出したプログラムモジュールの位置を表す情報を含んでもよい。 20 and 21 show an example of a search result list representing the search results by the template search unit 53. Although not shown in FIGS. 20 and 21, the search result list may include information indicating the location of the extracted program module, as shown in FIG. 6 or 14.

図20(a)に示す実施例では、テンプレートに基づいて、ソースコード2から外部関数(ex_strcpy)が検出され、その外部関数を含むプログラムモジュールが検索結果リスト81に登録されている。なお、テンプレート検索部53は、ユーザが作成した関数のうちで、違反がない下記の書式に沿った関数を含むプログラムモジュールを抽出する。
書式:関数名(格納先アドレス、格納先サイズ、読出し元アドレス)
なお、この実施例で抽出された関数は、格納先アドレスにデータを書き込むときに、指定された格納先サイズを超えないようにすることで、バッファオーバランを防いでいる。
In the embodiment shown in FIG. 20A, an external function (ex_strcpy) is detected from the source code 2 based on the template, and a program module including the external function is registered in the search result list 81. The template search unit 53 extracts, from among the functions created by the user, a program module that includes a function that conforms to the following format without any violation.
Format: Function name (storage destination address, storage destination size, read source address)
Note that the function extracted in this example prevents a buffer overrun by not exceeding a specified storage destination size when writing data to a storage destination address.

図20(b)に示す例では、ソースコード2から特定関数(strcpy_s)が検出され、その特定関数を含むプログラムモジュールが検索結果リスト81に登録されている。このコピー関数も、バッファオーバランを回避するように、パラメータ(dest、size、src)が指定されている。 In the example shown in FIG. 20(b), a specific function (strcpy_s) is detected from the source code 2, and a program module including the specific function is registered in the search result list 81. This copy function also has parameters (dest, size, src) specified to avoid buffer overruns.

図21(a)に示す例では、ソースコード2から「ループ+配列操作」に係わる記述が検出され、検出した記述を含むプログラムモジュールが検索結果リスト81に登録されている。例えば、ループ処理として、while文またはfor文が検出される。配列処理として、「dest[n]=データ」を表す記述が検出される。この実施例では、配列に文字データを1バイトずつコピーするための記述が検出されている。 In the example shown in FIG. 21A, a description related to "loop + array operation" is detected from the source code 2, and a program module including the detected description is registered in the search result list 81. For example, a while statement or a for statement is detected as a loop process. As the array processing, a description expressing "dest[n]=data" is detected. In this example, a description for copying character data one byte at a time to an array is detected.

図21(b)に示す例では、ソースコード2から「ループ+ポインタ操作」に係わる記述が検出され、検出した記述を含むプログラムモジュールが検索結果リスト81に登録されている。例えば、ループ処理として、while文またはfor文が検出される。配列処理として、「*dest=データ」を表す記述が検出される。この実施例では、指定されたアドレスが示す領域に文字データを1バイトずつコピーするための記述が検出されている。 In the example shown in FIG. 21(b), a description related to "loop + pointer operation" is detected from the source code 2, and a program module including the detected description is registered in the search result list 81. For example, a while statement or a for statement is detected as a loop process. As the array processing, a description representing "*dest=data" is detected. In this embodiment, a description for copying character data one byte at a time to the area indicated by the specified address is detected.

判定部54は、テンプレート検索部53によりソースコード2から抽出された各プログラムモジュールについて、他の言語に置き換えるか否かを判定する。すなわち、検索結果リスト81に登録されている各プログラムモジュールについて、他の言語に置き換えるか否か判定される。 The determination unit 54 determines whether each program module extracted from the source code 2 by the template search unit 53 should be replaced with another language. That is, it is determined whether each program module registered in the search result list 81 is to be replaced with another language.

図22は、判定部54の処理の一例を示すフローチャートである。このフローチャートの処理は、テンプレート検索部53によりソースコード2から1または複数のプログラムモジュールが抽出された後に実行される。すなわち、このフローチャートの処理が実行される前に検索結果リスト81が作成されているものとする。 FIG. 22 is a flowchart illustrating an example of processing by the determination unit 54. The processing in this flowchart is executed after one or more program modules are extracted from the source code 2 by the template search unit 53. That is, it is assumed that the search result list 81 has been created before the processing in this flowchart is executed.

S81において、判定部54は、テンプレート検索部53により作成された検索結果リストを取得する。S82において、判定部54は、検索結果リストからプログラムモジュールを選択する。S83において、判定部54は、選択したプログラムモジュールを他の言語に置き換えることの容易さに基づいて優先度を決定する。他の言語に置き換えることの容易さは、例えば、プログラムモジュールの複雑さまたは記述内容の結合度により判定される。 In S81, the determination unit 54 obtains the search result list created by the template search unit 53. In S82, the determination unit 54 selects a program module from the search result list. In S83, the determination unit 54 determines the priority based on the ease of replacing the selected program module with another language. The ease of replacing with another language is determined by, for example, the complexity of the program module or the degree of coupling of written contents.

図23~図24は、図20~図21に示す検索結果リストに登録されている各プログラムモジュールに対して優先度を付与した状態を示す。この実施例では、プログラムモジュールの結合度(または、他の言語に置き換えることの容易さ)は、3つのレベルで表される。また、プログラムモジュールの優先度は、結合度に対して設定される。例えば、図23に示す例では、外部関数ex_strcpyは、その結合度が中レベル(レベル2)であり、中レベル(レベル2)の優先度が付与されている。また、特定関数strcpy_sは、その結合度が低レベル(レベル1)であり、高レベル(レベル3)の優先度が付与されている。 23 and 24 show a state in which priorities are assigned to each program module registered in the search result list shown in FIGS. 20 and 21. In this example, the degree of coupling (or ease of replacing with other languages) of a program module is expressed in three levels. Furthermore, the priority of the program module is set with respect to the degree of coupling. For example, in the example shown in FIG. 23, the degree of coupling of the external function ex_strcpy is medium level (level 2) and is given medium level (level 2) priority. Further, the specific function strcpy_s has a low level of connectivity (level 1) and is given a high level (level 3) of priority.

S84において、判定部54は、選択したプログラムモジュールの優先度に応じて、そのプログラムモジュールに対する処理を決定する。優先度が「レベル3(高)」であるときは、判定部54は、選択したプログラムモジュールを他の言語に置き換えることが容易であると判定する。この場合、判定部54は、S85において、そのプログラムモジュールを他言語置換えリストに追加する。優先度が「レベル2(中)」であるときは、判定部54は、選択したプログラムモジュールを他の言語に置き換えることが、やや困難であると判定する。この場合、判定部54は、S86において、そのプログラムモジュールを他処理リストに追加する。優先度が「レベル1(低)」であるときは、判定部54は、選択したプログラムモジュールを他の言語に置き換えることが困難であると判定する。この場合、S85およびS86の処理はスキップされる。 In S84, the determination unit 54 determines processing for the selected program module according to the priority of the program module. When the priority is "level 3 (high)", the determination unit 54 determines that it is easy to replace the selected program module with another language. In this case, the determination unit 54 adds the program module to the other language replacement list in S85. When the priority is "level 2 (medium)", the determination unit 54 determines that it is somewhat difficult to replace the selected program module with another language. In this case, the determination unit 54 adds the program module to the other processing list in S86. When the priority is "level 1 (low)", the determination unit 54 determines that it is difficult to replace the selected program module with another language. In this case, the processes of S85 and S86 are skipped.

S87において、判定部54は、S83~S86の処理を実行していないプログラムモジュールが検索結果リストに残っているかチェックする。S83~S86の処理を実行していないプログラムモジュールが検索結果リストに残っているときには、判定部54の処理はS82に戻る。すなわち、検索結果リストから次のプログラムモジュールが選択される。この後、新たに選択されたプログラムモジュールに対してS83~S86の処理が実行される。そして、検索結果リストに登録されているすべてのプログラムモジュールに対してS83~86の処理が実行されると、判定部54の処理は終了する。この結果、他言語置換えリストおよび他処理リストが作成される。 In S87, the determination unit 54 checks whether there are any program modules remaining in the search result list for which the processes in S83 to S86 have not been executed. If a program module that has not undergone the processes of S83 to S86 remains in the search result list, the process of the determination unit 54 returns to S82. That is, the next program module is selected from the search result list. Thereafter, the processes of S83 to S86 are executed for the newly selected program module. Then, when the processes of S83 to S86 are executed for all program modules registered in the search result list, the process of the determination unit 54 ends. As a result, a foreign language replacement list and a foreign processing list are created.

このように、ソースコード修正支援装置1Cは、テンプレート52を利用して、ソースコード2から、信頼性の高い言語に置き換えることが好ましいプログラムモジュールを抽出する。そして、ソースコード修正支援装置1Cにより得られた結果は、ソースコード修正装置55に与えられる。 In this way, the source code modification support device 1C uses the template 52 to extract program modules that are preferably replaced with a highly reliable language from the source code 2. The results obtained by the source code modification support device 1C are then given to the source code modification device 55.

ソースコード修正装置55の動作は、図1に示すソースコード修正装置4と実質的に同じである。すなわち、ソースコード修正装置55は、ソースコード修正支援装置1Cから出力される情報に基づいてソースコードを修正する。例えば、ソースコード修正装置55は、ソースコード修正支援装置1Cにより生成される他言語置換えリストに登録されているプログラムモジュールをRUSTに置き換える。この後、図9に示す手順と同様に、試験装置5を用いて修正後のソースコードの試験を行ってもよい。 The operation of source code modification device 55 is substantially the same as source code modification device 4 shown in FIG. That is, the source code modification device 55 modifies the source code based on the information output from the source code modification support device 1C. For example, the source code modification device 55 replaces the program module registered in the other language replacement list generated by the source code modification support device 1C with RUST. Thereafter, the modified source code may be tested using the testing device 5, similar to the procedure shown in FIG.

<バリエーション>
図25は、本発明の実施形態のバリエーションを示す。本発明の実施形態のバリエーションにおいては、図1に示すソースコード修正支援装置1または図10に示すソースコード修正支援装置1Bの入力側に、図17に示すソースコード修正支援装置1Cが設けられる。以下の記載では、図1に示すソースコード修正支援装置1または図10に示すソースコード修正支援装置1Bを「ソースコード修正支援装置1/1B」と呼ぶことがある。
<Variation>
FIG. 25 shows a variation of an embodiment of the invention. In a variation of the embodiment of the present invention, a source code modification support device 1C shown in FIG. 17 is provided on the input side of the source code modification support device 1 shown in FIG. 1 or the source code modification support device 1B shown in FIG. In the following description, the source code modification support device 1 shown in FIG. 1 or the source code modification support device 1B shown in FIG. 10 may be referred to as "source code modification support device 1/1B."

ソースコード修正支援装置1Cとソースコード修正支援装置1/1Bとの間に図17に示すソースコード修正装置55が設けられる。また、ソースコード修正支援装置1/1Bの出力側に図1または図10に示すソースコード修正装置4および試験装置5が設けられる。この構成によれば、メトリクス及び/又はセキュアコーディングルールに基づいて、リスクが高いプログラムモジュールが信頼性の高い言語に置き換えられることに加えて、脆弱性が発生し得るコードスタイルおよび脆弱性の対策が行われているコードスタイルに係わるプログラムモジュールも信頼性の高い言語に置き換えられる。 A source code modification device 55 shown in FIG. 17 is provided between source code modification support device 1C and source code modification support device 1/1B. Further, the source code modification device 4 and testing device 5 shown in FIG. 1 or 10 are provided on the output side of the source code modification support device 1/1B. According to this configuration, in addition to replacing high-risk program modules with reliable languages based on metrics and/or secure coding rules, code styles that can lead to vulnerabilities and countermeasures for vulnerabilities are Program modules related to the current code style are also replaced with more reliable languages.

なお、図25に示す構成において、ソースコード修正装置4が、ソースコード修正支援装置1/1Bにより生成される他言語置換えリストだけでなく、ソースコード修正支援装置1Cにより生成される他言語置換えリストにも基づいてソースコードを修正する場合には、ソースコード修正装置55を備える必要はない。また、ソースコード修正支援装置1Cは、図25ではソースコード修正支援装置1/1Bの入力側に設けられているが、ソースコード修正支援装置1/1Bの出力側に設けられてもよい。さらに、ソースコード修正支援装置1/1Bおよびソースコード修正支援装置1Cが1つのソースコード修正支援装置を構成してもよい。 In the configuration shown in FIG. 25, the source code modification device 4 uses not only the foreign language replacement list generated by the source code modification support device 1/1B but also the foreign language replacement list generated by the source code modification support device 1C. If the source code is to be modified based on the source code, it is not necessary to provide the source code modification device 55. Further, although the source code modification support device 1C is provided on the input side of the source code modification support device 1/1B in FIG. 25, it may be provided on the output side of the source code modification support device 1/1B. Furthermore, the source code modification support device 1/1B and the source code modification support device 1C may constitute one source code modification support device.

<ハードウェア構成>
図26は、ソースコード修正支援装置1、1B、または1Cのハードウェア構成の一例を示す。ソースコード修正支援装置1、1B、または1Cは、プロセッサ201、メモリ202、記憶装置203、入出力デバイス204、記録媒体読取り装置205、および通信インタフェース206を備えるコンピュータ200により実現される。
<Hardware configuration>
FIG. 26 shows an example of the hardware configuration of the source code modification support device 1, 1B, or 1C. The source code modification support device 1, 1B, or 1C is realized by a computer 200 including a processor 201, a memory 202, a storage device 203, an input/output device 204, a recording medium reading device 205, and a communication interface 206.

プロセッサ201は、記憶装置203に保存されている修正支援プログラムを実行することにより、ソースコード修正支援装置1、1B、または1Cの動作を制御する。ソースコード修正支援装置1においては、修正支援プログラムは、図3、図5、および図7に示すフローチャートの手順を記述したプログラムコードを含む。よって、プロセッサ201がこのプログラムを実行することで、図1に示すメトリクスルールリスト作成部11、メトリクスルールリスト取得部12、構造解析部13、および判定部14の機能が提供される。また、ソースコード修正支援装置1Bにおいては、修正支援プログラムは、図3、図5、図13、および図15に示すフローチャートの手順を記述したプログラムコードを含む。よって、プロセッサ201がこのプログラムを実行することで、図10に示すメトリクスルールリスト作成部11、メトリクスルールリスト取得部12、構造解析部13、セキュリティルールリスト作成部31、セキュリティルールリスト取得部32、静的解析部33、および判定部14Bの機能が提供される。さらに、ソースコード修正支援装置1Cにおいては、修正支援プログラムは、図19および図22に示すフローチャートの手順を記述したプログラムコードを含む。よって、プロセッサ201がこのプログラムを実行することで、図17に示すテンプレート検索部53および判定部54の機能が提供される。メモリ202は、プロセッサ201の作業領域として使用される。記憶装置203は、上述した修正支援プログラムおよび他のプログラムを保存する。 Processor 201 controls the operation of source code modification support device 1, 1B, or 1C by executing a modification support program stored in storage device 203. In the source code modification support device 1, the modification support program includes a program code that describes the procedures of the flowcharts shown in FIGS. 3, 5, and 7. Therefore, when the processor 201 executes this program, the functions of the metrics rule list creation section 11, metrics rule list acquisition section 12, structure analysis section 13, and determination section 14 shown in FIG. 1 are provided. Furthermore, in the source code modification support device 1B, the modification support program includes program codes that describe the procedures of the flowcharts shown in FIGS. 3, 5, 13, and 15. Therefore, by the processor 201 executing this program, the metrics rule list creation section 11, the metrics rule list acquisition section 12, the structure analysis section 13, the security rule list creation section 31, the security rule list acquisition section 32, shown in FIG. The functions of the static analysis section 33 and the determination section 14B are provided. Furthermore, in the source code modification support device 1C, the modification support program includes a program code that describes the procedures of the flowcharts shown in FIGS. 19 and 22. Therefore, when the processor 201 executes this program, the functions of the template search unit 53 and determination unit 54 shown in FIG. 17 are provided. Memory 202 is used as a work area for processor 201. The storage device 203 stores the above-mentioned modification support program and other programs.

入出力デバイス204は、キーボード、マウス、タッチパネル、マイクなどの入力デバイスを含む。また、入出力デバイス204は、表示装置、スピーカーなどの出力デバイスを含む。記録媒体読取り装置205は、記録媒体210に記録されているデータおよび情報を取得できる。記録媒体210は、コンピュータ200に着脱可能なリムーバブル記録媒体である。また、記録媒体210は、例えば、半導体メモリ、光学的作用で信号を記録する媒体、または磁気的作用で信号を記録する媒体により実現される。なお、修正支援プログラムは、記録媒体210からコンピュータ200に与えられてもよい。通信インタフェース206は、ネットワークに接続する機能を提供する。なお、修正支援プログラムがプログラムサーバ220に保存されているときは、コンピュータ200は、プログラムサーバ220から修正支援プログラムを取得してもよい。 The input/output device 204 includes input devices such as a keyboard, a mouse, a touch panel, and a microphone. In addition, the input/output device 204 includes an output device such as a display device and a speaker. The recording medium reading device 205 can acquire data and information recorded on the recording medium 210. The recording medium 210 is a removable recording medium that can be attached to and detached from the computer 200. Further, the recording medium 210 is realized by, for example, a semiconductor memory, a medium for recording signals by optical action, or a medium for recording signals by magnetic action. Note that the modification support program may be provided to the computer 200 from the recording medium 210. Communication interface 206 provides the ability to connect to a network. Note that when the modification support program is stored in the program server 220, the computer 200 may acquire the modification support program from the program server 220.

図26に示すコンピュータ200は、ソースコード修正支援装置1、1B、1Cの機能に加えて、ソースコード修正装置4、ソースコード修正装置55、および試験装置5の機能を提供してもよい。また、ソースコード修正支援装置1、1B、1C、ソースコード修正装置4、55、および試験装置5は、別々のコンピュータで実現してもよい。 Computer 200 shown in FIG. 26 may provide the functions of source code modification device 4, source code modification device 55, and testing device 5 in addition to the functions of source code modification support devices 1, 1B, and 1C. Further, the source code modification support devices 1, 1B, 1C, the source code modification devices 4, 55, and the testing device 5 may be realized by separate computers.

1、1B、1C ソースコード修正支援装置
2 ソースコード
3 メトリクスリスト
4 ソースコード修正装置
5 試験装置
11 メトリクスルールリスト作成部
12 メトリクスルールリスト取得部
13 構造解析部
14、14B 判定部
21 評価値リスト
22 メトリクスルールリスト
23 分析結果リスト
24 分析結果の概要を表す分析結果リスト
25 他言語置換えリスト
26 他処理リスト
30 セキュアコーディングルール
31 セキュリティルールリスト作成部
32 セキュリティルールリスト取得部
33 静的解析部
41 優先度リスト
42 セキュリティルールリスト
43 検索結果リスト
44 検索結果の概要を表す検索結果リスト
45 他言語置換えリスト
46 他処理リスト
51 テンプレート作成部
52 テンプレート
53 テンプレート検索部
54 判定部
200 コンピュータ
201 プロセッサ
202 メモリ
203 記憶装置
204 入出力デバイス
205 記録媒体読取り装置
206 通信インタフェース
210 記録媒体
220 プログラムサーバ
1, 1B, 1C Source code modification support device 2 Source code 3 Metrics list 4 Source code modification device 5 Test device 11 Metrics rule list creation section 12 Metrics rule list acquisition section 13 Structural analysis section 14, 14B Judgment section 21 Evaluation value list 22 Metric rule list 23 Analysis result list 24 Analysis result list 25 representing an overview of analysis results Other language replacement list 26 Other processing list 30 Secure coding rules 31 Security rule list creation unit 32 Security rule list acquisition unit 33 Static analysis unit 41 Priority List 42 Security rule list 43 Search result list 44 Search result list 45 showing an overview of search results Other language replacement list 46 Other processing list 51 Template creation section 52 Template 53 Template search section 54 Judgment section 200 Computer 201 Processor 202 Memory 203 Storage device 204 Input/output device 205 Recording medium reading device 206 Communication interface 210 Recording medium 220 Program server

Claims (7)

ソースコードの構造の分析に係わる複数のメトリクス項目それぞれに対してプログラムの複雑さを判断するための基準値およびプログラムの複雑さに対応する評価値を付与することで作成されるメトリクスルールリストを取得するメトリクスルールリスト取得部と、
第1の言語で記述されたソースコード中の各プログラムモジュールについて、前記メトリクスルールリストに登録されている各メトリクス項目に対応する基準値に違反しているか否かをそれぞれ判定し、基準値に違反しているメトリクス項目に対応する評価値の和を表す評価点数を計算する構造解析部と、
前記構造解析部により計算された評価点数に基づいて、各プログラムモジュールに対する対処方針を判定する判定部と、
を備えるソースコード修正支援装置。
Obtain a metrics rule list created by assigning a reference value for determining program complexity and an evaluation value corresponding to program complexity to each of multiple metrics items related to source code structure analysis. a metrics rule list acquisition unit,
For each program module in the source code written in the first language, it is determined whether or not it violates the standard value corresponding to each metrics item registered in the metrics rule list, and the standard value is violated. a structural analysis unit that calculates an evaluation score representing the sum of evaluation values corresponding to the metrics items being evaluated;
a determination unit that determines a response policy for each program module based on the evaluation score calculated by the structure analysis unit;
A source code modification support device comprising:
前記判定部は、前記構造解析部により計算された評価点数が所定の閾値を超えているプログラムモジュールを、前記第1の言語よりも信頼性の高い第2の言語に置き換える、ことを指示する情報を出力する
ことを特徴とする請求項1に記載のソースコード修正支援装置。
Information instructing the determination unit to replace a program module whose evaluation score calculated by the structure analysis unit exceeds a predetermined threshold with a second language that is more reliable than the first language. The source code modification support device according to claim 1, wherein the source code modification support device outputs the following.
前記メトリクスルールリストにおいて、プログラムモジュールの記述が基準値に違反するときにセキュリティ上のリスクが大きくなるメトリクス項目ほど高い評価点が付与されている
ことを特徴とする請求項2に記載のソースコード修正支援装置。
The source code correction according to claim 2, wherein in the metrics rule list, a metrics item that poses a greater security risk when the description of a program module violates a standard value is given a higher evaluation point. Support equipment.
前記第1の言語で記述された前記ソースコードにおいて、ソースコードを記述する際に守らなければならない予め決められたコーディングルールに違反する違反記述を抽出する静的解析部をさらに備え、
前記判定部は、前記静的解析部により抽出された違反記述を含む各プログラムモジュールについて、前記構造解析部により計算された評価点数に基づいて対処方針を判定する
ことを特徴とする請求項1に記載のソースコード修正支援装置。
Further comprising a static analysis unit that extracts, in the source code written in the first language, a violation description that violates a predetermined coding rule that must be followed when writing the source code,
According to claim 1, the determination unit determines a response policy for each program module including the violation description extracted by the static analysis unit, based on the evaluation score calculated by the structural analysis unit. Source code modification support device described.
前記第1の言語で記述されたソースコードにおいて脆弱性が発生し得るコードスタイルまたは前記第1の言語において脆弱性に係わる対策が行われているコードスタイルの少なくとも一方が登録されたテンプレートを取得し、前記ソースコードから、前記テンプレートに登録されているコードスタイルを含むプログラムモジュールを抽出するテンプレート検索部と、
前記テンプレート検索部により抽出されたプログラムモジュールを前記第2の言語に置き換えるか否かを判定する第2の判定部と、をさらに備える
ことを特徴とする請求項1に記載のソースコード修正支援装置。
Obtaining a template in which at least one of a code style in which vulnerabilities may occur in source code written in the first language or a code style in which countermeasures related to vulnerabilities are taken in the first language is registered. , a template search unit that extracts a program module including a code style registered in the template from the source code;
The source code modification support device according to claim 1, further comprising a second determination unit that determines whether to replace the program module extracted by the template search unit with the second language. .
ソースコードの構造の分析に係わる複数のメトリクス項目それぞれに対してプログラムの複雑さを判断するための基準値およびプログラムの複雑さに対応する評価値を付与することで作成されるメトリクスルールリストを取得するメトリクスルールリスト取得部と、
第1の言語で記述されたソースコード中の各プログラムモジュールについて、前記メトリクスルールリストに登録されている各メトリクス項目に対応する基準値に違反しているか否かをそれぞれ判定し、基準値に違反しているメトリクス項目に対応する評価値の和を表す評価点数を計算する構造解析部と、
各プログラムモジュールについて、前記構造解析部により計算された評価点数に基づいて、前記第1の言語よりも信頼性の高い第2の言語に置き換えるべきか否かを判定する判定部と、
前記判定部により前記第2の言語に置き換えるべきと判定されたプログラムモジュールを、前記第2の言語の記述に変換する変換部と、
を備えるソースコード修正システム。
Obtain a metrics rule list created by assigning a reference value for determining program complexity and an evaluation value corresponding to program complexity to each of multiple metrics items related to source code structure analysis. a metrics rule list acquisition unit,
For each program module in the source code written in the first language, it is determined whether or not it violates the standard value corresponding to each metrics item registered in the metrics rule list, and the standard value is violated. a structural analysis unit that calculates an evaluation score representing the sum of evaluation values corresponding to the metrics items being evaluated;
a determination unit that determines whether each program module should be replaced with a second language that is more reliable than the first language based on the evaluation score calculated by the structure analysis unit;
a conversion unit that converts a program module determined by the determination unit to be replaced with the second language into a description in the second language;
A source code modification system.
ソースコードの構造の分析に係わる複数のメトリクス項目それぞれに対してプログラムの複雑さを判断するための基準値およびプログラムの複雑さに対応する評価値を付与することで作成されるメトリクスルールリストを取得し、
第1の言語で記述されたソースコード中の各プログラムモジュールについて、前記メトリクスルールリストに登録されている各メトリクス項目に対応する基準値に違反しているか否かをそれぞれ判定し、基準値に違反しているメトリクス項目に対応する評価値の和を表す評価点数を計算し、
前記評価点数に基づいて、各プログラムモジュールに対する対処方針を判定する
ことを特徴とするソースコード修正支援方法。
Obtain a metrics rule list created by assigning a reference value for determining program complexity and an evaluation value corresponding to program complexity to each of multiple metrics items related to source code structure analysis. death,
For each program module in the source code written in the first language, it is determined whether or not it violates the standard value corresponding to each metrics item registered in the metrics rule list, and the standard value is violated. Calculate the evaluation score that represents the sum of the evaluation values corresponding to the metrics items that are
A source code modification support method characterized by determining a response policy for each program module based on the evaluation score.
JP2022193242A 2022-08-23 2022-12-02 Source code modification support device and source code modification support method Pending JP2024031735A (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2022132394 2022-08-23
JP2022132394 2022-08-23

Publications (1)

Publication Number Publication Date
JP2024031735A true JP2024031735A (en) 2024-03-07

Family

ID=90105587

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2022193242A Pending JP2024031735A (en) 2022-08-23 2022-12-02 Source code modification support device and source code modification support method

Country Status (1)

Country Link
JP (1) JP2024031735A (en)

Similar Documents

Publication Publication Date Title
CN109426722B (en) SQL injection defect detection method, system, equipment and storage medium
Ocariza et al. An empirical study of client-side JavaScript bugs
KR100509650B1 (en) Method to detect malicious scripts using code insertion technique
KR101051600B1 (en) Systems for performing code inspection on abap source code
EP3458953A1 (en) Systems and methods for model-based analysis of software
US20050223361A1 (en) Software testing based on changes in execution paths
US20040181677A1 (en) Method for detecting malicious scripts using static analysis
US8732676B1 (en) System and method for generating unit test based on recorded execution paths
US20160299831A1 (en) Target Typing-dependent Combinatorial Code Analysis
CN105205144A (en) Method and system used for data diagnosis and optimization
JP6282217B2 (en) Anti-malware system and anti-malware method
JP4951416B2 (en) Program verification method and program verification apparatus
CN112131120B (en) Source code defect detection method and device
EP2105837B1 (en) Test script transformation analyzer with change guide engine
CN114911711A (en) Code defect analysis method and device, electronic equipment and storage medium
JP6486574B2 (en) Program code generating apparatus, program code generating method, and program code generating program
US7624304B2 (en) Defect detection for integers
CN111919214A (en) Automatic generation of patches for security violations
CN109032946B (en) Test method and device and computer readable storage medium
JP2024031735A (en) Source code modification support device and source code modification support method
JP4929121B2 (en) Source program analysis apparatus, source program analysis method, and computer program
Dhatchayani et al. Test Case Generation and Reusing Test Cases for GUI Designed with HTML.
JP2024013784A (en) Source code modification support device and source code modification support method
Li et al. DepTaint: a static taint analysis method based on program dependence
WO2020008632A1 (en) Hypothesis inference device, hypothesis inference method, and computer-readable recording medium