Account verification rule extraction method, device, equipment, storage medium and program product
By generating an abstract syntax tree and extracting the accounting rule table, the problems of low accounting testing efficiency and high error rate in financial transaction business migration are solved, and automated accounting testing is realized, which improves testing efficiency and reduces errors.
Patent Information
- Application Number
- CN202210517456.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-12
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2042-05-12
AI Technical Summary
During the migration of financial transaction business, the accounting testing efficiency is low and the error rate is high, mainly due to the strict requirements of manual testing.
By obtaining the target code, an abstract syntax tree is generated, and the accounting rules are extracted based on the subtree, the accounting rules table is constructed to realize automated accounting testing.
Fully automatic accounting testing is realized, which improves testing efficiency and avoids errors caused by manual operations.
Smart Images

Figure CN114841707B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology and can be applied to the financial field or other fields. Specifically, it relates to a method, apparatus, device, storage medium and program product for extracting accounting rules. Background Art
[0002] As the financial industry's business architecture transforms, trading operations originally running on mainframes (such as IBM mainframes) are gradually migrating to new platforms. To facilitate migration, the programs to be migrated need to undergo operations such as data decoupling. After data decoupling, the programs will change, so accounting testing (such as account verification) needs to be re-conducted.
[0003] Due to the complexity of transaction business, accounting testing is currently carried out manually, which places relatively harsh demands on testers and leads to problems such as low testing efficiency and high error rate. Summary of the Invention
[0004] In view of the above problems, the present disclosure provides a method, apparatus, device, storage medium and program product for extracting accounting rules.
[0005] According to a first aspect of the present disclosure, a method for extracting account verification rules is provided, comprising:
[0006] Get the object code;
[0007] Generate an abstract syntax tree according to the target code, wherein the abstract syntax tree includes at least one subtree, and each subtree is generated according to a target code block related to a target library table in the target code;
[0008] At least one verification rule is generated according to each subtree to obtain a verification rule table, and the verification rule table is used to verify the transactions to be verified.
[0009] According to an embodiment of the present disclosure, the target library table includes a first library table and a second library table, and generating an abstract syntax tree according to the target code includes:
[0010] Obtaining, from the target code, an assignment code related to the first library table;
[0011] Traverse upward from the assignment code to obtain a judgment condition code that belongs to the same code block as the assignment code and involves the second library table;
[0012] The target code block involving the target library table in the target code is determined according to the assignment code and the judgment condition code.
[0013] According to an embodiment of the present disclosure, each of the subtrees includes a first branch and a second branch, each of the first branch and the second branch includes a plurality of nodes having a parent-child relationship, and generating an abstract syntax tree according to the target code further includes:
[0014] Generating the first branch of the subtree according to the assignment code;
[0015] At least one second branch of the subtree is generated according to the judgment condition code.
[0016] Generating at least one accounting rule according to each of the subtrees includes:
[0017] At least one of the accounting rules is generated based on the leaf nodes in the first branch and at least one of the second branches.
[0018] According to an embodiment of the present disclosure, generating at least one of the verification rules according to the leaf nodes in the first branch and the second branch includes:
[0019] Extracting the verification field and the verification rule value according to the leaf node of the first branch;
[0020] Extracting an accounting rule key according to at least one leaf node of the second branch;
[0021] At least one of the accounting rules is generated according to the accounting field, the accounting rule value and the accounting rule key.
[0022] According to an embodiment of the present disclosure, the first library table includes a card issuance log table, the second library table includes a log separation parameter table, and generating at least one of the verification rules based on the verification field, the verification rule value, and the verification rule key includes:
[0023] Associating the card issuance log table with the log separation parameter table, and converting the format of the account verification rule key to generate an SQL statement;
[0024] The SQL statement is integrated with the accounting verification field and the accounting verification rule value to obtain at least one of the accounting verification rules.
[0025] According to an embodiment of the present disclosure, the leaf nodes in the first branch include objects and variables in the assignment code, and the leaf nodes in the second branch include objects and variables in the judgment condition code.
[0026] According to an embodiment of the present disclosure, generating an abstract syntax tree according to the target code further includes:
[0027] The root node of the subtree is generated according to the judgment operator of the judgment condition code in the first line in the target code block.
[0028] A second aspect of the present disclosure provides an account verification rule extraction device, comprising:
[0029] Acquisition module, used to obtain target code;
[0030] a processing module, configured to generate an abstract syntax tree according to the target code, wherein the abstract syntax tree includes at least one subtree, and each subtree is generated according to a target code block related to a target library table in the target code;
[0031] The generating module is configured to generate at least one verification rule according to each of the subtrees to obtain a verification rule table, wherein the verification rule table is used to verify the transactions to be verified.
[0032] The third aspect of the present disclosure provides an electronic device, comprising: one or more processors; a memory for storing one or more programs, wherein, when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned accounting rule extraction method.
[0033] The fourth aspect of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above-mentioned accounting verification rule extraction method.
[0034] The fifth aspect of the present disclosure further provides a computer program product, comprising a computer program, which implements the above-mentioned accounting verification rule extraction method when executed by a processor.
[0035] One or more of the above embodiments have the following advantages or beneficial effects:
[0036] By adopting the method for extracting account verification rules of the embodiment of the present disclosure, the account-related code can be extracted from the account-related program to obtain the target code, and then an abstract syntax tree is constructed based on the target code, and the account verification rules are extracted based on each subtree of the abstract syntax tree, and then a formatted account verification rule table is obtained, thereby realizing the automatic extraction of the account verification rules. Moreover, after the account verification rule table is extracted, the account verification rule table can be imported into the account verification platform. Since the account verification rule table has a standard format, it is possible to realize automatic account verification and other accounting tests. In other words, the method for extracting account verification rules based on the embodiment of the present disclosure is conducive to realizing fully automatic account testing, greatly improving the efficiency of the test, and avoiding problems such as errors caused by manual operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0038] Figure 1 A diagram schematically illustrates an application scenario of the method, device, electronic device, storage medium, and program product for extracting account verification rules according to an embodiment of the present disclosure;
[0039] Figure 2 A flowchart of a method for extracting accounting rules according to an embodiment of the present disclosure is schematically shown;
[0040] Figure 3 Schematically shows one of the flow charts for generating a grammar book according to an embodiment of the present disclosure;
[0041] Figure 4 Schematically shows the second flow chart of generating a grammar book according to an embodiment of the present disclosure;
[0042] Figure 5 Schematically shows a flow chart of extracting accounting verification rules according to an embodiment of the present disclosure;
[0043] Figure 6 A flowchart of extracting accounting rules based on leaf nodes in a first branch and at least one second branch according to an embodiment of the present disclosure is schematically shown;
[0044] Figure 7 The following schematically illustrates a flow chart for generating at least one verification rule based on a verification field, a verification rule value, and a verification rule key according to an embodiment of the present disclosure;
[0045] Figure 8 The following schematically shows a structural block diagram of an apparatus for extracting account verification rules according to an embodiment of the present disclosure;
[0046] Figure 9 A block diagram of an electronic device suitable for implementing the accounting verification rule extraction method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0047] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present disclosure. In the detailed description below, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0048] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise," "include," etc. used herein indicate the presence of the features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0049] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0050] When expressions such as "at least one of A, B and C, etc." are used, they should generally be interpreted in accordance with the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0051] It should be noted that the accounting verification rule extraction method, apparatus, electronic device, storage medium, and program product provided in this disclosure relate to the field of computer technology. The accounting verification rule extraction method, apparatus, electronic device, storage medium, and program product provided in the embodiments of this disclosure can be applied to the financial field or any field other than the financial field. For example, the accounting verification rule extraction method, apparatus, electronic device, storage medium, and program product provided in the embodiments of this disclosure can be applied to accounting testing services in the financial field. This disclosure does not limit the application fields of the accounting verification rule extraction method, apparatus, electronic device, storage medium, and program product.
[0052] In the technical solution disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure and application of user personal information involved comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.
[0053] An embodiment of the present disclosure provides a method for extracting accounting rules, which includes: obtaining target code; generating an abstract syntax tree based on the target code, the abstract syntax tree including at least one subtree, each subtree generated based on a target code block involving a target library table in the target code; generating at least one accounting rule based on each subtree to obtain an accounting rule table, the accounting rule table being used to perform accounting on transactions to be verified.
[0054] By adopting the method for extracting account verification rules of the embodiment of the present disclosure, the account-related code can be extracted from the account-related program to obtain the target code, and then an abstract syntax tree is constructed based on the target code, and the account verification rules are extracted based on each subtree of the abstract syntax tree, and then a formatted account verification rule table is obtained, thereby realizing the automatic extraction of the account verification rules. Moreover, after the account verification rule table is extracted, the account verification rule table can be imported into the account verification platform. Since the account verification rule table has a standard format, it is possible to realize automatic account verification and other accounting tests. In other words, the method for extracting account verification rules based on the embodiment of the present disclosure is conducive to realizing fully automatic account testing, greatly improving the efficiency of the test, and avoiding problems such as errors caused by manual operation.
[0055] Figure 1 The following schematically illustrates an application scenario diagram of the method, device, electronic device, storage medium, and program product for extracting accounting rules according to an embodiment of the present disclosure. Figure 1 As shown, the application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired or wireless communication links or optical fiber cables.
[0056] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0057] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0058] The server 105 may be a server that provides various services, such as a background management server (for example only) that supports websites browsed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process received data such as user requests, and feed back processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0059] It should be noted that the accounting verification rule extraction method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the accounting verification rule extraction device provided in the embodiment of the present disclosure can generally be set in the server 105. The accounting verification rule extraction method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the accounting verification rule extraction device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0060] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.
[0061] The following will be based on Figure 1 The scene described by Figures 2 to 7 The accounting verification rule extraction method of the disclosed embodiment is described in detail.
[0062] Figure 2 The flowchart of the method for extracting accounting rules according to an embodiment of the present disclosure is schematically shown. Figure 2 As shown, the accounting verification rule extraction method of this embodiment includes steps S210 to S230.
[0063] It should be noted that although Figure 2 The steps in the figure are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the figure may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0064] In step S210, the target code is obtained.
[0065] In the embodiment of the present disclosure, the transaction business running in the host can be divided into two parts, one is the end-of-day batch business module, and the other is the real-time online business module. At present, in order to realize the transfer of the transaction business in the host to the new platform, it is necessary to perform data decoupling on the account-related programs in the real-time online business module, while the account-related programs in the end-of-day batch business module do not need to be decoupled. For a transaction, the account-related operations in the end-of-day batch business module and the real-time online business module are roughly the same. Therefore, in the embodiment of the present disclosure, the code of the account-related program, that is, the target code, can be extracted from the end-of-day batch business module, and then the verification rules can be extracted based on the code, and then the decoupled account-related programs in the real-time online business module can be tested for accounting.
[0066] Optionally, the target code may include account-related code in an account-related program.
[0067] For example, the end-of-day batch business module is configured with an accounting-related program A1, and the real-time online business module is configured with an accounting-related program A2. Accounting-related program A1 and accounting-related program A2 perform the same transaction operations, but the difference is that accounting-related program A2 in the real-time online business module performs real-time settlement, while accounting-related program A1 in the end-of-day batch business module performs batch settlement at the end of the day. Therefore, the accounting-related code can be extracted from accounting-related program A1 to obtain the target code. Subsequently, accounting verification rule B1 is generated through steps S220 and S230. After data decoupling is performed on program A2 in the real-time online business module, accounting testing can be performed on the decoupled accounting-related program A2 using accounting verification rule B1.
[0068] Optionally, the target code may include languages such as C++, Java, and host Cobol, which can be determined according to actual needs and are not limited here.
[0069] In step S220, an abstract syntax tree is generated according to the target code. The abstract syntax tree includes at least one subtree. Each subtree is generated according to a target code block related to a target library table in the target code.
[0070] An abstract syntax tree (AST), also known as a syntax tree, is a concept in compiler theory. Its purpose is to represent an abstract grammatical structure in a tree-like form. Each non-leaf node in the tree represents an operator in the abstract syntax, while the leaf nodes represent specific objects in the AST. Using a syntax tree allows machines to understand the inherent meaning of the abstract syntax and the order in which it is executed.
[0071] In the disclosed embodiments, a transaction can be written into a code block according to the transaction logic. This code block can include code for assigning values to target database tables to achieve persistence of transaction results. Therefore, in the disclosed embodiments, the target code block involving the target database table can include code related to assigning values to the target database table. For example, the target code block can include code for determining conditions and code for assigning values after the conditions are met.
[0072] In the embodiment of the present disclosure, the transaction logic is implicit in the above-mentioned target code block. Therefore, a subtree of the abstract syntax tree can be generated based on the target code block, thereby expressing the transaction logic implicit in the target code block in a tree form, so that the computer can read and recognize it, and generate accounting rules based on these transaction logics.
[0073] Optionally, each subtree is generated according to a target code block involving a target library table in the target code.
[0074] In step S230, at least one verification rule is generated according to each subtree to obtain a verification rule table, which is used to verify the transactions to be verified.
[0075] In the disclosed embodiment, multiple subtrees can be generated, each corresponding to a code block. A corresponding accounting rule can then be generated for each subtree, thereby obtaining multiple accounting rules. The multiple accounting rules can then be integrated to form a formatted accounting rule table.
[0076] By adopting the method for extracting account verification rules of the embodiment of the present disclosure, the account-related code can be extracted from the account-related program to obtain the target code, and then an abstract syntax tree is constructed based on the target code, and the account verification rules are extracted based on each subtree of the abstract syntax tree, and then a formatted account verification rule table is obtained, thereby realizing the automatic extraction of the account verification rules. Moreover, after the account verification rule table is extracted, the account verification rule table can be imported into the account verification platform. Since the account verification rule table has a standard format, it is possible to realize automatic account verification and other accounting tests. In other words, the method for extracting account verification rules based on the embodiment of the present disclosure is conducive to realizing fully automatic account testing, greatly improving the efficiency of the test, and avoiding problems such as errors caused by manual operation.
[0077] The following combination Figures 2 to 7 The accounting verification rule extraction method of the embodiment of the present disclosure is further explained.
[0078] In some specific embodiments, the target library table includes a first library table, Figure 3 Schematically shows one of the flow charts for generating a grammar book according to an embodiment of the present disclosure, as shown in FIG. Figure 3 As shown, step S220 includes steps S221 to S223.
[0079] In step S221, the assignment code related to the first library table is obtained from the target code.
[0080] In the embodiment of the present disclosure, the first library table may be used as the first keyword to screen the target code, and the assignment code containing the first keyword may be found from the target code to obtain the assignment code involving the first library table.
[0081] For example, the first library table includes table B1, and the target code includes the assignment code "B1=A" for library table B1, that is, "A" is assigned to library table B1. At this time, the assignment code "B1=A" can be found from the target code to obtain the assignment code involving the first library table.
[0082] In step S222, traverse upward from the assignment code to obtain the judgment condition code that belongs to the same code block as the assignment code.
[0083] In a code block, the assignment code is preceded by the conditional code that implies the transaction logic. For example, a code block might include "if C NOT = D; B1 = A," where "B1 = A" is the assignment code and "if C NOT = D" is the conditional code. This means that when the value of C is D, "A" is assigned to table B1. Therefore, after finding the first code, you can traverse the conditional code upwards within the code block to which the first code belongs until you find all the conditional code, for example, the first line of code in the code block. This way, the conditional code you obtain will contain the entire transaction logic for a transaction.
[0084] In some specific embodiments, the target library table may further include a second library table, and step S222 includes: filtering the obtained judgment condition code according to the second library table to obtain the judgment condition code that belongs to the same code block as the assignment code and is for the second library table, so as to filter out useless information.
[0085] In the embodiment of the present disclosure, the second library table may be used as the second keyword to filter out the judgment condition codes containing the second keyword from the extracted judgment condition codes, thereby obtaining the final required judgment condition codes.
[0086] In step S223, the target code block involving the target library table in the target code is determined according to the assignment code and the judgment condition code.
[0087] In the embodiment of the present disclosure, the target code block obtained includes all the judgment conditions of a transaction (judgment condition code) and the transaction results after the judgment conditions are met (assignment code), so that the code used to implement the transaction and implicitly contains all the transaction logic can be found.
[0088] In some specific embodiments, each subtree includes a first branch and a second branch, and the first branch and the second branch each include a plurality of nodes having a parent-child relationship. Figure 4 The second flow chart of generating a grammar book according to an embodiment of the present disclosure is schematically shown. Figure 4 As shown, step S220 also includes step S224 and step S225.
[0089] In step S224, a first branch of the subtree is generated according to the assignment code.
[0090] In step S225, at least one second branch of the subtree is generated according to the judgment condition code.
[0091] In the disclosed embodiment, the verification rules can be stored in a key-value database. For example, the key-value database can include an SQL database. Therefore, when extracting the verification rules, the information in the key nodes in the subtree can be converted into a key-value language. Specifically, the subtree can be divided into a first branch and a second branch. The leaf nodes in the first branch include variables in the assignment code, and the leaf nodes in the second branch include variables in the judgment condition code. In this way, when extracting the verification rules in the subsequent steps, the verification rule value (Vulue) and the verification rule key (Key) can be extracted respectively according to the first branch and the second branch. The details will be introduced in detail below and will not be repeated here.
[0092] In some specific embodiments, the root node of the subtree is generated according to the judgment operator of the first line of judgment condition code in the target code block.
[0093] Optionally, in the subtree, the first branch is located to the right of the second branch.
[0094] Optionally, when the assignment code is the nth line of code, in the subtree, the second branch generated according to the n-1th line of judgment condition code is located to the right of the second branch generated according to the n-2th line of judgment condition code, where n is a positive integer.
[0095] For example, assume that the target code block includes: the first line of judgment condition code "when E = F", the second line of judgment condition code "if C NOT = D", and the assignment code "B1 = A". The meaning of the target code block is: when the value of E is F and the value of C is not D, assign "A" to library table B1. Here, B1 represents a file in the first library table, E represents a file in the second library table, and C represents another file in the second library table.
[0096] For the assignment code "B1=A", a first branch X can be generated, wherein "B1" and "A" are respectively used as the two first leaf nodes of the first branch, and "=" is used as the parent node of the two first leaf nodes in the first branch. For the judgment condition codes "if CNOT=D" and "when E=F", two second branches can be generated respectively, wherein the second branch Y1 is generated according to "if CNOT=D", and the second branch Y2 is generated according to "when E=F". In the subtree, the first branch X is located to the right of the second branch Y1, and the second branch Y1 is located to the right of the second branch Y2. Among them, "C" and "D" are respectively used as the two leaf nodes of the second branch Y1, "E" and "F" are respectively used as the two leaf nodes of the second branch Y2, "NOT=" is used as the parent node of the two leaf nodes of the second branch Y1, "=" is used as the parent node of the two leaf nodes of the second branch Y2, "if" is used as the parent node of the "NOT=" node in the second branch Y1 and the "=" node in the first branch X, and "when" is used as the subtree root node, that is, the parent node of the "if" node in the first branch X (second branch Y1) and the "=" node in the second branch Y2.
[0097] In this way, in subsequent steps, the subtree can be traversed from right to left and from bottom to top to extract the accounting rules.
[0098] Figure 5 A flowchart of extracting accounting rules according to an embodiment of the present disclosure is schematically shown. Figure 5 As shown, in some specific embodiments, step S230 includes step S231.
[0099] In step S231, at least one accounting rule is generated based on the leaf nodes in the first branch and at least one second branch.
[0100] In some specific embodiments, the leaf nodes in the first branch include objects and variables in the assignment code, and the leaf nodes in the second branch include objects and variables in the judgment condition code, so that at least one accounting rule can be generated based on the objects and variables in the assignment code and the objects and variables in the judgment condition code.
[0101] Figure 6 A flowchart of extracting accounting rules based on the leaf nodes in the first branch and at least one second branch according to an embodiment of the present disclosure is schematically shown. Figure 6 As shown, in some specific embodiments, step S231 includes steps S2311 to S2313.
[0102] In step S2311, based on the leaf node of the first branch, the verification field and the verification rule value are extracted.
[0103] In the disclosed embodiment, objects and variables related to the assignment code of the first library table can be extracted from the leaf nodes of the first branch. Then, the accounting rule value can be determined based on the extracted objects and variables. For example, the objects are used as the accounting field, and the variables are used as the accounting rule value. For example, for the assignment code "B1=A", after the first branch X is generated, the two leaf nodes of the first branch X are "B1" and "A", respectively. In step S231, "B1" and "A" are extracted from the two leaf nodes, "B1" is used as the accounting field, and "A" is used as the accounting rule value.
[0104] In step S2312, the accounting rule key is extracted based on the leaf node of at least one second branch.
[0105] In the disclosed embodiment, there can be multiple second branches in the subtree. For each second branch, the judgment logic of a judgment condition code can be extracted from the leaf node of the second branch. After the above operation is performed on multiple second branches, the judgment logic of multiple judgment condition codes can be extracted. After the extracted judgment logic is integrated, the accounting rule key is determined. For example, for the judgment condition code "if C NOT = D", after generating the second branch Y1, the leaf nodes are "C" and "D" respectively, "NOT = " is the parent node of the two, and "if" is the parent node of "NOT = ". For the judgment condition code "when E = F", after generating the second branch Y2, the leaf nodes are "E" and "F" respectively, " = " is the parent node of the two, and "when" is the parent node of "if" and " = ". After extracting the judgment logic of the second branch Y1 and the second branch Y2 and integrating them, the accounting rule key "when E = F and if C NOT in (2, 3)" can be obtained.
[0106] In step S2313, at least one verification rule is generated according to the verification field, the verification rule value, and the verification rule key.
[0107] In the embodiment of the present disclosure, the accounting verification field, the accounting verification rule value, and the accounting verification rule key may be integrated into a record according to a preset format and stored in the accounting verification rule table to obtain an accounting verification rule.
[0108] In some specific embodiments, the first library table includes a card issuance log table, and the second library table includes a log separation parameter table. Figure 7 The flowchart of generating at least one verification rule according to the verification field, verification rule value and verification rule key according to an embodiment of the present disclosure is schematically shown. Figure 7 As shown, step S2313 includes step S23131 and step S23132.
[0109] In step S23131, the card issuance log table and the log separation parameter table are associated, and the accounting rule key is formatted to generate an SQL statement.
[0110] For example, the TRXCODE in the card issuance log table may be associated with the TRXCODE in the log separation parameter table, and / or the SEPCODE in the card issuance log table may be associated with the SEPCODE in the log separation parameter table.
[0111] In step S23132, the SQL statement is integrated with the accounting verification field and the accounting verification rule value to obtain at least one accounting verification rule.
[0112] Optionally, the card issuance log table and the log separation parameter table may be associated and then integrated with the account verification rule key after format conversion according to a preset format to obtain the final required SQL statement.
[0113] In some specific embodiments, the verification rule table can be imported into the verification rule platform, which can then scan in real time to obtain newly added transaction data. Using this newly added transaction data, the platform can simulate transaction results for the account-related program under test, i.e., pending verification transactions, and also simulate benchmark transaction results based on the verification rules in the verification rule table. By comparing the pending verification transactions with the benchmark transaction results to determine whether they match, it can be determined whether the pending verification transactions are pending transactions. For example, if the two are not equal, it can be determined that a pending transaction has occurred.
[0114] In some specific embodiments, the target code block may include IfStatement, SwitchStatement, SwitchCase, ConditionalExpression, WhileStatement, DoStatement, etc., which can be determined according to actual needs and are not limited here.
[0115] Based on the above-mentioned accounting rule extraction method, the present disclosure also provides an accounting rule extraction device. Figure 8 The device is described in detail.
[0116] Figure 8 The structural block diagram of the accounting rule extraction device according to the embodiment of the present disclosure is schematically shown. Figure 8 As shown, the accounting rule extraction device 800 of this embodiment includes an acquisition module 810 , a processing module 820 and a generation module 830 .
[0117] The acquisition module 810 is used to acquire the target code. In one embodiment, the acquisition module 810 can be used to execute the step S210 described above, which will not be described in detail here.
[0118] The processing module 820 is used to generate an abstract syntax tree based on the target code. The abstract syntax tree includes at least one subtree, each of which is generated based on a target code block related to the target library table in the target code. In one embodiment, the processing module 820 can be used to execute step S220 described above, which will not be repeated here.
[0119] The generation module 830 is used to generate at least one verification rule based on each subtree to obtain a verification rule table, which is used to verify the transactions to be verified. In one embodiment, the generation module 830 can be used to perform step S230 described above, which will not be repeated here.
[0120] By using the account verification rule extraction device of the embodiment of the present disclosure, the account-related code can be extracted from the account-related program to obtain the target code, and then an abstract syntax tree is constructed based on the target code, and the account verification rules are extracted based on each subtree of the abstract syntax tree, and then a formatted account verification rule table is obtained, thereby realizing the automatic extraction of the account verification rules. Moreover, after the account verification rule table is extracted, the account verification rule table can be imported into the account verification platform. Since the account verification rule table has a standard format, it is possible to realize automatic account verification and other accounting tests. In other words, the account verification rule extraction method based on the embodiment of the present disclosure is conducive to realizing fully automatic accounting tests, greatly improving the efficiency of the test, and avoiding problems such as errors caused by manual operations.
[0121] According to an embodiment of the present disclosure, any multiple modules in the acquisition module 810, the processing module 820, and the generation module 830 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the acquisition module 810, the processing module 820, and the generation module 830 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation modes of software, hardware, and firmware, or in an appropriate combination of any of them. Alternatively, at least one of the acquisition module 810, the processing module 820, and the generation module 830 can be at least partially implemented as a computer program module, which can perform the corresponding function when the computer program module is executed.
[0122] According to an embodiment of the present disclosure, the target library table includes a first library table and a second library table, and the processing module includes:
[0123] The first processing unit is used to obtain the assignment code related to the first library table from the target code.
[0124] The second processing unit is used to traverse upward from the assignment code to obtain the judgment condition code that belongs to the same code block as the assignment code and involves the second library table.
[0125] The third processing unit is used to determine the target code block related to the target library table in the target code according to the assignment code and the judgment condition code.
[0126] According to an embodiment of the present disclosure, each subtree includes a first branch and a second branch, each of the first branch and the second branch includes a plurality of nodes having a parent-child relationship, and the processing module further includes:
[0127] The fourth processing unit is configured to generate a first branch of the subtree according to the assignment code.
[0128] The fifth processing unit is configured to generate at least one second branch of the subtree according to the judgment condition code.
[0129] The sixth processing unit is configured to generate at least one accounting verification rule based on each subtree, including:
[0130] The seventh processing unit is used to generate at least one accounting rule based on the leaf nodes in the first branch and at least one second branch.
[0131] According to an embodiment of the present disclosure, the seventh processing unit includes:
[0132] The first processing sub-unit is used to extract the account verification field and the account verification rule value according to the leaf node of the first branch.
[0133] The second processing sub-unit is used to extract the accounting rule key based on the leaf node of at least one second branch.
[0134] The third processing subunit is used to generate at least one accounting verification rule according to the accounting verification field, the accounting verification rule value and the accounting verification rule key.
[0135] According to an embodiment of the present disclosure, the first library table includes a card issuance log table, the second library table includes a log separation parameter table, and the third processing subunit is specifically configured to:
[0136] The card issuance log table and the log separation parameter table are associated, and the verification rule key is formatted to generate SQL statements.
[0137] The SQL statement is integrated with the accounting verification field and the accounting verification rule value to obtain at least one accounting verification rule.
[0138] According to an embodiment of the present disclosure, the leaf nodes in the first branch include objects and variables in the assignment code, and the leaf nodes in the second branch include objects and variables in the judgment condition code.
[0139] According to an embodiment of the present disclosure, the processing module further includes:
[0140] The eighth processing unit is configured to generate a root node of the subtree according to the judgment operator of the first line of judgment condition code in the target code block.
[0141] Figure 9 Schematically shows a block diagram of an electronic device suitable for implementing the method for extracting account verification rules according to an embodiment of the present disclosure, as shown in FIG. Figure 9 As shown, the electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. The processor 901 may, for example, include a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0142] Various programs and data required for the operation of the electronic device 900 are stored in the RAM 903. The processor 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. The processor 901 executes the various operations of the method flow according to the embodiment of the present disclosure by executing the programs in the ROM 902 and / or the RAM 903. It should be noted that the programs may also be stored in one or more memories other than the ROM 902 and the RAM 903. The processor 901 may also execute the various operations of the method flow according to the embodiment of the present disclosure by executing the programs stored in the one or more memories.
[0143] According to an embodiment of the present disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The electronic device 900 may further include one or more of the following components connected to the I / O interface 905: an input portion 906 including a keyboard, a mouse, etc.; an output portion 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage portion 908 including a hard disk, etc.; and a communication portion 909 including a network interface card such as a LAN card or a modem. The communication portion 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed in the drive 910 as needed, so that a computer program read therefrom can be installed into the storage portion 908 as needed.
[0144] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments, or may exist independently and not be incorporated into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the accounting rule extraction method according to the embodiments of the present disclosure.
[0145] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.
[0146] The embodiments of the present disclosure also include a computer program product, which includes a computer program containing program code for executing the method shown in the flowchart. When the computer program product is executed in a computer system, the program code is used to enable the computer system to implement the accounting rule extraction method provided in the embodiments of the present disclosure.
[0147] The computer program executes the above functions defined in the system / device of the embodiment of the present disclosure when the processor 901 executes the computer program. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0148] In one embodiment, the computer program may be stored on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may be transmitted and distributed in the form of a signal on a network medium, downloaded and installed via the communication portion 909, and / or installed from a removable medium 911. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to wireless, wired, or any suitable combination thereof.
[0149] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909, and / or installed from a removable medium 911. When the computer program is executed by the processor 901, the above-described functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the systems, devices, means, modules, units, etc. described above can be implemented by computer program modules.
[0150] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computer programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, python, "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect via the Internet).
[0151] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0152] Those skilled in the art will appreciate that the features described in the various embodiments and / or claims of this disclosure may be combined and / or coupled in various ways, even if such combinations and / or couplings are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure may be combined and / or coupled in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or couplings are intended to fall within the scope of this disclosure.
[0153] The embodiments of the present disclosure are described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although each embodiment has been described separately above, this does not mean that the measures in each embodiment cannot be used in combination to advantage. The scope of the present disclosure is defined by the appended claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A method for extracting account verification rules, characterized in that: include: Get the object code; Generate an abstract syntax tree according to the target code, wherein the abstract syntax tree includes at least one subtree, and each subtree is generated according to a target code block related to a target library table in the target code; At least one verification rule is generated according to each subtree to obtain a verification rule table, wherein the verification rule table is used to verify the transactions to be verified. The target library table includes a first library table and a second library table, and generating an abstract syntax tree according to the target code includes: Obtaining, from the target code, an assignment code related to the first library table; Traverse upward from the assignment code to obtain a judgment condition code that belongs to the same code block as the assignment code and involves the second library table; The target code block involving the target library table in the target code is determined according to the assignment code and the judgment condition code.
2. The method for extracting accounting rules according to claim 1, characterized in that: Each of the subtrees includes a first branch and a second branch, wherein the first branch and the second branch each include a plurality of nodes having a parent-child relationship, and the generating of an abstract syntax tree according to the target code further includes: Generating the first branch of the subtree according to the assignment code; At least one second branch of the subtree is generated according to the judgment condition code. Generating at least one accounting rule according to each of the subtrees includes: At least one of the accounting rules is generated based on the leaf nodes in the first branch and at least one of the second branches.
3. The method for extracting accounting rules according to claim 2, characterized in that: Generating at least one of the accounting verification rules according to the leaf nodes in the first branch and the second branch includes: Extracting the verification field and the verification rule value according to the leaf node of the first branch; Extracting an accounting rule key according to at least one leaf node of the second branch; At least one of the accounting rules is generated according to the accounting field, the accounting rule value and the accounting rule key.
4. The method for extracting accounting rules according to claim 3, characterized in that: The first library table includes a card issuance log table, the second library table includes a log separation parameter table, and generating at least one of the verification rules according to the verification field, the verification rule value, and the verification rule key includes: Associating the card issuance log table with the log separation parameter table, and converting the format of the account verification rule key to generate an SQL statement; The SQL statement is integrated with the accounting verification field and the accounting verification rule value to obtain at least one of the accounting verification rules.
5. The method for extracting accounting rules according to claim 2, characterized in that: The leaf nodes in the first branch include objects and variables in the assignment code, and the leaf nodes in the second branch include objects and variables in the judgment condition code.
6. The method for extracting accounting rules according to claim 1, characterized in that: Generating an abstract syntax tree according to the target code further includes: The root node of the subtree is generated according to the judgment operator of the judgment condition code in the first line in the target code block.
7. A device for extracting account verification rules, characterized in that: include: Acquisition module, used to obtain target code; a processing module, configured to generate an abstract syntax tree according to the target code, wherein the abstract syntax tree includes at least one subtree, and each subtree is generated according to a target code block related to a target library table in the target code; A generating module is used to generate at least one verification rule according to each subtree to obtain a verification rule table, wherein the verification rule table is used to verify the transactions to be verified. The target library table includes a first library table and a second library table, and the processing module includes: A first processing unit is configured to obtain, from the target code, an assignment code related to the first library table; A second processing unit is configured to traverse upward from the assignment code to obtain a judgment condition code that belongs to the same code block as the assignment code and involves the second library table; The third processing unit is configured to determine the target code block in the target code that is related to the target library table according to the assignment code and the judgment condition code.
8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors execute the accounting rule extraction method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that Executable instructions are stored thereon, which, when executed by a processor, cause the processor to execute the accounting rule extraction method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method for extracting accounting rules according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Test code generation method and device, computer system and medium
CN113778848A