Large-model-assisted program function automatic sensing fuzzy testing method and large-model-assisted program function automatic sensing fuzzy testing system
Through large-model-assisted methods, analyzing program source code and explanation documents, extracting functional parameters and identifying dependencies, the limitations of existing fuzz testing technology in complex software systems are solved, and more efficient test coverage and quality assurance are achieved.
Patent Information
- Application Number
- CN202510199284.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-24
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2045-02-24
AI Technical Summary
The existing fuzz testing technology has limitations in program function parameter identification, dependency extraction, test case generation and test result analysis, making it difficult to effectively test complex software systems.
Using a large-model-assisted method, the source code and description documents of the test program are analyzed, functional parameters are extracted, and the dependencies and constraints between functional parameters are identified, efficient test cases are generated, and the test results are automatically analyzed.
It significantly improves the accuracy of functional parameter identification, the systematic nature of dependency extraction, and the efficiency of test case generation and execution, optimizes the coverage and effectiveness of fuzzy testing, and ensures the quality and safety of complex software systems.
Smart Images

Figure CN119690854A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a large model-assisted program function automatic perception fuzzy testing method, system, electronic device and computer-readable storage medium. 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 issue in the field of software engineering. Among them, comprehensive fuzz testing for program functions has gradually become a key means of program security testing. However, existing fuzz testing technology still has great limitations in function identification, test case generation, and test result analysis. When faced with modern software systems with complex functions, diverse parameters, and highly coupled dependencies, its test coverage and effectiveness are insufficient. 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 labor-intensive, but also prone to omissions or misunderstandings. In addition, the description of the function in the documentation is often inconsistent with the actual source code implementation, further increasing the difficulty of identifying function parameters.
[0004] 2. Insufficient extraction of dependencies and constraints between functional parameters. In modern complex programs, there are usually highly complex dependencies and constraints between program function parameters. For example, the values of some parameters may be limited by the value range of other parameters, specific program states, or external environmental conditions. Existing testing technologies lack a systematic method for automatically identifying and processing these dependencies and constraints, resulting in the generated test cases not being able to cover critical paths or trigger potential defects. In addition, generating invalid test cases that do not meet the constraints will also waste a lot of testing resources and reduce testing efficiency.
[0005] 3. Insufficient automation of fuzz testing. Traditional fuzz testing methods rely on simple randomization techniques or predefined rules in the process of test case generation and test execution, and it is difficult to generate targeted and efficient test cases in combination with the specific functional characteristics of the program. At the same time, in the analysis of test results, traditional methods often need to rely on manual work, which is not only inefficient, but also easy to miss potential defects, affecting the comprehensiveness of the test.
[0006] 4. It is difficult to guarantee the efficiency of testing large-scale complex programs. As the scale and complexity of software increase, the test paths may grow exponentially, and traditional fuzz testing tools are often unable to effectively handle this complexity. This leads to a significant decrease in test coverage, and fails to fully verify the reliability of the program in various functional scenarios, increasing the risk of potential defects.
[0007] In recent years, the rapid development of artificial intelligence technology, especially the breakthroughs of big models in natural language processing and code analysis, has provided new technical support for program testing. Big models have shown significant advantages in automatic extraction of program function parameters, identification of dependencies, and intelligent test case generation. However, there is still a lack of mature methods and tools for systematically applying big models to program function perception and fuzz testing.
[0008] It should be noted that the information disclosed in the background technology section of the invention is only intended to deepen the understanding of the general background technology of the invention, and should not be regarded as an admission or suggestion in any form that the information constitutes prior art already known to those skilled in the art. Summary of the invention
[0009] The purpose 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 to comprehensively improve the accuracy of function parameter identification, the systematicness of dependency 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-mentioned objectives, the present invention provides a large model-assisted program function automatic 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 functional parameters supported by the program to be tested; identifying the dependencies and constraints between functional parameters based on the source code and the functional parameters; performing fuzz testing based on the dependencies and constraints between the functional parameters; and automatically analyzing the test results of the fuzz test based on the second large model to generate a structured report.
[0011] Optionally, the source code and the description document are analyzed based on the first large model to obtain all functional parameters supported by the program to be tested, including: semantically parsing the description document based on the first large model to identify functional parameters in the description document and generate a first functional parameter set; statically analyzing the source code based on the first large model to identify functional parameters supported by the source code and generate a second functional parameter set; generating a complete functional parameter set based on the first functional parameter set and the second functional parameter set to obtain all functional parameters supported by the program to be tested.
[0012] Optionally, the static analysis of the source code based on the first large model to identify functional parameters supported by the source code and generate a second set of functional parameters 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 functional parameter parsing and corresponding functional parameter parsing functions; extracting the names, description information and default values of the functional parameters from the code snippets related to functional parameter parsing; and forming the second set of functional parameters with the names, description information and default values of the extracted functional parameters.
[0013] Optionally, 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 an intersection and a difference between the two, wherein the intersection includes function parameters that are consistent between the description document and the source code, and the difference 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, 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, and if so, adding 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, 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, and if so, adding the function parameter to the intersection to expand the intersection; obtaining a complete function parameter set according to the expanded intersection.
[0014] Optionally, for a function parameter that appears in the description document but is not implemented in the source code, the description document and the source code are analyzed based on the first large model to determine whether the function parameter is a potential missing function parameter, including: using the first large model to perform semantic analysis on the description corresponding to the function parameter to obtain keywords; fuzzy matching the keywords in the source code and the comments contained in the source code; if there is a matching potential implementation code, using the first large model to analyze the potential implementation code and determine whether its function is consistent with the function description corresponding to the function parameter; if they are consistent, determining that the function parameter is a potential missing function parameter.
[0015] Optionally, the identifying dependencies and constraints between functional parameters based on the source code and the functional parameters includes: analyzing the usage path of each functional parameter based on the first large model and the data flow analysis method; obtaining the intersection of usage paths between different functional parameters according to the analysis results of the usage paths of each functional parameter; and generating a dependency graph and a set of constraint rules between the functional parameters according to the intersection of usage paths between different functional parameters.
[0016] Optionally, performing fuzzy testing based on the dependencies and constraints between the functional parameters includes: using the first large model to analyze the functional parameter attributes and the dependency graph to generate an initial test case set; designing a test case mutation strategy based on the dependency graph; starting to perform fuzzy 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; and continuing to perform fuzzy testing based on the new test case set and the optimized test case mutation strategy.
[0017] To achieve the above-mentioned objectives, the present invention also provides a large-model-assisted program function automatic-aware fuzz testing system, comprising: a first acquisition module, configured to acquire the source code and description document of the program to be tested; a second acquisition module, configured to analyze the source code and the description document based on the first large model to acquire all functional parameters supported by the program to be tested; an identification module, configured to identify the dependencies and constraints between functional parameters based on the source code and the functional parameters; a testing module, configured to perform fuzz testing based on the dependencies and constraints between the functional parameters; and an analysis module, configured to automatically analyze the test results of the fuzz test based on the second large model to generate a structured report.
[0018] To achieve the above-mentioned objectives, the present invention also provides an electronic device, comprising at least one processor and at least one storage device, wherein the storage device is suitable for storing multiple program codes, and the program codes are suitable for being loaded and run by the processor to execute the large model-assisted program function automatic perception fuzzy testing method described in any one of the above items.
[0019] To achieve the above objectives, the present invention also provides a computer-readable storage medium on which multiple program codes are stored, and the program codes are suitable for being loaded and run by a processor to execute any of the large model-assisted program function automatic perception fuzzy testing methods described above.
[0020] Compared with the prior art, the program function automatic perception fuzz testing method, system, electronic device and computer-readable storage medium assisted by the large model provided by the present invention have the following beneficial effects: the present invention analyzes the source code and description document of the obtained program to be tested based on the first large model to obtain all functional parameters supported by the program to be tested, which can give full play to the advantages of the large model in natural language processing and code semantic understanding, and realize the accurate extraction of functional parameters; by identifying the dependencies and constraints between functional parameters based on the source code and the functional parameters, guiding the execution of fuzz testing, not only improving the coverage and automation level of the test, but also improving the pertinence and effectiveness of the test case, thereby significantly optimizing the efficiency and effect of fuzz testing. In summary, it can be seen that the program function automatic perception fuzz testing method assisted by the large model provided by the present invention can be combined with the actual characteristics of the program function, comprehensively improve the accuracy of functional parameter identification, the systematicness of dependency extraction, and the efficiency of test case generation and execution, thereby optimizing the coverage and effectiveness of fuzz testing, and comprehensively guaranteeing the quality and security of complex software systems.
[0021] Since the large model-assisted program function automatic perception fuzzy 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 fuzzy testing method provided by the present invention, the large model-assisted program function automatic perception fuzzy 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 fuzzy testing method provided by the present invention. For details, please refer to the relevant description above. Therefore, the beneficial effects of the large model-assisted program function automatic perception fuzzy testing system, electronic device and computer-readable storage medium provided by the present invention will not be described one by one. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 A flowchart of a large model-assisted program function automatic perception fuzzy testing method provided in one embodiment of the present invention.
[0023] Figure 2 A flowchart for obtaining all functional parameters supported by the program to be tested is provided in one embodiment of the present invention.
[0024] Figure 3 A flowchart for identifying dependencies and constraints between function parameters provided by one embodiment of the present invention.
[0025] Figure 4 A flowchart for performing fuzzy testing provided by one embodiment of the present invention.
[0026] Figure 5 A structural block diagram of a large model-assisted program function automatic perception fuzzy testing system provided in one embodiment of the present invention.
[0027] Figure 6 A structural block diagram of an electronic device provided in one embodiment of the present invention.
[0028] The reference numerals are described as follows: first acquisition module 110; second acquisition module 120; identification module 130; testing module 140; analysis module 150; processor 210; storage device 220. DETAILED DESCRIPTION
[0029] The following is a further detailed description of the large model-assisted program function automatic perception fuzzy testing method, system, electronic device and computer-readable storage medium proposed in the present invention in combination with the accompanying drawings and specific embodiments. According to the following description, the advantages and features of the present invention will be clearer. It should be noted that the drawings are in a very simplified form and use non-precise proportions, which are only used to conveniently and clearly assist in explaining the purpose of the present invention. In order to make the purposes, features and advantages of the present invention more obvious and easy to understand, please refer to the accompanying drawings. It should be noted that the structures, proportions, sizes, etc. illustrated in the drawings of this specification are only used to match the contents disclosed in the specification for people familiar with this technology to understand and read, and are not used to limit the limiting conditions for the implementation of the present invention. Any structural modification, change in proportional relationship or adjustment of size, in the case of the same or similar effects and purposes that can be achieved by the present invention, should still fall within the scope of 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 to comprehensively improve the accuracy of function parameter identification, the systematicness of dependency 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.
[0031] It should be noted that the large model-assisted program function automatic perception fuzzy testing method provided by the present invention can be applied to the large model-assisted program function automatic perception fuzzy testing system provided by the present invention, and the large model-assisted program function automatic perception fuzzy testing system can be configured on an electronic device, wherein the electronic device can be a personal computer, a mobile terminal, etc., and the mobile terminal can be a mobile phone, a tablet computer, and other hardware devices with various operating systems.
[0032] To realize the above idea, the present invention provides a large model-assisted program function automatic perception fuzzy testing method, please refer to Figure 1 , which is a flow chart of a large model-assisted program function automatic perception fuzzy testing method provided by an embodiment of the present invention. Figure 1 As shown, the large model-assisted program function automatic perception fuzzy testing method provided by the present invention includes: step S100, obtaining the source code and description document of the program to be tested; step S200, analyzing 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; step S300, identifying the dependencies and constraints between functional parameters based on the source code and the functional parameters; step S400, performing fuzzy testing based on the dependencies and constraints between the functional parameters; step S500, automatically analyzing the test results of the fuzzy test based on the second large model to generate a structured report.
[0033] Thus, the present invention analyzes the acquired source code and description documents of the program to be tested based on the first large model to obtain all functional parameters supported by the program to be tested, which can give full play to the advantages of the large model in natural language processing and code semantic understanding, and realize the accurate extraction of functional parameters; by identifying the dependencies and constraints between functional parameters based on the source code and the functional parameters, guiding the execution of fuzzy testing, not only the coverage and automation level of the test are improved, but also the pertinence and effectiveness of the test cases are improved, thereby significantly optimizing the efficiency and effect of fuzzy testing. In summary, it can be seen that the automatic perception fuzzy testing method of program functions assisted by the large model provided by the present invention can be combined with the actual characteristics of program functions, comprehensively improve the accuracy of functional parameter identification, the systematicness of dependency extraction, and the efficiency of test case generation and execution, thereby optimizing the coverage and effectiveness of fuzzy testing, and comprehensively guaranteeing the quality and security of complex software systems.
[0034] Specifically, fuzz testing is an automated software testing method that injects illegal, deformed or unexpected inputs into the system to reveal software defects and vulnerabilities. It should be noted that the first large model can be but not limited to ChatGPT-o1 and DeepSeek-V3, and the second large model can be but not limited to DeepSeek-V3, ChatGPT-o1 and qwen2.5.
[0035] In some exemplary embodiments, the step S100, obtaining the source code and description document of the program to be tested, includes: obtaining the source code repository of the program to be tested, and analyzing the compilation description document in the source code repository based on the first large model to construct an automated compilation script; and preprocessing the unstructured description document to obtain a description document in a standardized format.
[0036] Specifically, first obtain the source code repository of the program to be tested from a designated source code repository (such as a Git repository) or a local file system, and then analyze the compilation instructions in the source code repository based on the first large model, such as files in directories such as Readme files or Install, extract the program's compilation commands and dependent environment construction methods, and build an automated compilation script. In addition, obtain various project description documents from the source code repository, online project usage documents, or local project description document directories, including usage instructions, user help manuals, or project promotion documents, etc. These documents may exist in various forms (such as PDF, DOCX, PPTX, Markdown, HTML pages, etc.). Collect these documents through automated tools or scripts, and preprocess the unstructured description documents to obtain standardized format description documents. The preprocessing includes converting various file formats into Markdown file formats, while removing embedded images and streaming media data.
[0037] Please continue to refer to Figure 2 , which is a flowchart of obtaining all functional parameters supported by the program to be tested provided by an embodiment of the present invention. 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 functional parameters supported by the program to be tested, includes: step S210, semantically parsing the description document based on the first large model to identify the functional parameters in the description document and generate a first functional parameter set; step S220, statically analyzing the source code based on the first large model to identify the functional parameters supported by the source code and generate a second functional parameter set; step S230, generating a complete functional parameter set based on the first functional parameter set and the second functional parameter set to obtain all functional parameters supported by the program to be tested.
[0038] Therefore, through the above-mentioned steps S210 to S230, the accuracy and completeness of functional parameter extraction can be effectively improved, so as to further optimize the coverage and effectiveness of fuzz testing and comprehensively ensure the quality and security of complex software systems.
[0039] Specifically, by using the first model to perform semantic analysis on the description document, the key paragraphs involving the function description can be analyzed to identify the core attributes of the function. Furthermore, by defining the function and output format through the set prompt words, the first model will understand the content of the description document in context to extract the function parameter name (such as parameter name or option name), description information (such as the purpose of the function or operation effect) and default value (such as the default behavior when the parameter is not set), and finally generate the first function parameter set consisting of the name, description information and default value of all collected function parameters.
[0040] In some exemplary embodiments, the step S220, statically analyzing the source code based on the first large model to identify the 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 function of the program) contained in the program to be tested; constructing a function call graph with the main function of the program as the root node; analyzing the function call graph and the source code based on the first large model to locate the code snippet related to the function parameter parsing and the corresponding function parameter parsing function; extracting the name, description information and default value of the function parameter from the code snippet; and forming the second function parameter set with the name, description information and default value of the extracted function parameter. In this way, the function function can be accurately located to ensure that the function parameter information is complete and accurate.
[0041] In some exemplary embodiments, the use of a source code static analysis tool to identify all functions contained in the program to be tested includes: first, using a static code analysis tool (such as LLVM Clang or other tools that support the construction of an abstract syntax tree (AST)) to parse the source code based on an automated compilation script. By traversing the abstract syntax tree, all function information defined in the program to be tested can be collected, including function name, parameter list, return value type, and code location, etc. In particular, the main function of the program (such as the main() function or other entry point function in the C language) needs to be located and marked as the root node of the function call graph (CG).
[0042] Specifically, the Abstract Syntax Tree (AST) is a concept in program analysis. The AST is an intermediate representation of the source code during the processing of the compiler or interpreter. It abstracts the grammatical structure of the code, ignores the specific grammatical details (such as brackets, semicolons, etc.), and only retains the core information that can reflect the logic of the code. 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 in which each node represents a grammatical unit in the program, such as a function, statement, expression, or variable.
[0043] A function call graph (CG) can show the relationship between functions in a computer program. Each node is a function, and each edge (f, g) indicates that function f calls function g.
[0044] The main function of a program is the starting point of program execution. It is usually a special function used by the operating system to start the program. It controls program execution by directing to other functions in the program through function calls.
[0045] In some exemplary embodiments, the function call graph and the source code are analyzed based on the first large model to locate code snippets related to function parameter parsing, including: using the first large model to analyze the function call graph and its associated source code snippets to identify code snippets that may be responsible for function parameter parsing; using the first large model to perform recursive analysis along the function call graph to extract call chains related to function parameter parsing; and using the first large model to locate code locations related to function parameter parsing in combination with the control flow graph and context information of the source code.
[0046] Specifically, after constructing the function call graph, the large model is used to further analyze the nodes of the function call graph and its associated source code snippets to locate the function parameter parsing logic. Specifically, first, the 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 parameter parsing logic or configuration file loading logic. The first large model identifies and returns the code snippets that may be responsible for function parameter parsing through context semantic analysis (for example, 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 function parameter parsing. For example, if the main() function calls parse_arguments(), which in turn calls add_option(), the first large model will further analyze the logic of these functions and determine all functions involved in function parameter parsing (i.e., function parameter parsing functions). Finally, the first large model is used to locate the code location related to function parameter parsing in combination with the context information of the control flow graph and the source code. For example, the code snippet of command line parsing may contain function calls such as getopt() function or argparse() function. For programs that use non-standard function parameter parsing functions (such as getopt()), the Chain-of-Thought technology is used to predefine sample codes and working logic based on common custom parameter parsing structures such as switch-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 locations related to user-defined non-standard function parameter parsing.
[0047] In some exemplary embodiments, extracting the name, description information and default value of the function parameter from the code snippet related to the function parameter parsing includes: using the first large model to analyze the code snippet related to the function parameter parsing to extract the name, description information and default value of the function parameter.
[0048] Specifically, the names, description information and default values of the extracted function parameters can be stored in a structured format. Furthermore, the first large model can be used to locate the functions and code snippets related to the function parameter parsing in the program to be tested, and identify the names of the function parameters, such as extracting verbose and config as the function parameter names. The first large model can be used to extract the description information of each function parameter (such as "Enable verbose mode" and "Path to configuration file") based on semantic analysis. This description information is usually used to help users understand the purpose corresponding to the function parameter. The first large model is used to analyze the context of the code snippets related to the function parameter parsing and extract the possible default values of the function parameters. If the default value is not explicitly defined in the code, the usage code of the function parameter is tracked, and the first large model is used to further infer its possible type and type value range based on the usage code of the function parameter (such as the default value of a Boolean parameter is false or true).
[0049] In some exemplary embodiments, the step S230, 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 an intersection and a difference between the two, wherein the intersection includes function parameters that are consistent between the description document and the source code, and the difference 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, based on The first large model analyzes the description document and the source code to determine whether the function parameter is a potential missing function parameter. If so, the function parameter (the name, description information and default value of the function parameter) is added to the intersection to expand the intersection; for the function parameter implemented in the source code but not appearing in the description document, the definition and usage location of the function parameter in the source code are analyzed based on the first large model to determine whether the function parameter is used. If so, the function parameter is added to the intersection to expand the intersection; and a complete function parameter set is obtained according to the expanded intersection.
[0050] Therefore, through the above steps, all functional parameters actually supported by the program to be tested can be covered, so as to further optimize the coverage and effectiveness of fuzz testing and comprehensively ensure the quality and security of complex software systems.
[0051] Specifically, the second function parameter set (e.g., {"verbose", "config", "output_dir"}) obtained by parsing the source code is compared with the first function parameter set (e.g., {"verbose", "config", "log_level"}) extracted from the description document to determine the intersection and difference between the two. The function parameters in the intersection are clearly reflected in both the source code and the description document, such as {"verbose", "config"} in the above example. The function parameters in the intersection indicate that the document record is consistent with the program implementation, and usually no further verification is required.
[0052] The function parameters in the difference set include the following two situations: (1) function parameters declared in the description 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) function parameters implemented in the source code but not recorded in the description document (such as "output_dir"). These parameters may be newly developed functions or were ignored when the document was written.
[0053] In some exemplary embodiments, for a function parameter that appears in the description document but is not implemented in the source code, the description document and the source code are analyzed based on the first large model to determine whether the function parameter is a potential missing function parameter, including: using the first large model to perform semantic analysis on the description corresponding to the function parameter to obtain keywords; fuzzy matching the keywords in the source code and the comments contained in the source code, if there is a matching potential implementation code, using the first large model to analyze the potential implementation code and determine whether its function is consistent with the function description corresponding to the function parameter; if they are consistent, determining that the function parameter is a potential missing function parameter.
[0054] Specifically, if the function parameter that appears in the description document but is not implemented in the source code is described in the description document as "log_level: Sets the verbosity of log messages", the first large model is used to summarize the function description to obtain keywords, for example, the keyword "log level" is extracted, and the keyword is fuzzy matched 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 to determine the consistency of its function with the function description. If it is determined to be consistent, the potential implementation code is further analyzed, and the name, description information and default value of the function parameter are added to the intersection, and the potential implementation code is recorded in the function parameter parsing function set; if the matching result is empty (that is, there is no matching potential implementation code), the function parameter is ignored.
[0055] In some exemplary embodiments, for a function parameter implemented in the source code but not appearing in the specification document, the definition and usage position of the function parameter in the source code are analyzed based on the first large model to determine whether the function parameter is used, including: using a program static analysis method to trace from the parsed position of the function parameter along the function call graph to the upper layer function of the current function, and extracting the context source code of the upper layer function calling the current function position, and tracing the parsed usage logic of the function 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 parsed code of the function parameter into a code snippet and input into the first large model to determine whether the function parameter is used.
[0056] Specifically, the use logic is the processing logic after the input data corresponding to the function parameter is parsed. If the function parameter is determined to be used, the name, description information and default value of the function parameter are added to the intersection; if it is determined not to be used, the function parameter is ignored.
[0057] Please continue to refer to Figure 3 , which is a flow chart of identifying dependencies and constraints between function parameters provided by one embodiment of the present invention. Figure 3As shown, in some exemplary embodiments, the step S300, identifying the dependencies and constraints between the function parameters based on the source code and the function parameters, includes: step S310, analyzing the use path of each function parameter based on the first large model and the data flow analysis method; step S320, obtaining the intersection of the use paths between different function parameters according to the analysis results of the use paths of each function parameter; step S330, generating the dependency graph and constraint rule set between the function parameters according to the intersection of the use paths between different function parameters. In this way, the accuracy and completeness of the generated dependency graph and constraint rule set 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 analyzes the usage path of each functional parameter based on the first large model and the data flow analysis method, including: based on the source code and the function call graph, taking the parsing code of the functional parameters in the functional parameter parsing function as the starting point, using the program dependency graph to track the execution path related to the functional parameters, and extracting the code nodes on the path involved in the definition, reference and transfer operations of variables related to the functional parameters; using the first large model to perform semantic analysis on the usage scenarios and logical relationships of the functional parameters, and identifying possible implicit paths and special constraints; using the first large model to infer implicit associations from the code context.
[0059] Therefore, by using the first model to perform semantic analysis on the usage scenarios and logical relationships of functional parameters, possible implicit paths and special constraints can be identified; using the first model to infer implicit association relationships from the code context can supplement the deficiencies of data flow analysis.
[0060] Specifically, the code nodes include assignment nodes, conditional nodes, function call nodes and operation nodes. The assignment nodes are code locations where function parameters are assigned; the conditional nodes are branch statements in the program, such as if, else, switch-case, which determine the value range and constraint logic of function parameters; the function call nodes represent nodes where function parameters are passed or modified when calling other functions. The operation nodes represent operation nodes related to function parameters, such as assignment, comparison, addition and subtraction operations, etc.
[0061] The Program Dependence Graph is composed of control dependency and data dependency: control dependency reflects the control flow logic of the program, such as the use of function parameters in conditional statements (if, switch-case) and loop statements (for, while). Data dependency represents the dependency relationship of function parameters defined, transferred, referenced and modified in the program, such as assignment statements.
[0062] In some exemplary embodiments, the step S320, according to the analysis results of the use paths of each function parameter, obtains the intersection of the use paths between different function parameters, including: for each pair of function parameters, compares the set of code nodes on the use paths, and finds common code nodes to form the corresponding intersection of the use paths. If the use paths of two function parameters contain a conditional node (such as an if or while statement) at the same time, it indicates that they may be logically related, for example, when the settings of the two function parameters meet a certain condition at the same time, a certain function of the program will be activated. If the intersection (path intersection) of the nodes on the use paths between the two function parameters involves the same function call node, it may indicate that they are passed or affect each other in the same function call. The operation nodes in the intersection may reflect the calculation relationship or constraint rules between the function parameters, for example, the value range of a function parameter may depend on the calculation result of another function parameter. The logical relationship of the intersection nodes is analyzed using the first large model. For example, if multiple function parameters share a conditional node and the node involves a complex logical expression, the logical expression is further parsed to accurately describe the relationship and constraint between the function parameters.
[0063] In some exemplary embodiments, the step S330, generating a dependency graph and a constraint rule set between functional parameters based on the intersection of usage paths between different functional parameters, includes: constructing a dependency graph with functional parameters as nodes based on the intersection of usage paths between different functional parameters; attaching information of code nodes in the intersection of usage paths to the directed edges of the dependency graph; using the first large model to analyze the logical relationship of code nodes in the intersection of usage paths between different functional parameters to obtain constraint conditions between each functional parameter; and organizing the constraint conditions between each functional parameter into a formalized constraint rule set.
[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 order of dependency transmission. For example, the dependency relationship between two functional parameters may be determined by the judgment logic of a conditional node, and this information will be marked on the directed edge. The analyzed constraints are organized into a formalized set of rules: (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 functional parameter must be a positive integer, or the default value is a specific constant; (2) Multi-parameter constraints: describe the logical association between multiple functional parameters, such as the mutual constraints or dependencies between 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 the value of functional parameter C is a certain value, functional parameter D must meet specific conditions.
[0065] In some exemplary embodiments, the large model-assisted automatic perception fuzzy testing method for program functions provided by the present invention further includes: optimizing the dependency graph and constraint rule set. Specifically, redundant rules can be merged or the graph structure can be simplified. At the same time, the validity of the rules can be tested in the actual operating environment through a dynamic verification method to ensure that the logic and constraints described by them are consistent with the actual behavior of the program.
[0066] Please continue to refer to Figure 4 , which is a flowchart of performing fuzzy testing provided by one embodiment of the present invention. Figure 4 As shown, in some exemplary embodiments, the step S400, performing fuzzy testing based on the dependencies and constraints 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 fuzzy 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 test 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 fuzzy testing based on the new test case set and the optimized test case mutation strategy.
[0067] Therefore, by dynamically generating a new set of test cases during the testing process, various combinations of 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 and depth of fuzz testing can be gradually improved, thereby further optimizing the coverage 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 function parameter attributes and the dependency graph to generate an initial test case set, includes: using the first large model to parse the value range, constraints, dependency logic of each function 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 path of each function parameter in the dependency graph, such as the conditional dependency, transfer order and scope of action between each function parameter; based on the above analysis results, generating initial test cases covering a variety of typical scenarios, such as boundary values, abnormal values and dependency value combinations. It should be noted that each test case includes the input value of the function parameter and the corresponding expected behavior description.
[0069] In some exemplary embodiments, the step S420, designing a test case variation strategy based on the dependency graph, includes: determining key functional parameters and associated nodes using the dependency graph; and designing a test case variation strategy based on the key functional parameters and associated nodes.
[0070] Specifically, the test case mutation strategies include: (1) single-function parameter mutation: changing the input value of a single function parameter, such as generating a random value; (2) multi-function parameter mutation: jointly changing the input values of multiple related function parameters; (3) program input data mutation: changing the input files or network traffic processed by the program.
[0071] In some exemplary embodiments, a fuzz testing framework (such as AFL, libFuzzer) is used to run test cases and record 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 constraints between the functional parameters, also includes: during the test, real-time monitoring of abnormal behavior of 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: monitoring the code coverage effect of the test case in real time, determining the paths or code segments that are not triggered; using the first large model to analyze the characteristics of the uncovered paths, and automatically adjusting the mutation rules. For example, generating specific test inputs to trigger uncovered branch nodes.
[0074] In some exemplary embodiments, the step S500 automatically analyzes the test results of the fuzzy test based on the second largest model to generate a structured report, including: during the test process, recording test cases of various exceptions (such as crashes, resource leaks); extracting corresponding function code snippets and problem descriptions based on the code in the program stack recorded by an analysis tool (such as Sanitizer) when a program exception occurs; using the second largest model to analyze based on the function code snippets and the problem description to generate a structured report, including a problem description, problem cause analysis, related functional parameters and repair suggestions.
[0075] Based on the same inventive concept, the present invention also provides a large model-assisted program function automatic perception fuzzy testing system, please refer to Figure 5 , which is a structural block diagram of a large model-assisted program function automatic perception fuzzy testing system provided by an embodiment of the present invention. Figure 5 As 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 obtain the source code and description document of the program to be tested; a second acquisition module 120, 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 130, configured to identify the dependencies and constraints between functional parameters based on the source code and the functional parameters; a testing module 140, configured to perform fuzz testing based on the dependencies and constraints between the functional parameters; and an analysis module 150, configured to automatically analyze the test results of the fuzz test 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 fuzzy testing system provided by the present invention can be used to execute the large model-assisted program function automatic perception fuzzy testing method described above. The technical principles, technical problems solved and technical effects produced by the two are similar. Technical personnel in this technical field can clearly understand that for the convenience and conciseness of description, more content about the large model-assisted program function automatic perception fuzzy testing system provided by the present invention can refer to the content described in the large model-assisted program function automatic perception fuzzy testing method provided by the present invention above, and will not be repeated 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 an electronic device provided by an embodiment of the present invention. Figure 6As shown, the electronic device includes at least one processor 210 and at least one storage device 220, and the storage device 220 is suitable for storing multiple program codes, and the program codes are suitable for being loaded and run by the processor 210 to execute the large model-assisted program function automatic perception fuzzy testing method described above. Since the electronic device provided by the present invention and the large model-assisted program function automatic perception fuzzy 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 fuzzy testing method provided by the present invention. Therefore, the beneficial effects of the electronic device provided by the present invention can refer to the relevant description of the beneficial effects of the large model-assisted program function automatic perception fuzzy testing method provided by the present invention, and will not be repeated here one by one.
[0078] In some exemplary embodiments, the electronic device may include multiple storage devices 220 and multiple processors 210. The program that executes the above-mentioned large model-assisted program function automatic perception fuzzy testing method can be divided into multiple sub-programs, and each sub-program can be loaded and run by the processor 210 to execute different steps of the above-mentioned large model-assisted program function automatic perception fuzzy testing method. Specifically, each sub-program can be stored in different storage devices 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 fuzzy testing method, that is, each processor 210 executes different steps of the above-mentioned large model-assisted program function automatic perception fuzzy testing method respectively to jointly implement the above-mentioned large model-assisted program function automatic perception fuzzy testing method.
[0079] The above-mentioned multiple processors 210 may be processors 210 deployed on the same device. For example, the above-mentioned electronic device may be a high-performance device composed of multiple processors 210, and the above-mentioned multiple processors 210 may be processors configured on the high-performance device. In addition, the above-mentioned multiple processors 210 may also be processors deployed on different devices. For example, the above-mentioned electronic device may be a server cluster, and the above-mentioned multiple processors 210 may be processors on different servers in the server cluster.
[0080] The present invention also provides a computer-readable storage medium having a plurality of program codes stored thereon, wherein the program codes are suitable for being loaded and run by a processor to execute the large model-assisted automatic perception fuzzy testing method for program functions described above. Since the computer-readable storage medium provided by the present invention and the large model-assisted automatic perception fuzzy testing method for program functions provided by the present invention belong to the same inventive concept, the computer-readable storage medium provided by the present invention at least has all the beneficial effects of the large model-assisted automatic perception fuzzy testing method for program functions 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 description of the beneficial effects of the large model-assisted automatic perception fuzzy testing method for program functions provided by the present invention, and no further description will be given 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 systematic nature of dependency 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.
[0082] It should be noted that the above description is only a description of the preferred embodiment of the present invention, and is not any limitation on the scope of the present invention. Any changes and modifications made by a person skilled in the art in the field of the present invention based on the above disclosure are within the scope of protection of the present invention. Obviously, a person 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 equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A large model-assisted program function automatic perception fuzzy testing method, characterized in that: include: Get the source code and documentation of the program to be tested; Analyze the source code and the description 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 functional parameters; The test results of the fuzz test are automatically analyzed based on the second largest model to generate a structured report.
2. The large model-assisted program function automatic perception fuzzy testing method according to claim 1 is characterized in that: The source code and the description document are analyzed based on the first large 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 large 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 the functional parameters supported by the source code and generate a second functional 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 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 program function automatic 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 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, and 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 position 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, 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: The step of analyzing the description document and the source code based on the first large model for the function parameter that appears in the description document but is not implemented in the source code to determine whether the function parameter is a potential missing function parameter includes: Using the first model to perform semantic analysis on the description corresponding to the function parameter to obtain keywords; Performing fuzzy matching on the keyword 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 functional description corresponding to the functional parameter. If consistent, the functional parameter is determined to be a potential missing functional parameter.
6. The large model-assisted program function automatic perception fuzzy testing method according to claim 1 is characterized in that: The identifying the dependency relationship and constraint conditions between the function parameters based on the source code and the function parameters includes: Analyze the usage path of each functional parameter based on the first large 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; A dependency graph and a set of constraint rules between functional parameters are generated according to the intersection of usage paths between different functional parameters.
7. The large model-assisted automatic program function perception fuzzy testing method according to claim 6 is characterized in that: The performing of fuzz testing based on the dependency relationship and constraint conditions between the functional parameters includes: Analyzing the 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; Based on the initial test case set and the test case mutation strategy, start to perform fuzz testing; 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; Continue to perform fuzz testing based on the new test case set and the optimized test case mutation strategy.
8. 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 The analysis module is configured to automatically analyze the test results of the fuzz test based on the second largest model to generate a structured report.
9. An electronic device comprising at least one processor and at least one storage device, wherein the storage device is suitable for storing a plurality of program codes, characterized in that: 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 7.
10. 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 7.
Citation Information
Patent Citations
State-aware Internet of Things trusted execution environment fuzzy testing method and system
CN114840856A
Deep learning compiler fuzzy test method and system based on large language model
CN117632751A
ECU fuzzy test method and system based on AUTOSAR
CN117667747A
Fuzzy test case generation method and system based on large language model
CN118964212A
Cited By
Automatic program component risk prediction and fuzzy testing device and method
CN120180453A
Automated program component risk prediction and fuzzing apparatus and methods
CN120180453B
Feedback fuzzy test method for configuration defects of automatic driving system
CN120316016A
A feedback fuzz testing method for autonomous driving system configuration defects
CN120316016B
API intelligent test method based on context awareness
CN120803956A