WO2018158893A1 - ソースコード解析装置、ソースコード解析方法及びソースコード解析プログラム - Google Patents

ソースコード解析装置、ソースコード解析方法及びソースコード解析プログラム Download PDF

Info

Publication number
WO2018158893A1
WO2018158893A1 PCT/JP2017/008178 JP2017008178W WO2018158893A1 WO 2018158893 A1 WO2018158893 A1 WO 2018158893A1 JP 2017008178 W JP2017008178 W JP 2017008178W WO 2018158893 A1 WO2018158893 A1 WO 2018158893A1
Authority
WO
WIPO (PCT)
Prior art keywords
source code
inter
domain
domain communication
unit
Prior art date
Application number
PCT/JP2017/008178
Other languages
English (en)
French (fr)
Inventor
藤本 卓也
忠隆 浅川
中村 勝彦
Original Assignee
三菱電機株式会社
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 三菱電機株式会社 filed Critical 三菱電機株式会社
Priority to PCT/JP2017/008178 priority Critical patent/WO2018158893A1/ja
Publication of WO2018158893A1 publication Critical patent/WO2018158893A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Definitions

  • the present invention relates to software analysis.
  • Patent Document 1 discloses a technique for detecting an error in how to use a resource capture / release function for capturing and releasing resources.
  • an error in how to use the resource capture / release function is detected by specifying a resource capture / release function in the program and analyzing the source code of the program.
  • Patent Document 2 discloses a technique for preventing an erroneous indication of securing and releasing dynamic memory.
  • the processing flow on the transmission side and the processing flow on the reception side are associated with each other from the descriptor obtained by the static analysis for the multi-thread program to secure and release the dynamic memory. Prevent false indications.
  • the main purpose of the present invention is to solve the above problems. More specifically, the main object of the present invention is to obtain a configuration capable of detecting a problem that occurs when a plurality of programs are executed in parallel by inter-domain communication.
  • the source code analysis apparatus is: An extraction unit that extracts a part that realizes the inter-domain communication from each of a plurality of source codes of a plurality of programs executed in a plurality of domains in which inter-domain communication is performed; A coupling unit coupling a plurality of inter-domain communication part source codes extracted by the extraction unit; And an analysis unit for analyzing the combined source code obtained by combining the plurality of inter-domain communication partial source codes by the combining unit.
  • a problem that occurs when a plurality of programs are executed in parallel by inter-domain communication is detected. Can do.
  • FIG. 3 is a diagram illustrating a functional configuration example of a source code analysis apparatus according to the first embodiment.
  • FIG. 3 is a diagram illustrating a hardware configuration example of the source code analysis device according to the first embodiment.
  • FIG. 3 is a diagram illustrating a correspondence between a functional configuration and a hardware configuration of the source code analysis apparatus according to the first embodiment.
  • FIG. 3 is a diagram showing an example of source code of a program according to the first embodiment.
  • FIG. 4 is a diagram showing a format example of program element information according to the first embodiment.
  • FIG. 5 is a diagram showing a description example of program element information according to the first embodiment. The figure which shows the example of the static analysis result obtained when the source code of each program which concerns on Embodiment 1 carries out static analysis independently.
  • FIG. 3 is a diagram illustrating a functional configuration example of a source code analysis apparatus according to the first embodiment.
  • FIG. 3 is a diagram illustrating a hardware configuration example of the source code analysis device according to the first embodiment
  • FIG. 3 shows an example of combined source code according to the first embodiment.
  • FIG. 5 is a flowchart showing an operation example of the source code analysis apparatus according to the first embodiment.
  • FIG. *** Explanation of configuration *** FIG. 1 shows a functional configuration example of a source code analysis apparatus 10 according to this embodiment.
  • FIG. 2 shows a hardware configuration example of the source code analysis apparatus 10.
  • FIG. 3 shows a correspondence between the functional configuration shown in FIG. 1 and the hardware configuration shown in FIG.
  • the operations performed in the source code analysis device 10 correspond to a source code analysis method and a source code analysis program.
  • the source code analysis apparatus 10 receives communication data and source code from a domain A21, a domain B22, and a domain N23.
  • Domain A21, domain B22, and domain N23 are computers that execute programs. Domain A21, domain B22, and domain N23 are, for example, a PC (Personal Computer), a server device, and the like.
  • the domain A21 executes the program A210.
  • Domain B22 executes program B220.
  • the domain N23 executes the program N230. Domain A21, domain B22, and domain N23 perform inter-domain communication and transmit / receive communication data to / from each other.
  • the source code analysis device 10 is a computer.
  • the source code analysis device 10 includes a processor 901, a storage device 902, a communication interface 903, and an input / output interface 904 as hardware.
  • the storage device 902 stores programs that realize the functions of the collection unit 101, the extraction unit 103, the combination unit 104, and the analysis unit 105 shown in FIG.
  • the processor 901 executes these programs, and performs operations of the collection unit 101, the extraction unit 103, the combining unit 104, and the analysis unit 105, which will be described later.
  • FIG. 3 schematically illustrates a state in which the processor 901 is executing a program that realizes the functions of the collection unit 101, the extraction unit 103, the combination unit 104, and the analysis unit 105.
  • the program element information storage unit 102 and the analysis result information storage unit 106 shown in FIG. 1 are realized by a storage device 902 as shown in FIG.
  • the communication interface 903 is used for the source code analysis apparatus 10 to communicate with the domain A21, the domain B22, and the domain N23.
  • the input / output interface 904 is used by the user of the source code analysis apparatus 10 to input various instructions to the source code analysis apparatus 10.
  • the input / output interface 904 is used by the source code analysis apparatus 10 to present various data to the user.
  • the collection unit 101 collects communication data communicated between a plurality of domains via the communication interface 903. In the example of FIG. 1, inter-domain communication is performed between the domain A 21 and the domain B 22, and the collection unit 101 collects communication data transmitted and received between the domain A 21 and the domain B 22.
  • the collection unit 101 extracts program elements, which are elements included in a program executed in each domain, from the collected communication data, and generates program element information indicating the extracted program elements.
  • the collection unit 101 stores the generated program element information in the program element information storage unit 102.
  • the program element information storage unit 102 stores program element information.
  • the extraction unit 103 collects source codes of programs executed in each domain from each of a plurality of domains in which inter-domain communication is performed via the communication interface 903. And the extraction part 103 extracts the part which implement
  • the extraction unit 103 identifies the interdomain communication partial source code in each of the plurality of source codes based on the communication time of the communication data and the program elements (function, return value, argument) included in the communication data. Further, the extraction unit 103 outputs the extracted plurality of inter-domain communication partial source codes to the combining unit 104. The operation performed by the extraction unit 103 corresponds to extraction processing.
  • the combining unit 104 combines a plurality of inter-domain communication partial source codes extracted by the extracting unit 103.
  • the source code obtained by the combining unit 104 combining a plurality of inter-domain communication part source codes is referred to as combined source code.
  • the combining unit 104 outputs the combined source code to the analyzing unit 105.
  • the operation performed by the combining unit 104 corresponds to a combining process.
  • the analysis unit 105 performs static analysis of the combined source code. Then, the analysis unit 105 stores analysis result information indicating the result of the static analysis in the analysis result information storage unit 106. The operation performed by the analysis unit 105 corresponds to analysis processing.
  • the analysis result information storage unit 106 stores analysis result information.
  • FIG. 4 shows source code 2100 of program A210 and source code 2200 of program B220.
  • FIG. 5 shows a format example of the program element information.
  • FIG. 6 shows a description example of program element information.
  • FIG. 7 shows analysis result information obtained when the source code 2100 and the source code 2200 are statically analyzed independently.
  • FIG. 8 shows an example of the combined source code.
  • FIG. 9 shows an example of analysis result information obtained when the combined source code is statically analyzed.
  • FIG. 10 shows an operation example of the source code analysis apparatus 10.
  • the collection unit 101 is activated when a user of the source code analysis apparatus 10 gives an instruction using the input / output interface 904 (step S101).
  • the collection unit 101 communicates with each program in each domain, starts each program, and executes each program (step S102).
  • the collection unit 101 collects communication data transmitted / received by inter-domain communication, and generates program element information based on the collected communication data (step S103).
  • a function for transmitting communication data to the collection unit 101 has already been inserted into each program in each domain, and when each program is executed, communication between domains is performed and communication data transmitted by inter-domain communication is performed. Is also transmitted to the collection unit 101 by the function.
  • the collection unit 101 receives communication data transmitted from each program and generates program element information in the format shown in FIG. Then, the collection unit 101 stores the generated program element information in the program element information storage unit 102. As shown in FIG.
  • program element information includes communication time 501, function name 502, source code file name 503, line number 504, return variable name 505 and return value 506, argument variable name 505 and argument value.
  • a pair with 506 is included.
  • a plurality of pairs of the argument variable name 505 and the argument value 506 may be included.
  • the communication time 501 is a time when inter-domain communication is performed.
  • a function name 502 is a name of a function that performs inter-domain communication.
  • the source code file name 503 is the name of the source code file in which the function indicated by the function name 502 is called.
  • a line number 504 is a line number in the source file indicated by the source code file name 503.
  • a return value variable name 505 is a variable name of a return value of the function indicated by the function name 502.
  • a return value 506 is a return value of the function indicated by the function name 502.
  • the argument variable name 505 is a variable name of an argument included in the function indicated by the function name 502.
  • the argument value 506 is an argument value included in the function indicated by the function name 502.
  • FIG. 6 shows program element information generated based on communication data from the program A 210 and the program B 220.
  • the collection unit 101 confirms the end of the program in the domain. If the program has not been completed by the specified timing, the user of the source code analysis apparatus 10 instructs the collection unit 101 to forcibly terminate the program, and the collection unit 101 forcibly terminates the program (step S104). .
  • the extraction unit 103 acquires program element information and source code (step S105). More specifically, the extraction unit 103 reads program element information from the program element information storage unit 102. Further, the source code is received from each of a plurality of domains in which the collection unit 101 has collected communication data in step S103, that is, a plurality of domains that have transmitted and received communication data by inter-domain communication. In the example of FIG. 1, since inter-domain communication is performed between the domain A21 and the domain B22, the extraction unit 103 receives the source code of the program A210 from the domain A21 and receives the source code of the program B220 from the domain B22. .
  • the extraction unit 103 receives the source code 2100 as the source code of the program A210 from the domain A21 and the source code 2200 as the source code of the program B220 from the domain B22, as shown in FIG. To do. Further, it is assumed that the extraction unit 103 has read the program element information shown in FIG. In FIG. 4, data is written to a storage area used by the program B 220 by write_to_B () of the program A 210, and data is read from the storage area by read_from_A () of the program B 220. In the above description, the extraction unit 103 receives source code from each domain.
  • the extraction unit 103 A source file may be acquired, and the source code of each domain may be acquired from the acquired source file.
  • the extraction unit 103 may acquire the source code of each domain from the external device. Further, the extraction unit 103 may change the source code acquisition method for each domain. For example, the extraction unit 103 receives the source code of the domain A21 from the domain A21, acquires the source code of the domain B22 from the source file in the source code analysis device 10, and acquires the source code of the domain N23 from the external device. It may be.
  • the extraction unit 103 analyzes the program element information and the source code acquired in step S105, and extracts an inter-domain communication partial source code from each source code (step S106). Specifically, the extraction unit 103 specifies a pair of records corresponding to transmission / reception of communication data in the program element information. In the example of FIG. 6, the extraction unit 103 extracts the first row record and the second row record of the program element information. Then, the extraction unit 103 uses the function name 502 (“write_to_B”), the line number 504 (“3”), the argument 1 variable name 505 (“unit_no”), etc. in the first line of the program element information, as shown in FIG. A function 211 is extracted from the source code 2100.
  • the extraction unit 103 extracts a code block of reference numeral 212 that is the substance of the function of reference numeral 211. Further, the extraction unit 103 sets the function name 502 (“read_from_A”), the line number 504 (“5”), the return value variable name 505 (“idx”), the argument 1 variable name 505 ( Based on “unit_no”) and the like, the code block 221 is extracted from the source code 2200 of FIG. Both the code block denoted by reference numeral 212 and the code block denoted by reference numeral 221 are portions that realize inter-domain communication, and are inter-domain communication partial source codes. In the example of FIGS.
  • the extraction unit 103 extracts a code block denoted by reference numeral 212 and a code block denoted by reference numeral 221 as inter-domain communication partial source codes.
  • the extraction unit 103 outputs the extracted inter-domain communication partial source code to the combining unit 104.
  • the combining unit 104 combines the inter-domain communication partial source code output from the combining unit 104 to generate a combined source code (Step S107). 8, the combining unit 104 extracts the inter-domain communication partial source code (code block 212) extracted from the source code 2100 in FIG. 4 and the inter-domain communication partial source code extracted from the source code 2200 in FIG. A combined source code generated by combining (a code block of reference numeral 221) is shown.
  • the extraction unit 103 determines whether or not an unextracted inter-domain communication part source code exists (step S108). If there is no unextracted inter-domain communication part source code, the combining unit 104 determines that the combined source The code is output to the analysis unit 105. Then, the analysis unit 105 performs a static analysis of the combined source code (step S109). Thereafter, the analysis unit 105 stores the analysis result information in the analysis result information storage unit 106 (step S110). The analysis unit 105 may display the analysis result information on the display device that is the input / output interface 904, together with storing the analysis result information in the analysis result information storage unit 106.
  • FIG. 7 shows analysis result information obtained when the source code 2100 and the source code 2200 shown in FIG.
  • FIG. 9 shows an example of analysis result information obtained when the combined source code shown in FIG. 8 is statically analyzed.
  • the analysis unit 105 performs static analysis on the source code 2100 and the source code 2200 individually, as shown in FIG. 7, no problem related to the variable idx is detected for the program B220.
  • the analysis unit 105 performs a static analysis on the combined source code, as shown in FIG. 9, a problem relating to the variable idx is newly detected for the program B220.
  • a warning is described as a result of the static analysis.
  • the source code analysis apparatus 10 analyzes a combined source code obtained by combining a plurality of inter-domain communication partial source codes, so that a plurality of programs are executed in parallel by inter-domain communication. It is possible to detect problems that occur when That is, it is possible to detect a problem that cannot be detected by analyzing each of a plurality of source codes. As a result, according to the present embodiment, it is possible to improve the defect detection hit rate of the static analysis result and to effectively ensure the mounting quality.
  • the extraction unit 103 extracts the inter-domain communication partial source code from the source code of two programs executed in two domains.
  • the extraction unit 103 extracts inter-domain communication partial source code from source codes of three or more programs executed in the three or more domains.
  • the collection unit 101 may generate program element information including items different from the items illustrated in FIG. 5 according to the elements included in the program executed in the domain.
  • a processor 901 illustrated in FIG. 2 is an IC (Integrated Circuit) that performs processing.
  • the processor 901 is a CPU (Central Processing Unit), a DSP (Digital Signal Processor), or the like.
  • the storage device 902 illustrated in FIG. 2 is a RAM (Random Access Memory), a ROM (Read Only Memory), a flash memory, a HDD (Hard Disk Drive), or the like.
  • the communication interface 903 shown in FIG. 2 includes a receiver that receives data and a transmitter that transmits data.
  • the communication interface 903 is, for example, a communication chip or a NIC (Network Interface Card).
  • the input / output interface 904 is, for example, a mouse, a keyboard, and a display.
  • the storage device 902 also stores an OS (Operating System). Then, at least a part of the OS is executed by the processor 901.
  • the processor 901 executes a program that realizes the functions of the collection unit 101, the extraction unit 103, the combining unit 104, and the analysis unit 105 while executing at least a part of the OS.
  • the processor 901 executes the OS, task management, memory management, file management, communication control, and the like are performed.
  • at least one of information, data, a signal value, and a variable value indicating processing results of the collection unit 101, the extraction unit 103, the combination unit 104, and the analysis unit 105 is stored in the storage device 902, the processor 901, and the cache memory. Is stored in at least one of the following.
  • a program that realizes the functions of the collection unit 101, the extraction unit 103, the combining unit 104, and the analysis unit 105 is a portable storage medium such as a magnetic disk, a flexible disk, an optical disk, a compact disk, a Blu-ray (registered trademark) disk, and a DVD. May be stored.
  • the “unit” of the collection unit 101, the extraction unit 103, the combination unit 104, and the analysis unit 105 may be read as “circuit”, “process”, “procedure”, or “processing”.
  • the source code analyzing apparatus 10 may be realized by an electronic circuit such as a logic IC (Integrated Circuit), a GA (Gate Array), an ASIC (Application Specific Integrated Circuit), or an FPGA (Field-Programmable Gate Array).
  • the collection unit 101, the extraction unit 103, the combination unit 104, and the analysis unit 105 are each realized as part of an electronic circuit.
  • the processor and the electronic circuit are also collectively referred to as a processing circuit.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

抽出部(103)は、ドメイン間通信が行われる複数のドメインで実行される複数のプログラムの複数のソースコードの各々からドメイン間通信を実現する部分をドメイン間通信部分ソースコードとして抽出する。結合部(104)は、抽出部(103)により抽出された複数のドメイン間通信部分ソースコードを結合する。解析部(105)は、結合部(104)により複数のドメイン間通信部分ソースコードが結合されて得られた結合ソースコードを解析する。

Description

ソースコード解析装置、ソースコード解析方法及びソースコード解析プログラム
 本発明は、ソフトウェアの解析に関する。
 例えば、特許文献1では、リソースの捕捉及び開放を行うリソース捕捉・開放関数の使い方の誤りを検出する技術が開示されている。具体的には、特許文献1の技術では、プログラム内のリソース捕捉・開放関数を特定し、当該プログラムのソースコードを解析することで、リソース捕捉・開放関数の使い方の誤りを検出する。
 また、特許文献2では、動的メモリの確保と解放の誤指摘を防止する技術が開示されている。具体的には、特許文献2の技術では、マルチスレッドプログラムに対する静的解析で得られるディスクリプタから、送信側の処理フローと受信側の処理フローとの関連付けを行い、動的メモリの確保と解放の誤指摘を防止する。
特開2016-151855号公報 特開2014-130401号公報
 特許文献1の技術及び特許文献2の技術は、タスク等の一つのドメインにて実行されるプログラムを静的解析の対象としている。このため、特許文献1の技術及び特許文献2の技術では、ドメイン間通信により複数のプログラムが並行して実行される際に生じる問題を検出することができない。つまり、特許文献1の技術及び特許文献2の技術では、プログラム間で通信される情報を解析の対象としないため、例えば、リソース捕捉処理とリソース開放処理との対応付けを誤る可能性がある。リソース捕捉処理とリソース開放処理との対応付けを誤ると、正しい解析結果は得られない。
 このように、特許文献1の技術及び特許文献2の技術では、ドメイン単位でプログラムを解析するため、ドメイン間通信により複数のドメインで複数のプログラムが並行して実行される際に生じる問題を検出することができないという課題がある。
 本発明は、上記のような課題を解決することを主な目的の一つとしている。より具体的には、本発明は、ドメイン間通信により複数のプログラムが並行して実行される際に生じる問題を検出できる構成を得ることを主な目的とする。
 本発明に係るソースコード解析装置は、
 ドメイン間通信が行われる複数のドメインで実行される複数のプログラムの複数のソースコードの各々から前記ドメイン間通信を実現する部分をドメイン間通信部分ソースコードとして抽出する抽出部と、
 前記抽出部により抽出された複数のドメイン間通信部分ソースコードを結合する結合部と、
 前記結合部により前記複数のドメイン間通信部分ソースコードが結合されて得られた結合ソースコードを解析する解析部とを有する。
 本発明によれば、複数のドメイン間通信部分ソースコードが結合されて得られた結合ソースコードを解析するため、ドメイン間通信により複数のプログラムが並行に実行される際に生じる問題を検出することができる。
実施の形態1に係るソースコード解析装置の機能構成例を示す図。 実施の形態1に係るソースコード解析装置のハードウェア構成例を示す図。 実施の形態1に係るソースコード解析装置の機能構成とハードウェア構成との対応付けを示す図。 実施の形態1に係るプログラムのソースコードの例を示す図。 実施の形態1に係るプログラム要素情報のフォーマット例を示す図。 実施の形態1に係るプログラム要素情報の記述例を示す図。 実施の形態1に係る各プログラムのソースコードを単独で静的解析した際に得られる静的解析結果の例を示す図。 実施の形態1に係る結合ソースコードの例を示す図。 実施の形態1に係る結合ソースコードを静的解析した際に得られる静的解析結果の例を示す図。 実施の形態1に係るソースコード解析装置の動作例を示すフローチャート。
 以下、本発明の実施の形態について、図を用いて説明する。以下の実施の形態の説明及び図面において、同一の符号を付したものは、同一の部分または相当する部分を示す。
 実施の形態1.
***構成の説明***
 図1は、本実施の形態に係るソースコード解析装置10の機能構成例を示す。図2は、ソースコード解析装置10のハードウェア構成例を示す。図3は、図1に示す機能構成と図2に示すハードウェア構成との対応付けを示す。
 なお、ソースコード解析装置10で行われる動作は、ソースコード解析方法及びソースコード解析プログラムに相当する。
 図1に示すように、ソースコード解析装置10は、ドメインA21、ドメインB22及びドメインN23から通信データ及びソースコードを受け取る。
 ドメインA21、ドメインB22、ドメインN23は、それぞれプログラムを実行するコンピュータである。ドメインA21、ドメインB22、ドメインN23は、例えば、PC(Personal Computer)、サーバ装置等である。ドメインA21は、プログラムA210を実行する。ドメインB22は、プログラムB220を実行する。ドメインN23は、プログラムN230を実行する。ドメインA21、ドメインB22、ドメインN23は、ドメイン間通信を行い、相互に通信データを送受信する。
 ソースコード解析装置10の機能構成を説明する前に、図2を参照して、ソースコード解析装置10のハードウェア構成を説明する。
 ソースコード解析装置10は、コンピュータである。
 ソースコード解析装置10は、ハードウェアとして、プロセッサ901、記憶装置902、通信インタフェース903及び入出力インタフェース904を備える。
 記憶装置902には、図1に示す、収集部101、抽出部103、結合部104及び解析部105の機能を実現するプログラムが記憶されている。
 そして、プロセッサ901がこれらプログラムを実行して、後述する収集部101、抽出部103、結合部104及び解析部105の動作を行う。
 図3では、プロセッサ901が収集部101、抽出部103、結合部104及び解析部105の機能を実現するプログラムを実行している状態を模式的に表している。
 また、図1に示すプログラム要素情報記憶部102及び解析結果情報記憶部106は、図3に示すように、記憶装置902により実現される。
 通信インタフェース903は、ソースコード解析装置10がドメインA21、ドメインB22、ドメインN23と通信するために用いられる。
 入出力インタフェース904は、ソースコード解析装置10のユーザがソースコード解析装置10に各種指示を入力するために用いられる。また、入出力インタフェース904は、ソースコード解析装置10がユーザに各種データを提示するために用いられる。
 次に、図1を参照して、ソースコード解析装置10の機能構成を説明する。
 収集部101は、通信インタフェース903を介して、複数のドメインの間で通信される通信データを収集する。図1の例では、ドメインA21とドメインB22との間でドメイン間通信が行われており、収集部101は、ドメインA21とドメインB22との間で送受信される通信データを収集する。
 収集部101は、収集した通信データから、各ドメインで実行されるプログラムに含まれる要素であるプログラム要素を抽出して、抽出したプログラム要素が示されるプログラム要素情報を生成する。また、収集部101は、生成したプログラム要素情報をプログラム要素情報記憶部102に格納する。
 プログラム要素情報記憶部102は、プログラム要素情報を記憶する。
 抽出部103は、通信インタフェース903を介して、ドメイン間通信が行われる複数のドメインの各々から、各ドメインで実行されるプログラムのソースコードを収集する。
 そして、抽出部103は、収集した複数のプログラムの複数のソースコードの各々からドメイン間通信を実現する部分をドメイン間通信部分ソースコードとして抽出する。より具体的には、抽出部103は、プログラム要素情報を参照し、プログラム要素情報に示されるプログラム要素に基づき、複数のソースコードの各々においてドメイン間通信部分ソースコードを特定する。更に、抽出部103は、特定したドメイン間通信部分ソースコードを複数のソースコードの各々から抽出する。抽出部103は、例えば、通信データの通信時刻及び通信データに含まれるプログラム要素(関数、戻り値、引数)に基づき、複数のソースコードの各々においてドメイン間通信部分ソースコードを特定する。
 また、抽出部103は、抽出した複数のドメイン間通信部分ソースコードを結合部104に出力する。
 なお、抽出部103により行われる動作は、抽出処理に相当する。
 結合部104は、抽出部103により抽出された複数のドメイン間通信部分ソースコードを結合する。結合部104が複数のドメイン間通信部分ソースコードを結合して得られたソースコードを結合ソースコードという。
 結合部104は、結合ソースコードを解析部105に出力する。
 なお、結合部104により行われる動作は、結合処理に相当する。
 解析部105は、結合ソースコードの静的解析を行う。そして、解析部105は静的解析の結果が示される解析結果情報を解析結果情報記憶部106に格納する。
 なお、解析部105により行われる動作は、解析処理に相当する。
 解析結果情報記憶部106は、解析結果情報を記憶する。
***動作の説明***
 図4-図10を用いて、本実施の形態に係るソースコード解析装置10の動作例を説明する。
 なお、図4は、プログラムA210のソースコード2100とプログラムB220のソースコード2200を示す。
 図5は、プログラム要素情報のフォーマット例を示す。
 図6は、プログラム要素情報の記述例を示す。
 図7は、ソースコード2100とソースコード2200とを単独で静的解析した際に得られる解析結果情報を示す。
 図8は、結合ソースコードの例を示す。
 図9は、結合ソースコードを静的解析した際に得られる解析結果情報の例を示す。
 図10は、ソースコード解析装置10の動作例を示す。
 図10に示すように、先ず、ソースコード解析装置10のユーザが入出力インタフェース904を用いて指示を与えることにより、収集部101が起動する(ステップS101)。
 次に、収集部101が、各ドメインの各プログラムと通信を行って、各プログラムを起動させ、また、各プログラムを実行させる(ステップS102)。
 次に、収集部101は、ドメイン間通信で送受信される通信データを収集し、収集した通信データに基づきプログラム要素情報を生成する(ステップS103)。
 なお、各ドメインの各プログラムには通信データを収集部101に送信する関数が挿入済みであり、各プログラムが実行されると、ドメイン間通信が行われるとともに、ドメイン間通信で送信される通信データが当該関数により収集部101にも送信される。収集部101は、各プログラムから送信される通信データを受信して、図5に示すフォーマットでプログラム要素情報を生成する。そして、収集部101は、生成したプログラム要素情報をプログラム要素情報記憶部102に格納する。
 図5に示すように、プログラム要素情報は、通信時刻501、関数名502、ソースコードファイル名503、行番号504、戻り値変数名505と戻り値506との対、引数変数名505と引数値506との対を含む。引数変数名505と引数値506との対は、複数含まれる場合がある。
 通信時刻501は、ドメイン間通信が行われた時刻である。関数名502は、ドメイン間通信を行った関数の名前である。ソースコードファイル名503は、関数名502に示される関数が呼び出されているソースコードファイルの名前である。行番号504は、ソースコードファイル名503に示されるソースファイル内の行の番号である。戻り値変数名505は、関数名502に示される関数の戻り値の変数名である。戻り値506は、関数名502に示される関数の戻り値である。引数変数名505は、関数名502に示される関数に含まれる引数の変数名である。引数値506は、関数名502に示される関数に含まれる引数の値である。
 図6では、プログラムA210及びプログラムB220からの通信データに基づき生成されたプログラム要素情報を示す。
 次に、収集部101がドメインでのプログラムの終了を確認する。なお、規定タイミングまでにプログラムが終了していない場合は、ソースコード解析装置10のユーザが収集部101に当該プログラムの強制終了を指示し、収集部101が当該プログラムを強制終了させる(ステップS104)。
 次に、抽出部103が、プログラム要素情報とソースコードとを取得する(ステップS105)。
 より具体的には、抽出部103は、プログラム要素情報記憶部102からプログラム要素情報を読み出す。また、ステップS103で収集部101が通信データを収集した複数のドメイン、つまり、ドメイン間通信により通信データを送受信していた複数のドメインの各々よりソースコードを受信する。図1の例では、ドメインA21とドメインB22の間でドメイン間通信が行われているので、抽出部103は、ドメインA21からプログラムA210のソースコードを受け取り、ドメインB22からプログラムB220のソースコードを受け取る。
 ここでは、抽出部103は、図4に示すように、ドメインA21からプログラムA210のソースコードとして、ソースコード2100を受信し、ドメインB22からプログラムB220のソースコードとして、ソースコード2200を受信したと想定する。また、抽出部103は、図6に示すプログラム要素情報を読み出したと想定する。
 図4では、プログラムA210のwrite_to_B()によりプログラムB220が用いる記憶領域にデータが書き込まれ、プログラムB220のread_from_A()により当該記憶領域からデータが読み出される。
 なお、上記では、抽出部103が各ドメインからソースコードを受信することとしているが、ソースコード解析装置10内に各ドメインのソースコードがソースファイルとして保存されている場合は、抽出部103は、ソースファイルを取得し、取得したソースファイルから各ドメインのソースコードを取得するようにしてもよい。また、各ドメイン以外の外部装置から各ドメインのソースコードを取得できる場合は、抽出部103は、外部装置から各ドメインのソースコードを取得するようにしてよい。また、抽出部103は、ドメインごとに、ソースコードの取得方法を変えてもよい。抽出部103は、例えば、ドメインA21のソースコードはドメインA21から受信し、ドメインB22のソースコードはソースコード解析装置10内のソースファイルから取得し、ドメインN23のソースコードは外部装置から取得するようにしてもよい。
 次に、抽出部103は、ステップS105で取得したプログラム要素情報とソースコードを解析して、各ソースコードからドメイン間通信部分ソースコードを抽出する(ステップS106)。
 具体的には、抽出部103は、プログラム要素情報において、通信データの送受信に対応する対となるレコードを特定する。図6の例では、抽出部103は、プログラム要素情報の1行目のレコードと2行目のレコードを抽出する。そして、抽出部103は、プログラム要素情報の1行目の関数名502(「write_to_B」)、行番号504(「3」)、引数1変数名505(「unit_no」)等に基づき、図4のソースコード2100から符号211の関数を抽出する。更に、抽出部103は、符号211の関数の実体である符号212のコードブロックを抽出する。また、抽出部103は、プログラム要素情報の2行目の関数名502(「read_from_A」)、行番号504(「5」)、戻り値変数名505(「idx」)、引数1変数名505(「unit_no」)等に基づき、図4のソースコード2200から符号221のコードブロックを抽出する。
 符号212のコードブロック及び符号221のコードブロックは、ともに、ドメイン間通信を実現する部分であり、ドメイン間通信部分ソースコードである。
 抽出部103は、図4及び図6の例では、ドメイン間通信部分ソースコードとして、符号212のコードブロック及び符号221のコードブロックを抽出する。
 抽出部103は、抽出したドメイン間通信部分ソースコードを結合部104に出力する。
 結合部104は、結合部104から出力されたドメイン間通信部分ソースコードを結合して、結合ソースコードを生成する(ステップS107)。
 図8は、結合部104が、図4のソースコード2100から抽出されたドメイン間通信部分ソースコード(符号212のコードブロック)と、図4のソースコード2200から抽出されたドメイン間通信部分ソースコード(符号221のコードブロック)とを結合して生成した結合ソースコードを示す。
 抽出部103が、未抽出のドメイン間通信部分ソースコードが存在するか否かを判定し(ステップS108)、未抽出のドメイン間通信部分ソースコードが存在しない場合は、結合部104が、結合ソースコードを解析部105に出力する。
 そして、解析部105が、結合ソースコードの静的解析を実行する(ステップS109)。
 その後、解析部105は、解析結果情報を解析結果情報記憶部106に格納する(ステップS110)。なお、解析部105は、解析結果情報の解析結果情報記憶部106への格納とともに、解析結果情報を入出力インタフェース904であるディスプレイ装置に表示してもよい。
 図7は、図4に示すソースコード2100とソースコード2200とを単独で静的解析した際に得られる解析結果情報を示す。
 図9は、図8に示す結合ソースコードを静的解析した際に得られる解析結果情報の例を示す。
 解析部105がソースコード2100及びソースコード2200にそれぞれ個別に静的解析を行った場合には、図7に示すように、プログラムB220について、変数idxに関係する問題は検出されない。一方、解析部105が結合ソースコードに静的解析を行った場合は、図9に示すように、プログラムB220について、変数idxに関わる問題が新規に検出される。この結果、静的解析の結果として警告が記述される。
***実施の形態の効果の説明***
 本実施の形態よれば、ソースコード解析装置10は、複数のドメイン間通信部分ソースコードが結合されて得られた結合ソースコードを解析するため、ドメイン間通信により複数のプログラムが並行して実行される際に生じる問題を検出することができる。つまり、複数のソースコードの各々に対する解析では検出できない問題を検出することができる。
 この結果、本実施の形態によれば、静的解析結果の不具合検出ヒット率が向上し、実装品質が効率的に確保されるという効果を奏することができる。
 なお、図4及び図8では、抽出部103が、2つのドメインで実行される2つのプログラムのソースコードからドメイン間通信部分ソースコードを抽出する例を説明した。3つ以上のドメインの間で通信が行われる場合は、抽出部103は、3つ以上のドメインで実行される3つ以上のプログラムのソースコードからドメイン間通信部分ソースコードを抽出する。
 また、収集部101は、ドメインで実行されるプログラムに含まれる要素に応じて、図5に示す項目と異なる項目で構成されるプログラム要素情報を生成してもよい。
***ハードウェア構成の説明***
 最後に、ソースコード解析装置10のハードウェア構成の補足説明を行う。
 図2に示すプロセッサ901は、プロセッシングを行うIC(Integrated Circuit)である。
 プロセッサ901は、CPU(Central Processing Unit)、DSP(Digital Signal Processor)等である。
 図2に示す記憶装置902は、RAM(Random Access Memory)、ROM(Read Only Memory)、フラッシュメモリ、HDD(Hard Disk Drive)等である。
 図2に示す通信インタフェース903は、データを受信するレシーバー及びデータを送信するトランスミッターを含む。
 通信インタフェース903は、例えば、通信チップ又はNIC(Network Interface Card)である。
 入出力インタフェース904は、例えば、マウス、キーボード及びディスプレイである。
 記憶装置902には、OS(Operating System)も記憶されている。
 そして、OSの少なくとも一部がプロセッサ901により実行される。
 プロセッサ901はOSの少なくとも一部を実行しながら、収集部101、抽出部103、結合部104及び解析部105の機能を実現するプログラムを実行する。
 プロセッサ901がOSを実行することで、タスク管理、メモリ管理、ファイル管理、通信制御等が行われる。
 また、収集部101、抽出部103、結合部104及び解析部105の処理の結果を示す情報、データ、信号値及び変数値の少なくともいずれかが、記憶装置902、プロセッサ901内のレジスタ及びキャッシュメモリの少なくともいずれかに記憶される。
 また、収集部101、抽出部103、結合部104及び解析部105の機能を実現するプログラムは、磁気ディスク、フレキシブルディスク、光ディスク、コンパクトディスク、ブルーレイ(登録商標)ディスク、DVD等の可搬記憶媒体に記憶されてもよい。
 また、収集部101、抽出部103、結合部104及び解析部105の「部」を、「回路」又は「工程」又は「手順」又は「処理」に読み替えてもよい。
 また、ソースコード解析装置10は、ロジックIC(Integrated Circuit)、GA(Gate Array)、ASIC(Application Specific Integrated Circuit)、FPGA(Field-Programmable Gate Array)といった電子回路により実現されてもよい。
 この場合は、収集部101、抽出部103、結合部104及び解析部105は、それぞれ電子回路の一部として実現される。
 なお、プロセッサ及び上記の電子回路を総称してプロセッシングサーキットリーともいう。
 10 ソースコード解析装置、21 ドメインA、22 ドメインB、23 ドメインN、101 収集部、102 プログラム要素情報記憶部、103 抽出部、104 結合部、105 解析部、106 解析結果情報記憶部、210 プログラムA、220 プログラムB、230 プログラムN、901 プロセッサ、902 記憶装置、903 通信インタフェース、904 入出力インタフェース、2100 ソースコード、2200 ソースコード。

Claims (5)

  1.  ドメイン間通信が行われる複数のドメインで実行される複数のプログラムの複数のソースコードの各々から前記ドメイン間通信を実現する部分をドメイン間通信部分ソースコードとして抽出する抽出部と、
     前記抽出部により抽出された複数のドメイン間通信部分ソースコードを結合する結合部と、
     前記結合部により前記複数のドメイン間通信部分ソースコードが結合されて得られた結合ソースコードを解析する解析部とを有するソースコード解析装置。
  2.  前記ソースコード解析装置は、更に、
     前記複数のドメインの間で通信される通信データを収集する収集部を有し、
     前記抽出部は、
     前記収集部により収集された前記通信データに基づき、前記複数のソースコードの各々において前記ドメイン間通信部分ソースコードを特定し、特定した前記ドメイン間通信部分ソースコードを前記複数のソースコードの各々から抽出する請求項1に記載のソースコード解析装置。
  3.  前記抽出部は、
     前記通信データの通信時刻、前記通信データに含まれる関数、戻り値、引数のうちの少なくともいずれかに基づき、前記複数のソースコードの各々において前記ドメイン間通信部分ソースコードを特定する請求項2に記載のソースコード解析装置。
  4.  コンピュータが、ドメイン間通信が行われる複数のドメインで実行される複数のプログラムの複数のソースコードの各々から前記ドメイン間通信を実現する部分をドメイン間通信部分ソースコードとして抽出し、
     前記コンピュータが、抽出された複数のドメイン間通信部分ソースコードを結合し、
     前記コンピュータが、前記複数のドメイン間通信部分ソースコードが結合されて得られた結合ソースコードを解析するソースコード解析方法。
  5.  ドメイン間通信が行われる複数のドメインで実行される複数のプログラムの複数のソースコードの各々から前記ドメイン間通信を実現する部分をドメイン間通信部分ソースコードとして抽出する抽出処理と、
     前記抽出処理により抽出された複数のドメイン間通信部分ソースコードを結合する結合処理と、
     前記結合処理により前記複数のドメイン間通信部分ソースコードが結合されて得られた結合ソースコードを解析する解析処理とをコンピュータに実行させるソースコード解析プログラム。
PCT/JP2017/008178 2017-03-01 2017-03-01 ソースコード解析装置、ソースコード解析方法及びソースコード解析プログラム WO2018158893A1 (ja)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/JP2017/008178 WO2018158893A1 (ja) 2017-03-01 2017-03-01 ソースコード解析装置、ソースコード解析方法及びソースコード解析プログラム

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2017/008178 WO2018158893A1 (ja) 2017-03-01 2017-03-01 ソースコード解析装置、ソースコード解析方法及びソースコード解析プログラム

Publications (1)

Publication Number Publication Date
WO2018158893A1 true WO2018158893A1 (ja) 2018-09-07

Family

ID=63371210

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2017/008178 WO2018158893A1 (ja) 2017-03-01 2017-03-01 ソースコード解析装置、ソースコード解析方法及びソースコード解析プログラム

Country Status (1)

Country Link
WO (1) WO2018158893A1 (ja)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007310727A (ja) * 2006-05-19 2007-11-29 Fujitsu Ltd 資産診断のためのプログラム解析方法
JP2009122754A (ja) * 2007-11-12 2009-06-04 Mitsubishi Electric Corp ソフトウェア開発支援装置
JP2012146243A (ja) * 2011-01-14 2012-08-02 Nec Corp ソフトウェア構造解析装置、ソフトウェア構造解析方法及びプログラム
JP2015102878A (ja) * 2013-11-21 2015-06-04 株式会社日立製作所 プログラム関連分析方法
JP2016015052A (ja) * 2014-07-02 2016-01-28 富士通株式会社 プログラム、情報処理装置及び情報処理方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007310727A (ja) * 2006-05-19 2007-11-29 Fujitsu Ltd 資産診断のためのプログラム解析方法
JP2009122754A (ja) * 2007-11-12 2009-06-04 Mitsubishi Electric Corp ソフトウェア開発支援装置
JP2012146243A (ja) * 2011-01-14 2012-08-02 Nec Corp ソフトウェア構造解析装置、ソフトウェア構造解析方法及びプログラム
JP2015102878A (ja) * 2013-11-21 2015-06-04 株式会社日立製作所 プログラム関連分析方法
JP2016015052A (ja) * 2014-07-02 2016-01-28 富士通株式会社 プログラム、情報処理装置及び情報処理方法

Similar Documents

Publication Publication Date Title
US10474826B2 (en) Methods and apparatuses for improved app security testing
US8931102B2 (en) Testing web applications for file upload vulnerabilities
US9355003B2 (en) Capturing trace information using annotated trace output
US9965631B2 (en) Apparatus and method for analyzing malicious code in multi-core environment using a program flow tracer
US8959400B2 (en) System, program, and method for collecting errors which occur while a user uses a computer
WO2017012241A1 (zh) 文件的检测方法、装置、设备及非易失性计算机存储介质
US20140201842A1 (en) Identifying stored security vulnerabilities in computer software applications
US10412101B2 (en) Detection device, detection method, and detection program
US20120054724A1 (en) Incremental static analysis
CN103886258A (zh) 一种病毒检测方法及装置
US9996447B2 (en) Automated identification of redundant method calls
CN110651260A (zh) 增强的组件延迟跟踪
US10024911B2 (en) Debug circuit, semiconductor device, and debug method
CN114386045A (zh) 一种Web应用程序漏洞检测方法、装置及存储介质
US20150154103A1 (en) Method and apparatus for measuring software performance
WO2018158893A1 (ja) ソースコード解析装置、ソースコード解析方法及びソースコード解析プログラム
JP6611963B2 (ja) プログラム解析装置、プログラム解析システム、プログラム解析方法および解析プログラム
US20140067854A1 (en) Crawling of generated server-side content
CN111737155B (zh) 一种芯片调试系统、方法、装置、设备及存储介质
JP6048555B1 (ja) 分類情報作成装置、分類情報作成方法、分類情報作成プログラム、検索装置、検索方法、及び、検索プログラム
US10810098B2 (en) Probabilistic processor monitoring
KR101976993B1 (ko) 모바일 코드 자동 분석을 위한 동적 바이너리 계측 코드추출장치 및 그 방법
JP6998803B2 (ja) 送信装置、受信装置、送信方法、受信方法、送信プログラム及び受信プログラム
JP5421735B2 (ja) コアファイル取得装置、コアファイル取得方法及びコアファイル取得プログラム
CN116166462A (zh) 程序异常的收集管理方法、装置、终端设备及介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17898888

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17898888

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: JP