Large Model-Assisted Automatic Perception Fuzz Testing Method and System for Program Functions
Through the large-model-assisted automatic fuzz testing method, the limitations of functional identification and test case generation in the prior art are solved, and efficient and comprehensive quality and safety guarantees for complex software systems are achieved.
Patent Information
- Application Number
- CN202510199284.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-24
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2045-02-24
AI Technical Summary
The existing fuzz testing technology has limitations in function identification, test case generation and result analysis, and it is difficult to effectively deal with complex software systems, resulting in low test coverage and low efficiency, and the inability to fully guarantee the safety and reliability of the program.
The automatic fuzz testing method of large-model-assisted program functions is adopted to obtain source code and document descriptions, identify functional parameters and their dependencies and constraints, generate structured reports, and optimize test coverage and effectiveness.
It improves the accuracy of functional parameter recognition and the efficiency of test case generation, improves the coverage and effectiveness of fuzzy testing, and ensures the quality and safety of complex software systems.
Smart Images

Figure CN119690854B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and particularly to a method, system, electronic device and computer-readable storage medium for automatically perceiving function-based fuzz testing assisted by a large model. Background Art
[0002] With the rapid development of software technology, the scale and complexity of software systems have increased significantly. How to ensure the security and reliability of programs in complex operating environments has become an important topic in the field of software engineering. Among them, comprehensive fuzz testing for program functions has gradually become a key means in the program security testing process. However, existing fuzz testing technologies still have significant limitations in function recognition, test case generation, and test result analysis. When facing modern software systems with complex functions, diverse parameters, and highly coupled dependencies, their test coverage and effectiveness are insufficient. The existing technologies mainly face the following challenges.
[0003] 1. Difficulty in identifying program function parameters. Program function parameters are the basis for test logic coverage and efficient test case generation. However, traditional methods usually rely on developers to manually sort out function parameters, which is not only time-consuming and laborious but also prone to omissions or misunderstandings. In addition, the descriptions of functions in documentation often do not match the actual source code implementation, further increasing the difficulty of function parameter identification.
[0004] 2. Insufficient extraction of dependencies and constraints between function parameters. In modern complex programs, there are usually highly complex dependencies and constraints between program function parameters. For example, the value of some parameters may be restricted by the value range of other parameters, specific program states, or external environmental conditions. Existing testing technologies lack systematic methods for automatically identifying and handling these dependencies and constraints, resulting in test cases that may not cover critical paths or trigger potential defects. In addition, generating invalid test cases that do not meet the constraints also wastes a large amount of test resources and reduces test efficiency.
[0005] 3. Insufficient automation of fuzz testing. In the process of test case generation and test execution, traditional fuzz testing methods mostly rely on simple randomization techniques or predefined rules, and it is difficult to generate targeted and efficient test cases in combination with the specific function characteristics of the program. At the same time, in the analysis of test results, traditional methods often require manual completion, which is not only inefficient but also prone to omissions of potential defects, affecting test comprehensiveness.
[0006] 4. It is difficult to ensure the efficiency of large-scale complex program testing. As the scale and complexity of software increase, the test paths may grow exponentially, and traditional fuzz testing tools often fail to effectively handle this complexity. This results in a significant decrease in test coverage, insufficient verification of the reliability of the program under various functional scenarios, and an increased risk of potential defects.
[0007] In recent years, the rapid development of artificial intelligence technology, especially the breakthroughs of large models in the fields of natural language processing and code analysis, has provided new technical support for program testing. Large models have shown significant advantages in the automatic extraction of program function parameters, the identification of dependency relationships, and the generation of intelligent test cases. However, there is still a lack of mature methods and tools for systematically applying large models to the fields of program function perception and fuzz testing.
[0008] It should be noted that the information disclosed in the background art section of this invention is only intended to deepen the understanding of the general background technology of this invention, and should not be regarded as an admission or any form of implication that this information constitutes the prior art known to those skilled in the art. Summary of the Invention
[0009] The purpose of this invention is to provide a large model-assisted automatic program function perception fuzz testing method, system, electronic device, and computer-readable storage medium. This invention can combine the actual characteristics of program functions to comprehensively improve the accuracy of function parameter identification, the systematicness of dependency relationship extraction, and the efficiency of test case generation and execution, thereby optimizing the coverage and effectiveness of fuzz testing and comprehensively ensuring the quality and security of complex software systems.
[0010] To achieve the above objective, this invention provides a large model-assisted automatic program function perception fuzz testing method, including: obtaining the source code and description document of the program to be tested; analyzing the source code and the description document based on the first large model to obtain all function parameters supported by the program to be tested; identifying the dependency relationships and constraint conditions between the function parameters based on the source code and the function parameters; performing fuzz testing based on the dependency relationships and constraint conditions between the function parameters; and automatically analyzing the test results of the fuzz testing based on the second large model to generate a structured report.
[0011] Optionally, analyze the source code and the description document based on the first large model to obtain all function parameters supported by the program to be tested, including: perform semantic parsing on the description document based on the first large model to identify function parameters in the description document and generate a first function parameter set; perform static analysis on the source code based on the first large model to identify function parameters supported by the source code and generate a second function parameter set; generate a complete function parameter set according to the first function parameter set and the second function parameter set to obtain all function parameters supported by the program to be tested.
[0012] Optionally, the performing static analysis on the source code based on the first large model to identify function parameters supported by the source code and generate a second function parameter set includes: using a source code static analysis tool to identify all functions included in the program to be tested; constructing a function call graph with the main function of the program among all the functions as the root node; analyzing the function call graph and the source code based on the first large model to locate code segments related to function parameter parsing and corresponding function parameter parsing functions; extracting the names, description information, and default values of function parameters from the code segments related to function parameter parsing; and forming the second function parameter set with the extracted names, description information, and default values of function parameters.
[0013] Optionally, the obtaining a complete function parameter set according to the first function parameter set and the second function parameter set includes: comparing the first function parameter set with the second function parameter set to obtain their intersection and difference sets, where the intersection includes function parameters that are consistent between the description document and the source code, and the difference set includes function parameters that appear in the description document but are not implemented in the source code, and function parameters that are implemented in the source code but do not appear in the description document; for function parameters that appear in the description document but are not implemented in the source code, analyze the description document and the source code based on the first large model to determine whether the function parameter is a potentially missing function parameter, and if so, add the function parameter to the intersection to expand the intersection; for function parameters that are implemented in the source code but do not appear in the description document, analyze the definition and usage locations of the function parameter in the source code based on the first large model to determine whether the function parameter is used, and if so, add the function parameter to the intersection to expand the intersection; and obtain a complete function parameter set according to the expanded intersection.
[0014] Optionally, for the function parameters that appear in the specification document but are not implemented in the source code, analyze the specification document and the source code based on the first large model to determine whether the function parameter is a potential missing function parameter, including: performing semantic analysis on the description corresponding to the function parameter using the first large model to obtain keywords; performing fuzzy matching of the keywords in the source code and the comments included in the source code; if there is potential implementation code that matches, analyze the potential implementation code using the first large model and determine whether its function is consistent with the function description corresponding to the function parameter. If it is consistent, determine that the function parameter is a potential missing function parameter.
[0015] Optionally, the identifying the dependency relationships and constraint conditions between function parameters based on the source code and the function parameters includes: analyzing the usage paths of each function parameter based on the first large model and a data flow analysis method; obtaining the intersection of the usage paths between different function parameters according to the analysis results of the usage paths of each function parameter; generating a dependency relationship graph and a set of constraint rules between function parameters according to the intersection of the usage paths between different function parameters.
[0016] Optionally, the performing fuzz testing based on the dependency relationships and constraint conditions between function parameters includes: analyzing the function parameter attributes and the dependency relationship graph using the first large model to generate an initial test case set; designing a test case mutation strategy based on the dependency relationship graph; starting to perform fuzz testing based on the initial test case set and the test case mutation strategy; dynamically generating a new test case set during the testing process, and optimizing the test case mutation strategy based on the first large model and real-time code coverage feedback; continuing to perform fuzz testing based on the new test case set and the optimized test case mutation strategy.
[0017] To achieve the above object, the present invention further provides a large model-assisted program function automatic perception fuzz testing system, including: a first acquisition module configured to acquire the source code and the specification document of the program to be tested; a second acquisition module configured to analyze the source code and the specification document based on the first large model to obtain all function parameters supported by the program to be tested; an identification module configured to identify the dependency relationships and constraint conditions between function parameters based on the source code and the function parameters; a testing module configured to perform fuzz testing based on the dependency relationships and constraint conditions between function parameters; and an analysis module configured to automatically analyze the test results of the fuzz testing based on the second large model to generate a structured report.
[0018] To achieve the above object, the present invention further provides an electronic device, including at least one processor and at least one storage device, where the storage device is adapted to store multiple program codes, and the program codes are adapted to be loaded and run by the processor to execute the large model-assisted program function automatic perception fuzz testing method described in any one of the above.
[0019] To achieve the above object, the present invention further provides a computer-readable storage medium, on which multiple program codes are stored, and the program codes are adapted to be loaded and run by a processor to execute the large model-assisted program function automatic perception fuzz testing method described in any one of the above.
[0020] Compared with the prior art, the large model-assisted program function automatic perception fuzz testing method, system, electronic device, and computer-readable storage medium provided by the present invention have the following beneficial effects: By analyzing the source code and documentation of the program to be tested based on the first large model, all function parameters supported by the program to be tested can be obtained, giving full play to the advantages of the large model in natural language processing and code semantic understanding, and achieving accurate extraction of function parameters; By identifying the dependency relationships and constraint conditions between function parameters based on the source code and the function parameters, guiding the execution of fuzz testing not only improves the test coverage and automation level, but also enhances the pertinence and effectiveness of test cases, thus significantly optimizing the efficiency and effect of fuzz testing. In summary, by adopting the large model-assisted program function automatic perception fuzz testing method provided by the present invention, it is possible to combine the actual characteristics of program functions, comprehensively improve the accuracy of function parameter identification, the systematicness of dependency relationship extraction, and the efficiency of test case generation and execution, thereby optimizing the coverage and effectiveness of fuzz testing and comprehensively ensuring the quality and security of complex software systems.
[0021] Since the large model-assisted program function automatic perception fuzz testing system, electronic device, and computer-readable storage medium provided by the present invention belong to the same inventive concept as the large model-assisted program function automatic perception fuzz testing method provided by the present invention, the large model-assisted program function automatic perception fuzz testing system, electronic device, and computer-readable storage medium provided by the present invention at least have all the beneficial effects of the large model-assisted program function automatic perception fuzz testing method provided by the present invention. For specific reference, please refer to the relevant descriptions in the above text. Therefore, the beneficial effects of the large model-assisted program function automatic perception fuzz testing system, electronic device, and computer-readable storage medium provided by the present invention will not be elaborated one by one here. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a flowchart of the large model-assisted program function automatic perception fuzz testing method provided by an embodiment of the present invention.
[0023] Figure 2 A flowchart for obtaining all functional parameters supported by the program to be tested provided by an embodiment of the present invention.
[0024] Figure 3 A flowchart for identifying the dependency relationships and constraint conditions among functional parameters provided by an embodiment of the present invention.
[0025] Figure 4 A flowchart for performing fuzz testing provided by an embodiment of the present invention.
[0026] Figure 5 A structural block diagram of a large model-assisted program function automatic perception fuzz testing system provided by an embodiment of the present invention.
[0027] Figure 6 A structural block diagram of an electronic device provided by an embodiment of the present invention.
[0028] Among them, the reference numeral descriptions are as follows: the first acquisition module - 110; the second acquisition module - 120; the identification module - 130; the test module - 140; the analysis module - 150; the processor - 210; the storage device - 220. Detailed implementation manners
[0029] The following further elaborates on the large model-assisted program function automatic perception fuzz testing method, system, electronic device, and computer-readable storage medium proposed by the present invention in combination with the accompanying drawings and specific implementation manners. According to the following description, the advantages and features of the present invention will be clearer. It should be noted that the accompanying drawings are in a very simplified form and all use non-precise scales, only for conveniently and clearly assisting in explaining the purpose of the present invention. In order to make the purpose, features, and advantages of the present invention more obvious and understandable, please refer to the accompanying drawings. It should be known that the structures, scales, sizes, etc. shown in the drawings of this specification are only used to cooperate with the content disclosed in the specification for those skilled in this technology to understand and read, and are not used to limit the limiting conditions of the implementation of the present invention. Any modification of the structure, change of the proportional relationship, or adjustment of the size, in the case of being the same or approximate to the effects that the present invention can produce and the purposes that can be achieved, should still fall within the scope covered by the technical content disclosed by the present invention.
[0030] The core idea of the present invention is to provide a large model-assisted program function automatic perception fuzz testing method, system, electronic device, and computer-readable storage medium. The present invention can combine the actual characteristics of program functions, comprehensively improve the accuracy of functional parameter identification, the systematicness of dependency relationship extraction, and the efficiency of test case generation and execution, thereby optimizing the coverage rate and effectiveness of fuzz testing, and comprehensively ensuring the quality and security of complex software systems.
[0031] It should be noted that the large model-assisted program function automatic perception fuzz testing method provided by the present invention can be applied to the large model-assisted program function automatic perception fuzz testing system provided by the present invention. The large model-assisted program function automatic perception fuzz testing system can be configured on an electronic device. Among them, the electronic device can be a personal computer, a mobile terminal, etc. The mobile terminal can be a hardware device such as a mobile phone, a tablet computer, etc. with various operating systems.
[0032] To implement the above idea, the present invention provides a large model-assisted program function automatic perception fuzz testing method. Please refer to Figure 1 , which is a flowchart of the large model-assisted program function automatic perception fuzz testing method provided by an embodiment of the present invention. As Figure 1 shown, the large model-assisted program function automatic perception fuzz testing method provided by the present invention includes: Step S100, obtaining the source code and the instruction document of the program to be tested; Step S200, analyzing the source code and the instruction document based on the first large model to obtain all function parameters supported by the program to be tested; Step S300, identifying the dependency relationships and constraint conditions between the function parameters based on the source code and the function parameters; Step S400, performing fuzz testing based on the dependency relationships and constraint conditions between the function parameters; Step S500, automatically analyzing the test results of the fuzz testing based on the second large model to generate a structured report.
[0033] Thus, by analyzing the source code and the instruction document of the program to be tested obtained based on the first large model to obtain all function parameters supported by the program to be tested, the present invention can give full play to the advantages of the large model in natural language processing and code semantic understanding, and achieve accurate extraction of function parameters; by identifying the dependency relationships and constraint conditions between the function parameters based on the source code and the function parameters to guide the execution of fuzz testing, it not only improves the test coverage rate and automation level, but also improves the pertinence and effectiveness of test cases, thereby significantly optimizing the efficiency and effect of fuzz testing. In summary, by adopting the large model-assisted program function automatic perception fuzz testing method provided by the present invention, it is possible to combine the actual characteristics of program functions, comprehensively improve the accuracy of function parameter identification, the systematicness of dependency relationship extraction, and the efficiency of test case generation and execution, thereby optimizing the coverage rate and effectiveness of fuzz testing and comprehensively ensuring the quality and security of complex software systems.
[0034] Specifically, fuzz testing is an automated software testing method that injects illegal, malformed, or unexpected inputs into a system to reveal software defects and vulnerabilities. It should be noted that the first large model can be, but is not limited to, ChatGPT-o1 and DeepSeek-V3, and the second large model can be, but is not limited to, DeepSeek-V3, ChatGPT-o1, and qwen2.5.
[0035] In some exemplary embodiments, the step S100 of obtaining the source code and documentation of the program to be tested includes: obtaining the source code repository of the program to be tested, and analyzing the compilation documentation in the source code repository based on the first large model to construct an automated compilation script; preprocessing the unstructured documentation to obtain a standardized format of the documentation.
[0036] Specifically, first obtain the source code repository of the program to be tested from a specified source code repository (such as a Git repository) or the local file system, and then analyze the compilation documentation in the source code repository based on the first large model, such as the Readme file or files in directories such as Install, to extract the compilation commands of the program and the method for constructing the dependency environment, and construct an automated compilation script. In addition, obtain various project documentation from the source code repository, online project usage documents, or local project documentation directories, including usage instruction documents, user help manuals, or project promotion documents, etc. These documents may exist in various forms (such as formats like PDF, DOCX, PPTX, Markdown, HTML pages, etc.). Collect these documents through automated tools or scripts, and preprocess the unstructured documentation to obtain a standardized format of the documentation. The preprocessing includes uniformly converting various file formats into the Markdown file format and removing embedded images and streaming media data.
[0037] Please continue to refer to Figure 2 , which is a flowchart of obtaining all function parameters supported by the program to be tested provided by an embodiment of the present invention. As Figure 2As shown, in some exemplary embodiments, the step S200, analyzing the source code and the description document based on the first large model to obtain all function parameters supported by the to-be-tested program, includes: step S210, performing semantic parsing on the description document based on the first large model to identify function parameters in the description document and generate a first function parameter set; step S220, performing static analysis on the source code based on the first large model to identify function parameters supported by the source code and generate a second function parameter set; step S230, generating a complete function parameter set according to the first function parameter set and the second function parameter set to obtain all function parameters supported by the to-be-tested program.
[0038] Thus, through the above steps S210 to S230, the accuracy and integrity of function parameter extraction can be effectively improved, so as to further optimize the coverage rate and effectiveness of fuzz testing and comprehensively ensure the quality and security of complex software systems.
[0039] Specifically, by using the first large model to perform semantic parsing on the description document, the key paragraphs related to function descriptions can be analyzed to identify the core attributes of the functions. Further, through the limitation of the function and output format by the set prompt words, the first large model will perform context understanding on the content of the description document to extract the names of function parameters (such as parameter names or option names), description information (such as the purpose or operation effect of the function), and default values (such as the default behavior when the parameter is not set), and finally generate a first function parameter set composed of the names, description information, and default values of all collected function parameters.
[0040] In some exemplary embodiments, the step S220, performing static analysis on the source code based on the first large model to identify function parameters supported by the source code and generate a second function parameter set, includes: using a source code static analysis tool to identify all functions (including the main program function) included in the to-be-tested program; constructing a function call graph with the main program function as the root node; analyzing the function call graph and the source code based on the first large model to locate the code segments related to function parameter parsing and the corresponding function parameter parsing functions; extracting the names, description information, and default values of function parameters from the code segments; and forming the second function parameter set with the extracted names, description information, and default values of function parameters. Thus, the function functions can be accurately located to ensure the integrity and accuracy of function parameter information.
[0041] In some exemplary embodiments, identifying all functions included in the program to be tested using the source code static analysis tool includes: First, using a static code analysis tool (such as LLVM Clang or other tools supporting the construction of Abstract Syntax Tree (AST)), based on an automated compilation script, parse the source code. By traversing the abstract syntax tree, all function information defined in the program to be tested can be collected, including function names, parameter lists, return value types, and their code positions, etc. In particular, locate the program's main function (such as the main() function in C language or other entry point functions), and mark it as the root node of the Call Graph (CG).
[0042] Specifically, the Abstract Syntax Tree (AST) is a concept in program analysis. The abstract syntax tree is an intermediate representation form of the source code during the processing of the compiler or interpreter. It abstracts the syntax structure of the code, ignores specific syntax details (such as parentheses, semicolons, etc.), and only retains the core information that can embody the code logic. Based on the source code of the program to be tested and the compilation parameters corresponding to the source code, its complete abstract syntax tree can be obtained. The abstract syntax tree is a rooted tree, where each node represents a syntax unit in the program, such as a function, statement, expression, or variable.
[0043] The Call Graph (CG) can show the relationships between functions in a computer program. Each node is a function, and each edge (f, g) represents that function f calls function g.
[0044] The program's main function is the starting point of program execution. It is usually a special function used by the operating system to start the program, and it controls the program execution by calling other functions in the program.
[0045] In some exemplary embodiments, analyzing the call graph and the source code based on the first large model to locate code segments related to function parameter parsing includes: Using the first large model to analyze the call graph and its associated source code segments to identify code segments that may be responsible for function parameter parsing; Using the first large model to perform recursive analysis along the call graph to extract call chains related to function parameter parsing; Combining the control flow graph and the context information of the source code, using the first large model to locate the code positions related to function parameter parsing.
[0046] Specifically, after constructing the function call graph, a large model is used to further analyze the nodes of the function call graph and their associated source code snippets to locate the functional parameter parsing logic. Specifically, first, a first large model is used to analyze the main function of the program and the functions directly called by it. For example, the main() function usually contains command-line argument parsing logic or configuration file loading logic. The first large model identifies and returns code snippets that may be responsible for functional parameter parsing through context semantic analysis (e.g., analyzing keywords such as argv, parse, config, etc.). Secondly, the first large model is used to perform recursive analysis along the function call graph to extract the call chain related to functional parameter parsing. For example, if the main() function calls parse_arguments(), and the latter calls add_option(), the first large model will further analyze the logic of these functions and determine all functions involved in functional parameter parsing (i.e., functional parameter parsing functions). Finally, in combination with the control flow graph and the context information of the source code, the first large model is used to locate the code positions related to functional parameter parsing. For example, the code snippet for command-line parsing may contain function calls such as the getopt() function or the argparse() function. For programs using non-standard functional parameter parsing functions (such as getopt()), the Chain-of-Thought technique is used to pre-define the example code and working logic of common custom parameter parsing structures such as swith-case, for-if-else, while-if-else, etc., to assist the first large model in analyzing the program to be tested, so as to locate the code positions related to user-defined non-standard functional parameter parsing.
[0047] In some exemplary embodiments, extracting the name, description information, and default value of a functional parameter from the code snippet related to functional parameter parsing includes: using the first large model to analyze the code snippet related to functional parameter parsing to extract the name, description information, and default value of the functional parameter.
[0048] Specifically, the names, description information, and default values of the extracted functional parameters can be stored in a structured format. Further, the first large model can be used to locate the functions and code snippets related to the parsing of functional parameters within the program to be tested, and identify the names of the functional parameters. For example, "verbose" and "config" are extracted as the names of the functional parameters. Using the first large model, the description information of each functional parameter can be extracted based on semantic analysis (such as "Enable verbose mode" and "Path to configuration file"). Such description information is usually used to help users understand the corresponding purposes of the functional parameters. Using the first large model to analyze the context of the code snippets related to the parsing of functional parameters, the possible default values of the functional parameters can be extracted. If the default value is not explicitly defined in the code, trace the usage code of the functional parameter, and use the first large model to further infer its possible type and the value range of the type (such as the default value of a boolean parameter is false or true) based on the usage code of the functional parameter.
[0049] In some exemplary embodiments, step S230 of obtaining the complete set of functional parameters according to the first set of functional parameters and the second set of functional parameters includes: comparing the first set of functional parameters with the second set of functional parameters to obtain their intersection and difference sets. Among them, the intersection includes the functional parameters whose documentation and source code are consistent, and the difference set includes the functional parameters that appear in the documentation but are not implemented in the source code, and the functional parameters that are implemented in the source code but do not appear in the documentation; for the functional parameters that appear in the documentation but are not implemented in the source code, analyze the documentation and the source code based on the first large model to determine whether the functional parameter is a potentially missing functional parameter. If so, add the functional parameter (the name, description information, and default value of the functional parameter) to the intersection to expand the intersection; for the functional parameters that are implemented in the source code but do not appear in the documentation, analyze the definition and usage location of the functional parameter in the source code based on the first large model to determine whether the functional parameter is used. If so, add the functional parameter to the intersection to expand the intersection; obtain the complete set of functional parameters according to the expanded intersection.
[0050] Thus, through the above steps, all the functional parameters actually supported by the program to be tested can be covered, thereby further optimizing the coverage rate and effectiveness of fuzz testing and comprehensively ensuring the quality and security of complex software systems.
[0051] Specifically, the second set of functional parameters obtained by parsing the source code (e.g., {"verbose", "config", "output_dir"}) is compared with the first set of functional parameters extracted from the specification document (e.g., {"verbose", "config", "log_level"}) to determine their intersection and difference sets. Among them, the functional parameters in the intersection are clearly reflected in both the source code and the specification document. For example, {"verbose", "config"} in the above example. The functional parameters in the intersection indicate that the documentation record is consistent with the program implementation and usually do not require further verification.
[0052] The functional parameters in the difference set include the following two cases: (1) Functional parameters declared in the specification document but not implemented in the source code (such as "log_level"). These parameters may be due to untimely documentation updates or omissions in program function implementation and require further analysis and confirmation; (2) Functional parameters implemented in the source code but not recorded in the specification document (such as "output_dir"). These parameters may be newly developed functions or overlooked during documentation writing.
[0053] In some exemplary embodiments, for the functional parameters that appear in the specification document but are not implemented in the source code, the specification document and the source code are analyzed based on the first large model to determine whether the functional parameter is a potential omitted functional parameter, including: performing semantic analysis on the description corresponding to the functional parameter using the first large model to obtain keywords; performing fuzzy matching of the keywords in the source code and the comments included in the source code. If there is potential implementation code that matches, the first large model is used to analyze the potential implementation code and determine whether its function is consistent with the function description corresponding to the functional parameter. If they are consistent, it is determined that the functional parameter is a potential omitted functional parameter.
[0054] Specifically, for a functional parameter that appears in the said specification document but is not implemented in the said source code, if the functional description in the specification document is "log_level: Sets the verbosity of log messages", the first large model is used to summarize the functional description to obtain keywords. For example, the keyword "log level" is extracted, and this keyword is used for fuzzy matching in the source code and the comments included in the source code. If there is potential implementation code that matches, the first large model is used to analyze the potential implementation code to determine the consistency of its function with the said functional description. For those determined to be consistent, the analysis of the potential implementation code is continued, and the name, description information, and default value of this functional parameter are added to the intersection set, and at the same time, this potential implementation code is recorded in the set of functional parameter parsing functions. If the matching result is empty (i.e., there is no potential implementation code that matches), this functional parameter is ignored.
[0055] In some exemplary embodiments, for a functional parameter that is implemented in the said source code but does not appear in the said specification document, based on the first large model, the definition and usage location of this functional parameter in the source code are analyzed to determine whether this functional parameter is used, including: using the program static analysis method to trace from the parsing location of this functional parameter along the function call graph to the upper-layer function of the current function, and extracting the context source code at the location where the upper-layer function calls the current function, and at the same time tracing the usage logic after parsing of this functional parameter along the function call graph. If the usage logic includes calls to other functions, the extracted upper-layer code and lower-layer code are combined with the parsing code of this functional parameter to form a code snippet and input into the first large model to determine whether this functional parameter is used.
[0056] Specifically, the usage logic is the processing logic after the input data corresponding to this functional parameter is parsed. If this functional parameter is determined to be used, the name, description information, and default value of this functional parameter are added to the intersection set. If it is determined not to be used, this functional parameter is ignored.
[0057] Please continue to refer to Figure 3 , which is a flowchart for identifying the dependencies and constraints between functional parameters provided by an embodiment of the present invention. As Figure 3As shown, in some exemplary embodiments, the step S300 of identifying the dependencies and constraints between functional parameters based on the source code and the functional parameters includes: step S310 of analyzing the usage paths of each functional parameter based on the first large model and the data flow analysis method; step S320 of obtaining the intersection of the usage paths between different functional parameters according to the analysis results of the usage paths of each functional parameter; step S330 of generating a dependency graph and a set of constraint rules between functional parameters according to the intersection of the usage paths between different functional parameters. Thus, the accuracy and integrity of the generated dependency graph and set of constraint rules can be ensured to further optimize the coverage and effectiveness of fuzz testing and comprehensively guarantee the quality and security of complex software systems.
[0058] In some exemplary embodiments, the step S310 of analyzing the usage paths of each functional parameter based on the first large model and the data flow analysis method includes: based on the source code and the function call graph, starting from the parsing code of the functional parameter in the function that parses the functional parameter, using the program dependency graph to trace the execution paths related to the functional parameter, and extracting the code nodes on the paths involved in the definition, reference, and transfer operations of the variables related to the functional parameter; using the first large model to perform semantic analysis on the usage scenarios and logical relationships of the functional parameters to identify possible implicit paths and special constraint conditions; using the first large model to infer implicit association relationships from the code context.
[0059] Thus, by using the first large model to perform semantic analysis on the usage scenarios and logical relationships of the functional parameters to identify possible implicit paths and special constraint conditions, and using the first large model to infer implicit association relationships from the code context, the defects of data flow analysis can be supplemented.
[0060] Specifically, the code nodes include assignment nodes, conditional nodes, function call nodes, and operation nodes. Among them, the assignment node is the code position where the functional parameter is assigned a value; the conditional node is a branch statement in the program, such as if, else, switch-case, and these nodes determine the value range and constraint logic of the functional parameter; the function call node represents the node where the functional parameter is passed or modified when calling other functions. The operation node represents an operation node related to the functional parameter, such as assignment, comparison, addition, and subtraction operations.
[0061] The Program Dependence Graph is composed of control dependence and data dependence: Control dependence reflects the control flow logic of the program, such as the usage of functional parameters in conditional statements (if, switch-case) and loop statements (for, while). Data dependence represents the dependence relationships of functional parameters in terms of definition, passing, reference, and modification in the program, such as assignment statements, etc.
[0062] In some exemplary embodiments, step S320, obtaining the intersection of usage paths between different functional parameters according to the analysis results of the usage paths of each functional parameter, includes: For each pair of functional parameters, comparing the sets of code nodes on their usage paths to find common code nodes to form the corresponding intersection of usage paths. If the usage paths of two functional parameters both contain a conditional node (such as an if or while statement), it indicates that they may have a logical association. For example, when the settings of two functional parameters both meet a certain condition, a certain function of the program will be activated. If the intersection of the nodes on the usage paths between two functional parameters (path intersection) involves the same function call node, it may indicate that they are passed or interact with each other in the same function call. The operation nodes in the intersection may reflect the calculation relationships or constraint rules between functional parameters. For example, the value range of one functional parameter may depend on the calculation result of another functional parameter. Analyze the logical relationships of the intersection nodes using the first large model. For example, if multiple functional parameters share a certain conditional node and this node involves a complex logical expression, further parse the logical expression to accurately describe the relationships and constraints between functional parameters.
[0063] In some exemplary embodiments, step S330, generating a dependence relationship graph and a set of constraint rules between functional parameters according to the intersection of usage paths between different functional parameters, includes: Constructing a dependence relationship graph with functional parameters as nodes according to the intersection of usage paths between different functional parameters; Attaching the information of the code nodes in the intersection of usage paths to the directed edges of the dependence relationship graph; Analyzing the logical relationships of the code nodes in the intersection of usage paths between different functional parameters using the first large model to obtain the constraint conditions between each functional parameter; Organizing the constraint conditions between each functional parameter into a formalized set of constraint rules.
[0064] Specifically, each directed edge in the dependency graph represents the dependency relationship between functional parameters, and the direction of the directed edge represents the transfer order of the dependencies. For example, the dependency relationship between two functional parameters may be determined by the judgment logic of a certain conditional node, and this information will be marked on the directed edge. The analyzed constraint conditions are sorted into a formal rule set: (1) Single-parameter constraints describe the value range, default value logic, or special conditions of a single functional parameter. For example, the value of a certain functional parameter must be a positive integer, or the default value is a specific constant; (2) Multi-parameter constraints: describe the logical associations between multiple functional parameters, such as the mutual restriction or dependency relationship of the value ranges of two functional parameters. For example, the value of functional parameter A must be less than that of functional parameter B, or when functional parameter C takes a certain specific value, functional parameter D must meet specific conditions.
[0065] In some exemplary embodiments, the large model-assisted program function automatic perception fuzz testing method provided by the present invention further includes: optimizing the dependency graph and the constraint rule set. Specifically, redundant rules can be merged or the graph structure can be simplified. At the same time, the effectiveness of the rules can be tested in the actual running environment through dynamic verification methods to ensure that the logic and constraints described are consistent with the actual behavior of the program.
[0066] Please continue to refer to Figure 4 , which is a flowchart for performing fuzz testing provided by an embodiment of the present invention. As Figure 4 shown, in some exemplary embodiments, the step S400, performing fuzz testing based on the dependency relationship and constraint conditions between the functional parameters, includes: step S410, using the first large model to analyze the functional parameter attributes and the dependency graph to generate an initial test case set; step S420, designing a test case mutation strategy based on the dependency graph; step S430, starting to perform fuzz testing based on the initial test case set and the test case mutation strategy; step S440, dynamically generating a new test case set during the testing process, and optimizing the test case mutation strategy based on the first large model and real-time code coverage feedback; step S450, continuing to perform fuzz testing based on the new test case set and the optimized test case mutation strategy.
[0067] Thus, by dynamically generating a new test case set during the testing process, various combined inputs of functional parameters can be covered; by optimizing the test case mutation strategy based on the first large model and real-time code coverage feedback, the coverage range and depth of fuzz testing can be gradually improved, thereby further optimizing the coverage rate and effectiveness of fuzz testing and comprehensively ensuring the quality and security of complex software systems.
[0068] In some exemplary embodiments, the step S410, using the first large model to analyze the functional parameter attributes and the dependency graph to generate an initial test case set, includes: using the first large model to parse the value range, constraint conditions, dependency logic of each functional parameter and its key role in the program to be tested, such as whether it is an input parameter, a global variable or a configuration item; using the first large model to parse the association paths of each functional parameter in the dependency graph, such as the conditional dependencies, transfer orders and scopes of action between functional parameters; according to the above analysis results, generating initial test cases covering a variety of typical scenarios, such as boundary values, outliers and combinations of dependency values. It should be noted that each test case includes the input value of the functional parameter and the corresponding expected behavior description.
[0069] In some exemplary embodiments, the step S420, designing a test case mutation strategy based on the dependency graph, includes: using the dependency graph to determine the key functional parameters and associated nodes; designing a test case mutation strategy based on the key functional parameters and associated nodes.
[0070] Specifically, the test case mutation strategy includes: (1) single functional parameter mutation: changing the input value of a single functional parameter, such as generating a random value; (2) multi-functional parameter mutation: jointly changing the input values of multiple associated functional parameters; (3) program input data mutation: changing the input file or network traffic processed by the program.
[0071] In some exemplary embodiments, use a fuzz testing framework (such as AFL, libFuzzer) to run the test cases and record the state coverage of the program to be tested, including edge coverage, etc.
[0072] In some exemplary embodiments, the step S400, performing fuzz testing based on the dependencies and constraint conditions between functional parameters, further includes: during the testing process, real-time monitoring of abnormal behaviors during program execution, including illegal memory access, resource leakage, etc.
[0073] In some exemplary embodiments, the step S440, optimizing the test case mutation strategy based on the first large model and real-time code coverage feedback, includes: real-time monitoring of the code coverage effect of the test cases, determining the untriggered paths or code segments; using the first large model to analyze the characteristics of the uncovered paths and automatically adjusting the mutation rules. For example, to trigger an uncovered branch node, generate specific test inputs.
[0074] In some exemplary embodiments, the step S500, automatically analyzing the test results of the fuzz testing based on the second large model to generate a structured report, includes: during the testing process, recording test cases of various types of anomalies (such as causing crashes, resource leaks); extracting corresponding function code snippets and problem descriptions from the code in the program stack recorded by an analysis tool (such as Sanitizer) when a program anomaly occurs; using the second large model to analyze based on the function code snippets and the problem descriptions to generate a structured report, including problem descriptions, analysis of problem causes, relevant function parameters, and repair suggestions.
[0075] Based on the same inventive concept, the present invention also provides a large model-assisted program function automatic perception fuzz testing system. Please refer to Figure 5 , which is a structural block diagram of the large model-assisted program function automatic perception fuzz testing system provided by an embodiment of the present invention. As Figure 5 shown, the large model-assisted program function automatic perception fuzz testing system provided by the present invention includes: a first acquisition module 110 configured to acquire the source code and documentation of the program to be tested; a second acquisition module 120 configured to analyze the source code and the documentation based on the first large model to acquire all function parameters supported by the program to be tested; an identification module 130 configured to identify the dependency relationships and constraint conditions between the function parameters based on the source code and the function parameters; a testing module 140 configured to perform fuzz testing based on the dependency relationships and constraint conditions between the function parameters; and an analysis module 150 configured to automatically analyze the test results of the fuzz testing based on the second large model to generate a structured report.
[0076] It should be noted that the large model-assisted program function automatic perception fuzz testing system provided by the present invention can be used to execute the large model-assisted program function automatic perception fuzz testing method described above. The technical principles, technical problems solved, and technical effects produced by the two are similar. Those skilled in the art of this technology can clearly understand that for the sake of convenience and brevity of description, more content about the large model-assisted program function automatic perception fuzz testing system provided by the present invention can refer to the content described in the above regarding the large model-assisted program function automatic perception fuzz testing method provided by the present invention, and will not be elaborated here.
[0077] Based on the same inventive concept, the present invention also provides an electronic device. Please refer to Figure 6 , which is a structural block diagram of the electronic device provided by an embodiment of the present invention. As Figure 6As shown, the electronic device includes at least one processor 210 and at least one storage device 220. The storage device 220 is adapted to store multiple program codes, and the program codes are adapted to be loaded and run by the processor 210 to execute the large model-assisted program function automatic perception fuzz testing method described above. Since the electronic device provided by the present invention and the large model-assisted program function automatic perception fuzz testing method provided by the present invention belong to the same inventive concept, the electronic device provided by the present invention at least has all the beneficial effects of the large model-assisted program function automatic perception fuzz testing method provided by the present invention. Therefore, for the beneficial effects of the electronic device provided by the present invention, reference can be made to the relevant descriptions of the beneficial effects of the large model-assisted program function automatic perception fuzz testing method provided by the present invention above, and no further elaboration will be made here.
[0078] In some exemplary embodiments, the electronic device may include multiple storage devices 220 and multiple processors 210. The program for executing the above-mentioned large model-assisted program function automatic perception fuzz testing method can be divided into multiple sub-programs, and each sub-program can be loaded and run by the processor 210 respectively to execute different steps of the above-mentioned large model-assisted program function automatic perception fuzz testing method. Specifically, each sub-program can be stored in a different storage device 220 respectively, and each processor 210 can be configured to execute the program in one or more storage devices 220 to jointly implement the above-mentioned large model-assisted program function automatic perception fuzz testing method, that is, each processor 210 executes different steps of the above-mentioned large model-assisted program function automatic perception fuzz testing method respectively to jointly implement the above-mentioned large model-assisted program function automatic perception fuzz testing method.
[0079] The above-mentioned multiple processors 210 can be processors 210 deployed on the same device. For example, the above-mentioned electronic device can be a high-performance device composed of multiple processors 210, and the above-mentioned multiple processors 210 can be the processors configured on this high-performance device. In addition, the above-mentioned multiple processors 210 can also be processors deployed on different devices. For example, the above-mentioned electronic device can be a server cluster, and the above-mentioned multiple processors 210 can be the processors on different servers in the server cluster.
[0080] The present invention also provides a computer-readable storage medium, on which multiple program codes are stored. The program codes are adapted to be loaded and run by a processor to execute the large model-assisted program function automatic perception fuzz testing method described above. Since the computer-readable storage medium provided by the present invention and the large model-assisted program function automatic perception fuzz testing method provided by the present invention belong to the same inventive concept, the computer-readable storage medium provided by the present invention has at least all the beneficial effects of the large model-assisted program function automatic perception fuzz testing method provided by the present invention. Therefore, for the beneficial effects of the computer-readable storage medium provided by the present invention, reference can be made to the relevant descriptions of the beneficial effects of the large model-assisted program function automatic perception fuzz testing method provided by the present invention in the above text, and no further elaboration will be made here.
[0081] In summary, compared with the prior art, the large model-assisted program function automatic perception fuzz testing method, system, electronic device, and computer-readable storage medium provided by the present invention have the following beneficial effects: The present invention can combine the actual characteristics of program functions to comprehensively improve the accuracy of function parameter identification, the systematicness of dependency relationship extraction, and the efficiency of test case generation and execution, thereby optimizing the coverage rate and effectiveness of fuzz testing and comprehensively ensuring the quality and security of complex software systems.
[0082] It should be noted that the above description is only a description of the preferred embodiments of the present invention and does not limit the scope of the present invention in any way. Any changes and modifications made by those of ordinary skill in the art of the present invention based on the above disclosure belong to the protection scope of the present invention. Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations fall within the scope of the present invention and its equivalent technologies, the present invention also intends to include these modifications and variations.
Claims
1. A large model-assisted program function automatic perception fuzz testing method, characterized in that: include: Obtain the source code and documentation of the program to be tested; Analyzing the source code and the instruction document based on the first model to obtain all functional parameters supported by the program to be tested; identifying dependencies and constraints between function parameters based on the source code and the function parameters; Performing fuzz testing based on dependencies and constraints between the function parameters; Automatically analyzing the test results of the fuzz test based on the second model to generate a structured report; The identifying dependencies and constraints between function parameters based on the source code and the function parameters includes: Analyze the usage path of each functional parameter based on the first model and data flow analysis method; According to the analysis results of the usage paths of each functional parameter, the intersection of usage paths between different functional parameters is obtained; According to the intersection of usage paths between different functional parameters, a dependency graph with functional parameters as nodes is constructed; Adding information of code nodes in the intersection of usage paths to the directed edges of the dependency graph; Use the first model to analyze the logical relationship of code nodes in the intersection of usage paths between different functional parameters to obtain the constraints between various functional parameters; Organize the constraints between various functional parameters into a formalized set of constraint rules.
2. The large model-assisted automatic program function perception fuzz testing method according to claim 1 is characterized in that: The source code and the instruction document are analyzed based on the first model to obtain all functional parameters supported by the program to be tested, including: Performing semantic parsing on the description document based on the first model to identify function parameters in the description document and generate a first function parameter set; Performing static analysis on the source code based on the first large model to identify function parameters supported by the source code and generate a second function parameter set; A complete function parameter set is generated according to the first function parameter set and the second function parameter set to obtain all function parameters supported by the program to be tested.
3. The large model-assisted automatic program function perception fuzzy testing method according to claim 2 is characterized in that: The static analysis of the source code based on the first large model to identify function parameters supported by the source code and generate a second function parameter set includes: Using a source code static analysis tool to identify all functions contained in the program to be tested; Constructing a function call graph with the main function of the program among all the functions as the root node; Analyzing the function call graph and the source code based on the first large model to locate code snippets related to function parameter parsing and corresponding function parameter parsing functions; Extract function parameter names, descriptions, and default values from code snippets related to function parameter parsing; The names, description information and default values of the extracted function parameters are combined into the second function parameter set.
4. The large model-assisted automatic program function perception fuzzy testing method according to claim 2 is characterized in that: The acquiring a complete function parameter set according to the first function parameter set and the second function parameter set includes: Comparing the first function parameter set with the second function parameter set to obtain an intersection and a difference between the two, wherein the intersection includes function parameters that are consistent between the specification document and the source code, and the difference includes function parameters that appear in the specification document but are not implemented in the source code, and function parameters that are implemented in the source code but do not appear in the specification document; For a function parameter that appears in the specification document but is not implemented in the source code, analyzing the specification document and the source code based on the first large model to determine whether the function parameter is a potential missing function parameter; if so, adding the function parameter to the intersection to expand the intersection; For a function parameter implemented in the source code but not appearing in the specification document, analyzing the definition and usage location of the function parameter in the source code based on the first large model to determine whether the function parameter is used; if so, adding the function parameter to the intersection to expand the intersection; A complete function parameter set is obtained according to the expanded intersection.
5. The large model-assisted automatic program function perception fuzzy testing method according to claim 4 is characterized in that: For a function parameter that appears in the description document but is not implemented in the source code, analyzing the description document and the source code based on the first large model to determine whether the function parameter is a potential missing function parameter includes: Using the first model, semantic analysis is performed on the description corresponding to the function parameter to obtain keywords; Performing fuzzy matching on the keywords in the source code and the comments contained in the source code; If there is a matching potential implementation code, the first large model is used to analyze the potential implementation code and determine whether its function is consistent with the function description corresponding to the function parameter. If consistent, the function parameter is determined to be a potential missing function parameter.
6. The large model-assisted automatic program function perception fuzzy testing method according to claim 1 is characterized in that: The performing of fuzz testing based on the dependencies and constraints between the functional parameters includes: Analyzing function parameter attributes and the dependency graph using the first large model to generate an initial test case set; Designing a test case mutation strategy based on the dependency graph; Starting to perform fuzz testing based on the initial test case set and the test case mutation strategy; Dynamically generate a new set of test cases during the testing process, and optimize the test case mutation strategy based on the first large model and real-time code coverage feedback; Fuzz testing is continued based on the new test case set and the optimized test case mutation strategy.
7. A large model-assisted program function automatic perception fuzzy testing system, characterized in that: include: A first acquisition module is configured to acquire source code and description documents of the program to be tested; A second acquisition module is configured to analyze the source code and the description document based on the first large model to obtain all functional parameters supported by the program to be tested; an identification module configured to identify dependencies and constraints between function parameters based on the source code and the function parameters; A testing module configured to perform fuzz testing based on dependencies and constraints between the functional parameters; as well as an analysis module configured to automatically analyze the test results of the fuzz test based on the second model to generate a structured report; The identifying dependencies and constraints between function parameters based on the source code and the function parameters includes: Analyze the usage path of each functional parameter based on the first model and data flow analysis method; According to the analysis results of the usage paths of each functional parameter, the intersection of usage paths between different functional parameters is obtained; According to the intersection of usage paths between different functional parameters, a dependency graph with functional parameters as nodes is constructed; Adding information of code nodes in the intersection of usage paths to the directed edges of the dependency graph; Use the first model to analyze the logical relationship of code nodes in the intersection of usage paths between different functional parameters to obtain the constraints between various functional parameters; Organize the constraints between various functional parameters into a formalized set of constraint rules.
8. An electronic device comprising at least one processor and at least one storage device, wherein the storage device is adapted to store a plurality of program codes, wherein: The program code is suitable for being loaded and run by the processor to execute the large model-assisted program function automatic perception fuzz testing method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a plurality of program codes stored thereon, characterized in that: The program code is suitable for being loaded and run by a processor to execute the large model-assisted program function automatic perception fuzz testing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
State-aware Internet of Things trusted execution environment fuzzy testing method and system
CN114840856A
ECU fuzzy test method and system based on AUTOSAR
CN117667747A