Configuration item error determination method and related device
By constructing program statements that determine the correlation between configuration items by program dependency graphs and slice operations, finding overlapping statements and determining the association syntax rules based on them, the problem of difficult to verify the correlation error of configuration items in the prior art is solved, and a comprehensive verification of configuration items syntax errors is achieved.
Patent Information
- Application Number
- CN202411742639.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-18
AI Technical Summary
The prior art is difficult to determine the correlation errors between configuration items, especially the difficulty in performing error verification according to the association syntax rules.
By obtaining the source code and reading points of the configuration item, building a program dependency graph, slicing operations determine the program statement associated with the configuration item, finding the overlapping statement, determining the association syntax rules based on the overlapping statement, and performing verification to determine the syntax error of the configuration item.
It realizes effective verification of syntax errors of configuration items with associated relationships, expands the dimension of configuration item syntax rules, and improves the comprehensiveness of configuration item error determination.
Smart Images

Figure CN119645808A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a configuration item error determination method and related devices. Background Art
[0002] With the rapid development of computer technology, more and more systems use a large number of configuration items in the source code to improve their flexibility. These configuration items allow users to adjust the operating status of the system without modifying the source code. However, even if the program code and the data input into the program code are correct, if there are errors in the configuration items, the program will still not run properly. Therefore, it is particularly important to identify configuration item errors in the program code.
[0003] In the related art, some configuration diagnosis systems can usually be used to verify simple configuration items, such as performing basic format checks and parameter range verification on individual configuration items.
[0004] However, the above method is difficult to determine the association grammar rules between the configuration items with association relationships, and it is even more difficult to perform error checking based on the association grammar rules. Summary of the invention
[0005] In view of the above problems, the present application provides a configuration item error determination method and related devices, which are used to solve the problem that it is difficult to verify the correlation errors of configuration items.
[0006] Based on this, this application discloses the following technical solutions:
[0007] In a first aspect, an embodiment of the present application provides a method for determining a configuration item error, the method comprising:
[0008] Acquire a source code including a plurality of configuration items and configuration item reading points corresponding to the plurality of configuration items respectively;
[0009] Constructing a program dependency graph for the source code, wherein the program dependency graph is used to characterize the relationship between program statements;
[0010] According to the configuration item reading points respectively corresponding to the configuration items, the program dependency graph is sliced to determine the program statements respectively associated with the configuration items;
[0011] For a first configuration item and a second configuration item among the plurality of configuration items, determining overlapping statements between a program statement associated with the first configuration item and a program statement associated with the second configuration item;
[0012] An associated grammatical rule between the first configuration item and the second configuration item is determined according to the overlapping statements, so as to perform verification according to the associated grammatical rule to determine grammatical errors of the configuration items having an associated relationship.
[0013] Optionally, the slicing operation includes a first slicing operation and a second slicing operation, the program dependency graph includes a control dependency graph and a data dependency graph, the control dependency graph is used to characterize the relationship between control flow statements, the data dependency graph is used to characterize the relationship between data flow statements, and the slicing operation on the program dependency graph according to the configuration item reading points respectively corresponding to the configuration items to determine the program statements respectively associated with the configuration items includes:
[0014] According to the configuration item reading points respectively corresponding to the configuration items, a first slicing operation is performed on the program dependency graph to determine initial program statements respectively associated with the configuration items, wherein the first slicing operation is used to divide the initial program statements related to the configuration items according to the configuration item reading points;
[0015] A second slicing operation is performed on the initial program statements corresponding to each of the configuration items to determine the program statements associated with each of the configuration items, wherein the second slicing operation is used to remove data flow statements whose occurrence frequency is less than a preset threshold.
[0016] Optionally, performing a second slicing operation on the initial program statements corresponding to the respective configuration items to determine the program statements associated with the respective configuration items includes:
[0017] Performing a second slicing operation on the initial program statements corresponding to the configuration items to determine the program statements not including the weights that are associated with the configuration items;
[0018] Assigning weights to program statements not including weights respectively associated with each of the configuration items, to obtain program statements including weights respectively associated with each of the configuration items, wherein the higher the importance of the program statement, the higher the weight of the program statement, the importance of the control flow statement is greater than the importance of the data flow statement, and the higher the occurrence frequency of the data flow statement, the higher the importance of the data flow statement;
[0019] The determining, according to the overlapping statements, an associated grammar rule between the first configuration item and the second configuration item comprises:
[0020] Determining the total weight of the overlapping sentences according to the weights respectively corresponding to the overlapping sentences;
[0021] According to the ratio of the total weight of the overlapping statements to the number of program statements associated with the first configuration item, the association score corresponding to the association grammar rule between the second configuration item and the first configuration item is determined, so that when there are multiple association grammar rules between the first configuration item and multiple configuration items, the verification order of the association grammar rules is determined according to the association score, and the higher the association score, the higher the verification order of the association grammar rule corresponding to the association score.
[0022] Optionally, the method further comprises:
[0023] Obtaining an environment configuration manual and a statement processing model, wherein the environment configuration manual includes statements describing the dependency relationship between the configuration items and the operating environment during operation, and the statement processing model is used to identify statements in the environment configuration manual that record configuration item constraints;
[0024] Identify the environment configuration manual and determine the associated statements of the target configuration items;
[0025] According to the association statement, the statement processing model is used to process the statement to obtain a constraint statement recording the constraint condition of the target configuration item;
[0026] Performing feature extraction on the constraint statement to obtain a semantic rule corresponding to the target configuration item, wherein the semantic rule is used to describe a constraint condition corresponding to the target configuration item in the operating environment;
[0027] The target configuration item is verified according to the verification function corresponding to the semantic rule, so as to determine the environment error of the target configuration item.
[0028] Optionally, the reading point of the configuration item is determined in the following manner:
[0029] Acquire a mapping relationship between the configuration item and the configuration variable, and a configuration file including a plurality of the configuration items in the source code;
[0030] Generate an abstract syntax tree for the configuration file, identify the abstract syntax tree, and obtain each of the configuration items;
[0031] Determine the configuration variables corresponding to each of the configuration items according to the mapping relationship;
[0032] The reading points corresponding to the respective configuration items are determined according to the calling positions of the configuration variables corresponding to the respective configuration items.
[0033] In a second aspect, an embodiment of the present application provides a configuration item error determination device, the device comprising: an acquisition unit, a construction unit, and a determination unit;
[0034] The acquisition unit is used to acquire a source code including a plurality of configuration items and configuration item reading points corresponding to the plurality of configuration items respectively;
[0035] The construction unit is used to construct a program dependency graph for the source code, wherein the program dependency graph is used to characterize the relationship between program statements;
[0036] The determining unit is used to slice the program dependency graph according to the configuration item reading points corresponding to the configuration items, and determine the program statements associated with the configuration items;
[0037] The determining unit is further configured to determine, for a first configuration item and a second configuration item among the plurality of configuration items, overlapping statements between a program statement associated with the first configuration item and a program statement associated with the second configuration item;
[0038] The determining unit is further configured to determine an associated grammatical rule between the first configuration item and the second configuration item according to the overlapping statement, so as to perform verification according to the associated grammatical rule to determine grammatical errors of the configuration items having an associated relationship.
[0039] Optionally, the determining unit is specifically configured to:
[0040] According to the configuration item reading points respectively corresponding to the configuration items, a first slicing operation is performed on the program dependency graph to determine initial program statements respectively associated with the configuration items, wherein the first slicing operation is used to divide the initial program statements related to the configuration items according to the configuration item reading points;
[0041] A second slicing operation is performed on the initial program statements corresponding to each of the configuration items to determine the program statements associated with each of the configuration items, wherein the second slicing operation is used to remove data flow statements whose occurrence frequency is less than a preset threshold.
[0042] In a third aspect, an embodiment of the present application provides a computer device, wherein the computer device includes a processor and a memory:
[0043] The memory is used to store a computer program and transmit the computer program to the processor;
[0044] The processor is configured to execute the method according to the first aspect of claim 1 according to the computer program.
[0045] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method described in the first aspect above.
[0046] In a fifth aspect, an embodiment of the present application provides a computer program product comprising a computer program, which, when executed on a computer device, enables the computer device to execute the method described in the first aspect above.
[0047] It can be seen from the above technical solutions that the present application has at least the following beneficial effects:
[0048] Obtain source code including multiple configuration items, and configuration item reading points corresponding to the multiple configuration items. Construct a program dependency graph for characterizing the relationship between program statements for the source code. According to the configuration item reading points corresponding to each configuration item, slice the program dependency graph to determine the program statements associated with each configuration item. For a first configuration item and a second configuration item among the multiple configuration items, determine the overlapping statements between the program statement associated with the first configuration item and the program statement associated with the second configuration item. Determine the association grammar rule between the first configuration item and the second configuration item based on the overlapping statements, so as to verify according to the association grammar rule and determine the grammatical errors of the configuration items with the association relationship. Thus, determining the association grammar rule based on the overlapping statements before the configuration items can facilitate the determination of the association errors of the configuration items based on the association grammar rule, expand the dimension of the configuration item grammar rule, and improve the comprehensiveness of the configuration item error determination. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0050] Figure 1 A flowchart of a method for determining a configuration item error provided in an embodiment of the present application;
[0051] Figure 2 An overall framework diagram of a software program configuration detection device provided in an embodiment of the present application;
[0052] Figure 3 A schematic diagram of a software program configuration error detection device flow provided in an embodiment of the present application;
[0053] Figure 4 A schematic diagram of a configuration unit flow chart provided in an embodiment of the present application;
[0054] Figure 5 A schematic diagram of the structure of a grammar rule inference device provided in an embodiment of the present application;
[0055] Figure 6A schematic diagram of a flow chart of a configuration item slicing operator provided in an embodiment of the present application;
[0056] Figure 7 A schematic diagram of a flow chart of a common grammar rule inference element provided in an embodiment of the present application;
[0057] Figure 8 A schematic diagram of a flow chart of an associative grammar rule inference element provided in an embodiment of the present application;
[0058] Fig. 9 A flowchart of a semantic rule inference component provided in an embodiment of the present application;
[0059] Fig.10 A schematic diagram of a flow chart of configuring a detection unit provided in an embodiment of the present application;
[0060] Fig.11 A schematic diagram of the structure of a configuration item error determination device provided in an embodiment of the present application;
[0061] Fig.12 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not intended to limit the scope of protection of the present application.
[0063] As mentioned in the background technology, the related technology can often only verify simple configuration items, such as basic format checking and parameter range verification for individual configuration items, and cannot determine and verify correlation errors between multiple configuration items with correlation relationships.
[0064] Based on this, the embodiment of the present application provides a configuration item error determination method and related devices, which obtain source code including multiple configuration items and configuration item reading points corresponding to the multiple configuration items. A program dependency graph for characterizing the relationship between program statements is constructed for the source code. According to the configuration item reading points corresponding to each configuration item, the program dependency graph is sliced to determine the program statements associated with each configuration item. For the first configuration item and the second configuration item in the multiple configuration items, the overlapping statements between the program statement associated with the first configuration item and the program statement associated with the second configuration item are determined. According to the overlapping statements, the association grammar rules between the first configuration item and the second configuration item are determined so as to verify according to the association grammar rules and determine the grammatical errors of the configuration items with the association relationship. Thus, the association grammar rules are determined according to the overlapping statements before the configuration items, which can facilitate the determination of the association errors of the configuration items according to the association grammar rules, expand the dimension of the configuration item grammar rules, and improve the comprehensiveness of the configuration item error determination.
[0065] The configuration item error determination method provided in this application can be applied to computer devices with data processing capabilities, such as terminal devices and servers. Specifically, the terminal device can be a desktop computer, a laptop computer, a mobile phone, and a tablet computer; the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. The terminal device and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.
[0066] See also Figure 1 , which is a flow chart of a configuration item error determination method provided in an embodiment of the present application. For ease of description, the following embodiment is introduced by taking the execution subject of the configuration item error determination method as a server as an example. Figure 1 As shown, the method includes S101-S105.
[0067] S101: Acquire source code including a plurality of configuration items and configuration item reading points respectively corresponding to the plurality of configuration items.
[0068] Source code is uncompiled program code, including multiple configuration items. Configuration items refer to parameters or options used to configure the system, application or software, which are used to control the behavior of the system or application to meet specific requirements or achieve specific functions. For example, configuration items can be port numbers, paths, maximum number of connections, etc. These configuration items are often defined in configuration files and are read and used when the program is running.
[0069] A configuration item read point refers to the location where a configuration item is read in the source code, usually an assignment statement for a variable or a function call.
[0070] In a possible implementation, the read point of the configuration item is determined as follows:
[0071] Obtain the mapping relationship between configuration items and configuration variables, and the configuration file including multiple configuration items in the source code. Generate an abstract syntax tree for the configuration file, identify the abstract syntax tree, and obtain each configuration item. Determine the configuration variables corresponding to each configuration item according to the mapping relationship. Determine the reading point corresponding to each configuration item according to the call position of the configuration variable corresponding to each configuration item.
[0072] In the source code, the name of the configuration item is passed as a parameter to the configuration item calling method. This name is usually passed in as a variable, which is a configuration variable. There is a mapping relationship between the configuration item and the configuration variable. The abstract syntax tree is a tree-like data structure used to represent the syntax structure of program code. The abstract syntax tree parses the source code into a tree structure, and each node represents a syntax element, such as a variable declaration, assignment statement, etc.
[0073] Therefore, by generating an abstract syntax tree and identifying the configuration file, the reading point of the configuration item can be accurately located according to the mapping relationship between the configuration item and the configuration variable, thereby improving the accuracy and efficiency of the configuration error determination process.
[0074] S102: Construct a program dependency graph for the source code.
[0075] A program dependency graph (CDG) is a directed graph used to represent the relationship between program statements. A program dependency graph usually includes a control dependency graph (CDG) and a data dependency graph (DFG). Each node represents a program statement (control flow statement or data flow statement), and an edge represents a control dependency relationship or a data dependency relationship.
[0076] For example, a control dependency can be a node B control dependency on another node A, that is, the execution result of A determines whether B will be executed. A data dependency can be a node B data dependency on another node A, that is, the execution result of A is used by B.
[0077] As an implementation method, the source code can be parsed by a lexical analyzer and a syntax analyzer to respectively construct a control dependency graph and a data dependency graph corresponding to the source code, thereby obtaining a program dependency graph corresponding to the source code.
[0078] S103: Slicing the program dependency graph according to the configuration item reading points corresponding to the configuration items, and determining the program statements associated with the configuration items.
[0079] Specifically, the reading position of the configuration item in the source code can be found from the program dependency graph according to the configuration item reading point, and a slicing operation is performed starting from the configuration item reading point to obtain various nodes related to the configuration item, thereby determining the program statement associated with the configuration item.
[0080] S104: For a first configuration item and a second configuration item among the multiple configuration items, determine overlapping statements between a program statement associated with the first configuration item and a program statement associated with the second configuration item.
[0081] Overlapping statements are statements that exist in program statements associated with multiple configuration items. Overlapping statements reflect the association relationship between the first configuration item and the second configuration item. Determining overlapping statements helps to discover the dependency relationship between the various configuration items.
[0082] For example, in the associated program statements corresponding to the first configuration item port and the second configuration item ip, "serverSocket.bind(new InetSocketAddress(ip,port));" is an overlapping statement.
[0083] S105: Determine an association grammar rule between the first configuration item and the second configuration item according to the overlapping statements, so as to perform verification according to the association grammar rule and determine grammatical errors of the configuration items having the association relationship.
[0084] The association grammar rule is used to represent the association constraints that should be satisfied between multiple configuration items. For example, the association grammar rule can be "serverSocket.bind(new InetSocketAddress(ip,port));", that is, if the first configuration item port is set to a certain value, the second configuration item ip must be set to a valid IP address, and the first configuration item port and the second ip must be set at the same time, and one of them cannot be set separately.
[0085] As an implementation method, the associated grammar rules may be directly determined through overlapping sentences, or feature analysis may be performed on overlapping sentences, and the associated grammar rules may be determined based on the feature analysis results.
[0086] Therefore, the configuration items can be checked by the associated grammar rules to determine the grammatical errors of the configuration items with associated relationships. For example, port is 8080, which is a valid port number, and ip is 127.0.0.1, which is a valid IP address. Port and ip are set at the same time, which meets the associated grammar rules. If they are not satisfied, an alarm message is issued, which includes the associated grammar rules that trigger the alarm and the corresponding associated configuration items.
[0087] It can be seen from the above technical solution that a source code including multiple configuration items and configuration item reading points corresponding to the multiple configuration items are obtained. A program dependency graph for characterizing the relationship between program statements is constructed for the source code. According to the configuration item reading points corresponding to each configuration item, a slice operation is performed on the program dependency graph to determine the program statements associated with each configuration item. For a first configuration item and a second configuration item among multiple configuration items, the overlapping statements between the program statement associated with the first configuration item and the program statement associated with the second configuration item are determined. According to the overlapping statements, the association grammar rules between the first configuration item and the second configuration item are determined so as to verify according to the association grammar rules and determine the grammatical errors of the configuration items with the association relationship. Thus, the association grammar rules are determined according to the overlapping statements before the configuration items, which can facilitate the determination of the association errors of the configuration items according to the association grammar rules, expand the dimension of the configuration item grammar rules, and improve the comprehensiveness of the configuration item error determination.
[0088] In a possible implementation, the slicing operation includes a first slicing operation and a second slicing operation, the program dependency graph includes a control dependency graph and a data dependency graph, the control dependency graph is used to characterize the relationship between control flow statements, and the data dependency graph is used to characterize the relationship between data flow statements. According to the configuration item reading points corresponding to each configuration item, the program dependency graph can be sliced through the following steps to determine the program statements associated with each configuration item:
[0089] According to the configuration item reading points corresponding to each configuration item, a first slicing operation is performed on the program dependency graph to determine the initial program statements associated with each configuration item. The first slicing operation is used to divide the initial program statements related to the configuration items according to the configuration item reading points.
[0090] A second slicing operation is performed on the initial program statements corresponding to each configuration item to determine the program statements associated with each configuration item. The second slicing operation is used to remove data flow statements whose occurrence frequency is less than a preset threshold.
[0091] Therefore, through the first slicing operation and the second slicing operation, data flow statements with low occurrence frequency are removed, and the noise interference of statements that have no effect on determining the association relationship on the overlapping statements is reduced, thereby improving the accuracy of the overlapping statements and the accuracy of the association grammar rules.
[0092] The present application also provides a method for granting rights to program statements:
[0093] A second slicing operation is performed on the initial program statements corresponding to the respective configuration items to determine the program statements not including the weights respectively associated with the respective configuration items.
[0094] Weights are assigned to program statements that do not include weights and are respectively associated with each configuration item, to obtain program statements that include weights and are respectively associated with each configuration item, wherein the higher the importance of a program statement, the higher the weight of the program statement, the importance of a control flow statement is greater than that of a data flow statement, and the higher the frequency of occurrence of a data flow statement, the higher the importance of the data flow statement.
[0095] The total weight of the overlapping sentences is determined according to the weights corresponding to the overlapping sentences respectively.
[0096] According to the ratio of the total weight of overlapping statements to the number of program statements associated with the first configuration item, the association score corresponding to the association grammar rule between the second configuration item and the first configuration item is determined, so that when there are multiple association grammar rules between the first configuration item and multiple configuration items, the verification order of the association grammar rules is determined according to the association score, and the higher the association score, the higher the verification order of the association grammar rule corresponding to the association score.
[0097] Specifically, the correlation score can be determined by the following formula:
[0098]
[0099] Among them, N AB is the association score corresponding to the association grammar rule between the first configuration item A and the second configuration item B, CountStatement(AB) is the number of overlapping statements between the first configuration item A and the second configuration item B, and w s is the total weight of the overlapping statements s, Statements(A) is the number of program statements associated with the first configuration item A.
[0100] Therefore, by slicing and weighting program statements, the association strength between configuration items is quantified, and the verification order of associated grammar rules is optimized, thereby improving the efficiency and accuracy of configuration item error determination.
[0101] In a possible implementation, the embodiment of the present application further provides a method for determining a semantic rule and determining an environmental error according to the semantic rule:
[0102] Obtain the environment configuration manual and statement processing model. The environment configuration manual refers to a document that contains the dependency relationship between configuration items and the operating environment during operation. The environment configuration manual includes statements that describe the dependency relationship between configuration items and the operating environment during operation. The statement processing model is used to identify statements in the environment configuration manual that record the constraints of configuration items.
[0103] The sentence processing model is obtained by training through natural language technology. For example, the sentence processing model may be a support vector machine (SVM).
[0104] Identify the environment configuration manual and determine the associated statements that record the target configuration item. The target configuration item is one of multiple configuration items. The associated statements are statements related to a configuration item, and these sentences describe the constraints of the configuration items. According to the associated statements, the statement processing model is used to process them to obtain the constraint statements that record the constraints of the target configuration items. Feature extraction is performed on the constraint statements to obtain the semantic rules corresponding to the target configuration items. The semantic rules are rules that describe the constraints corresponding to the configuration items in the running environment.
[0105] According to the verification function corresponding to the semantic rule, the target configuration item is verified to determine the environment error of the target configuration item. For example, the bind() function can be used to determine whether the port configured by the user is occupied.
[0106] Therefore, the constraints of the configuration item on the operating environment can be verified through the semantic rules determined by the statement processing model to determine the configuration item environment error, thereby improving the comprehensiveness of the configuration item error determination.
[0107] The following is an example of an actual application scenario of the configuration item error determination method:
[0108] See also Figure 2 , Figure 2 The overall framework diagram of a software program configuration detection device provided in an embodiment of the present application. Among them, with the source code and configuration file path as input, the configuration parsing unit is mainly used to parse the configuration file to obtain the information of the configuration item, as well as the configuration variables and configuration item reading points corresponding to it in the source code. The configuration rule inference unit receives the configuration item related information sent by the previous unit and can mine the grammatical rules and semantic rules of the configuration item. The configuration error detection unit receives the grammatical rules and semantic rules to check the correctness of the configuration item to detect the configuration error, and outputs a configuration error report to provide modification suggestions.
[0109] Specifically, see Figure 3 , Figure 3 A flowchart of a software program configuration error detection device provided by an embodiment of the present application. The configuration file parsing unit first finds the configuration file in the source code according to the input configuration file path, generates an abstract syntax tree according to the configuration file, identifies all configuration items in the syntax tree, obtains the name, parameter, type and other information of the configuration item, locates the declaration statement of the configuration variable in the code according to the configuration item name to obtain the configuration variable corresponding to the configuration item, realizes the mapping of the configuration item and the configuration variable, finds the configuration item call location according to the configuration item and the configuration variable to locate the configuration item reading point in the code, and the configuration parsing unit transmits the obtained configuration item information, configuration variables, and configuration reading point to the configuration rule inference unit for configuration rule mining.
[0110] The configuration rule inference unit receives the configuration item information, configuration variables and configuration reading points from the configuration parsing unit, takes the configuration item reading point as the starting point, extracts the data flow and control flow of the configuration item to obtain the value range, associated information and data type of the configuration item, and mines the grammatical rules of the configuration item from this information; processes the user manual and collects the semantic information of the configuration item, and infers the semantic rules based on this information. The configuration rule inference unit transmits the grammatical rules and semantic rules to the configuration error detection unit for configuration error detection.
[0111] The configuration error detection unit receives the syntax and semantic rules sent by the configuration rule inference unit to check the configuration items, and outputs a configuration error report to provide modification suggestions. Users can modify the configuration according to this report to troubleshoot the problem.
[0112] See also Figure 4 , Figure 4 A flow chart of a configuration parsing unit provided in an embodiment of the present application. The configuration file is found in the source code according to the input configuration file path. The abstract syntax tree generator generates an abstract syntax tree according to the configuration file. The configuration item identifier first determines all configuration classes based on the abstract syntax tree, identifies the configuration items, and obtains the configuration item information. The configuration variable mapper receives the configuration item information from the configuration item identifier, locates the configuration variable declaration statement in the code, and maps the configuration item into a configuration variable. The configuration read point locator receives the configuration item and the configuration variable, identifies the configuration read point call position, and locates the configuration item read point.
[0113] See also Figure 5 , Figure 5 A schematic diagram of the structure of a grammar rule inference device provided in an embodiment of the present application. The grammar rule inference device is composed of a configuration item slicing operator, a general rule inference element, and an association rule inference element.
[0114] See also Figure 6 , Figure 6 A flow chart of a configuration item slicing operator provided for an embodiment of the present application. The configuration item slicing operator is used to slice the configuration item program (first slicing operation), and to prune and weight the statements in the slice (second slicing operation), prune unnecessary initialization statements and outputs, etc., and weight important statements such as arithmetic operations and branch conditions. Slicing refers to program statements related to configuration items extracted from program source code. The processed streamlined slices will be passed to the general rule inference element and the association rule inference element.
[0115] See also Figure 7 , Figure 7 A schematic diagram of a flow chart of a common grammar rule inference component provided in an embodiment of the present application. The common grammar rule inference component is used to mine common configuration rules of configuration items, including data types, value ranges, and string formats.
[0116] See also Figure 8 , Figure 8 A flow chart of an association grammar rule inference element provided for an embodiment of the present application. The association rule inference element is used to mine the association relationship between configuration items. If the same program statement exists in the program statement associated with some configuration items, it means that the control flow or data flow of some configuration items overlaps, that is, there is an association between the configuration items. The association relationship and rules between the configuration items are inferred by calculating the association score between the configuration items. When there is an overlapping statement between configuration item A and configuration item B, the total number of overlapping statements in the control flow or data flow of the two configuration items is recorded, and the association score between configuration item A and configuration item B is calculated according to the weight of the overlapping statement. If there is no overlap between them, the configuration item A is calculated with the next configuration item C for the association score, and so on.
[0117] See also Fig. 9 , Fig. 9 A flowchart of a semantic rule inference component provided in an embodiment of the present application. The semantic rule inference component uses natural language processing technology to extract environment-related configuration information from a user manual (an environment configuration manual), processes it into usable semantic information, and uses the processed semantic information to infer the semantic rules of the configuration items.
[0118] See also Fig.10 , Fig.10 A flow chart of a configuration detection unit provided in an embodiment of the present application. The grammatical error detector and the semantic error detector in the configuration detection unit respectively receive the grammatical rules and semantic rules transmitted from the configuration rule inference unit to check the configuration items, and finally output a configuration error report.
[0119] See also Fig.11 , Fig.11 A configuration item error determination device provided in an embodiment of the present application, the device 1100 includes: an acquisition unit 1101, a construction unit 1102 and a determination unit 1103;
[0120] The acquisition unit 1101 is used to acquire source code including multiple configuration items and configuration item reading points corresponding to the multiple configuration items respectively;
[0121] The construction unit 1102 is used to construct a program dependency graph for the source code, wherein the program dependency graph is used to represent the relationship between program statements;
[0122] The determining unit 1103 is used to slice the program dependency graph according to the configuration item reading points corresponding to the configuration items, and determine the program statements associated with the configuration items;
[0123] The determining unit 1103 is further configured to determine, for a first configuration item and a second configuration item among the plurality of configuration items, overlapping statements between a program statement associated with the first configuration item and a program statement associated with the second configuration item;
[0124] The determining unit 1103 is further configured to determine an associated grammatical rule between the first configuration item and the second configuration item according to the overlapping statements, so as to perform verification according to the associated grammatical rule to determine grammatical errors of the configuration items having an associated relationship.
[0125] As can be seen from the above technical solution, the acquisition unit acquires source code including multiple configuration items and configuration item reading points corresponding to the multiple configuration items. The construction unit constructs a program dependency graph for characterizing the relationship between program statements for the source code. The determination unit slices the program dependency graph according to the configuration item reading points corresponding to each configuration item, and determines the program statements associated with each configuration item. For the first configuration item and the second configuration item in the multiple configuration items, the determination unit determines the overlapping statements between the program statement associated with the first configuration item and the program statement associated with the second configuration item. The determination unit determines the association grammar rule between the first configuration item and the second configuration item according to the overlapping statements, so as to verify according to the association grammar rule and determine the grammatical errors of the configuration items with the association relationship. Thus, the association grammar rule is determined according to the overlapping statements before the configuration items, which can facilitate the determination of the association errors of the configuration items according to the association grammar rule, expand the dimension of the configuration item grammar rule, and improve the comprehensiveness of the configuration item error determination.
[0126] As a possible implementation manner, the determining unit is specifically configured to:
[0127] According to the configuration item reading points respectively corresponding to the configuration items, a first slicing operation is performed on the program dependency graph to determine initial program statements respectively associated with the configuration items, wherein the first slicing operation is used to divide the initial program statements related to the configuration items according to the configuration item reading points;
[0128] A second slicing operation is performed on the initial program statements corresponding to each of the configuration items to determine the program statements associated with each of the configuration items, wherein the second slicing operation is used to remove data flow statements whose occurrence frequency is less than a preset threshold.
[0129] As a possible implementation manner, the determining unit is specifically configured to:
[0130] Performing a second slicing operation on the initial program statements corresponding to the configuration items to determine the program statements not including the weights that are associated with the configuration items;
[0131] Assigning weights to program statements not including weights respectively associated with each of the configuration items, to obtain program statements including weights respectively associated with each of the configuration items, wherein the higher the importance of the program statement, the higher the weight of the program statement, the importance of the control flow statement is greater than the importance of the data flow statement, and the higher the occurrence frequency of the data flow statement, the higher the importance of the data flow statement;
[0132] Determining the total weight of the overlapping sentences according to the weights respectively corresponding to the overlapping sentences;
[0133] According to the ratio of the total weight of the overlapping statements to the number of program statements associated with the first configuration item, the association score corresponding to the association grammar rule between the second configuration item and the first configuration item is determined, so that when there are multiple association grammar rules between the first configuration item and multiple configuration items, the verification order of the association grammar rules is determined according to the association score, and the higher the association score, the higher the verification order of the association grammar rule corresponding to the association score.
[0134] As a possible implementation manner, the device further includes an environment error determination unit, configured to:
[0135] Obtaining an environment configuration manual and a statement processing model, wherein the environment configuration manual includes statements describing the dependency relationship between the configuration items and the operating environment during operation, and the statement processing model is used to identify statements in the environment configuration manual that record configuration item constraints;
[0136] Identify the environment configuration manual and determine the associated statements of the target configuration items;
[0137] According to the association statement, the statement processing model is used to process the statement to obtain a constraint statement recording the constraint condition of the target configuration item;
[0138] Performing feature extraction on the constraint statement to obtain a semantic rule corresponding to the target configuration item, wherein the semantic rule is used to describe a constraint condition corresponding to the target configuration item in the operating environment;
[0139] The target configuration item is verified according to the verification function corresponding to the semantic rule, so as to determine the environment error of the target configuration item.
[0140] As a possible implementation manner, the acquisition unit is specifically used to:
[0141] Acquire a mapping relationship between the configuration item and the configuration variable, and a configuration file including a plurality of the configuration items in the source code;
[0142] Generate an abstract syntax tree for the configuration file, identify the abstract syntax tree, and obtain each of the configuration items;
[0143] Determine the configuration variables corresponding to each of the configuration items according to the mapping relationship;
[0144] The reading points corresponding to the respective configuration items are determined according to the calling positions of the configuration variables corresponding to the respective configuration items.
[0145] See also Fig.12 , the embodiment of the present application further provides a computer device, the computer device comprising a memory 1201 and a processor 1202:
[0146] The memory is used to store a computer program and transmit the computer program to the processor;
[0147] The processor is configured to execute the method of the above method embodiment according to the computer program.
[0148] An embodiment of the present application further provides a computer-readable storage medium, characterized in that the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method of the above method embodiment.
[0149] The embodiment of the present application also provides a computer program product including a computer program, which, when executed on a computer device, enables the computer device to execute the method of the above method embodiment.
[0150] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0151] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0152] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0153] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0154] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0155] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for determining a configuration item error, characterized in that: The method comprises: Acquire a source code including a plurality of configuration items and configuration item reading points corresponding to the plurality of configuration items respectively; Constructing a program dependency graph for the source code, wherein the program dependency graph is used to characterize the relationship between program statements; According to the configuration item reading points respectively corresponding to the configuration items, the program dependency graph is sliced to determine the program statements respectively associated with the configuration items; For a first configuration item and a second configuration item among the plurality of configuration items, determining overlapping statements between a program statement associated with the first configuration item and a program statement associated with the second configuration item; An associated grammatical rule between the first configuration item and the second configuration item is determined according to the overlapping statements, so as to perform verification according to the associated grammatical rule to determine grammatical errors of the configuration items having an associated relationship.
2. The method according to claim 1, characterized in that: The slicing operation includes a first slicing operation and a second slicing operation, the program dependency graph includes a control dependency graph and a data dependency graph, the control dependency graph is used to characterize the relationship between control flow statements, the data dependency graph is used to characterize the relationship between data flow statements, and the slicing operation on the program dependency graph is performed according to the configuration item reading points respectively corresponding to the configuration items to determine the program statements respectively associated with the configuration items, including: According to the configuration item reading points respectively corresponding to the configuration items, a first slicing operation is performed on the program dependency graph to determine initial program statements respectively associated with the configuration items, wherein the first slicing operation is used to divide the initial program statements related to the configuration items according to the configuration item reading points; A second slicing operation is performed on the initial program statements corresponding to each of the configuration items to determine the program statements associated with each of the configuration items, wherein the second slicing operation is used to remove data flow statements whose occurrence frequency is less than a preset threshold.
3. The method according to claim 2, characterized in that The performing a second slicing operation on the initial program statements corresponding to the respective configuration items to determine the program statements associated with the respective configuration items includes: Performing a second slicing operation on the initial program statements corresponding to the configuration items to determine the program statements not including the weights that are associated with the configuration items; Assigning weights to program statements not including weights respectively associated with each of the configuration items, to obtain program statements including weights respectively associated with each of the configuration items, wherein the higher the importance of the program statement, the higher the weight of the program statement, the importance of the control flow statement is greater than the importance of the data flow statement, and the higher the occurrence frequency of the data flow statement, the higher the importance of the data flow statement; The determining, according to the overlapping statements, an associated grammar rule between the first configuration item and the second configuration item comprises: Determining the total weight of the overlapping sentences according to the weights respectively corresponding to the overlapping sentences; According to the ratio of the total weight of the overlapping statements to the number of program statements associated with the first configuration item, the association score corresponding to the association grammar rule between the second configuration item and the first configuration item is determined, so that when there are multiple association grammar rules between the first configuration item and multiple configuration items, the verification order of the association grammar rules is determined according to the association score, and the higher the association score, the higher the verification order of the association grammar rule corresponding to the association score.
4. The method according to claim 1, characterized in that: The method further comprises: Obtaining an environment configuration manual and a statement processing model, wherein the environment configuration manual includes statements describing the dependency relationship between the configuration items and the operating environment during operation, and the statement processing model is used to identify statements in the environment configuration manual that record configuration item constraints; Identify the environment configuration manual and determine the associated statements of the target configuration items; According to the association statement, the statement processing model is used to process the statement to obtain a constraint statement recording the constraint condition of the target configuration item; Performing feature extraction on the constraint statement to obtain a semantic rule corresponding to the target configuration item, wherein the semantic rule is used to describe a constraint condition corresponding to the target configuration item in the operating environment; The target configuration item is verified according to the verification function corresponding to the semantic rule, so as to determine the environment error of the target configuration item.
5. The method according to claim 1, characterized in that The read point of the configuration item is determined as follows: Acquire a mapping relationship between the configuration item and the configuration variable, and a configuration file including a plurality of the configuration items in the source code; Generate an abstract syntax tree for the configuration file, identify the abstract syntax tree, and obtain each of the configuration items; Determine the configuration variables corresponding to each of the configuration items according to the mapping relationship; The reading points corresponding to the respective configuration items are determined according to the calling positions of the configuration variables corresponding to the respective configuration items.
6. A configuration item error determination device, characterized in that: The device comprises: an acquisition unit, a construction unit and a determination unit; The acquisition unit is used to acquire a source code including a plurality of configuration items and configuration item reading points corresponding to the plurality of configuration items respectively; The construction unit is used to construct a program dependency graph for the source code, wherein the program dependency graph is used to characterize the relationship between program statements; The determining unit is used to slice the program dependency graph according to the configuration item reading points corresponding to the configuration items, and determine the program statements associated with the configuration items; The determining unit is further configured to determine, for a first configuration item and a second configuration item among the plurality of configuration items, overlapping statements between a program statement associated with the first configuration item and a program statement associated with the second configuration item; The determining unit is further configured to determine an associated grammatical rule between the first configuration item and the second configuration item according to the overlapping statement, so as to perform verification according to the associated grammatical rule to determine grammatical errors of the configuration items having an associated relationship.
7. The device according to claim 6, characterized in that The determining unit is specifically configured to: According to the configuration item reading points respectively corresponding to the configuration items, a first slicing operation is performed on the program dependency graph to determine initial program statements respectively associated with the configuration items, wherein the first slicing operation is used to divide the initial program statements related to the configuration items according to the configuration item reading points; A second slicing operation is performed on the initial program statements corresponding to each of the configuration items to determine the program statements associated with each of the configuration items, wherein the second slicing operation is used to remove data flow statements whose occurrence frequency is less than a preset threshold.
8. A computer device, characterized in that: The computer device comprises a processor and a memory: The memory is used to store a computer program and transmit the computer program to the processor; The processor is configured to execute the method according to any one of claims 1 to 6 according to the computer program.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 5.
10. A computer program product comprising a computer program, characterized in that When the method is executed on a computer device, the computer device is enabled to execute the method according to any one of claims 1 to 5.
Citation Information
Cited By
Newly-added configuration key identification method, deployment application system, electronic equipment and storage medium
CN121614199A