A software detection method based on data flow analysis
By generating software flow charts and dividing them into independent subprocesses, and testing them in combination with data flow analysis technology, the existing software testing methods are solved, and the testing efficiency is improved and the possibility of distributed testing is provided.
Patent Information
- Application Number
- CN202211633357.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-19
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2042-12-19
AI Technical Summary
The existing software testing methods are complex and difficult to implement distributed testing, resulting in low testing efficiency.
The flowchart automatically generates a flow chart of the software program, divided into several independent subprocesses, and uses data flow analysis technology to test each subprocess to detect functional vulnerabilities and code logic problems.
It improves the efficiency of software testing, provides the possibility of distributed testing, and simplifies the testing process.
Smart Images

Figure CN115934551B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of software testing, relates to data flow analysis technology, and specifically is a software detection method based on data flow analysis. Background Art
[0002] Data flow testing is used to analyze the flow of data in a program. It is the process of collecting information about how variables flow data in a program; it tries to obtain specific information about each specific point in the process; Data flow testing is a set of testing strategies used to examine the control flow of a program in order to explore the order of variables in terms of the sequence of events. It focuses primarily on the values assigned to variables and by focusing on the points at which these values are used, data flow can be tested;
[0003] However, most current software testing adopts the form of constructing the complete software into a unified test flow diagram, which has high test complexity and is difficult to achieve distributed testing. Therefore, a method is needed to divide the software process into multiple independent processes to improve software testing efficiency.
[0004] Therefore, a software detection method based on data flow analysis is proposed. Summary of the invention
[0005] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention proposes a software detection method based on data flow analysis, which generates a flowchart of a software program by using a flowchart automatic generation tool; then divides the software flowchart into several independent sub-processes based on the same function name outside the tool class function; performs traditional black-white gray-box testing on the tool class function to detect the functional vulnerabilities of the tool class function; then uses data flow analysis technology to analyze the program logic and code vulnerabilities of each independent sub-process; by splitting the independent sub-process, the efficiency of software testing is greatly improved, and the possibility of distributed testing is provided.
[0006] To achieve the above object, according to an embodiment of the first aspect of the present invention, a software detection method based on data flow analysis is provided, comprising the following steps:
[0007] Step 1: Use a flowchart automatic generation tool to generate a flowchart of the software program; it should be understood that in the software flowchart, each process is a function name;
[0008] Step 2: Count the names of common tool functions from the software code;
[0009] Step 3: Group the software flow chart based on the same function name; obtain several groups of code flow groups whose code logics are not related to each other;
[0010] Step 4: Perform functional tests on each tool function. If the output result is abnormal, prompt the tester. Otherwise, output the test success log.
[0011] Step 5: For each code flow group, test the program code in the code flow group through data flow analysis technology; if the program output result is abnormal, prompt the tester; otherwise, output the test success log;
[0012] The flowchart automatic generation tool is a tool for constructing a flowchart of the data flow of each function of the software program according to each function file in the software code and the mutual calling relationship between functions;
[0013] Since there are many files in the software, the function names may be the same; preferably, the function name is in the form of function file name_function name, so as to facilitate the identification of the function;
[0014] The tool function is a function that implements a general function without any restrictions on the calling scenario;
[0015] Grouping software flowcharts based on the same function name includes the following steps:
[0016] Step S1: save all tool function set names in the software program using a set, and mark the tool function set as T;
[0017] Step S2: for all processes except the tool function set T in the software flow chart, find out all processes that have a calling and called relationship with the process;
[0018] Step S3: Divide the flowchart into several independent flowcharts according to the calling relationship between each process in the flowchart; the independent flowchart is that each process in the flowchart except the process in the tool function set T is not included in other independent flowcharts; each independent flowchart is called a code flow group;
[0019] The way to perform functional testing on each tool function is as follows: construct several test input samples according to the input parameter types required by the function;
[0020] By inputting the test input sample into the tool function and observing the output of the program, if an exception occurs during program operation or the output operation result does not match the logical result, it means that the tool function fails the test;
[0021] Test input samples include normal test samples, boundary test samples, and abnormal test samples;
[0022] If the output result of a tool function is abnormal, the tester is prompted by: writing the abnormal input parameters, function output or program abnormal prompts and the number of abnormal code lines into the test log of the test software; and using text to describe the abnormal test results in the debugging window of the visual interface of the test software;
[0023] Testing the program code within the code flow group using data flow analysis technology includes the following steps:
[0024] Step P1: Determine the “definition-use chain” for each variable; that is, determine the function chain that the variable passes through for each variable;
[0025] Step P2: for the flow chart in the code flow group, determine the test standard according to the actual needs; the test standard includes taking all definitions, taking all uses and taking all paths, etc.;
[0026] Step P3: According to the actual execution logic of the flow chart in the code flow group, design several test cases as the input of the entry function in the flow chart to test the logic of the entire flow chart; if during the test, the test program has an exception or the output running result does not match the logical result, it means that there is a vulnerability in the program in the code flow group and it fails the test.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] The present invention generates a flowchart of a software program by using a flowchart automatic generation tool; then divides the software flowchart into a number of independent sub-processes based on the same function name outside the tool class function; detects the functional vulnerabilities of the tool class function by performing traditional black-white and gray-box testing on the tool class function; then uses data flow analysis technology to analyze the program logic and code vulnerabilities of each independent sub-process; by splitting the independent sub-processes, the efficiency of software testing is greatly improved, and the possibility of distributed testing is provided. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION
[0030] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0031] like Figure 1As shown, a software detection method based on data flow analysis includes the following steps:
[0032] Step 1: Use a flowchart automatic generation tool to generate a flowchart of the software program; it should be understood that in the software flowchart, each process is a function name;
[0033] Step 2: Count the names of common tool functions from the software code;
[0034] Step 3: Group the software flow chart based on the same function name; obtain several groups of code flow groups whose code logics are not related to each other;
[0035] Step 4: Perform functional tests on each tool function. If the output result is abnormal, prompt the tester. Otherwise, output the test success log.
[0036] Step 5: For each code flow group, test the program code in the code flow group through data flow analysis technology; if the program output result is abnormal, prompt the tester; otherwise, output the test success log;
[0037] Data flow testing is used to analyze the flow of data in a program. It is the process of collecting information about how variables flow data in a program; it tries to obtain specific information about each specific point in the process; Data flow testing is a set of testing strategies used to examine the control flow of a program in order to explore the order of variables in terms of the sequence of events. It focuses primarily on the values assigned to variables and by focusing on the points at which these values are used, data flow can be tested;
[0038] In this embodiment, the flowchart automatic generation tool is a tool for constructing a flowchart of the data flow of each function according to each function file in the software code and the mutual calling relationship between functions; specifically, the flowchart automatic generation tool can be AutoFlowChart software;
[0039] Since there are many files in the software, the function names may be the same; preferably, the function name is in the form of function file name_function name, so as to facilitate the identification of the function;
[0040] In a preferred embodiment, the tool function is a function that implements a general function without limiting the calling scenario; as an example, a function that implements the splicing function of strings in the code is a tool function; it can be understood that for the tool function, the logic test can be directly performed by inputting the corresponding input parameters without executing the complete program chain;
[0041] In a preferred embodiment, grouping software flow charts based on the same function name includes the following steps:
[0042] Step S1: save all tool function set names in the software program using a set, and mark the tool function set as T;
[0043] Step S2: for all processes (i.e., function names) in each software flow chart except the tool function set T, find out all processes that have a calling and called relationship with the process;
[0044] Step S3: Divide the flowchart into several independent flowcharts according to the calling relationship between each process in the flowchart; the independent flowchart is that each process in the flowchart except the process in the tool function set T is not included in other independent flowcharts; each independent flowchart is called a code flow group;
[0045] The way to perform functional testing on each tool function is as follows: construct several test input samples according to the input parameter types required by the function;
[0046] By inputting the test input sample into the tool function and observing the output of the program, if an exception occurs during program operation or the output operation result does not match the logical result, it means that the tool function fails the test;
[0047] Preferably, the test input samples include normal test samples, boundary test samples, and abnormal test samples;
[0048] Furthermore, the types of testing for tool class functions may include white box testing, black box testing, and gray box testing;
[0049] If the output result of a tool function is abnormal, the tester is prompted by: writing the abnormal input parameters, function output or program abnormal prompts and the number of abnormal code lines into the test log of the test software; and using text to describe the abnormal test results in the debugging window of the visual interface of the test software;
[0050] Testing the program code within the code flow group using data flow analysis technology includes the following steps:
[0051] Step P1: Determine the “definition-use chain” for each variable; that is, determine the function chain that the variable passes through for each variable;
[0052] Step P2: for the flow chart in the code flow group, determine the test standard according to the actual needs; the test standard includes taking all definitions, taking all uses and taking all paths, etc.;
[0053] Step P3: According to the actual execution logic of the flow chart in the code flow group, design several test cases as the input of the entry function in the flow chart to test the logic of the entire flow chart; if during the test process, the test program has an exception or the output running result does not match the logical result, it means that the program in the code flow group has a vulnerability and fails the test;
[0054] Preferably, if an abnormality occurs in the program output result, the way to prompt the tester is: write the abnormal input parameters, code flow group output or program exception prompt and the number of abnormal code lines into the test log of the test software; and use text to describe the test abnormality result in the debugging window of the visual interface of the test software.
[0055] The above embodiments are only used to illustrate the technical method of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical method of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical method of the present invention.
Claims
1. A software detection method based on data flow analysis, characterized in that: The following steps are involved: Generate flowcharts of software programs using automatic flowchart generation tools; Count the names of common tool functions from the software code; The software flow chart is grouped based on the same function name; and a plurality of code flow groups whose code logics are not related to each other are obtained; Perform functional testing for each tool function; If the output result is abnormal, the tester will be prompted; For each code flow group, the program code in the code flow group is tested by using data flow analysis technology; If the program output results are abnormal, the tester will be prompted; The flowchart automatic generation tool is a tool for constructing a flowchart of the data flow of each function of the software program according to each function file in the software code and the mutual calling relationship between functions; Grouping software flowcharts based on the same function name includes the following steps: All tool function set names in the software program are saved using a set, and the tool function set is marked as T; For each process in the software flow chart except for the tool function set T, find out all processes that have a calling and called relationship with the process; According to the calling relationship between each process in the flowchart, it is divided into several independent flowcharts; the independent flowchart is that each process in the flowchart except the process in the tool function set T is not included in other independent flowcharts; each independent flowchart is called a code flow group.
2. A software detection method based on data flow analysis according to claim 1, characterized in that: The tool function is a function that implements a general function without limiting the calling scenario.
3. The software detection method based on data flow analysis according to claim 1, characterized in that: The way to perform functional testing on each tool class function is as follows: construct several test input samples according to the input parameter types required by the function; By inputting the test input sample into the tool class function and observing the output of the program, if an exception occurs during the program running or the output running result does not match the logical result, it means that the tool class function has failed the test.
4. The software detection method based on data flow analysis according to claim 1, characterized in that: Testing the program code within the code flow group using data flow analysis technology includes the following steps: Step P1: Determine the "definition-use chain" for each variable; Step P2: For the flow chart in the code flow group, determine the test standard according to actual needs; Step P3: According to the actual execution logic of the flow chart in the code flow group, design several test cases as the input of the entry function in the flow chart to test the logic of the entire flow chart; if during the test, the test program has an exception or the output running result does not match the logical result, it means that there is a vulnerability in the program in the code flow group and it fails the test.
Citation Information
Patent Citations
Program variable effective definition detection method and device based on code behavior unit
CN111611149A
Source code defect detection method and device
CN112579469A