Code repair verification method, knowledge base construction method, active defense method and related equipment
By using dependency analysis and the construction of a three-dimensional influence matrix, test cases are precisely selected. Combined with structured data files, this solves the problems of resource waste and defect defense during code repair, and achieves efficient code verification and proactive defense.
Patent Information
- Application Number
- CN202511482700.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-16
- Publication Date
- 2026-01-23
AI Technical Summary
The lack of analysis on the impact of existing code fixes leads to a serious waste of full-scale testing resources, low verification efficiency, low knowledge accumulation and reuse rate, and difficulty in preventing the recurrence of similar defects.
By performing dependency analysis on the code, constructing a three-dimensional influence matrix, identifying target test cases, replacing full testing with precise testing, and creating structured data files in the data warehouse, proactive defense is achieved.
It reduces testing resource consumption, shortens verification time, improves the update speed and reuse rate of the knowledge base, and effectively prevents the recurrence of similar defects.
Smart Images

Figure CN121387728A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of information technology, and in particular to a code repair verification, knowledge base construction, active defense method and related equipment. BACKGROUND
[0002] In the current software development process, if a code defect is found in the testing process, the general processing flow at this time is as shown in Figure 1
[0003] When a defect is found in testing, a work order is first created in a code project management system (such as Jira), and then handed over to a developer to repair the code. After the developer completes the repair, it is submitted to a code review system (such as Gerrit) for code review, and after the review is passed, it is subjected to full-amount testing by a code continuous integration system (such as Jenkins) to verify whether the repaired code is verified. If the verification fails, the developer continues to repair, and the above code review and testing process is repeated; if the verification passes, the work order is closed in the code project management system, and then the solution of this code repair is manually archived to update the relevant knowledge base.
[0004] However, this approach has the following defects: there is a lack of analysis of the impact caused by code repair in the entire processing process, so it is not possible to accurately determine the test cases to be used in testing, so in the existing solution, full-amount testing is generally used to avoid test omissions. Since in actual scenarios, only about 15%-30% of the test cases in full-amount testing are actually related to the current repaired code, more than 70% of the computing resources may be wasted, resulting in low verification efficiency.
[0005] At the same time, since the existing solution uses a manual archiving method to archive the solution of code repair, it is inefficient and cannot effectively deposit relevant knowledge, resulting in low knowledge reuse rate and slow knowledge base update speed. In addition, there is a lack of defense mechanism for similar defects, making it difficult to avoid the repeated occurrence of similar defects. SUMMARY
[0006] An object of the present application is to provide a code repair verification, knowledge base construction, active defense method and related equipment.
[0007] To achieve the above object, the present application provides a code repair verification method, which comprises: obtaining a first code submitted by a user; performing dependency analysis on the first code to determine related code methods, related application program interfaces and related data entities that have a dependency relationship with the first code; According to the related code method, the related application program interface and the related data entity, a three-dimensional influence matrix is constructed; According to the three-dimensional influence matrix, a target test case related to the first code is determined; The first code is tested using the target test case.
[0008] Further, a dependency analysis is performed on the first code to determine related code methods, related application program interfaces and related data entities that have a dependency relationship with the first code, including: The dependency analysis is performed on the first code by static analysis to parse the code syntax structure, obtain the calling relationship, and determine the related code methods that have a dependency relationship with the first code; The dependency analysis is performed on the first code by dynamic tracking to obtain a runtime path containing the calling relationship between microservices, and determine the related application program interfaces that have a dependency relationship with the first code; The dependency analysis is performed on the first code by data flow scanning to parse SQL statements, and determine the related data entities that have a dependency relationship with the first code.
[0009] Further, the target test case includes a test case related to a related code method, a test case related to a related application program interface and a test case related to a related data entity.
[0010] The application also provides a knowledge base construction method, which comprises: The first code is tested using the code repair verification method described above; After the code test, a structured data file related to the current code repair verification is created in a data warehouse homologous to the first code, wherein the structured data file is bound to the change identifier of the first code, and at least includes a trigger condition, a root cause, a verification path and a defense rule.
[0011] Further, the structured data file adopts a YAML format.
[0012] The application also provides a proactive defense method for code defects, which comprises: A second code submitted by a user is obtained; It is checked whether the second code matches the trigger condition of a structured data file, wherein the structured data file is created using the knowledge base construction method described above; If it matches the trigger condition of any one of the structured data files, a preset defense processing is performed according to the defense rule of the structured data file.
[0013] Further, performing a preset defense processing according to the defense rule of the structured data file, including: displaying, to the user, the check item to be processed in the second code according to the defense rule.
[0014] Further, after displaying, to the user, the check item to be processed in the second code according to the defense rule, the method further includes: obtaining the second code in which the user modifies the check item; verifying the second code according to the target test case corresponding to the verification path of the structured data file through the blocking check, to determine that the user has modified the content related to the check item.
[0015] Further, the method further includes: prompting the user to input the defense rule in the structured data file through the IDE plug-in when the user writes the second code.
[0016] According to another aspect of the present application, a computing device is also provided, which includes a memory for storing computer program instructions and a processor for executing the computer program instructions, wherein the computer program instructions, when executed by the processor, trigger the code repair verification method, the knowledge base construction method, or the active defense method.
[0017] The embodiments of the present application also provide a computer readable medium having computer program instructions stored thereon, and the computer program instructions can be executed by a processor to implement the code repair verification method, the knowledge base construction method, or the active defense method.
[0018] Compared with the prior art, the application provides a code repair verification scheme, which comprises the following steps: after a first code submitted by a user is obtained, dependency analysis is performed on the first code to determine relevant code methods, relevant application program interfaces and relevant data entities having a dependency relationship with the first code; a three-dimensional influence matrix is constructed according to the relevant code methods, the relevant application program interfaces and the relevant data entities; target test cases related to the first code are determined according to the three-dimensional influence matrix; and the first code is tested by using the target test cases. According to the scheme, the dependency analysis is performed on the first code, the relevant code methods, the relevant application program interfaces and the relevant data entities having a dependency relationship with the first code are obtained from three aspects respectively, accurate and comprehensive dependency analysis is realized, and the three-dimensional influence matrix is constructed on the basis, so that the actual influence caused by the repaired first code can be accurately and comprehensively reflected, and the target test cases related to the first code can be accurately selected according to the three-dimensional influence matrix to perform code testing, so that the original full-scale testing is replaced by the accurate testing, the calculation resource consumption during testing is effectively reduced, and the verification time is shortened.
[0019] The application also provides a knowledge base construction scheme, which adopts the code repair verification scheme to test the first code, and after the code testing, a structured data file about the code repair verification is created in a data warehouse homologous to the first code, wherein the structured data file is bound to the change identifier of the first code, and at least includes a trigger condition, a root cause, a target test case and a defense rule. Through the active knowledge encapsulation, the reusability of knowledge and the updating speed of the knowledge base can be effectively improved.
[0020] The application also provides an active defense scheme for code defects, which needs to use the structured data file created by the foregoing scheme, after a second code submitted by a user is obtained, it is checked whether the second code matches the trigger condition of the structured data file, if the second code matches the trigger condition of any one of the structured data files, a preset defense processing is performed according to the defense rule of the structured data file. In this way, the structured data file in the knowledge base can be effectively used to actively check the same type of defects when the developer submits the code, active defense is realized, and the repeated occurrence of the same type of defects can be effectively avoided. BRIEF DESCRIPTION OF DRAWINGS
[0021] Other features, objects and advantages of the application will become more apparent from the following detailed description of non-limiting embodiments, made with reference to the accompanying drawings: Figure 1 A processing flow diagram for discovering code defects in the prior art; Figure 2A processing flow schematic diagram of a code repair verification method provided by an embodiment of the present application is shown in FIG. 1. Figure 3 A processing mode schematic diagram when performing dependency analysis in an embodiment of the present application is shown in FIG. 2. Figure 4 A processing flow schematic diagram of a code defect proactive defense method provided by an embodiment of the present application is shown in FIG. 3. Figure 5 A specific flow schematic diagram when implementing code repair verification, intelligent knowledge base construction and proactive defense by using the scheme provided by an embodiment of the present application is shown in FIG. 4. Figure 6 An interaction flow schematic diagram between various systems when performing proactive defense in the scheme of an embodiment of the present application is shown in FIG. 5. The same or similar reference signs in the drawings represent the same or similar components. DETAILED DESCRIPTION
[0022] The present application will be further described below in conjunction with the drawings.
[0023] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0024] In a typical configuration of the present application, the devices of the terminal and the service network each include one or more processors (CPU), input / output interfaces, network interfaces and memories.
[0025] The memory can include a non-permanent memory in a computer readable medium, random access memory (RAM) and / or non-volatile memory such as read only memory (ROM) or flash memory (flash RAM). The memory is an example of the computer readable medium.
[0026] Computer-readable media includes permanent and non-permanent, removable and non-removable media, which can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape disk storage or other magnetic storage device, or any other non-transmission medium that can be used to store information accessible by a computing device.
[0027] The embodiment of the present application provides a code repair verification method, which comprises the following steps:
[0028] In actual scenarios, the execution subject of the method can include a user device, a network device, or a device integrated by the user device and the network device through a network, or can also be an application program running on the above-mentioned devices. The user device includes, but is not limited to, computers, mobile phones, tablet computers and various terminal devices; the network device includes, but is not limited to, network hosts, single network servers, servers centralized by multiple network servers, or servers in a distributed cloud network, etc. The distributed cloud network herein is composed of a large number of hosts or network servers based on cloud computing.
[0029] Figure 2 The embodiment of the present application provides a code repair verification method, which comprises the following steps: Step S201, obtaining a first code submitted by a user. The first code is a code repaired by a developer after discovering a code defect. For example, in an actual scenario, the first code can be a code submitted by a developer to a code review system (such as Gerrit) for re-review after completing code repair. At this time, the code review system generates a corresponding change identification (Change-ID) bound to the code review and the corresponding code content, and automatically triggers subsequent dependency analysis processing.
[0030] Step S202, performing dependency analysis on the first code to determine related code methods, related application program interfaces, and related data entities that have a dependency relationship with the first code.
[0031] In some embodiments of the present application, dependency analysis can be performed from three aspects, including static analysis, dynamic tracking, and data flow scanning, thereby identifying corresponding dependency analysis results, respectively. The dependency analysis results include three aspects: related code methods, related application program interfaces, and related data entities that have a dependency relationship with the first code. Specifically, the method shown in FIG. 1 can be used, where the input of dependency analysis is a Gerrit change set, which is the first code submitted to Gerrit, including the following processing mode: Figure 3 1. Perform dependency analysis on the first code by static analysis, parse the code syntax structure, obtain the calling relationship, and determine the related code methods that have a dependency relationship with the first code. For example, the following code implementation can be used: def build_call_graph(files): ast=parse_to_ast(files) return ast.get_caller_callee_map() First, a method named build_call_graph is defined, the parameter of the method is the aforementioned code modification file, and then a syntax analysis tool is called to parse the code modification file using the parse_to_ast() method, and the return value ast of the method execution is obtained, thereby determining the related code methods that have a dependency relationship with the first code.
[0032] 2. Perform dependency analysis on the first code in a dynamic tracking manner, obtain a runtime path containing the calling relationship between microservices, and determine a related application program interface that has a dependency relationship with the first code. For example, in this embodiment, distributed link tracking tools such as Jaeger and SkyWalking can be used, and the following code implementation can be used: List traces = JaegerClient.queryTraces( change.getMethods(), startTime, endTime); An API of Jaeger is called to query the runtime path of the call relationship between microservices in the time period from startTime to endTime, to determine the related application interfaces that have a dependency relationship with the first code.
[0033] 3. The first code is analyzed for dependencies by means of data flow scanning, and SQL statements are parsed to determine the related data entities that have a dependency relationship with the first code. For example, in this embodiment, the related data entities can be extracted by a SQL parser, and the following SQL statement can be used: SELECT table_name FROM sql_parser WHERE change_id='I0a9b8c7d' Thus, the data table involved in the first code with change identifier I0a9b8c7d can be queried, and for example, in this embodiment, the first code modifies the structure of the orders table, which affects the data of the payment_records table, so that all related data entities that have a dependency relationship with the first code can be clearly determined.
[0034] In step S203, a three-dimensional impact matrix is constructed according to the related code methods, related application interfaces, and related data entities.
[0035] In step S204, the target test cases related to the first code are determined according to the three-dimensional impact matrix.
[0036] The three-dimensional impact matrix can be used to represent the impact of the first code on code methods, application interfaces, and data entities, so when the target test cases related to the first code are determined according to the three-dimensional impact matrix, several types of target test cases for targeted testing of the impact on these three aspects can also be obtained. The target test cases can include test cases involving related code methods, test cases involving related application interfaces, and test cases involving related data entities.
[0037] In this embodiment, the following specific implementation method can be used when selecting the above several types of target test cases: def select_tests(impact_matrix): core_tests = UnitTest.query( methods=impact_matrix['changed_methods']) edge_tests = APITest.query( apis=impact_matrix['affected_apis']) db_checks = [f"pg_check_constraints('{table}')" for table in impact_matrix['data_entities']] return {core_tests, edge_tests, db_checks} The implementation in the foregoing three-dimensional impact matrix impact_matrix is defined as a function method of select_tests( ). Among them, the core test core_tests is directly associated with the test case of the changed method changed_methods (that is, the related code method of the first code). The boundary test edge_tests corresponds to the test case of the upstream and downstream of the affected API (that is, the related application programming interface). The data check db_checks uses a formatted string to generate a series of database check commands, thereby determining the test case related to the related data entity.
[0038] Step S205, after determining the target test case, the target test case can be used to test the first code.
[0039] Among them, the code test can be completed in the code continuous integration system, for example, in this example, Jenkins can be used to realize through the pipeline, the specific code is as follows: pipeline {stages {stage('Core Validation') { steps {runTests(params.core_tests)}}stage('Edge Impact') { when { expression { params.edge_tests!= null}} steps {runAPITests(params.edge_tests)}}stage('Data Integrity') { steps { sh "psql -f ${params.db_checks}"}}}} In this way, the structure of the Jenkins test pipeline can be defined to ensure smooth code testing.
[0040] The entire code repair verification scheme realizes accurate and comprehensive dependency analysis by performing dependency analysis on the first code, respectively obtains relevant code methods, relevant application program interfaces and relevant data entities that have a dependency relationship with the first code from three aspects, and constructs a three-dimensional influence matrix on this basis, so that it can accurately and comprehensively reflect the actual influence caused by the repaired first code. Therefore, the target test case related to the first code can be accurately selected according to the three-dimensional influence matrix to perform code testing, so as to replace the original full-scale testing in a precise testing manner, effectively reducing the consumption of computing resources during testing, and shortening the verification time.
[0041] On the basis of the foregoing code repair verification method, the embodiment of the application further provides a knowledge base construction method, which first uses the foregoing code repair verification method to perform code testing on the first code, and after the code testing, a structured data file about the code repair verification is created in the data warehouse homologous to the first code. The structured data file is bound with the change identifier of the first code, and at least includes a trigger condition, a root cause, a verification path and a defense rule.
[0042] The trigger condition is key information for realizing subsequent active defense, which can be a file path list in an actual scenario, used for matching with a subsequently submitted code modification file, and when the matching is successful, the active defense mechanism can be triggered. The root cause records the specific reason for the occurrence of the code defect this time, which is the core value of knowledge sedimentation. The verification path is used to record the target test case required to verify whether the code defect is solved, so as to quickly provide targeted test cases for precise testing without using full-scale testing for verification. The defense rule can be a rule list, which specifies the rules that need to be followed to avoid the recurrence of such defects, and provides a more rapid and accurate solution for subsequent developers who encounter similar code defects.
[0043] In addition, the structured data file can also include the change identifier generated by the code review system when the first code is submitted, such as Change-ID in Gerrit, and the structured data file is bound with the change identifier, thereby establishing a strong association between the knowledge entry and a specific code submission, ensuring that the knowledge does not be separated from the code version, and solving the problem that the knowledge entry cannot be associated with the code version in the traditional manual archiving method, and the knowledge document is prone to "expiration".
[0044] In some embodiments of this application, the structured data file adopts YAML format. Taking a YAML file / knowledge / order-service / KB_2025-17.yaml as an example, it may include the following data content: fingerprint: 89a2b4c6 trigger_files: - "src / main / java / com / order / Service.java" root cause: "Thread pool not being isolated leads to request backlog". verification: core_tests: ["OrderConcurrencyTest"] edge_tests: ["PaymentTimeoutTest"] rules: - "Thread pool configuration needs to isolate critical business logic" - "@Async requires specifying a separate executor" git_commit: "I0a9b8c7d" Here, `fingerprint` is the fingerprint identifier for this knowledge entry, which can be a hash value generated based on relevant data, used to uniquely identify the knowledge entry corresponding to this YAML file. `trigger_files` are the triggering conditions, `root_cause` is the root cause, and `verification` is the verification path, including specific test cases for core tests (`core_tests`) and edge tests (`edge_tests`). `Rules` are the defense rules, and `git_commit` is the change identifier when a user commits changes to code in Gerrit.
[0045] The YAML file and the first code are stored in the same Git repository, and their storage directory structure can be as follows: / knowledge / ├── order-service / │├── KB_2025-17.yaml │└── KB_2025-18.yaml └── payment-service / └── KB_2025-19.yaml On the basis of the foregoing technical solutions, the embodiment of the present application further provides a code defect active defense method, a processing flow of the method is shown in the figure, and specifically includes the following processing steps: Step S401, a second code submitted by a user is acquired.
[0046] Step S402, whether the second code matches a trigger condition of a structured data file is checked. The structured data file is created by the foregoing knowledge base construction method, and at least includes a trigger condition, a root cause, a verification path, a defense rule and the like, so that the trigger condition in the structured data file can be matched with the second code. For example, if the second code modifies Service.java to add a new function when the second code is submitted, the trigger condition of the structured data file / knowledge / order-service / KB_2025-17.yaml is matched after the second code is submitted to Gerrit, so that subsequent corresponding defense processing is performed.
[0047] Step S403, if the trigger condition of any one structured data file is matched, preset defense processing is performed according to the defense rule of the structured data file. Therefore, the structured data file in the knowledge base can be effectively utilized to actively check the same type of defects when the developer submits the code, active defense is realized, and the repeated occurrence of the same type of defects is effectively avoided.
[0048] In some embodiments of the present application, a preset defense processing mode is that an inspection item to be processed in the second code is displayed to the user according to the defense rule. For example, if the defense rule includes: "thread pool configuration needs to be isolated from key business" and "@Async needs to be specified independently executor", the inspection item to be processed in the second code can be displayed to the user according to the defense rule. In an actual code development scenario, an inspection task about the inspection item can be created in a code project management system (such as Jira), and the inspection item that must be processed is displayed to the developer by Jira, so that the user can modify the second code according to the inspection item of the inspection task.
[0049] After the inspection item to be processed in the second code is displayed to the user according to the defense rule, the second code of the inspection item modified by the user can be acquired, the second code is verified according to a target test case corresponding to the verification path of the structured data file by means of blocking inspection, it is determined that the user has modified the content involved in the inspection item, so that the same code defect can be effectively intercepted, and the recurrence rate of the same type of defects is reduced.
[0050] In addition, the defense rules in the corresponding structured data file can be prompted to the user through an IDE (Integrated Development Environment) plug-in when the user writes the second code, so as to improve the problem discovery rate in the development stage.
[0051] Figure 5 The specific process of implementing a series of processes such as code repair verification, intelligent knowledge base construction, and active defense by using the scheme provided in the embodiments of the application is shown, including the following steps: Step S501, the developer receives a Jira defect work order.
[0052] Step S502, the defect code is repaired according to the Jira defect work order, and the repaired first code is submitted to Gerrit for code review.
[0053] Step S503, the change dependency chain analysis engine performs dependency analysis on the first code, and obtains a dependency analysis result.
[0054] Step S504, a three-dimensional influence matrix is generated according to the dependency analysis result.
[0055] Step S505, the intelligent verification generator determines the target test case required according to the three-dimensional influence matrix.
[0056] Step S506, Jenkins tests the first code according to the target test case, to realize accurate verification.
[0057] Step S507, the knowledge encapsulation module creates a YAML file about the code repair verification in the data warehouse homologous to the first code according to the code repair and testing this time, and binds the YAML file with the change identifier of the first code, so as to complete the intelligent update of the knowledge base.
[0058] Step S508, when new second code is submitted, the active defense gateway performs active defense.
[0059] The interaction process between the systems when the active defense is performed in the embodiment can be as shown in Figure 6 , and specifically includes the following interaction steps: Step S601, the developer Dev submits the modified code OrderService.java to the code review system Gerrit.
[0060] Step S602, Gerrit queries the trigger condition from the knowledge base KnowledgeDB.
[0061] Step S603, the KnowledgeDB returns a list of trigger conditions.
[0062] Step S604, if there is a matching trigger condition, a verification task is created in Jira.
[0063] Step S605, Jira displays the check items that must be handled to Dev.
[0064] Step S606, Dev supplements and repairs the code according to the check items and then submits the code to Gerrit again.
[0065] Step S607, Gerrit triggers the Jenkins code continuous integration system to build the code and complete the relevant code testing according to the test cases required by the knowledge items.
[0066] Thus, the technical scheme proposed in the embodiments of the present application constructs a technical closed loop of precise analysis, intelligent verification, active precipitation and active defense, and breakthroughs are achieved in the dimensions of verification efficiency, analysis depth, knowledge activity and defense capability. When the technical scheme is applied to an actual development scenario, the research and development efficiency and system stability are significantly improved, wherein the defect repair period can be shortened from an average of 3.2 days to 0.5 day, and the same kind of faults in the production environment are reduced by 83%. In addition, the operation and maintenance cost is greatly reduced, and the computing resource consumption can be reduced by 75% compared with the full-amount test scheme.
[0067] Based on the same inventive concept, the embodiments of the present application also provide a computing device, which corresponds to the code repair verification method, the knowledge base construction method or the active defense method in the foregoing embodiments, and the problem solving principle thereof is similar to the method. The computing device provided by the embodiments of the present application comprises a memory for storing computer program instructions and a processor for executing the computer program instructions, wherein when the computer program instructions are executed by the processor, the device is triggered to implement the method and / or technical scheme of the foregoing embodiments of the present application.
[0068] The specific implementation of the device can include a user device, a network device or a device composed of a user device and a network device integrated through a network, or can also be an application program running on the above-mentioned device. The user device includes but is not limited to computers, mobile phones, tablet computers and various terminal devices; the network device includes but is not limited to network hosts, single network servers, multiple network servers centralized servers or servers in distributed cloud networks, etc. The distributed cloud network herein is composed of a large number of hosts or network servers based on cloud computing.
[0069] In particular, the methods and / or embodiments of this application can be implemented as a computer program product. For example, embodiments of the disclosure include a computer program product comprising a computer program tangibly embodied in a computer readable medium, the computer program containing program code for executing the methods illustrated in the flowcharts. When the computer program is executed by a processing unit, the aforementioned functions defined in the methods of this application are performed.
[0070] It should be noted that the computer readable medium described in this application can be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer readable medium may, for example, be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of computer readable storage media can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this application, the computer readable medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus.
[0071] In this application, the computer readable signal medium can include a data signal propagating in a baseband or as part of a carrier wave propagating in a baseband, in which computer readable program code is embodied. Such a propagating data signal can take many forms, including but not limited to electro-magnetic, optical or any suitable combination thereof. The computer readable signal medium can also be any computer readable medium that is not a computer readable storage medium and that can transmit, propagate or transport program code for use by or in connection with an instruction execution system, apparatus or device. Program code embodied on a computer readable medium can be transmitted using any suitable medium, including but not limited to wireless, wire line, optical fiber cable, RF, etc., or any suitable combination of the above.
[0072] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0073] The computer program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0074] As another aspect, the present application also provides a computer readable medium, which can be contained in the apparatus described in the above embodiments, or can exist separately without being assembled into the apparatus. The above computer readable medium carries one or more computer program instructions, which can be executed by a processor to implement the methods and / or technical solutions of the above embodiments of the present application.
[0075] It is noted that the present application can be implemented in software and / or in a combination of software and hardware, e.g., using application specific integrated circuits (ASIC), a general purpose computer or any other similar hardware devices. In some embodiments, software programs implementing the present application can be executed by a processor to perform the steps or functions described herein. Also, software programs (including related data structures) of the present application can be stored in computer-readable recording media, e.g., RAM memory, magnetic or optical drives or disks, and the like. Furthermore, some of the steps or functions can be implemented in hardware, e.g., as circuitry that cooperates with the processor in performing the various steps or functions.
[0076] It will be apparent to those skilled in the art that the present application is not limited to the details of the foregoing exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or essential characteristics of the present application. The present embodiments are therefore considered in all respects to be illustrative and not restrictive, the scope of the present application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. No feature of the claims, whether positional or otherwise, should be construed as limiting the claims to the precise configuration recited. Also, it is to be understood that the term "comprising" does not exclude other elements or steps, that singular articles do not exclude plural referents, and that references to processes should not be read as excluding corresponding steps carried out in any desired order. The word "first" does not necessarily mean "second", and vice versa. The numerical order of steps corresponding to the numbers does not imply any particular order of execution, which can be carried out in any order that is consistent with the logic of the execution.
Claims
1. A code repair and verification method, characterized in that, The method includes: Get the first code submitted by the user; Perform dependency analysis on the first code to identify related code methods, related application programming interfaces and related data entities that have dependencies on the first code; Based on the relevant code methods, relevant application programming interfaces, and relevant data entities, construct a three-dimensional influence matrix; Based on the three-dimensional influence matrix, target test cases related to the first code are determined; The first code is tested using the target test case.
2. The method according to claim 1, characterized in that, Dependency analysis is performed on the first code to identify related code methods, related application programming interfaces, and related data entities that have dependencies on the first code, including: Dependency analysis is performed on the first code using static analysis to parse the code syntax structure, obtain the call relationship, and determine the relevant code methods that have a dependency relationship with the first code. Dependency analysis is performed on the first code using dynamic tracing to obtain the runtime path containing the call relationships between microservices and to determine the relevant application interfaces that have dependencies on the first code. Dependency analysis is performed on the first code by data stream scanning, SQL statements are parsed, and relevant data entities that have dependencies on the first code are identified.
3. The method according to claim 1, characterized in that, The target test cases include test cases involving relevant code methods, test cases involving relevant application interfaces, and test cases involving relevant data entities.
4. A method for constructing a knowledge base, characterized in that, The method includes: The first code is tested using the method described in any one of claims 1 to 3; After the code passes the test, a structured data file about the code fix verification is created in the data warehouse that is from the same source as the first code. The structured data file is bound to the change identifier of the first code and includes at least the triggering condition, the root cause, the verification path, and the defense rules.
5. The method according to claim 4, characterized in that, The structured data file is in YAML format.
6. A proactive defense method for code defects, characterized in that, The method includes: Get the second code submitted by the user; Check whether the second code matches the triggering condition of the structured data file, wherein the structured data file is created using the method described in claim 4 or 5; If the triggering condition matches any structured data file, the preset defense processing will be executed according to the defense rules of the structured data file.
7. The method according to claim 6, characterized in that, Perform preset defense processing based on the defense rules of the structured data file, including: The user is shown the check items to be processed in the second code according to the defense rules.
8. The method according to claim 7, characterized in that, After displaying the check items to be processed in the second code to the user according to the defense rules, the process also includes: Get the second code of the user-modified check item; By using a blocking inspection method, the second code is verified based on the target test cases corresponding to the verification path of the structured data file to determine whether the user has modified the content involved in the inspection items.
9. The method according to claim 6, characterized in that, The method further includes: When users are writing second code, the IDE plugin prompts them with the defense rules in the corresponding structured data file.
10. A computing device, the device comprising a memory for storing computer program instructions and a processor for executing the computer program instructions, wherein, When the computer program instructions are executed by the processor, the device is triggered to perform the method of any one of claims 1 to 9.
11. A computer-readable medium having stored thereon computer program instructions that can be executed by a processor to implement the method as described in any one of claims 1 to 9.