Code defect identification method, electronic equipment, medium and program product

By replaying online traffic requests in the development environment and comparing code branches, the large model is used to analyze sub-call changes and code changes, solving the problem of low efficiency of manual analysis in existing technologies. This enables intelligent and automated identification of code defects, improving identification efficiency and accuracy.

CN120803906APending Publication Date: 2025-10-17KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510702422.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-28
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

Existing traffic replay testing methods rely on manual analysis, which is inefficient and leads to insufficient efficiency and accuracy in identifying code defects, thus affecting the quality and efficiency of software development.

Method used

By acquiring online traffic requests and replaying them in the development environment, and combining code branch comparisons to extract the changed parts, we use a large model to analyze the execution results and generate accurate information to identify code defects, including correlation analysis between sub-call changes and code changes.

Benefits of technology

It realizes intelligent and automatic identification of code defects, improves identification efficiency and accuracy, reduces labor costs, and improves the quality and speed of software development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803906A_ABST
    Figure CN120803906A_ABST
Patent Text Reader

Abstract

The invention provides a code defect identification method, an electronic device, a medium and a program product, and the identification method comprises the steps: obtaining and storing an online traffic request, and playing back the traffic request in a development environment to obtain an execution result of the development environment; comparing the code branch of the development environment with the code branch of the online environment, and extracting the change part of the code; analyzing an execution result of the development environment, judging whether a sub-call change exists or not, and combining the sub-call change with a change part of a code to generate accurate information as input of a large model; and analyzing the accurate information by using a large model, judging whether the code accords with the expectation or not, and giving a reason and a repair scheme which do not accord with the expectation, so that the defect of low manual analysis efficiency is overcome, the code defect identification efficiency and accuracy are remarkably improved, the labor cost and the workload are reduced, and the software development quality and speed are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer technology, and in particular to a code defect identification method, an electronic device, a medium and a program product. BACKGROUND

[0002] In today's rapidly developing software development field, traffic playback technology has become an indispensable part of the testing process. With the continuous expansion of Internet business and the increasing complexity of system architecture, development teams are facing higher and higher testing efficiency and quality requirements. Traffic playback technology captures real traffic in the production environment and plays it back in the development environment, providing strong support for regression testing and refactoring optimization testing. It can simulate online scenarios to help developers discover potential problems in the development stage, thereby effectively reducing the risk of online failures and improving the stability and reliability of the system.

[0003] However, despite the widespread application of traffic playback technology in the testing field, there are still some problems to be solved in the current implementation scheme. The current mainstream traffic playback testing method usually generates a large number of reports after playback execution, with a failure playback ratio sometimes as high as 50%. In the face of such a large amount of data, developers need to spend a lot of time and effort to manually analyze and judge the problem. This manual analysis method is not only inefficient, but also easily leads to a decrease in the enthusiasm of developers, and even may miss the opportunity to discover system errors and problems due to negligence, ultimately affecting online quality and causing potential losses to enterprises and users.

[0004] To address these challenges, there is an urgent need for a more intelligent and automated error identification scheme to improve the efficiency and accuracy of traffic playback testing. SUMMARY

[0005] The present application provides a code defect identification method, an electronic device, a medium and a program product to solve the problem of low efficiency of manual analysis in traffic playback in the prior art, and to realize a more intelligent and automated code error identification scheme.

[0006] The present application provides a code defect identification method, characterized in that it comprises: Obtaining online traffic requests and storing them, and playing back the traffic requests in the development environment to obtain the execution results of the development environment; Comparing the code branches of the development environment and the online environment, and extracting the changed part of the code; Analyzing the execution results of the development environment to determine whether there is a sub-call change, and combining the sub-call change with the changed part of the code to generate accurate information as input for the large model; The large model is used to analyze the accurate information, to determine whether the code meets the expectation, and to give the reason and repair scheme for not meeting the expectation.

[0007] According to the code defect identification method provided by the application, before the traffic request on the storage line, the method further comprises: preprocessing the traffic request, including removing duplicate requests, invalid requests and requests containing sensitive information.

[0008] According to the code defect identification method provided by the application, the execution result of the development environment includes at least one of the following: response time of traffic request, response data of development environment to each traffic request, error information of traffic request execution failure record in development environment, performance index.

[0009] According to the code defect identification method provided by the application, the code branch of the development environment and the code branch of the online environment are compared, and the changed part of the code is extracted, which specifically includes: By using the code comparison tool, the code branch of the development environment and the code branch of the online environment are compared, and the added part, the missing part and / or the difference part of the code are extracted.

[0010] According to the code defect identification method provided by the application, after extracting the changed part of the code, the method further comprises: classifying and labeling the changed part of the code according to file type, code change type and / or change complexity.

[0011] According to the code defect identification method provided by the application, the sub-call change includes sub-call missing, sub-call adding and / or sub-call difference; Analyzing the execution result of the development environment to determine whether there is a sub-call change, specifically including: Using the call link tracking tool, the complete call link of each traffic request in the development environment is tracked, and the call graph of the development environment is constructed based on the call link information, which is used to show the hierarchical structure, call order and dependency relationship of each sub-call in the development environment; Tracking the call link of each traffic request in the online environment to generate the call graph of the online environment, which is used to show the hierarchical structure, call order and dependency relationship of each sub-call in the online environment; Comparing the call graph of the development environment and the call graph of the online environment to check whether there is the sub-call missing, sub-call adding and / or sub-call difference in the development environment.

[0012] According to the code defect identification method provided by the application, the sub-call change is combined with the changed part of the code to generate accurate information, specifically including: correlate the sub-call variation and the changed part of the code according to preset correlation rules using a data integration tool; the correlation rules are used to define the correlation between the sub-call variation and the changed part of the code; integrate the correlated sub-call variation and the changed part of the code into a data structure to obtain the accurate information.

[0013] The application further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the code defect identification method of any of the above when executing the program.

[0014] The application further provides a non-transitory computer-readable storage medium having a computer program stored thereon, and the computer program implements the code defect identification method of any of the above when executed by a processor.

[0015] The application further provides a computer program product including a computer program, and the computer program implements the code defect identification method of any of the above when executed by a processor.

[0016] The code defect identification method, electronic device, medium, and program product provided by the application obtain online traffic requests and replay in a development environment, extract changed parts by comparing code branches, analyze execution results to determine sub-call variations, combine the sub-call variations with code changes to generate accurate information as input for a large model, and realize intelligent and automated identification of code defects. Compared with the way of relying on manual analysis of traffic replay results in the prior art, the application overcomes the defect of low efficiency of manual analysis, quickly and accurately identifies problems in the code through an automated process and intelligent analysis of a large model, provides specific repair solutions, significantly improves the efficiency and accuracy of code defect identification, reduces labor costs and workload, and effectively improves the quality and speed of software development. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.

[0018] Figure 1 is one of the flowcharts of the code defect identification method provided by the application.

[0019] Figure 2 is the second flowchart of the code defect identification method provided by the application.

[0020] Figure 3 is a logical framework diagram of the code defect identification method provided by the present application.

[0021] Figure 4 is a structural diagram of the code defect identification device provided by the present application.

[0022] Figure 5 is a structural diagram of the electronic device provided by the present application. DETAILED DESCRIPTION

[0023] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below in conjunction with the drawings in the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application.

[0024] Firstly, the terms involved in the embodiments of the present application are explained schematically.

[0025] Traffic request: Traffic request refers to the request sent by a client (such as a browser, mobile application, etc.) to a server to obtain resources or perform operations. These requests can be in the form of HTTP requests, RPC call requests, messages in message queues, etc. For example, when a user accesses a web page in a browser, the browser will send an HTTP request to the server, requesting the server to return the HTML content of the web page.

[0026] Development environment: Development environment refers to the environment used by developers to write, test and debug code. It usually includes development computers, integrated development environments (IDE), version control systems, testing tools, etc. The configuration of the development environment should be as consistent as possible with the production environment (online environment) to reduce problems caused by environmental differences.

[0027] Online environment: also known as production environment, refers to the environment in which a software system is actually deployed and provides services to users. It includes servers, operating systems, databases, middleware, etc. infrastructure, as well as runtime environment settings such as configuration files, deployment scripts. The stability and performance of the online environment directly affect the user experience.

[0028] Sub-call: Sub-call refers to the calling of other functions, methods or processes within a function, method or process. It is an important embodiment of modular programming and code reuse in software systems. For example, calling function B in function A, then function B is the sub-call of function A.

[0029] Subcall Missing: Subcall missing refers to a situation where a function, method, or procedure does not properly call its intended subcalls in a certain environment, such as a development environment. This can result in incomplete or incorrect functionality. For example, function A does not call function B in the development environment, but function A should call function B in the online environment, which is a subcall missing.

[0030] Subcall Addition: Subcall addition refers to a situation where a function, method, or procedure adds a call to another function, method, or procedure in a certain environment, such as a development environment. This can be caused by feature expansion or code refactoring. For example, function A adds a call to function C in the development environment, but function A does not have this call in the online environment, which is a subcall addition.

[0031] Subcall Difference: Subcall difference refers to a situation where the same function, method, or procedure has different subcalls in different environments, such as a development environment and an online environment. This can result in inconsistent functionality or errors. For example, function A calls function B in a different order in the development environment than in the online environment, which is a subcall difference.

[0032] Code Comparison Tool: A code comparison tool is a software tool used to compare differences between two pieces of code or two branches of code. It helps developers quickly identify added, missing, and modified parts of code. Common code comparison tools include Git's built-in `git diff` command, Beyond Compare, Araxis Merge, and WinMerge.

[0033] Call Trace Tool: A call trace tool is a tool used to record and analyze the call relationships between functions, methods, or procedures in a program. It helps developers understand the flow of requests through the system, identify performance bottlenecks, and find the root cause of errors. Common call trace tools include Zipkin, Jaeger, and SkyWalking.

[0034] Data Integration Tool: A data integration tool is a tool used to collect, clean, transform, and merge data from different sources. It helps developers integrate scattered data from various systems into a unified data warehouse or data lake, making it easier to analyze and process the data later. Common data integration tools include ETL tools (such as Informatica and Talend), data warehouse tools (such as Hive and Spark SQL), and others.

[0035] In software development, ensuring code quality and functional correctness is crucial. Traditional testing methods often rely on manual analysis and testing, which is not only time-consuming and labor-intensive, but also prone to omissions and errors. With the development of artificial intelligence technology, it is possible to use large models for automated code analysis and defect identification. The embodiment of the present invention provides an intelligent code defect identification method, which realizes the automatic detection and repair suggestion of code defects by combining traffic playback, code comparison and large model analysis.

[0036] The code defect identification method of the embodiment of the present invention is widely applicable to various software development scenarios, especially in the software development process of large Internet companies and financial institutions. Taking an e-commerce system as an example, during a promotion event, the system needs to be quickly iterated to cope with changing business needs. The development team can use this method to discover code defects in a timely manner and ensure the stable online of new functions. For example, in the development of a financial system, the security and accuracy of the code are extremely high, and this method can help developers quickly locate potential security vulnerabilities and logical errors, effectively reducing system risks.

[0037] In practical applications, the flexibility and efficiency of the code defect identification method of the embodiment of the present invention make it an important tool in modern software development processes. For example, in the e-commerce field, in addition to the emergency iteration during the promotion event, daily system maintenance and new function development also require high reliability and fast feedback mechanism. The development team can regularly run this method and integrate it into the continuous integration / continuous deployment (CI / CD) process, so as to automatically detect code defects in each deployment cycle, reduce manual intervention, and improve release frequency and quality.

[0038] For financial institutions, the stability and security of the system are directly related to the safety of users' funds and the reputation of the enterprise. The method of the embodiment of the present invention not only helps developers discover potential problems before code submission, but also can be used as part of compliance checks to ensure that the code meets industry standards and regulatory requirements. Through automation, financial institutions can more effectively manage their complex software assets and reduce operational risks caused by code defects.

[0039] In addition, the method of the embodiment of the present invention also has broad application prospects in other industries. In the medical and health field, the stability of medical information systems is crucial for patient treatment and data management. By applying the method of the embodiment of the present invention, the development team can ensure the high availability of the system and the accuracy of the data, avoiding medical accidents caused by software failures. In the field of intelligent manufacturing, the security of the code of industrial control systems is directly related to production efficiency and product quality. By using the method of the embodiment of the present invention, defects in the code can be found and repaired in a timely manner, reducing production line downtime and improving overall production efficiency.

[0040] Through these practical application cases in multiple industries, it can be seen that the code defect identification method of the embodiment of the present invention is not only applicable to specific business scenarios, but can also be customized according to different industry needs, providing strong technical support and guarantee for various software development projects.

[0041] In addition, the implementation of the methods of the embodiments of the present invention has certain requirements for the hardware environment to ensure the efficient execution of operations such as traffic playback, code comparison, and large model analysis. The server should have a multi-core processor, sufficient memory, and high-speed storage devices to support high-concurrency traffic playback and complex data processing tasks. At the same time, the network bandwidth should be large enough to ensure stable acquisition and storage of online traffic requests. For storage devices, in addition to high-performance disk arrays, you can also consider using distributed storage systems to meet the storage needs of large-scale data.

[0042] For a detailed description of the method of the embodiment of the present invention, see Figure 1 , Figure 1 This is one of the flow charts of the method for identifying code defects provided by the present invention, which includes the following steps: Step 101: Obtain and store online traffic requests, and replay the traffic requests in a development environment to obtain execution results of the development environment.

[0043] In real-world applications, capturing and storing online traffic requests and then replaying them in a development environment is a key step in ensuring code quality and functional correctness. This process not only helps development teams simulate real user behavior and system load, but also effectively identifies differences between the development and production environments, allowing them to identify potential issues promptly.

[0044] First, online traffic requests refer to various requests initiated by users or systems in a production environment, such as HTTP requests and RPC call requests. These requests carry a wealth of information, including the request URL, method, header information, request body, and parameters. To capture these requests, various methods can be used, such as network sniffing and API gateway interception. For example, in an e-commerce system, when users browse products, add to a shopping cart, or submit an order, corresponding HTTP requests are generated. By deploying an API gateway in front of the server, these requests can be intercepted and captured, recording their detailed information.

[0045] The acquired traffic requests need to be properly stored for subsequent playback in the development environment. The storage method can be a distributed file system such as HDFS, or a high-performance database such as MongoDB, Cassandra, etc. These storage solutions can provide high scalability, high reliability, and fast data access capabilities to meet the needs of large-scale data storage. For example, for a large Internet application, millions or even tens of millions of traffic requests may be generated every day, and using a distributed file system can effectively manage and store these data.

[0046] Next, replaying these traffic requests in the development environment is an important means of simulating online scenarios. By using playback tools such as JMeter, Locust, etc., parameters such as the number of concurrent requests, interval time, timeout policy, etc. can be set to simulate different load situations and user behaviors. For example, when testing a newly online function, a high number of concurrent requests can be set to simulate a scenario where a large number of users access simultaneously, and the system's performance and response time can be observed. During the playback process, the development environment will execute the corresponding code logic to generate execution results, including the response time of the traffic request, the response data of the development environment to each traffic request, error information of the traffic request execution failure record in the development environment, performance indicators, etc. The execution results of the development environment are important basis for evaluating code quality and functional correctness. These results contain rich information that can help the development team deeply understand the performance of the code in actual operation.

[0047] Specifically, the response time of the traffic request is one of the key indicators of system performance. It reflects the processing speed of the system to the request and directly affects the user experience. During testing, performance testing tools such as JMeter or Gatling can be used to record the response time of each request. These tools can simulate high-concurrency user access scenarios, generate a large number of requests, and accurately measure the time spent from sending a request to receiving a response. By analyzing the response time data, the development team can identify performance bottlenecks, such as the fact that some requests have excessively long response times, which may indicate that the backend service is slow or the database query is inefficient.

[0048] The response data of the development environment to each traffic request is also an important part of the execution results. Response data includes HTTP status codes, response headers, and response bodies, etc. By checking the response data, it can be verified whether the system returns the correct results as expected. For example, in an e-commerce system, when a user submits an order, the system should return a response containing order confirmation information. If the response data does not meet expectations, it may mean that there are logical errors or data processing problems in the code.

[0049] Error information recorded when the traffic request fails to execute in the development environment is crucial for problem localization and repair. Error information usually includes error codes, exception stack traces, error descriptions, and other details. The development team can quickly locate the root cause of the problem by analyzing these error information. For example, an "empty pointer exception" error may indicate that an object in the code was not properly initialized, while a "database connection timeout" error may point to a problem with the database configuration or network connection.

[0050] Performance indicators cover various aspects of the system, such as CPU usage, memory usage, disk I / O, etc. These indicators can help the development team understand the running state of the system comprehensively. For example, excessive CPU usage may indicate that there are computationally intensive operations in the code, while memory leakage problems may cause the system to gradually slow down or even crash. By monitoring and analyzing performance indicators, the development team can discover and solve potential performance problems before the code is deployed to the production environment.

[0051] To better understand this process, let's take a specific example. Suppose in the development of a financial system, the new payment interface function needs to be tested. First, capture the user-initiated payment request through the API gateway of the online environment, including the request URL, method, header information, request body, etc., and store these requests in a distributed file system. Then, in the development environment, use the JMeter playback tool to set the number of concurrent requests to 100, the request interval time to 1 second, and the timeout policy to 5 seconds to simulate a high-concurrency payment scenario. During the playback process, record the response time of each request, the returned payment result data, and possible error information such as the reason for payment failure. These execution results will be used for subsequent comparison and analysis with the online environment to help developers discover code defects in the development environment.

[0052] Through the above steps, online traffic requests can be effectively captured and played back in the development environment, providing a solid foundation for subsequent code defect identification and analysis. This process not only improves the efficiency and accuracy of testing, but also helps the development team to discover potential problems in a timely manner before code submission, ensuring the stability and reliability of the system.

[0053] Step 102, compare the code branches of the development environment and the online environment, and extract the changed part of the code.

[0054] In the process of software development, comparing the code branches of the development environment and the online environment and extracting the changed part of the code is an important link to ensure code quality and functional correctness. Through this process, the development team can clearly understand the differences between the code in different environments and discover potential problems and risks in a timely manner.

[0055] The code branch of the development environment is the basis for developers to write, modify, and test code in their daily work. It contains the latest feature development, bug fixes, and code optimization. The code branch of the online environment is the stable version of the code that has been tested and audited and is running in the production environment. By comparing the two branches, we can find out the new code, missing code, and modified code in the development environment.

[0056] To compare the code branches, version control systems such as Git, SVN, etc. are usually used. These systems not only record the history of each change in the code, but also provide powerful comparison functions. For example, Git's diff command can list the differences between two branches in detail, including the addition, deletion, and modification of files. By using the command git diff<online branch name>..<development branch name>, developers can quickly obtain all the details of changes between the two branches.

[0057] In actual operation, the command line tool of Git can be used, or graphical Git clients such as SourceTree, GitKraken, etc. can be used. These tools provide more intuitive interfaces to facilitate developers to view and manage code differences. For more complex code comparison needs, specialized code comparison tools such as BeyondCompare, Araxis Merge, etc. can be used. These tools not only compare the contents of code files, but also compare folder structures, code syntax structures, etc., providing more comprehensive and in-depth comparison results.

[0058] In the comparison process, in addition to focusing on the surface differences of the code, it is also necessary to understand and analyze the changed code in depth. For example, whether the newly added code follows the project's coding specifications, whether it may cause new problems; whether the missing code is due to accidental deletion, resulting in a lack of functionality; whether the modified code has a potential impact on other parts of the system, etc.

[0059] Through these detailed comparisons and analyses, the development team can more accurately grasp the changes in the code, providing a solid foundation for subsequent testing, deployment, and maintenance work. This process not only helps to improve the quality and stability of the code, but also effectively reduces the risk of problems in the online environment, ensuring the normal operation of the system.

[0060] Step 103, analyze the execution results of the development environment, determine whether there is a sub-call change, and generate accurate information by combining the code change part with the sub-call change as input for the large model.

[0061] In the process of software development, analyzing the execution results of the development environment, determining whether there are sub-call changes, and generating accurate information by combining these changes with the changed parts of the code are key steps to ensure code quality and functional correctness. This process not only helps the development team to find potential functional problems and performance bottlenecks, but also provides a solid data foundation for subsequent intelligent analysis and repair.

[0062] The execution results of the development environment contain rich information, such as response time of traffic requests, returned data, error information, and performance indicators. These information is an important basis for evaluating the running status of the development environment code. For example, long response time may indicate that the system has performance problems, while error information directly points out defects or abnormalities in the code.

[0063] Sub-call changes include sub-call missing, sub-call addition, and sub-call difference. These changes may affect the functional integrity and stability of the system. In order to accurately determine these changes, call link tracking tools such as Zipkin, Jaeger, etc. can be used. These tools can record the complete call link of each traffic request in the system, generate call graphs, and intuitively display the hierarchical structure, call order and dependency relationship of each sub-call.

[0064] By comparing the call graphs of the development environment and the online environment, the missing, addition or difference of sub-calls can be clearly identified. For example, if a key sub-call in the development environment is not triggered, but the sub-call is required in the online environment, this constitutes a sub-call missing. On the contrary, the addition of a sub-call in the development environment may introduce new functions or logic, which need to be further verified for correctness and compatibility.

[0065] After obtaining the sub-call changes and the changed parts of the code, use data integration tools to associate them according to the preset association rules. For example, if a sub-call missing corresponds to the deletion of a function in the code, then the two are associated. The associated information will be integrated into a unified data structure to form accurate information. These accurate information not only contains the detailed content of sub-call changes and code changes, but also covers the association relationship between them, providing comprehensive and accurate input for subsequent large model analysis.

[0066] Step 104, using a large model to analyze the accurate information to determine whether the code meets the expectations and to give the reasons and repair solutions that do not meet the expectations.

[0067] In the intelligent quality control process of software development, using large models to analyze precise information, determine whether the code meets expectations, and provide detailed reasons for not meeting expectations and repair solutions is a key step to improve code quality and development efficiency. This process, with the help of advanced artificial intelligence technology, has realized a major change from traditional manual code review to automated and intelligent analysis.

[0068] Large models such as GPT-4 and Codex are obtained by pre-training and fine-tuning on large-scale code and natural language data. They have strong code understanding and generation capabilities, can deeply analyze the input precise information, identify potential problems, and provide targeted solutions.

[0069] The input of large models needs to structure precise information into JSON, XML, etc. format and perform coding preprocessing to ensure that the model can correctly parse and understand. At the same time, the configuration of the model calling interface, such as API key, request address, timeout time and other parameters, also needs to be optimized according to the actual situation to realize efficient request batch processing and asynchronous calling.

[0070] In practical application, large models can evaluate code from multiple dimensions, including functional correctness, performance efficiency, readability, maintainability, etc. For example, for functional correctness, the model will check whether the code executes according to the expected logic, whether there are logical errors or improper exception handling, etc. For performance efficiency, the model will analyze whether the code has operations that may cause performance bottlenecks, such as unnecessary loops, resource leaks, etc.

[0071] Large models not only point out the problems, but also provide specific repair suggestions. For example, if a function has a logical error, the model may suggest adjusting the order of condition judgment or adding exception handling mechanisms. For performance problems, the model may recommend the use of optimized algorithms or data structures. These repair solutions are usually provided in the form of code snippets, which developers can directly reference and apply to actual code.

[0072] In this way, large models not only improve the efficiency and accuracy of code review, but also provide valuable learning resources for developers. The development team can use the analysis results of large models as part of code review to promote the overall technical level of the team.

[0073] The code defect identification method provided by the embodiment of the present invention obtains online traffic requests and replays them in the development environment, extracts the changed parts in combination with code branch comparison, and then analyzes the execution results to determine the sub-call changes. The sub-call changes are combined with the code changes to generate accurate information as the input of the large model, thereby realizing intelligent and automated identification of code defects. Compared with the existing method that relies on manual analysis of traffic replay results, the present invention overcomes the defect of low efficiency of manual analysis. Through automated processes and intelligent analysis of large models, it can quickly and accurately identify problems in the code and provide specific repair solutions, significantly improving the efficiency and accuracy of code defect identification, reducing labor costs and workload, and effectively improving the quality and speed of software development.

[0074] In addition, before the traffic requests on the storage line, the traffic requests can also be pre-processed, including removing duplicate requests, invalid requests, and requests containing sensitive information.

[0075] When processing online traffic requests, preprocessing them is a critical step to ensure the effectiveness of subsequent analysis and testing. The main goal of preprocessing is to clean and optimize traffic request data, remove unnecessary noise and sensitive information, and improve data quality and usability.

[0076] Duplicate requests can be removed in a variety of ways. One common approach is to use a Bloom filter to record unique identifiers of previously processed requests, such as the request's hash value. When a new request arrives, the system checks whether its hash value already exists in the Bloom filter. If so, the request is considered a duplicate and can be discarded. This approach offers excellent space efficiency and query speed, making it particularly well-suited for handling large-scale traffic requests.

[0077] A range of rules and algorithms can be used to identify and remove invalid requests. For example, validity can be determined by verifying that the request format conforms to expected specifications. This includes checking the HTTP method, URL path, header information, and request body format. Requests that do not conform to the specifications are likely invalid and should be filtered out. Furthermore, machine learning models can be used to identify and filter out anomalous requests. By training on the characteristics of both normal and anomalous requests, the model can automatically detect potentially invalid requests, thereby improving filtering accuracy and efficiency.

[0078] The processing of sensitive information is another important aspect of the preprocessing process. In storage and subsequent analysis, the privacy of users and sensitive data must be properly protected. This can be achieved by encrypting or desensitizing sensitive information. For example, requests containing sensitive information can be encrypted using encryption algorithms such as AES, and only authorized analysis environments can decrypt and view them. Desensitization can use data masking, replacement, and other techniques to replace sensitive information with meaningless placeholders or false data, preserving the structure and context of the request without revealing the true information.

[0079] During the software development process, comparing the code branches of the development environment and the online environment, and extracting the changed parts of the code, is an important step to ensure code quality and functional correctness. Through this process, the development team can clearly understand the differences between the code in different environments, and timely discover potential problems and risks.

[0080] In the code comparison step, the code comparison tool is used to compare the code branches of the development environment and the online environment, and extract the added, missing and / or different parts of the code.

[0081] Specifically, in actual operation, the command line tool of Git can be used, or graphical Git clients such as SourceTree, GitKraken, etc. can be used, which provide more intuitive interfaces for developers to view and manage code differences. For more complex code comparison requirements, specialized code comparison tools such as BeyondCompare, Araxis Merge, etc. can be used. These tools not only compare the contents of code files, but also compare folder structures, code syntax structures, etc., providing more comprehensive and in-depth comparison results.

[0082] For example, in an e-commerce system, the development team added a user review function in the development environment. By using the diff command of Git, developers can quickly obtain all the details of changes between the development environment and the online environment. These changes may include new code files, modified function logic, and adjusted configuration parameters, etc.

[0083] After extracting the changed parts of the code, the method further includes classifying and labeling the changed parts of the code according to file types, code change types, and / or change complexity, to obtain classified and labeled changed parts of the code.

[0084] The purpose of classification and labeling is to more clearly understand the nature and scope of code changes, facilitating subsequent analysis and processing. According to the file type classification, it can quickly locate the specific type of file, such as Java file, configuration file, front-end script file, etc. According to the code change type classification, it can distinguish between new code, modified code and deleted code, etc. According to the change complexity classification, it can evaluate the difficulty and risk of code changes, such as simple modification, complex logic adjustment and large-scale refactoring, etc.

[0085] For example, in a financial system, the development team optimizes the transaction processing module. Through classification and labeling, it is found that the changed part is mainly concentrated in the function modification of Java files, and the change complexity is complex logic adjustment. This prompts developers to pay special attention to these changes and conduct more in-depth testing and review.

[0086] Then, in the process of generating accurate information by combining the sub-call changes with the changed part of the code, accurate information can be generated according to the changed part of the code after classification and labeling and the sub-call changes.

[0087] Specifically, after obtaining the sub-call changes and the changed part of the code, the data integration tool is used to associate the two according to the preset association rules. For example, if a certain sub-call is missing and corresponds to the deletion of a certain function in the code, the two are associated. The associated information is integrated into a unified data structure to form accurate information. These accurate information not only contains the detailed content of sub-call changes and code changes, but also covers the association between them, providing comprehensive and accurate input for subsequent large model analysis.

[0088] For example, in an e-commerce system, the development team found that a payment interface call was missing in the development environment, and the relevant payment processing function was deleted in the code change part. By combining these information, the accurate information generated can clearly point out the problem of missing payment interface call and provide the corresponding code change details, providing strong support for subsequent repair work.

[0089] In the process of software development, analyzing the execution results of the development environment to determine whether there are sub-call changes is a key step to ensure code quality and functional correctness. Sub-call changes include sub-call missing, sub-call addition and sub-call difference, which may affect the functional integrity and stability of the system. Specifically, see Figure 2 , in step 103, the execution results of the development environment are analyzed to determine whether there are sub-call changes, which specifically includes: 201. Use the call link tracking tool to track the complete call link of each traffic request in the development environment, and build a call graph of the development environment based on the call link information to show the hierarchy, call sequence and dependency of each sub-call in the development environment.

[0090] To accurately determine sub-call changes, you can use call chain tracing tools such as Zipkin and Jaeger. These tools can record the complete call chain of each traffic request in the system, generate a call graph, and intuitively display the hierarchy, call sequence, and dependencies of each sub-call.

[0091] For example, in an e-commerce system, a user's order request triggers a series of sub-calls, including inventory checking, payment processing, order creation, etc. Using a call chain tracing tool, the execution of these sub-calls can be recorded in detail and a call graph can be generated.

[0092] 202. Trace the call link of each traffic request in the online environment and generate a call graph of the online environment to show the hierarchy, call sequence and dependency of each sub-call in the online environment.

[0093] Using a call link tracing tool to track the call link of each traffic request in the online environment is similar to the implementation process in step 201 above, and will not be repeated here.

[0094] 203. Compare the call graph of the development environment and the call graph of the online environment to check whether there are missing sub-calls, new sub-calls, and / or sub-call differences in the development environment.

[0095] By comparing the call graphs of the development and production environments, we can clearly identify missing, new, or different sub-calls. For example, if a critical sub-call is not triggered in the development environment, but is required in the production environment, this constitutes a missing sub-call. Conversely, a new sub-call added in the development environment may introduce new functionality or logic, requiring further verification of its correctness and compatibility.

[0096] In the process of combining sub-call changes with the changed part of the code to generate accurate information, a data integration tool is used to associate the sub-call changes with the changed part of the code according to preset association rules; the association rules are used to define the association relationship between the sub-call changes and the changed part of the code; the associated sub-call changes and the changed part of the code are integrated into a data structure to obtain the accurate information.

[0097] Common association rules include: File path-based association: If the subcall change and the code change part occur in the same file or class, they are considered to be associated.

[0098] Function name-based association: If the function involved in the sub-call change is the same as the function in the code change part, it is considered to have an association.

[0099] Call location-based association: If the call location of the sub-call change is the same as the modification location of the code change part, it is considered to have an association.

[0100] In addition, the detailed steps of the association process include: S1, Data extraction: Extract the data of sub-call changes and code change parts from the call link tracking tool and code comparison tool. These data include the type of sub-call (missing, new, difference), the type of code change (new, missing, difference), file path, function name, code line number, etc.

[0101] S2, Data cleaning: Clean the extracted data to remove duplicate, error or incomplete records, and ensure the accuracy and consistency of the data.

[0102] S3, Data conversion: Convert the data into a format suitable for association. For example, convert the data of sub-call changes and code change parts into structured table forms respectively, to facilitate subsequent association operations.

[0103] S4, Data association: According to the preset association rules, associate the sub-call changes and code change parts. For example, use SQL statements or the built-in functions of data integration tools to associate according to the key fields such as file path, function name, etc.

[0104] S5, Data integration: Integrate the associated data into a unified data structure to form accurate information. For example, the associated data can be stored as a JSON format file, each record containing detailed information of sub-call changes and code change parts, and their association relationship.

[0105] Suppose in an e-commerce system, the development team made code modifications to the user login function in the development environment, and found a sub-call missing problem. The specific steps of association are as follows: Data extraction: Extract the sub-call change data from the call link tracking tool and find that the log record function after user login is not called (sub-call missing). Extract the code change part data from the code comparison tool and find that the code of the user login function is modified.

[0106] Data cleaning: Clean the extracted data to ensure the accuracy and integrity of the data.

[0107] Data conversion: Convert the data of sub-call changes and code change parts into structured table forms respectively.

[0108] Data association: According to the preset association rule, the record of missing sub-call is associated with the record of code modification. For example, based on the association rule of file path and function name, it is found that the record of missing sub-call and the record of code modification occur in the same file and function.

[0109] Data integration: The associated data is integrated into the accurate information in JSON format, each record contains the detailed information of the sub-call change and the code change part, and the association relationship between them.

[0110] In order to facilitate the understanding of the scheme of the embodiments of the present application, see Figure 3 , Figure 3 The logical framework diagram of the embodiments of the present application is given.

[0111] 1) Flow playback In the production environment, the traffic requests initiated by users or systems are captured by network sniffing, API gateway interception and other methods. These requests can be HTTP requests, RPC call requests, etc., containing complete request headers, request bodies, parameters and other information.

[0112] The captured traffic request data is stored in a distributed file system (such as HDFS) or a high-performance database (such as MongoDB, Cassandra) for subsequent playback in the development environment.

[0113] 2) Playback results Use playback tools (such as JMeter, Locust) to simulate the execution process of online traffic requests in the development environment. Set the number of concurrent requests, interval time, timeout policy and other parameters to simulate the real online scene, and record the response time, returned data, error information and performance indicators of the development environment for each traffic request. These execution results will be used for subsequent analysis and comparison.

[0114] 3) Code change part Compare the code branches of the development environment and the online environment, use code comparison tools (such as Git, BeyondCompare) to extract the added part, missing part and difference part of the code. Classify and label the code change part according to file type, code change type and change complexity.

[0115] 4) Identification strategy Use call link tracking tools (such as Zipkin, Jaeger) to track the complete call link of each traffic request in the development environment, and build a call graph of the development environment. The call graph shows the hierarchy, call order and dependency of each sub-call. Then compare the call graphs of the development environment and the online environment to check if there are missing sub-calls, new sub-calls and / or sub-call differences in the development environment.

[0116] 5) Generate accurate information Correlate sub-call changes and code change parts: use data integration tools to correlate sub-call changes and code change parts according to pre-set correlation rules (such as based on file path, function name, call location, etc.).

[0117] Generate accurate information: integrate the correlated sub-call changes and code change parts into a unified data structure to form accurate information. The accurate information includes the detailed content of the sub-call changes and code changes, as well as their correlation.

[0118] 6) Large model Input the generated accurate information into a general large model, and the large model analyzes the accurate information to determine whether the code meets expectations and provides reasons and repair solutions for not meeting expectations.

[0119] Among them, a suitable general large model (such as GPT-4, Codex) can be selected and the model can be configured, including data format conversion, model calling interface configuration, etc.

[0120] 7) Recognition results and solutions After the large model analysis, output the judgment result of whether the code meets expectations, the reason for not meeting expectations, and the repair solution. The development team modifies and perfects the code according to the repair solution provided by the large model to ensure the code quality and system stability.

[0121] Through the above steps, the embodiment of the application realizes intelligent and automatic recognition of code defects, significantly improves the efficiency and accuracy of code defect recognition, reduces labor costs and workload, and effectively improves the quality and speed of software development.

[0122] The code defect recognition device provided by the embodiment of the application is described below, and the code defect recognition device described below can be correspondingly referred to the code defect recognition method described above.

[0123] The embodiment of the application provides a code defect recognition device, referring to Figure 4 , comprising: The request acquisition module 401 is configured to acquire traffic requests online and store them, and replay the traffic requests in the development environment to obtain the execution results of the development environment. A code comparison module 402 is used to compare the code branches of the development environment and the code branches of the online environment to extract the changed parts of the code; An information generation module 403 is used to analyze the execution results of the development environment, determine whether there are sub-call changes, and combine the sub-call changes with the changed parts of the code to generate accurate information as input for the large model; The result analysis module 404 is used to analyze the precise information using a large model, determine whether the code meets expectations, and provide reasons and repair solutions if it does not meet expectations.

[0124] The device further includes: a pre-processing module, configured to pre-process the traffic request before storing the traffic request on the line, including removing duplicate requests, invalid requests, and requests containing sensitive information.

[0125] Optionally, the code comparison module 402 is specifically used to compare the code branch of the development environment and the code branch of the online environment using a code comparison tool, and extract the newly added parts, missing parts and / or different parts of the code.

[0126] Optionally, the apparatus further comprises: a classification and annotation module for, after extracting the changed portion of the code, classifying and annotating the changed portion of the code according to file type, code change type and / or change complexity, to obtain the classified and annotated changed portion of the code; The information generation module 403 is used to generate accurate information based on the changed parts of the classified and annotated code and the sub-call changes.

[0127] Optionally, the subcall change includes subcall deletion, subcall addition, and / or subcall difference; the information generation module 403 is configured to: Use a call chain tracing tool to track the complete call chain of each traffic request in the development environment. Build a call graph of the development environment based on the call chain information to display the hierarchy, call sequence, and dependencies of each sub-call in the development environment. Track the call chain of each traffic request in the online environment and generate a call graph of the online environment to show the hierarchy, call sequence, and dependencies of each sub-call in the online environment; Compare the call graph of the development environment and the call graph of the online environment to check whether there are missing sub-calls, new sub-calls and / or sub-call differences in the development environment.

[0128] Optionally, the information generation module 403 is used to: use a data integration tool to associate the sub-call changes and the changed parts of the code according to preset association rules; the association rules are used to define the association relationship between the sub-call changes and the changed parts of the code; integrate the associated sub-call changes and the changed parts of the code into a data structure to obtain the precise information.

[0129] Figure 5 An example of a physical structure diagram of an electronic device is shown below. Figure 5 As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530, and a communications bus 540, wherein the processor 510, the communications interface 520, and the memory 530 communicate with each other via the communications bus 540. The processor 510 may call the logic instructions in the memory 530 to execute a code defect identification method, including: obtaining and storing online traffic requests, and replaying the traffic requests in a development environment to obtain execution results in the development environment; comparing the code branches in the development environment with the code branches in the online environment to extract the changed parts of the code; analyzing the execution results of the development environment to determine whether there are sub-call changes, and combining the sub-call changes with the changed parts of the code to generate precise information as input to a large model; and using the large model to analyze the precise information to determine whether the code meets expectations and provide reasons and repair solutions for non-compliance.

[0130] Furthermore, the logic instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0131] In another aspect, the present application also provides a computer program product comprising a computer program, the computer program being stored in a non-transitory computer-readable storage medium, and the computer program being executable by a processor to enable a computer to execute the code defect identification method provided by the above method, comprising: obtaining and storing traffic requests on a line, and playing back the traffic requests in a development environment to obtain an execution result of the development environment; comparing code branches of the development environment and code branches of an online environment, and extracting a changed part of the code; analyzing the execution result of the development environment to determine whether there is a child call change, and generating accurate information by combining the child call change and the changed part of the code as input of a large model; and using the large model to analyze the accurate information to determine whether the code meets expectations and to give reasons and repair solutions for not meeting expectations.

[0132] In another aspect, the present application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, the computer program being executable by a processor to implement the code defect identification method provided by the above method, comprising: obtaining and storing traffic requests on a line, and playing back the traffic requests in a development environment to obtain an execution result of the development environment; comparing code branches of the development environment and code branches of an online environment, and extracting a changed part of the code; analyzing the execution result of the development environment to determine whether there is a child call change, and generating accurate information by combining the child call change and the changed part of the code as input of a large model; and using the large model to analyze the accurate information to determine whether the code meets expectations and to give reasons and repair solutions for not meeting expectations.

[0133] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, i.e., they can be located in one place, or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment according to actual needs. Those skilled in the art can understand and implement without creative labor.

[0134] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments can be implemented by means of software plus necessary general hardware platforms, and of course can also be implemented by hardware. Based on such understanding, the above technical solutions, essentially or in terms of the contribution to the prior art, can be embodied in the form of a software product. The computer software product can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a plurality of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0135] Finally, it should be noted that the above examples are only used to illustrate the technical solutions of the present application, and are not intended to limit the same; although the present application has been described in detail with reference to the foregoing examples, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing examples, or make equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for identifying code defects, characterized in that: include: Obtain and store online traffic requests, and replay the traffic requests in the development environment to obtain the execution results of the development environment; Compare the code branches of the development environment and the online environment to extract the changes in the code; Analyze the execution results of the development environment to determine whether there are sub-call changes, and combine the sub-call changes with the changed parts of the code to generate accurate information as input for the large model; Use the big model to analyze the precise information, determine whether the code meets expectations, and provide reasons and repair solutions for non-compliance.

2. The method for identifying code defects according to claim 1, wherein: Before storing the traffic request on the line, the method further includes: The traffic requests are pre-processed, including removing duplicate requests, invalid requests, and requests containing sensitive information.

3. The method for identifying code defects according to claim 1, wherein: The execution result of the development environment includes at least one of the following: The response time of the traffic request, the response data of the development environment to each traffic request, the error information recorded when the traffic request fails to execute in the development environment, and performance indicators.

4. The method for identifying code defects according to claim 1, wherein: Compare the code branches of the development environment and the production environment to extract the changes in the code, including: Use code comparison tools to compare the code branches of the development environment and the code branches of the production environment to extract the new parts, missing parts and / or differences in the code.

5. The method for identifying code defects according to claim 1 or 4, characterized in that: After extracting the changed portion of the code, the method further includes: Classifying and labeling the changed portion of the code according to file type, code change type, and / or change complexity to obtain the classified and labeled changed portion of the code; Combine the subcall changes with the code changes to generate accurate information, including: Accurate information is generated based on the changed parts of the classified and annotated code and the subcall changes.

6. The method for identifying code defects according to claim 1, wherein: The subcall changes include subcall deletions, subcall additions and / or subcall differences; Analyze the execution results of the development environment to determine whether there are any sub-call changes, specifically including: Use a call chain tracing tool to track the complete call chain of each traffic request in the development environment. Build a call graph of the development environment based on the call chain information to display the hierarchy, call sequence, and dependencies of each sub-call in the development environment. Track the call chain of each traffic request in the online environment and generate a call graph of the online environment to show the hierarchy, call sequence, and dependencies of each sub-call in the online environment; Compare the call graph of the development environment and the call graph of the online environment to check whether there are missing sub-calls, new sub-calls and / or sub-call differences in the development environment.

7. The method for identifying code defects according to claim 1, wherein: Combine the subcall changes with the code changes to generate accurate information, including: Using a data integration tool, associating the sub-call changes with the changed portion of the code according to a preset association rule; the association rule is used to define the association relationship between the sub-call changes and the changed portion of the code; The associated sub-call changes and the changed parts of the code are integrated into a data structure to obtain the accurate information.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method for identifying code defects according to any one of claims 1 to 7 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for identifying code defects according to any one of claims 1 to 7 is implemented.

10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method for identifying code defects according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Code defect identification method and device, equipment, storage medium and computer program product

    CN121958117A