Regression fuzzy test method, device and equipment and storage medium
By obtaining and monitoring the control flow and data flow information of the program source code, updating the test cases until the program crashes, the problem of failure to effectively detect regression vulnerabilities in the existing technology is solved, and the regression vulnerability detection capability is significantly improved.
Patent Information
- Application Number
- CN202411228783.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2044-09-03
AI Technical Summary
The prior art only considers control flow information in regression testing scenarios, fails to effectively detect regression vulnerabilities, limiting detection capabilities.
By obtaining the control flow information and data flow information of the target code of the program source code, monitoring the control flow coverage and data flow coverage, updating the test cases until the program source code crashes, and obtaining the final test cases to improve the regression vulnerability detection capabilities.
By combining control flow coverage and data flow coverage, the target code and related code are fully covered, which significantly improves the regression vulnerability detection capabilities.
Smart Images

Figure CN119088709A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of fuzzy testing technology, and in particular to a regression fuzzy testing method, device, equipment and storage medium. Background Art
[0002] When the version of the program source code changes, new code will be generated, or part of the code in the program source code will change. The new code or the changed code is the target code. Regression fuzz testing technology can be used to test regression vulnerabilities caused by executing the target code. Existing fuzz testing technology for regression testing scenarios only considers control flow information, but does not consider data flow information that may be more likely to trigger regression vulnerabilities, thus limiting the ability to detect regression vulnerabilities.
[0003] In summary, the existing technologies do not consider the detection capability for regression vulnerabilities.
[0004] Therefore, the prior art still needs to be improved and enhanced. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a regression fuzzy testing method, device, equipment and storage medium, which solves the problem that the prior art does not consider the detection capability for regression vulnerabilities.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] In a first aspect, the present invention provides a regression fuzzy testing method, which includes:
[0008] Obtaining target code generated by version change of program source code, and extracting control flow information and data flow information of the target code;
[0009] Inputting a test case into the program source code, and when the program source code after the test case is input does not crash, monitoring the control flow coverage of the control flow information and the data flow coverage of the data flow information;
[0010] The test case is updated according to the control flow coverage and the data flow coverage until the program source code crashes, thereby obtaining a final test case.
[0011] In one implementation, extracting the control flow information and data flow information of the target code includes:
[0012] Extracting the calling function corresponding to the target code;
[0013] Extracting control flow information related to the target code and the calling function;
[0014] Parsing a basic block contained in the target code, wherein the basic block is a code block having only one input port and one output port;
[0015] Filtering out a definition basic block for defining a variable from the basic blocks, and filtering out a use basic block for calling a variable from the basic blocks;
[0016] Determining a data dependency graph between the defined basic blocks;
[0017] The definition basic block, the use basic block, and the data dependency graph are used as data flow information.
[0018] In one implementation, the monitoring of the control flow coverage of the control flow information and the data flow coverage of the data flow information includes:
[0019] Inserting a monitoring program into the program source code;
[0020] Monitoring the execution times of the control flow information by the monitoring program, and obtaining control flow coverage according to the execution times of the control flow information;
[0021] The data flow coverage of the data flow information is monitored by the monitoring program.
[0022] In one implementation, monitoring the data flow coverage of the data flow information by the monitoring program includes:
[0023] Monitoring, by the monitoring program, the closest distance and the farthest distance included in the data dependency graph of a target definition, wherein the target definition is the definition where the definition basic block is located;
[0024] Obtaining a definition sub-score of each target definition according to the closest distance and the farthest distance of each target definition;
[0025] According to the definition sub-score of each of the target definitions, a target definition score is filtered out from the definition sub-scores of all the target definitions;
[0026] The monitoring program is used to monitor the execution times of the basic block used corresponding to each target use, and a target use score is obtained according to the execution times corresponding to each target use, wherein the target use is the use where the basic block used is located;
[0027] The target definition score and the target usage score are overlaid as a data flow.
[0028] In one implementation, obtaining a target usage score according to the number of executions corresponding to each target usage includes:
[0029] The number of executions corresponding to each target usage is accumulated to obtain a target usage score.
[0030] In one implementation, updating the test case according to the control flow coverage and the data flow coverage until the program source code crashes to obtain a final test case includes:
[0031] When the control flow coverage is greater than a first threshold and / or the target definition score is greater than a second threshold and / or the target usage score is greater than a third threshold, determining a test variation case of the test case;
[0032] The test variation case is input into the program source code, and when the program source code does not crash after the test variation case is input, the test case is updated until the program source code crashes, thereby obtaining a target test case.
[0033] In one implementation, the updating of the test case according to the control flow coverage and the data flow coverage until the program source code crashes to obtain a final test case further includes:
[0034] When the program source code crashes after the test mutation case is input, the test mutation case is used as a target test case.
[0035] In a second aspect, an embodiment of the present invention further provides a regression fuzzy testing device, wherein the device comprises the following components:
[0036] An information extraction module, used to obtain the target code generated by the program source code due to the version change, and extract the control flow information and data flow information of the target code;
[0037] A monitoring module, used for inputting a test case into the program source code, and monitoring the control flow coverage of the control flow information and the data flow coverage of the data flow information when the program source code after the test case is input does not crash;
[0038] An update module is used to update the test case according to the control flow coverage and the data flow coverage until the program source code crashes, thereby obtaining a final test case.
[0039] In a third aspect, an embodiment of the present invention further provides a terminal device, wherein the terminal device includes a memory, a processor, and a regression fuzzy testing program stored in the memory and executable on the processor, and when the processor executes the regression fuzzy testing program, the steps of the above-mentioned regression fuzzy testing method are implemented.
[0040] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a regression fuzzy testing program is stored. When the regression fuzzy testing program is executed by a processor, the steps of the above-mentioned regression fuzzy testing method are implemented.
[0041] Beneficial effect: The present invention first extracts the control flow information and data flow information of the target code. After the test case is input into the program source code, the control flow coverage of the control flow information of the target code and the data flow coverage of the data flow information are monitored, and the control flow coverage and the data flow coverage are updated to update the test case until the program source code crashes, and the final test case is obtained, that is, the test case that can crash the program source code is found. From the above analysis, it can be seen that the present invention uses control flow coverage and data flow coverage to guide the update of test cases, so that the data flow coverage can fully cover the target code and its related code to improve the regression vulnerability detection capability. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is the overall flow chart of the present invention;
[0043] Figure 2 It is a flow chart of source code regression fuzzy testing in an embodiment of the present invention;
[0044] Figure 3 is a static analysis flow chart in an embodiment of the present invention;
[0045] Figure 4 A schematic diagram of data dependency in an embodiment of the present invention;
[0046] Figure 5 A structural diagram of the regression fuzzy testing device provided by the present invention;
[0047] Figure 6 This is a block diagram of the internal structure principle of the terminal device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The following is a clear and complete description of the technical solution of the present invention in combination with the embodiments and the accompanying drawings. 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.
[0049] Research has found that when the version of the program source code changes, new code will be generated, or part of the code in the program source code will change. The new code or the changed code is the target code. Regression fuzz testing technology can be used to test regression vulnerabilities caused by executing the target code. Existing fuzz testing technology for regression testing scenarios only considers control flow information, but does not consider data flow information that may be more likely to trigger regression vulnerabilities, thus limiting the ability to detect regression vulnerabilities.
[0050] In order to solve the above technical problems, the present invention provides a regression fuzzy testing method, device, equipment and storage medium, which solves the problem that the prior art does not consider the detection capability for regression vulnerabilities. In specific implementation, first obtain the target code generated by the program source code due to the version change, and extract the control flow information and data flow information of the target code; then input the test case into the program source code, and when the program source code after inputting the test case does not crash, monitor the control flow coverage of the control flow information and the data flow coverage of the data flow information; finally, update the test case according to the control flow coverage and the data flow coverage until the program source code crashes, and obtain the final test case.
[0051] For example, in the process of version iteration of the program source code, the local code of the program source code will change. The changed local code is the target code, that is, after the program version is changed, the changed code is called the target code. When the program source code changes, it is necessary to re-fuzz test the program source code, and this fuzz test is regression fuzz testing. Extract the control flow information and data flow information contained in the target code, where the control flow information is the various steps that the target code needs to execute to realize its function and the execution order of each step, and the data flow information is used to record the flow direction of the variables in the target code. Control flow information and data flow information represent the target code from two different perspectives.
[0052] The test case is input into the program source code. When the program source code starts to run the test case, if the program source code does not crash (if it crashes, the test case at this time is used as the final test case), then monitor how much of the control flow information of the target code is covered (that is, monitor how many control flows are executed, that is, monitor control flow coverage), monitor how much of the data flow information of the target code is covered (that is, monitor how many data flows are executed, that is, monitor data flow coverage), and then update the test case according to the control flow coverage and data flow coverage (update the test case as the prior art), and continue to input the updated test case into the program source code. If the program source code has not crashed yet, continue to update the test case until the program source code crashes. The test case corresponding to the crash is the final test case. The purpose of the present invention is to find a test case that can cause the program source code to crash, so as to clarify the regression vulnerability brought by the target code to the program source code.
[0053] The regression fuzzy testing method of this embodiment can be applied to a terminal device, which can be a terminal product with a program testing function, such as a computer. Figure 1 As shown in , the regression fuzzy testing method specifically includes the following steps:
[0054] S100, obtaining a target code generated by a version change of a program source code, and extracting control flow information and data flow information of the target code.
[0055] S200, inputting a test case into the program source code, and when the program source code does not crash after the test case is input, monitoring the control flow coverage of the control flow information and the data flow coverage of the data flow information.
[0056] S300, updating the test case according to the control flow coverage and the data flow coverage until the program source code crashes, thereby obtaining a final test case.
[0057] Embodiment 1: In this embodiment, step S100 includes the following specific steps S101 to S106:
[0058] S101, extracting the calling function corresponding to the target code.
[0059] like Figure 2 As shown, static analysis of the target code can be performed to analyze the calling functions contained in the target code. In this embodiment, the function containing the target code is the target function, and the calling function includes the function that directly or indirectly calls the target function and the target function.
[0060] S102: extract control flow information related to the target code and the calling function.
[0061] like Figure 2 As shown, the control flow information in this embodiment is the path information from the entry of the calling function to the function calling point where the calling function can reach the target code, so as to reduce the paths that need to be explored during the fuzz testing process, so that the test tends to contain the target function of the target code, thereby further improving the guidance capability.
[0062] In this embodiment, the algorithm required to extract control flow information is as follows:
[0063]
[0064] The above algorithm takes the program Program (that is, the program source code) and the target point (the target point is the basic block contained in the target code) set TargetPoints (TargetPoints is the target code) as input, and outputs a mapping TF2RBB from the target calling function to its related basic block set that may reach any target point (that is, outputs the path information from the entrance of the calling function to the function calling point where the calling function can reach the target code, and the path information is represented by the mapping TF2RBB). The algorithm extracts control flow information based on the following principles:
[0065] First, obtain the function call graph CG corresponding to the above function call, and obtain all target functions TargetFuncs including the target code in the program source code (lines 1-2), and initialize the mapping TF2RBB (line 3). For each target function tf, put the target function into the queue queue, and analyze its related target function calls (that is, for each target function, which functions call it each time) and target control flow information one by one (lines 4-14).
[0066] That is, when the queue is not empty, the algorithm takes out the head function cur_f and obtains all callers of the function from the function call graph CG (lines 6-8). For each caller, if the function has not been accessed, it is added to the mapping TF2RBB and the queue respectively (lines 10-12). Then, the algorithm obtains all call sites in the caller that call the current function cur_f (line 13) and the basic block set that can reach any call site (line 14), and adds these reachable basic block sets to the content of the corresponding current calling function caller in the mapping TF2RBB (line 14).
[0067] S103, parsing the basic blocks contained in the target code, wherein the basic blocks are code blocks having only one input port and one output port.
[0068] The target code contains several code blocks, and the code block with only one input port and one output port is a basic block.
[0069] S104, filtering out definition basic blocks for defining variables from the basic blocks, and filtering out use basic blocks for calling variables from the basic blocks.
[0070] A basic block including an Alloca instruction, a Load instruction, and a Store instruction is used as a definition basic block, wherein the Alloca instruction, the Load instruction, and the Store instruction are all instructions for defining variables. This embodiment uses a non-assigned target instruction (the target instruction is the instruction included in the target code) as a definition of the variable, so as to find a non-target instruction that uses the same variable data as the target instruction.
[0071] The instructions contained in the target code, except for the instructions for defining variables, are the use instructions, and the basic block containing the instructions for using variables is the use basic block.
[0072] This embodiment uses the following algorithm to filter and define basic blocks:
[0073]
[0074] The above algorithm takes the program Program (that is, the program source code) and the target point set TargetPoints (TargetPoints is the target code) as input, and outputs a mapping TargetDefs from the target point to the basic block set where its related target definition (target definition is the instruction used to define variables in the target code) is located.
[0075] That is, the above algorithm initializes the mapping TargetDefs to an empty mapping (line 1). Then, the algorithm analyzes the target points one by one and extracts their related target definition blocks (lines 2-13). That is, for the current target point tp, the algorithm obtains the target function tf in which it is located and performs definition-use analysis on the function (lines 2-4). Next, the target point tp is placed in the queue queue, and all target definitions of tp are iteratively extracted according to the queue (lines 6-11). If the queue queue is not empty, the head instruction cur_inst is taken out (line 8); and according to the result of the definition-use analysis in line 5, all related definitions defs of the instruction that are not in the same basic block are obtained (line 9). For each definition, the algorithm adds it to the set of mapping TargetDefs corresponding to the current target point tp (line 11). In addition, if the definition has not been visited, it is added to the queue queue (lines 12-13).
[0076] This embodiment uses the following algorithm to filter and use basic blocks:
[0077]
[0078]
[0079] For each target point (ie, the basic block contained in the target code), the algorithm iteratively analyzes and collects the target usage blocks related to the target point based on the use-definition analysis (line 5).
[0080] S105: Determine a data dependency graph between the defined basic blocks.
[0081] The data dependency graph is used to characterize the data dependency relationship between each definition basic block, that is, the data dependency graph is used to record the data or variables that each definition basic block jointly participates in defining. Using the data dependency graph to participate in the subsequent regression fuzz testing of the target code can trigger certain vulnerabilities with strict triggering conditions.
[0082] This embodiment collects all reachable target points or basic blocks (control flow) reachable from target points, as well as data dependency graphs (data flow) between these basic blocks, thereby enhancing the guidance capability of the fuzz testing process for target definition, target points, and target usage, and further triggering more regression vulnerabilities.
[0083] This embodiment uses the following algorithm to analyze and define the data dependency graph between basic blocks:
[0084]
[0085]
[0086] The above algorithm takes the program Program (that is, the program source code) and the target point (target point is the basic block contained in the target code) set TargetPoints (TargetPoints is the target code) as input, and the above algorithm outputs a mapping TGDD from the basic blocks reachable from the target points to the set of their related data-dependent basic blocks (that is, the above algorithm outputs a data dependency graph, which is used to record the connectivity between the basic blocks of the target code through the same data).
[0087] The algorithm first initializes the mapping TGDD to an empty mapping (line 1), then the algorithm analyzes the target points one by one and extracts their related guiding relationships (lines 2-9). That is, for each target point tp, the target function tf of the target point is obtained, and its definition and usage analysis is performed (lines 3-4). Subsequently, the algorithm obtains the basic block set TRBB in the target function tf that is reachable by the target point tp or that can reach the target point (line 5). For each instruction inst in each basic block bb in TRBB, all relevant definitions defs in the basic block where the non-inst is located are obtained (line 8). Finally, the algorithm adds the basic blocks where these definitions are located to the set corresponding to the current basic block bb in the mapping TGDD (line 9).
[0088] For example, Figure 4 As shown, "def d: use b" is the target instruction included in the target code, BB2 is the target definition (that is, the basic block BB2 is the definition basic block), and BB5 is the target use (that is, the basic block BB5 is the use basic block). Although BB1 and BB4 do not contain the use of variable b and the definition of d in BB2, BB1 can reach BB3, so (BB3, BB1) constitutes a data dependency graph (that is, data dependency relationship), and BB3 can reach BB4, so (BB4, BB3) also constitutes a data dependency graph, and BB5 can reach BB3, so (BB5, BB3) also constitutes a data dependency graph.
[0089] The data dependency relationship of this embodiment includes the target point (such as Figure 3 The data dependencies between the target points shown in the figure), target definitions, and target usage are collected into TGDD to facilitate the program instrumentation process to uniformly instrument all data dependencies, and use these relationships (i.e., edges) as target data flow coverage information to guide the fuzz testing process to explore different paths related to the target and their reachability. On this basis, combined with the target definition and target usage information that are strongly related to the target, the fuzz testing process can further enhance its ability to guide target definition, target points, and target usage, increase the possibility of triggering regression vulnerabilities, and thus improve the regression vulnerability detection capability.
[0090] S106, using the definition basic block, the use basic block, and the data dependency graph as data flow information.
[0091] That is, the data flow information of this embodiment includes the definition of basic blocks, the use of basic blocks, and the data dependency graph.
[0092] Embodiment 2, based on embodiment 1, in this embodiment, step S200 includes the following specific steps S201 to S207:
[0093] S201, inserting a monitoring program into the program source code.
[0094] The monitoring program of this embodiment includes the plugging of control flow information, the plugging of data flow information and the plugging of target score (that is, the monitoring program is used to monitor how much control flow is executed, how much data flow is executed, and the target score is calculated by the monitoring program). The plugging of target control flow information and data flow information not only guides the specific position during the fuzz test, but also fully tests the code related to the target. The plugging of target score information that is more related to the target point helps to further strengthen the guiding role of the fuzz test.
[0095] The monitoring procedure of this embodiment is as follows:
[0096]
[0097] The algorithm takes the original program Program (that is, the program source code), the target point set TargetPoints, the reachable basic block map TF2RBB of the calling function, the target definition map TargetDefs, the target use map TargetUses, and the target-directed data dependency map TGDD as input, and outputs the instrumented program.
[0098] The algorithm first instruments the control flow coverage information according to the mapping TF2RBB, and then instruments the data flow coverage information according to the mapping TGDD. Unlike control dependencies, the predecessor of data dependencies is not necessarily the basic block of the previous program execution. Therefore, the instrumentation of data flow coverage information requires first inserting a series of state access-related initialization instructions in each predecessor basic block (lines 4-5), and then calculating the hash value based on the access situation (line 9). Finally, in order to enhance the guidance ability of the fuzz testing process for target definition, target points, and target use, this paper calculates the relevant scores of each target (see Section 3.2.1 for details) and performs instrumentation based on these scores (lines 11-16) for feedback to the fuzz testing process.
[0099] S202, monitoring the execution times of the control flow information through the monitoring program, and obtaining the control flow coverage TPScore according to the execution times of the control flow information. tp (s):
[0100] TPScore tp (s)=Hit(tp)
[0101] Where s represents the test case, tp is the basic block contained in each control flow of the target code, and Hit(tp) is the number of executions of the basic block tp.
[0102] S203, monitoring the closest distance |b-tp| and the farthest distance L contained in the data dependency graph of the target definition b through the monitoring program, wherein the target definition is the definition where the definition basic block is located.
[0103] Several definition basic blocks are used together to complete the definition of a variable. If the variable is a variable in the target code, then the definition is the target definition.
[0104] In order to complete the definition of the target definition b, several definition basic blocks need to indirectly define multiple variables to complete the definition of the target definition b. The definition of each variable corresponds to a data dependency graph. The closest distance |b-tp| is the number of basic blocks contained in the data dependency graph containing the least basic blocks. The farthest distance L is the number of basic blocks contained in the data dependency graph containing the most basic blocks.
[0105] S204, obtaining a definition sub-score TDScore of each target definition according to the shortest distance and the farthest distance of each target definition tp (b)
[0106] TDScore tp (b) = L - (|b - tp|) + 1
[0107] S205, based on the definition sub-score of each target definition, filter out a target definition score TDScore from all the definition sub-scores of the target definition. tp (s):
[0108]
[0109] In the formula, TD s For the program source code, all target definitions involved in running test case s. For example, executing test case s involves ten target definitions. Each target definition corresponds to a definition sub-score, so there are ten definition sub-scores. The smallest definition sub-score is selected from the ten definition sub-scores, and the smallest definition sub-score is the target definition score.
[0110] S206, monitoring the execution count ValidHit of the use basic block tp′ corresponding to each target use b′ (target use is the use where the use basic block is located) through the monitoring program tp′ (b′), and accumulate the execution times corresponding to each target usage to obtain the target usage score TUScore tp′ (s):
[0111]
[0112] TUScoretp′ (b′) = ValidHit tp′ (b′)
[0113]
[0114] Hit(b′) is the number of effective executions of the target using b′ for the basic block tp′, TU s Use the constructed set for all targets on the execution path of test case s.
[0115] S207: Use the target definition score and the target usage score as a data flow overlay.
[0116] Embodiment 3, based on embodiment 2, in this embodiment, step S300 includes the following specific steps: when the control flow coverage is greater than the first threshold and / or the target definition score is greater than the second threshold and / or the target usage score is greater than the third threshold, determine the test variation case of the test case; input the test variation case into the program source code, and when the program source code does not crash after the test variation case is input, update the test case until the program source code crashes, and obtain the target test case. When the program source code crashes after the test variation case is input, use the test variation case as the target test case.
[0117] First, the algorithm selects a test case s from the seed pool S (corresponding to the second line of the algorithm) and assigns an energy value n to the test case s (corresponding to the third line of the algorithm, setting the energy value means setting the number of test mutation cases for the test case, where the generation of test mutation cases from the test case is the prior art). This value determines the number of sub-seeds (i.e., test cases) generated from the mutation of the seed (the seed is the test case) (corresponding to lines 4-5 of the algorithm). For each mutated test case, the algorithm will monitor the execution of the test case as a program input and collect the target control flow coverage (i.e., control flow coverage TPScore). tp (s)), target score (target score includes target definition score TDScore tp (s) and target usage score TUScore tp′(s)), crash and other information (corresponding to line 6 of the algorithm). If the test case can trigger a program crash, it is added to the crash set CRASHES (lines 7-8). If the execution path of the test case covers the new target control flow (corresponding to line 9 of the algorithm, that is, the control flow has undergone a new change) or the target data flow branch (corresponding to line 11 of the algorithm), or obtains a higher target score (corresponding to line 13 of the algorithm), then it is added to the seed pool S. Repeat the above process until the preset time limit is reached or a termination signal is received (corresponding to lines 2-14 of the algorithm).
[0118] The above algorithm is as follows:
[0119]
[0120] In summary, the present invention analyzes the data flow information that has a stronger correlation with the target point, and focuses on the detection of code blocks affected by the target point data flow. The present invention uses these data flow information as feedback information, and specifically designs a seed update strategy to guide fuzz testing, so that it can fully cover the target code and its related code, thereby improving the regression vulnerability detection capability.
[0121] This embodiment also provides a regression fuzzy testing device, such as Figure 5 As shown, the device comprises the following components:
[0122] The information extraction module 01 is used to obtain the target code generated by the program source code due to the version change, and extract the control flow information and data flow information of the target code;
[0123] A monitoring module 02, for inputting a test case into the program source code, and monitoring the control flow coverage of the control flow information and the data flow coverage of the data flow information when the program source code after the test case is input does not crash;
[0124] The update module is used to update the test case according to the control flow coverage and the data flow coverage until the program source code crashes to obtain the final test case.
[0125] Based on the above embodiments, the present invention further provides a terminal device, whose principle block diagram can be shown as follows: Figure 6As shown. The terminal device includes a processor, a memory, a network interface, and a display screen connected through a system bus. Among them, the processor of the terminal device is used to provide computing and control capabilities. The memory of the terminal device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the terminal device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a regression fuzzy testing method is implemented. The display screen of the terminal device can be a liquid crystal display screen or an electronic ink display screen.
[0126] Those skilled in the art will understand that Figure 6 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the terminal device to which the scheme of the present invention is applied. The specific terminal device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0127] In one embodiment, a terminal device is provided. The terminal device includes a memory, a processor, and a regression fuzzy test program stored in the memory and executable on the processor. When the processor executes the regression fuzzy test program, the following operation instructions are implemented:
[0128] Obtaining target code generated by version change of program source code, and extracting control flow information and data flow information of the target code;
[0129] Inputting a test case into the program source code, and when the program source code after the test case is input does not crash, monitoring the control flow coverage of the control flow information and the data flow coverage of the data flow information;
[0130] The test case is updated according to the control flow coverage and the data flow coverage until the program source code crashes, thereby obtaining a final test case.
[0131] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A regression fuzzy testing method, characterized in that: include: Obtaining target code generated by version change of program source code, and extracting control flow information and data flow information of the target code; Inputting a test case into the program source code, and when the program source code after the test case is input does not crash, monitoring the control flow coverage of the control flow information and the data flow coverage of the data flow information; The test case is updated according to the control flow coverage and the data flow coverage until the program source code crashes, thereby obtaining a final test case.
2. The regression fuzzy testing method according to claim 1, characterized in that: The extracting control flow information and data flow information of the target code includes: Extracting the calling function corresponding to the target code; Extracting control flow information related to the target code and the calling function; Parsing a basic block contained in the target code, wherein the basic block is a code block having only one input port and one output port; Filtering out a definition basic block for defining a variable from the basic blocks, and filtering out a use basic block for calling a variable from the basic blocks; Determining a data dependency graph between the defined basic blocks; The definition basic block, the use basic block, and the data dependency graph are used as data flow information.
3. The regression fuzzy testing method according to claim 2, characterized in that: The monitoring of the control flow coverage of the control flow information and the data flow coverage of the data flow information includes: Inserting a monitoring program into the program source code; Monitoring the execution times of the control flow information by the monitoring program, and obtaining control flow coverage according to the execution times of the control flow information; The data flow coverage of the data flow information is monitored by the monitoring program.
4. The regression fuzzy testing method according to claim 3, characterized in that: The monitoring of the data flow coverage of the data flow information by the monitoring program includes: Monitoring, by the monitoring program, the closest distance and the farthest distance included in the data dependency graph of a target definition, wherein the target definition is the definition where the definition basic block is located; Obtaining a definition sub-score of each target definition according to the closest distance and the farthest distance of each target definition; According to the definition sub-score of each of the target definitions, a target definition score is filtered out from the definition sub-scores of all the target definitions; The monitoring program is used to monitor the execution times of the basic block used corresponding to each target use, and a target use score is obtained according to the execution times corresponding to each target use, wherein the target use is the use where the basic block used is located; The target definition score and the target usage score are overlaid as a data flow.
5. The regression fuzzy testing method according to claim 4, characterized in that: The target usage score is obtained according to the execution times corresponding to each target usage, including: The number of executions corresponding to each target usage is accumulated to obtain a target usage score.
6. The regression fuzzy testing method according to claim 4, characterized in that: The step of updating the test case according to the control flow coverage and the data flow coverage until the program source code crashes to obtain a final test case includes: When the control flow coverage is greater than a first threshold and / or the target definition score is greater than a second threshold and / or the target usage score is greater than a third threshold, determining a test variation case of the test case; The test variation case is input into the program source code, and when the program source code does not crash after the test variation case is input, the test case is updated until the program source code crashes, thereby obtaining a target test case.
7. The regression fuzzy testing method according to claim 6, characterized in that: The updating of the test case according to the control flow coverage and the data flow coverage until the program source code crashes to obtain a final test case also includes: When the program source code crashes after the test mutation case is input, the test mutation case is used as a target test case.
8. A regression fuzzy testing device, characterized in that: The device comprises the following components: An information extraction module, used to obtain the target code generated by the program source code due to the version change, and extract the control flow information and data flow information of the target code; A monitoring module, used for inputting a test case into the program source code, and monitoring the control flow coverage of the control flow information and the data flow coverage of the data flow information when the program source code after the test case is input does not crash; An update module is used to update the test case according to the control flow coverage and the data flow coverage until the program source code crashes, thereby obtaining a final test case.
9. A terminal device, characterized in that: The terminal device includes a memory, a processor, and a regression fuzzy testing program stored in the memory and executable on the processor. When the processor executes the regression fuzzy testing program, the steps of the regression fuzzy testing method as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a regression fuzzy testing program, and when the regression fuzzy testing program is executed by the processor, the steps of the regression fuzzy testing method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Virtual machine escape vulnerability mining method, device, equipment and medium
CN110764870A
Fuzzy testing method for continuous integration process
CN115203041A
Vulnerability PoC-driven double-loop fuzzy test method and system
CN116992452A
Code testing method and device based on directional grey box fuzzy testing technology and medium
CN118227494A
Apparatus, computer-readable data carrier, computer program, and method for fuzz testing software
GB202313322D0
