Code change risk assessment method and device, equipment, medium and computer program product
By constructing a code call chain graph model and calculating the intermediary centrality and iterative convergence calculation, the shortcomings of code change risk assessment in existing technologies are solved, achieving more efficient and accurate risk assessment, improving system stability and reducing the vulnerability rate.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-26
- Publication Date
- 2026-04-10
AI Technical Summary
Existing code change risk assessment methods rely on test cases and human evaluation, which fail to fully consider the impact of code changes on business processes and upstream and downstream systems, resulting in reduced stability of live services, increased service failure handling time, and increased vulnerability rates.
By constructing a graph model based on the code call chain, recording the execution data of test cases, calculating the betweenness centrality, dividing the key subgraph, and performing iterative convergence calculations, the risk assessment value of code changes is obtained.
It improves the efficiency and accuracy of code change risk assessment, ensures system stability, and reduces vulnerability rates and maintenance difficulty.
Smart Images

Figure CN121833014A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, medium, and computer program product for assessing code change risks. Background Technology
[0002] With the rapid development of computer systems, version changes have become a breeding ground for risks. Existing code changes bring numerous risks, mainly manifested in unclear system topology and ambiguous upstream and downstream function relationships. Current code change risk assessment methods primarily rely on test cases and subjective user evaluations. However, test cases are not organically integrated with the actual business function call relationships during the testing process, often proving insufficient when dealing with complex system changes. Furthermore, subjective human evaluations frequently fail to fully consider the importance and relevance of changed functions within the business process and the upstream and downstream system impact, directly resulting in reduced network service stability and increased service failure handling time. It also leads to an increased service vulnerability rate and a higher number of vulnerability reopens, thereby increasing system uncertainty and maintenance difficulty. Summary of the Invention
[0003] The purpose of this invention is to provide a method, apparatus, device, medium, and computer program product for assessing code change risks. By implementing the testing process of test cases, the invention achieves the recording of the actual call chain of code changes and the weighting of the code logic topology. Furthermore, it introduces betweenness centrality to provide a unified quantitative measurement of code change risks, thereby improving the efficiency and accuracy of code change risk assessment.
[0004] To achieve the above objectives, embodiments of the present invention provide a code change risk assessment method, including: Obtain the code of the system under test, and construct a graph model based on the code call chain according to the changes in the code; Test cases are executed on the system under test, and the graph model is weighted based on the execution data to form a weighted link graph; The intermediary centrality is calculated based on the link graph, and the key subgraph is partitioned according to the intermediary centrality; The risk assessment value of the code change is obtained by iteratively converging the key subgraph.
[0005] As an improvement to the above solution, the step of obtaining the code of the system under test and constructing a graph model based on the code call chain according to the changes in the code includes: Obtain the code of the system under test, analyze the changed business functions and the addition or deletion of code that changed the functions, and filter the annotations and blank lines in the code to form a set of changed business functions; The business function set is subjected to syntactic analysis based on the abstract syntax tree to construct a preliminary syntax structure tree; Based on the syntax structure tree and ASM bytecode, a graph model based on the code call chain is constructed.
[0006] As an improvement to the above solution, the step of executing test cases on the system under test and weighting the graph model based on the execution data to form a weighted link graph includes: Test cases are executed on the system under test, and probe instrumentation is performed; wherein, each test case has a unique identifier; different types of test cases correspond to different weight values; different levels of test cases correspond to different weighting values; Based on the unique identifier of the test case, the test case and the code are bidirectionally bound during the testing process; The graph model is weighted and colored based on the execution data to form a weighted link graph; wherein the nodes of the link graph are business functions, and the link graph includes business function information, call relationships and weighting information.
[0007] As an improvement to the above scheme, the step of calculating the betweenness centrality based on the link graph and partitioning the key subgraph according to the betweenness centrality includes: Based on the calling relationship and the weighting information, calculate the intermediary centrality of the nodes in the link graph; Based on the intermediary centrality of the nodes, key nodes are identified, and key subgraphs are divided based on the key nodes.
[0008] As an improvement to the above scheme, the iterative convergence calculation of the key subgraph to obtain the risk assessment value of the code change includes: Based on the domain radius of the key nodes in the key subgraph, an iterative convergence calculation is performed to determine the maximum weighted value for risk assessment. The weighted values are normalized to obtain the risk assessment value of the code change.
[0009] As an improvement to the above solution, the method further includes: Based on the call chain and topology information of the key nodes, determine the scope of impact of the code change; A knowledge base is constructed based on the link graph and the key subgraphs, and then visualized.
[0010] This invention also provides a code change risk assessment device, comprising: The graph model construction module is used to obtain the code of the system under test and construct a graph model based on the code call chain according to the changes in the code. The weighted link graph module is used to execute test cases on the system under test and to weight the graph model based on the execution data to form a weighted link graph. A key subgraph partitioning module is used to calculate the intermediary centrality based on the link graph and partition the key subgraph according to the intermediary centrality; The risk assessment module is used to perform iterative convergence calculations on the key subgraph to obtain the risk assessment value of the code change.
[0011] This invention also provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the code change risk assessment method described in any of the preceding embodiments.
[0012] This invention also provides a computer-readable storage medium comprising a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the code change risk assessment method described above.
[0013] This invention also provides a computer program product, which includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, they implement the code change risk assessment method described above.
[0014] Compared to existing technologies, the beneficial effects of the code change risk assessment method, apparatus, device, medium, and computer program product provided by this invention are as follows: By acquiring the code of the system under test, a graph model based on the code call chain is constructed according to the code changes; test cases are executed on the system under test, and the graph model is weighted according to the execution data to form a weighted link graph; betweenness centrality is calculated based on the link graph, and key subgraphs are partitioned according to the betweenness centrality; iterative convergence calculation is performed on the key subgraphs to obtain the risk assessment value of the code change. This invention achieves the weighting of the actual call chain records and code logic topology of code changes through the testing process of test cases, and introduces betweenness centrality to provide a unified quantitative measure of code change risk, thereby improving the efficiency and accuracy of code change risk assessment. Attached Figure Description
[0015] Figure 1 This is a flowchart illustrating a preferred embodiment of a code change risk assessment method provided by the present invention; Figure 2 This is a schematic diagram of the graph model in the code change risk assessment method provided by the present invention; Figure 3This is a schematic diagram of a domain node in a code change risk assessment method provided by the present invention; Figure 4 This is a schematic diagram of a preferred embodiment of a code change risk assessment device provided by the present invention; Figure 5 This is a schematic diagram of a preferred embodiment of a terminal device provided by the present invention. Detailed Implementation
[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0017] Please see Figure 1 , Figure 1 This is a flowchart illustrating a preferred embodiment of a code change risk assessment method provided by the present invention. The code change risk assessment method includes: S1, Obtain the code of the system under test, and construct a graph model based on the code call chain according to the changes in the code; S2, execute test cases on the system under test, and weight the graph model according to the execution data to form a weighted link graph; S3, calculate the intermediary centrality based on the link graph, and divide the key subgraph according to the intermediary centrality; S4, perform iterative convergence calculation on the key subgraph to obtain the risk assessment value of the code change.
[0018] Specifically, this embodiment of the invention acquires the code of the system under test and uses code difference analysis tools to compare the code differences between the current version and the previous stable version, accurately identifying added, modified, and deleted lines of code, functions, classes, and other elements. Based on the code changes, static code analysis tools are used to parse the code, analyzing function call relationships, class inheritance relationships, method call relationships, etc. The extracted call chain information is represented in the form of a graph, where nodes represent functions, classes, and other elements in the code, and edges represent the call relationships between functions, thus constructing a graph model based on the code call chain. It should be noted that during the construction of the graph model, nodes and edges related to code changes can be specially marked for subsequent analysis and processing. For example, different colors or attributes can be used to distinguish added, modified, and deleted nodes and edges. Then, based on the functions and business requirements of the system under test, appropriate test cases are selected for execution. Test cases can include different levels of testing, such as unit testing, integration testing, and system testing, ensuring coverage of all aspects that may be affected by code changes. When executing test cases, automated testing tools can be used to execute them and collect various data during the test execution process, such as test case execution time, execution results (pass / fail), code coverage, etc. This data will be used to weight the graph model, forming a weighted link graph. In the weighted link graph, each node and edge is assigned a weight value, which can intuitively reflect the importance and performance of code elements during the testing process. Next, the betweenness centrality of nodes is calculated based on the link graph. Betweenness centrality is a metric used to measure the importance of a node in a network; it represents the degree to which a node acts as a bridge between other nodes in the network for the shortest path. After calculating the betweenness centrality of nodes, a critical subgraph is created based on the betweenness centrality. The critical subgraph contains code elements and call relationships that have a significant impact on the system under test during the testing process and is a key focus of code change risk assessment. Finally, an iterative method is used to further analyze and calculate the critical subgraph. In each iteration, the critical subgraph can be updated and optimized based on the weight information of nodes and edges, the betweenness centrality value, and other relevant metrics. Define convergence criteria for the iteration. For example, convergence is considered achieved when the changes in nodes and edges of the key subgraph are less than a certain threshold, the changes in risk assessment values are less than a certain threshold, or a preset number of iterations is reached. The convergence criteria need to be adjusted based on actual circumstances to ensure the rationality and effectiveness of the iteration process. After convergence, the risk assessment value of the code change is calculated by integrating various information from the key subgraph. Based on the calculated risk assessment value, the risk of the code change can be classified into different levels, such as low risk, medium risk, and high risk.The risk level classification can be set based on actual business needs and experience to provide a reference for subsequent decision-making.
[0019] This invention implements a weighted representation of the actual call chain record and code logic topology of code changes through the testing process of test cases, and introduces betweenness centrality to measure the weight of each node. Then, a change risk assessment value is obtained through convergence calculation, which provides a unified quantitative measure of code change risk and effectively improves the efficiency and accuracy of assessing and testing code risk.
[0020] In another preferred embodiment, step S1, acquiring the code of the system under test and constructing a graph model based on the code call chain according to the changes in the code, includes: S11: Obtain the code of the system under test, analyze the changed business functions and the addition or deletion of code that changed the functions, and filter the annotations and blank lines in the code to form a set of changed business functions; S12, Perform syntactic analysis on the business function set based on the abstract syntax tree to construct a preliminary syntax structure tree; S13. Based on the syntax structure tree and ASM bytecode, construct a graph model based on the code call chain.
[0021] Specifically, this embodiment of the invention acquires the business code of the system under test, analyzes it through a version management system to obtain the changed business functions and the code additions and deletions of these functions during the current test, and filters out annotations and blank lines in the code to form a set of changed business functions. For this set of business functions, code analysis is performed based on the existing code framework: first, syntax analysis is performed using an Abstract Syntax Tree (AST) to construct a preliminary syntax structure tree; simultaneously, the ASM bytecode obtained from the probe is used to construct the code method chain; subsequently, the semantic recognition capabilities of a large model are used to identify middleware connections, thereby constructing a graph model based on the code call chain, such as... Figure 2 As shown, Figure 2 This is a schematic diagram of the graph model structure in the code change risk assessment method provided by the present invention. In the graph model, nodes represent business functions, and edges between nodes represent the calling relationships between business functions.
[0022] In another preferred embodiment, step S2 involves executing test cases on the system under test and weighting the graph model based on the execution data to form a weighted link graph, including: S21, Execute test cases on the system under test and perform probe instrumentation; wherein, each test case has a unique identifier; different types of test cases correspond to different weight values; different levels of test cases correspond to different weighting values; S22, Based on the unique identifier of the test case, the test case and the code are bidirectionally bound during the testing process; S23, the graph model is weighted and colored according to the execution data to form a weighted link graph; wherein, the nodes of the link graph are business functions, and the link graph includes business function information, call relationships and weighting information.
[0023] Specifically, this embodiment of the invention provides a data entry program that can generate a unique identifier for each different test case. While generating the unique identifier, the program uniquely binds it to the test case being tested. When executing the test case, the unique identifier is carried in the network requests executed for each test case. This embodiment also provides a probe program that can perform online instrumentation on the system under test. First, the probe program is started within the host machine or container of the system under test. By binding to the process of the system under test, online instrumentation is performed through the instrumentation interface. Testers can select the business functions to be instrumented using flexible regular expressions. The test cases for this iteration are executed on the system under test. The test cases are divided into different types, each corresponding to a different weight value; the test cases are also divided into different levels, each assigned a different weight value. The success or failure of the test case is marked during execution. Based on the execution data, the code graph model is weighted and colored during test case execution, and the access of nodes (i.e., business functions), the input and output parameters of nodes, and the exception information thrown during runtime are recorded to form a weighted link graph. ;in, This represents the business function information in the link diagram. This represents the call relationships in the link diagram. This represents the weighted information in the link graph.
[0024] This invention employs probes to enhance the tested business system, weighting the call chain graph of business functions through attribute marking of test cases. Based on probes, the tested system is enhanced with non-intrusive instrumentation during the testing process, creating a two-way binding between test cases and code. Coloring the code call relationships based on test cases effectively connects the testing process of test cases with the relationship between code changes, outputting a colored function call relationship structure, providing relevant content for subsequent graph structure analysis. Topology components are then constructed from the obtained graph structure, and the function call chain is weighted using the test cases executed during the testing process.
[0025] In yet another preferred embodiment, step S3, calculating the betweenness centrality based on the link graph and partitioning the key subgraph according to the betweenness centrality, includes: S31, Calculate the intermediary centrality of the nodes in the link graph based on the calling relationship and the weighting information; S32, Based on the intermediary centrality of the nodes, determine the key nodes, and divide the key subgraph according to the key nodes.
[0026] Specifically, in this embodiment of the invention, the betweenness centrality of nodes in the link graph is calculated based on the call relationships and weighting information in the link graph to represent the weight of each business function. For example, the weighted betweenness centrality index is: ; in, Indicates weighted centrality of intermediaries; Represents a node and nodes Between nodes The sum of weights across all call chains; Represents a node and nodes The sum of the weights on the shortest path between them.
[0027] For all passing through By summing the values of the node pairs, we can obtain the relative betweenness centrality: ; .
[0028] Identify key nodes based on their betweenness centrality: ; in, Subgraph Middle node The importance of.
[0029] Based on key nodes, divide the call chain graph into key subgraphs and define the possibilities of each key subgraph: ; ; For each subset in the subgraph, Representing a subset middle The possibility of it being a key node.
[0030] The neighborhood radius, as a proportion of the network graph diameter, determines the influence range of a method function within the call chain, specifically the neighborhood radius of a topological node. Figure 3 As shown, Figure 3 This is a schematic diagram of a domain node in a code change risk assessment method provided by this invention. That is, the larger the radius, the wider the impact range; here, it is assumed... The value is 0.5.
[0031] The embodiments of the present invention employ weighted middle centrality, which can yield a more targeted risk index, thereby improving the stability of the service system and reducing the vulnerability rate.
[0032] In yet another preferred embodiment, step S4 involves iteratively converging the critical subgraph to obtain a risk assessment value for the code change, including: S41, perform iterative convergence calculation based on the domain radius of the key nodes in the key subgraph to determine the maximum weighted value for risk assessment; S42, normalize the weighted value to obtain the risk assessment value of the code change.
[0033] Specifically, in this embodiment of the invention, iterative convergence calculation is performed based on the neighborhood radius of key nodes in the key subgraph, and the convergence condition is defined as follows: .
[0034] Based on the set relationship obtained from the above steps, take... The maximum value is normalized and used as the risk index, i.e., the risk assessment value, for this code change.
[0035] This invention measures the weight of each node by using betweenness centrality, extracts and divides key subgraphs, and designs an iterative function by using neighborhood radius to perform iterative convergence calculations, forming a normalized quantified risk index for code changes.
[0036] As a preferred embodiment, the method further includes: Based on the call chain and topology information of the key nodes, determine the scope of impact of the code change; A knowledge base is constructed based on the link graph and the key subgraphs, and then visualized.
[0037] Specifically, after obtaining the risk assessment value of the code change, this embodiment of the invention simultaneously acquires the call chain of key nodes. Through the call chain and topology information, it determines the scope of the associated impact of the code change and automatically issues warnings for the services and products of the associated key nodes. Furthermore, it integrates the key point information set obtained through local iteration and the test case execution results into a knowledge base for visualization, and provides feedback on failure information and knowledge updates.
[0038] This invention, through acquiring key nodes and subgraphs within the system, extracts the impact range of changes carrying upstream and downstream function information, and establishes a knowledge base connecting the upstream and downstream call chains of different subsystems. This knowledge base, through a visually integrated display of the impact chains of upstream and downstream functions, significantly improves developers' risk awareness and system usability. This process not only helps developers identify change risks early but also accurately assesses the impact range of changes on the system. The entire process enables more effective management of change risks during system development and testing, enhances developer awareness, and ensures system stability and reliability.
[0039] In summary, this invention provides a code change risk assessment process based on precise testing. It uses plug-in probes to instrument the system under test, enhancing the tracking of business processes. Syntactic analysis of the changed code is performed based on an abstract syntax tree (AST) to construct a preliminary syntax tree structure and acquire code change information. Code changes are analyzed by combining ASM bytecode and actual call chains. The testing process of test cases is used to color the logical topology of the changed code, forming a method call chain graph structure. A graph computation engine is used to perform weighted mapping of the call chain topology structure based on test case attributes and characteristics. The betweenness centrality of each method in the call chain is calculated, and key subgraphs are further divided based on the obtained betweenness centrality. Iterative calculations based on the neighborhood radius of key nodes extract weighted values with higher risk assessment values. These weighted values are the risk metric for this code change, and the resulting graph data is archived as part of a knowledge base for easy and intuitive visualization.
[0040] Accordingly, the present invention also provides a code change risk assessment device, which can implement all the processes of the code change risk assessment method in the above embodiments.
[0041] Please see Figure 4 , Figure 4 This is a schematic diagram of a preferred embodiment of a code change risk assessment device provided by the present invention. The code change risk assessment device includes: The graph model construction module 401 is used to obtain the code of the system under test and construct a graph model based on the code call chain according to the changes in the code. The weighted link graph module 402 is used to execute test cases on the system under test and to weight the graph model according to the execution data to form a weighted link graph; The key subgraph partitioning module 403 is used to calculate the intermediary centrality based on the link graph and partition the key subgraph according to the intermediary centrality; The risk assessment module 404 is used to perform iterative convergence calculation on the key subgraph to obtain the risk assessment value of the code change.
[0042] Preferably, the graph model construction module 401 is specifically used for: Obtain the code of the system under test, analyze the changed business functions and the addition or deletion of code that changed the functions, and filter the annotations and blank lines in the code to form a set of changed business functions; The business function set is subjected to syntactic analysis based on the abstract syntax tree to construct a preliminary syntax structure tree; Based on the syntax structure tree and ASM bytecode, a graph model based on the code call chain is constructed.
[0043] Preferably, the weighted link graph module 402 is specifically used for: Test cases are executed on the system under test, and probe instrumentation is performed; wherein, each test case has a unique identifier; different types of test cases correspond to different weight values; different levels of test cases correspond to different weighting values; Based on the unique identifier of the test case, the test case and the code are bidirectionally bound during the testing process; The graph model is weighted and colored based on the execution data to form a weighted link graph; wherein the nodes of the link graph are business functions, and the link graph includes business function information, call relationships and weighting information.
[0044] Preferably, the key subgraph partitioning module 403 is specifically used for: Based on the calling relationship and the weighting information, calculate the intermediary centrality of the nodes in the link graph; Based on the intermediary centrality of the nodes, key nodes are identified, and key subgraphs are divided based on the key nodes.
[0045] Preferably, the change risk assessment module 404 is specifically used for: Based on the domain radius of the key nodes in the key subgraph, an iterative convergence calculation is performed to determine the maximum weighted value for risk assessment. The weighted values are normalized to obtain the risk assessment value of the code change.
[0046] Preferably, the device further includes a knowledge update module, used for: Based on the call chain and topology information of the key nodes, determine the scope of impact of the code change; A knowledge base is constructed based on the link graph and the key subgraphs, and then visualized.
[0047] In specific implementation, the working principle, control process and technical effects of the code change risk assessment device provided in this embodiment of the invention are the same as those of the code change risk assessment method in the above embodiments, and will not be repeated here.
[0048] Please see Figure 5 , Figure 5 This is a schematic diagram of a preferred embodiment of a terminal device provided by the present invention. The terminal device includes a processor 501, a memory 502, and a computer program stored in the memory 502 and configured to be executed by the processor 501. When the processor 501 executes the computer program, it implements the code change risk assessment method described in any of the above embodiments.
[0049] Preferably, the computer program can be divided into one or more modules / units (such as computer program 1, computer program 2, ...), and the one or more modules / units are stored in the memory 502 and executed by the processor 501 to complete the present invention. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.
[0050] The processor 501 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor 501 may be any conventional processor. The processor 501 is the control center of the terminal device, connecting various parts of the terminal device through various interfaces and lines.
[0051] The memory 502 mainly includes a program storage area and a data storage area. The program storage area can store the operating system, applications required for at least one function, etc., and the data storage area can store related data, etc. In addition, the memory 502 can be a high-speed random access memory, or a non-volatile memory, such as a plug-in hard disk, a smart media card (SMC), a secure digital card (SD), and a flash card, etc., or the memory 502 can also be other volatile solid-state storage devices.
[0052] It should be noted that the aforementioned terminal devices may include, but are not limited to, processors and memory, as will be understood by those skilled in the art. Figure 5 The structural diagram is merely an example of the terminal device described above and does not constitute a limitation on the terminal device described above. It may include more or fewer components than shown in the diagram, or combine certain components, or use different components.
[0053] This invention also provides a computer-readable storage medium, which includes a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the code change risk assessment method described in any of the above embodiments.
[0054] This invention also provides a computer program product, which includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, they implement the code change risk assessment method described in any of the above embodiments.
[0055] This invention provides a method, apparatus, device, medium, and computer program product for assessing code change risks. It involves acquiring the code of a system under test, constructing a graph model based on code call chains according to code changes, executing test cases on the system under test, and weighting the graph model based on the execution data to form a weighted link graph. The invention then calculates the betweenness centrality based on the link graph and divides the graph into key subgraphs based on the betweenness centrality. Finally, it iterative convergence calculations are performed on the key subgraphs to obtain the risk assessment value for the code change. This invention achieves weighted analysis of the actual call chain records and code logic topology of code changes through the testing process of test cases, and introduces betweenness centrality to provide a unified quantitative measure of code change risk, thereby improving the efficiency and accuracy of code change risk assessment.
[0056] It should be noted that the system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the system embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0057] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for assessing the risk of code changes, characterized in that, include: Obtain the code of the system under test, and construct a graph model based on the code call chain according to the changes in the code; Test cases are executed on the system under test, and the graph model is weighted based on the execution data to form a weighted link graph; The intermediary centrality is calculated based on the link graph, and the key subgraph is partitioned according to the intermediary centrality; The risk assessment value of the code change is obtained by iteratively converging the key subgraph.
2. The code change risk assessment method as described in claim 1, characterized in that, The process of acquiring the code of the system under test and constructing a graph model based on the code call chain according to the changes in the code includes: Obtain the code of the system under test, analyze the changed business functions and the addition or deletion of code that changed the functions, and filter the annotations and blank lines in the code to form a set of changed business functions; The business function set is subjected to syntactic analysis based on the abstract syntax tree to construct a preliminary syntax structure tree; Based on the syntax structure tree and ASM bytecode, a graph model based on the code call chain is constructed.
3. The code change risk assessment method as described in claim 1, characterized in that, The step of executing test cases on the system under test and weighting the graph model based on the execution data to form a weighted link graph includes: Test cases are executed on the system under test, and probe instrumentation is performed; wherein, each test case has a unique identifier; different types of test cases correspond to different weight values; different levels of test cases correspond to different weighting values; Based on the unique identifier of the test case, the test case and the code are bidirectionally bound during the testing process; The graph model is weighted and colored based on the execution data to form a weighted link graph; wherein the nodes of the link graph are business functions, and the link graph includes business function information, call relationships and weighting information.
4. The code change risk assessment method as described in claim 3, characterized in that, The step of calculating the betweenness centrality based on the link graph and partitioning the key subgraph according to the betweenness centrality includes: Based on the calling relationship and the weighting information, calculate the intermediary centrality of the nodes in the link graph; Based on the intermediary centrality of the nodes, key nodes are identified, and key subgraphs are divided based on the key nodes.
5. The code change risk assessment method as described in claim 4, characterized in that, The iterative convergence calculation of the key subgraph to obtain the risk assessment value of the code change includes: Based on the domain radius of the key nodes in the key subgraph, an iterative convergence calculation is performed to determine the maximum weighted value for risk assessment. The weighted values are normalized to obtain the risk assessment value of the code change.
6. The code change risk assessment method as described in claim 5, characterized in that, The method further includes: Based on the call chain and topology information of the key nodes, determine the scope of impact of the code change; A knowledge base is constructed based on the link graph and the key subgraphs, and then visualized.
7. A code change risk assessment device, characterized in that, include: The graph model construction module is used to obtain the code of the system under test and construct a graph model based on the code call chain according to the changes in the code. The weighted link graph module is used to execute test cases on the system under test and to weight the graph model based on the execution data to form a weighted link graph. A key subgraph partitioning module is used to calculate the intermediary centrality based on the link graph and partition the key subgraph according to the intermediary centrality; The risk assessment module is used to perform iterative convergence calculations on the key subgraph to obtain the risk assessment value of the code change.
8. A terminal device, characterized in that, The device includes a processor and a memory, wherein the memory stores a computer program and the computer program is configured to be executed by the processor, wherein the processor, when executing the computer program, implements the code change risk assessment method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the device containing the computer-readable storage medium executes the computer program, it implements the code change risk assessment method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, The computer program product includes a computer program or computer instructions, which, when executed by a processor, implement the code change risk assessment method as described in any one of claims 1 to 6.