Risk control policy coverage detection method and device, storage medium and electronic equipment

By parsing the risk control strategy and generating branch expression detection code, and using the code to generate a large model for strategy branch coverage detection, the problem of unknown strategy branch coverage in risk control strategy verification is solved, improving the convenience and efficiency of strategy branch coverage and ensuring the accuracy of risk control strategy.

CN120492356BActive Publication Date: 2025-11-11CHONGQING ANT CONSUMER FINANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510892197.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-27
Publication Date
2025-11-11
Estimated Expiration
2045-06-27

AI Technical Summary

Technical Problem

During the verification process of risk control strategies, it is impossible to determine the coverage of input parameters to strategy branches in the risk control strategy, which makes it impossible to ensure the integrity and accuracy of strategy branches.

Method used

By acquiring the target risk control strategy and strategy verification parameters in the risk control strategy verification scenario, the strategy is parsed to obtain the risk control logic expression, generating branch expression detection code, and using the code to generate a large model to perform strategy branch coverage detection, thus generating risk control strategy coverage detection data.

Benefits of technology

It has achieved automated strategy branch coverage statistics, which improves the convenience and efficiency of strategy branch coverage and ensures the accuracy and completeness of risk control strategies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120492356B_ABST
    Figure CN120492356B_ABST
Patent Text Reader

Abstract

This specification discloses a method, apparatus, storage medium, and electronic device for risk control strategy coverage detection. The method includes: after obtaining the target risk control strategy and strategy verification parameters for the target risk control strategy in a risk control strategy verification scenario, performing strategy parsing on the target risk control strategy to obtain a risk control logic expression, then performing strategy branch detection code generation processing on the target risk control strategy based on the risk control logic expression to obtain branch expression detection code, and finally performing strategy branch coverage detection processing on the target risk control strategy based on the strategy verification parameters and the branch expression detection code to obtain risk control strategy coverage detection data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of computer technology, and in particular to a method, apparatus, storage medium, and electronic device for detecting the coverage of risk control strategies. Background Technology

[0002] In related technologies, conducting thorough strategy testing and verification before releasing and launching risk control strategies on a specific platform or institution is a crucial step. The verification process typically involves constructing the input parameters for the risk control strategy, setting expected results for these parameters based on previous transaction logic and objectives, executing the input parameters to obtain output parameters, and then comparing these output parameters with the input parameters to verify whether the strategy works as expected. This ensures that the actual effect of the new strategy after launch matches expectations, effectively reducing risk and guaranteeing the stability and security of platform or institutional transactions. Summary of the Invention

[0003] This specification provides a method, apparatus, storage medium, and electronic device for detecting the coverage of risk control strategies. The technical solution is as follows:

[0004] Firstly, this specification provides a method for detecting the coverage of risk control strategies, the method comprising:

[0005] Obtain the target risk control strategy in the risk control strategy verification scenario, and obtain the strategy verification parameters for the target risk control strategy;

[0006] The target risk control strategy is parsed to obtain a risk control logic expression. Based on the risk control logic expression, the target risk control strategy is processed to generate a branch expression detection code.

[0007] Based on the strategy verification parameters and the branch expression detection code, the target risk control strategy is subjected to strategy branch coverage detection processing to obtain risk control strategy coverage detection data.

[0008] In one possible implementation, the step of generating branch expression detection code by performing strategy branch detection code generation processing on the target risk control strategy based on the risk control logic expression includes:

[0009] The risk control logic expression is split into strategy branches to obtain the strategy branch expression;

[0010] Based on the strategy branch expression, the target risk control strategy is processed to generate branch coverage detection code, thus obtaining branch expression detection code.

[0011] In one possible implementation, the step of generating branch coverage detection code for the target risk control strategy based on the strategy branch expression to obtain branch expression detection code includes:

[0012] Obtain the logical operators of the risk control logic expression, and generate target interpretation and execution code based on the logical operators and the strategy branch expression;

[0013] Insert a first expression detection code for the strategy branch expression and a second expression detection code for the risk control logic expression into the target interpretation and execution code to obtain the branch expression detection code.

[0014] In one possible implementation, the step of performing strategy branch decomposition on the risk control logic expression to obtain a strategy branch expression includes:

[0015] The risk control logic expression is subjected to expression verification processing to obtain the expression verification result;

[0016] If the expression verification result is a successful verification type, then the risk control logic expression is split into a strategy branch expression.

[0017] In one possible implementation, the step of performing strategy parsing processing on the target risk control strategy to obtain the risk control logic expression includes:

[0018] The target risk control strategy is parsed to obtain the target risk control conditions;

[0019] The target risk control conditions are transformed into risk control logic expressions through conditional logic transformation.

[0020] In one possible implementation, the step of performing strategy branch coverage detection processing on the target risk control strategy based on the strategy verification parameters and the branch expression detection code to obtain risk control strategy coverage detection data includes:

[0021] A code generation model is used to perform coverage detection code generation based on the strategy verification parameters and the branch expression detection code to obtain the target detection code.

[0022] The target detection code is processed by code execution to obtain risk control strategy coverage detection data.

[0023] In one possible implementation, the step of using a large code generation model to perform coverage detection code generation processing based on the strategy verification parameters and the branch expression detection code to obtain target detection code includes:

[0024] Based on the strategy verification parameters and the branch expression detection code, the code generation prompt words are determined;

[0025] Based on the code generation prompts, a large code generation model is used to parse and process the code task to obtain the target code generation task. Based on the target code generation task, coverage detection code generation is performed to obtain the target detection code.

[0026] In one possible implementation, the step of performing code execution processing on the target detection code to obtain risk control strategy coverage detection data includes:

[0027] The target detection code is subjected to code execution processing to obtain the first coverage result of the strategy verification parameters on the risk control logic expression and the second coverage result of the strategy verification parameters on the strategy branch expression;

[0028] Based on the first coverage result and the second coverage result, risk control strategy coverage detection data is generated.

[0029] Secondly, this specification provides a risk control strategy coverage detection device, the device comprising:

[0030] The strategy acquisition module is used to acquire the target risk control strategy in the risk control strategy verification scenario and to acquire the strategy verification parameters for the target risk control strategy.

[0031] The code generation module is used to perform strategy parsing processing on the target risk control strategy to obtain a risk control logic expression, and to perform strategy branch detection code generation processing on the target risk control strategy based on the risk control logic expression to obtain a branch expression detection code;

[0032] The branch detection module is used to perform policy branch coverage detection processing on the target risk control policy based on the policy verification parameters and the branch expression detection code, and obtain risk control policy coverage detection data.

[0033] Thirdly, this specification provides a computer storage medium having multiple instructions adapted to be loaded by a processor and executed by the method described above.

[0034] Fourthly, this specification provides a computer program product that stores at least one instruction, which is loaded by a processor and executes the method described above.

[0035] Fifthly, this specification provides an electronic device that may include: a memory and a processor; wherein the memory stores a computer program adapted to be loaded by the memory and to execute the methods described above.

[0036] The beneficial effects of the technical solutions provided in this specification include at least the following:

[0037] The risk control strategy coverage detection method provided in this specification, after obtaining the target risk control strategy and the strategy verification parameters for the target risk control strategy in the risk control strategy verification scenario, parses the target risk control strategy to obtain a risk control logic expression. Then, based on the risk control logic expression, it generates branch detection code for the target risk control strategy to obtain branch expression detection code. Finally, based on the strategy verification parameters and the branch expression detection code, it performs strategy branch coverage detection processing on the target risk control strategy to obtain risk control strategy coverage detection data. Therefore, by reusing the strategy verification parameters constructed in the risk control strategy verification scenario, the coverage statistics of strategy branches can be automatically performed based on the branch expression detection code, without requiring additional operations from risk control strategy developers. This increases the convenience of obtaining strategy branch coverage in risk control strategies and effectively improves the efficiency of obtaining strategy branch coverage. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0039] Figure 1 This is a schematic diagram of a scenario for a risk control strategy coverage detection system provided in the embodiments of this specification;

[0040] Figure 2 This is a flowchart illustrating a risk control strategy coverage detection method provided in the embodiments of this specification;

[0041] Figure 3 This is a schematic diagram of a risk control strategy verification scenario provided in the embodiments of this specification;

[0042] Figure 4 This is a flowchart illustrating another risk control strategy coverage detection method provided in the embodiments of this specification;

[0043] Figure 5 This is a schematic diagram of the structure of a risk control strategy coverage detection device provided in the embodiments of this specification;

[0044] Figure 6 This is a schematic diagram of the structure of an electronic device provided in the embodiments of this specification. Detailed Implementation

[0045] To make the inventive objectives, features, and advantages of the embodiments in this specification more apparent and understandable, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments in this specification, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments in this specification without creative effort are within the scope of protection of this specification.

[0046] In the description of this specification, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. In the description of this specification, it should be noted that, unless otherwise expressly specified and limited, "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices. Those skilled in the art can understand the specific meaning of the above terms in this specification based on the specific circumstances. Furthermore, in the description of this specification, unless otherwise stated, "multiple" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship.

[0047] In related technologies, during the verification of risk control strategies, the presence of problems can be verified by comparing the output parameters obtained from the input parameters of the risk control strategy with the expected results corresponding to the input parameters. However, in this process, the number of strategy branches in the risk control strategy that the input parameters constructed for the risk control strategy can cover is unknown. Therefore, during the verification of risk control strategies, there is a problem of not being able to determine the coverage rate of the input parameters to the strategy branches in the risk control strategy.

[0048] To address the aforementioned technical problems, this specification will be described in detail below with reference to specific embodiments.

[0049] Please see Figure 1 This is a schematic diagram of a risk control strategy coverage detection system provided in an embodiment of this specification. Figure 1 As shown in the diagram, this scenario can include at least a terminal cluster and a server.

[0050] In some embodiments, the terminal cluster may include at least one terminal, such as Figure 1As shown, it specifically includes terminal 1 corresponding to user 1, terminal 2 corresponding to user 2, ..., terminal n corresponding to user n, where n is an integer greater than 0.

[0051] Each terminal in a terminal cluster can be a smart device with communication capabilities, including but not limited to: wearable devices, handheld devices, personal computers, tablets, smartphones, computing devices, or other processing devices connected to a wireless modem. In different networks, smart devices may be called by different names, such as: user equipment, access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent or user device, cellular phone, cordless phone, personal digital assistant (PDA), electronic devices in 5G networks or future evolved networks, etc.

[0052] In some embodiments, a server is a hardware device with strong computing power. Specifically, the server can be a single server device, such as a rack-mount, blade, tower, or cabinet server device, or a workstation, mainframe, or other hardware device; or it can be a server cluster composed of multiple servers. The servers in the service cluster can be composed in a symmetrical manner, wherein each server is functionally and hierarchically equivalent in the transaction chain, and each server can provide services to the outside world independently. Providing services independently can be understood as not requiring the assistance of other servers.

[0053] In some embodiments, the electronic device executing the risk control strategy coverage detection method can be a server. The server can establish a communication connection with the terminals in the terminal cluster, and complete data interaction during the risk control strategy coverage detection process based on this communication connection. For example, in the risk control strategy coverage detection method, the terminals in the terminal cluster are terminals used by risk control strategy developers. The terminals store the target risk control strategy in the risk control strategy verification scenario and the strategy verification parameters for the target risk control strategy. The server can obtain the target risk control strategy in the risk control strategy verification scenario from the terminal, obtain the strategy verification parameters for the target risk control strategy, perform strategy parsing processing on the target risk control strategy to obtain a risk control logic expression, perform strategy branch detection code generation processing on the target risk control strategy based on the risk control logic expression to obtain branch expression detection code, and perform strategy branch coverage detection processing on the target risk control strategy based on the strategy verification parameters and the branch expression detection code to obtain risk control strategy coverage detection data.

[0054] It should be noted that the server and terminal establish a communication connection through a network for interactive communication. This network can be a wireless network or a wired network. Wireless networks include, but are not limited to, cellular networks, wireless LANs, infrared networks, or Bluetooth networks. Wired networks include, but are not limited to, Ethernet, universal serial bus (USB), or controller area networks. In one or more embodiments of this specification, technologies and / or formats including HyperText Markup Language (HTML), Extensible Markup Language (XML), etc., are used to represent data exchanged over the network (such as target compressed packets). Furthermore, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), and Internet Protocol Security (IPsec) can be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies can be used to replace or supplement the aforementioned data communication technologies.

[0055] The risk control strategy coverage detection system embodiments provided in this specification and the risk control strategy coverage detection methods described in one or more embodiments belong to the same concept. The execution entity corresponding to the risk control strategy coverage detection methods involved in one or more embodiments of this specification can be an electronic device, which can be the aforementioned server. The specific implementation process of the risk control strategy coverage detection system embodiments can be found in the following method embodiments, and will not be repeated here.

[0056] In one embodiment, such as Figure 2 As shown, a method for detecting the coverage of risk control strategies is proposed. This method can be implemented using a computer program and can run on a risk control strategy coverage detection device based on the von Neumann architecture. This computer program can be integrated into applications or run as a standalone tool application.

[0057] Specifically, the coverage detection method for this risk control strategy includes:

[0058] S102, Obtain the target risk control strategy in the risk control strategy verification scenario, and obtain the strategy verification parameters for the target risk control strategy.

[0059] It is understandable that risk control strategy verification scenarios refer to situations where the accuracy and effectiveness of risk control strategies are verified. Here, risk control strategies refer to strategies configured on specific platforms and in specific fields to identify, assess, and control potential risks. Risk control strategies can be configured on many platforms or institutions, such as credit platforms, e-commerce platforms, financial investment platforms, payment platforms, consumer finance institutions, and insurance institutions.

[0060] For example, see Figure 3 This diagram illustrates a risk control strategy verification scenario. Figure 3 As shown, in the risk control strategy verification scenario, after configuring the risk control strategy, the risk control strategy developers construct a strategy verification input table based on the content of the risk control strategy, and then submit the strategy verification task to the risk control management platform. This strategy verification input table includes parameters used to verify the risk control strategy. After reading the strategy verification input table, the risk control management platform compiles the source code of the risk control strategy to obtain Java code, and submits the verification task to the open data processing service for execution. The open data processing service outputs the strategy output results, resulting in a strategy verification output table. Finally, the risk control strategy developers compare the strategy verification output table with the expected results to verify the accuracy and effectiveness of the risk control strategy.

[0061] It is understandable that the target risk control strategy may include one or more risk control strategies that are awaiting verification or have been verified in the risk control strategy verification scenario.

[0062] Strategy validation parameters refer to the input data required to validate the risk control strategy constructed by the strategy. These input data are parameters that may lead to risks in simulated real-world scenarios. For example, strategy validation parameters may include user personal data, user behavior data, transaction information, account status, etc.

[0063] For example, policy verification parameters may include a set of verification parameters for multiple users, with each user corresponding to a set of verification parameters, and each set of verification parameters may include multi-dimensional verification parameters for the user.

[0064] In some embodiments, step S102 may specifically include: determining the risk control strategy to be detected in the risk control strategy verification scenario, identifying the risk control strategy to be detected as the target risk control strategy, and obtaining the strategy verification parameters for the target risk control strategy from the strategy verification configuration file. It is understood that the strategy verification configuration file may store strategy verification parameters for multiple risk control strategies involved in the risk control strategy verification scenario. These strategy verification parameters may be configured manually based on expert experience or generated using a large language model.

[0065] In some other embodiments, step S102 may specifically involve: obtaining the target risk control strategy and the strategy verification parameters for the target risk control strategy from the user terminal. The user terminal may be the terminal used by the risk control strategy developer.

[0066] S104, perform strategy parsing on the target risk control strategy to obtain the risk control logic expression, and perform strategy branch detection code generation on the target risk control strategy based on the risk control logic expression to obtain the branch expression detection code.

[0067] As can be understood, a risk control logic expression refers to a logical expression that a computer can understand to represent the risk control rules used to characterize a target risk control strategy. Risk control logic expressions can be used to represent risk control conditions, as well as operators between multiple risk control conditions. For example, a simple risk control logic expression may include risk control conditions, while a complex risk control logic expression may include multiple risk control conditions and operators between them.

[0068] Branch expression detection code refers to the functional code used to detect the coverage of a single strategy branch in a target risk control strategy.

[0069] In some embodiments, in step S104, risk control conditions are extracted from the target risk control strategy. If there are multiple risk control conditions, a risk control logic expression is determined based on the logical relationship between the multiple risk control conditions and the multiple risk control conditions. If there is only one risk control condition, a risk control logic expression is determined based on that risk control condition.

[0070] S106, Based on the strategy verification parameters and branch expression detection code, perform strategy branch coverage detection processing on the target risk control strategy to obtain risk control strategy coverage detection data.

[0071] It is understandable that the risk control strategy coverage test data includes the coverage data of the strategy branches of the target risk control strategy.

[0072] In some embodiments, a strategy branch coverage detection task can be generated based on strategy verification parameters and branch expression detection code. The code corresponding to the strategy branch coverage detection task is then executed to obtain risk control strategy coverage detection data, including the strategy branch coverage of the target risk control strategy represented by the risk control logic expression and the branch coverage of the strategy branch expression. The strategy branch coverage of the target risk control strategy can be understood as the percentage of strategy branches in the target risk control strategy that are hit by the strategy verification parameters out of the total number of strategy branches in the target risk control strategy. The branch coverage of the strategy branch expression is used to characterize whether a single strategy branch in the target risk control strategy is hit by the strategy verification parameters. If a single strategy branch is hit by the strategy verification parameters, the branch coverage of the corresponding strategy branch expression is 100%; if a single strategy branch is not hit by the strategy verification parameters, the branch coverage of the corresponding strategy branch expression is 0.

[0073] The risk control strategy coverage detection method provided in this specification, after obtaining the target risk control strategy and the strategy verification parameters for the target risk control strategy in the risk control strategy verification scenario, parses the target risk control strategy to obtain a risk control logic expression. Then, based on the risk control logic expression, it generates branch detection code for the target risk control strategy to obtain branch expression detection code. Finally, based on the strategy verification parameters and the branch expression detection code, it performs strategy branch coverage detection processing on the target risk control strategy to obtain risk control strategy coverage detection data. Therefore, by reusing the strategy verification parameters constructed in the risk control strategy verification scenario, the coverage statistics of strategy branches can be automatically performed based on the branch expression detection code, without requiring additional operations from risk control strategy developers. This increases the convenience of obtaining strategy branch coverage in risk control strategies and effectively improves the efficiency of obtaining strategy branch coverage.

[0074] Please see Figure 4 This is a flowchart illustrating another embodiment of a risk control strategy coverage detection method provided in this specification. Specifically, the method may include the following steps:

[0075] S202, Obtain the target risk control strategy in the risk control strategy verification scenario, and obtain the strategy verification parameters for the target risk control strategy.

[0076] For details on how step S202 is implemented, please refer to [link / reference]. Figure 2 The descriptions of the relevant steps in the illustrated embodiments will not be repeated here.

[0077] S204, perform strategy analysis on the target risk control strategy to obtain the target risk control conditions.

[0078] Understandably, risk control conditions are judgment criteria set according to certain specific rules in a risk control strategy. These conditions are used to determine whether a certain risk control decision should be triggered. Risk control conditions can be set based on specific transaction needs and risk management objectives, and they involve checking data from multiple dimensions, including user behavior, user personal information, account status, and transaction information.

[0079] For example, risk control conditions may include: determining whether the transaction amount exceeds a preset limit; determining whether the user's real-name status is verified; determining whether the number of transactions within a specific time range exceeds a preset limit, etc.

[0080] In some embodiments, step S204 may be performed by: querying the target Structured Query Language (SQL) statement corresponding to the target risk control strategy from the risk control rule data table or the risk control rule configuration file, and performing sentence parsing processing on the SQL statement to obtain the target risk control conditions.

[0081] For example, a portion of the target SQL statement corresponding to a target risk control strategy can be "case whenage>18 and user_is_realnamed = 1 then 1 else 0 end as rule_0", where "age>18and user_is_realnamed = 1" is the target risk control condition.

[0082] S206, the target risk control conditions are transformed into risk control logic expressions.

[0083] In some embodiments, a conditional expression can be determined based on the conditional logic of the target risk control conditions, and the conditional expression can be converted into a risk control logic expression written using a preset programming language. It is understood that the preset programming language refers to the programming language used to generate the detection code for detecting the coverage of risk control strategy branches, such as Java.

[0084] S208, perform strategy branch splitting on the risk control logic expression to obtain the strategy branch expression.

[0085] Among them, the strategy branch expression refers to the sub-expression extracted from the risk control logic expression. Each strategy branch expression corresponds to a specific judgment condition or decision path (also known as a strategy branch) in the risk control strategy. These strategy branches work together to form the complete risk control logic judgment of the risk control strategy.

[0086] For example, a risk control logic expression may include a logical AND operator, and the two sub-expressions connected by this operator are the strategy branch expressions.

[0087] In some embodiments, step S208 may include: performing expression verification processing on the risk control logic expression to obtain an expression verification result; if the expression verification result is a successful verification type, then performing expression splitting processing on the risk control logic expression to obtain a strategy branch expression.

[0088] Understandably, expression validation of risk control logic expressions can include syntax checking and logic verification. Validating risk control logic expressions ensures that they are syntactically and logically correct. If the risk control logic expression is syntactically and logically correct, a validation success result is generated; if the risk control logic expression has syntax and / or logical errors, a validation failure result is generated.

[0089] During the expression decomposition of the risk control logic expression, the logical operators in the risk control logic expression are obtained, and the strategy branch expressions connected by the logical operators are determined in the risk control logic expression.

[0090] For example, if the target risk control condition is “age>18 and user_is_realnamed = 1” in the SQL statement, the risk control logic expression obtained after the target risk control condition is transformed is “age>18&&user_is_realnamed ==1”, where “&&” is the logical AND operator, and the two policy branch expressions connected by this operator are “age>18” and “user_is_realnamed == 1”.

[0091] Understandably, taking the risk control logic expression as the main node and the strategy branch expressions as child nodes as an example, the risk control logic expression can include strategy branch expressions without child nodes, or it can include strategy branch expressions with child nodes. For instance, assuming there are three strategy branch expressions: expression 1, expression 2, and expression 3, in some scenarios, expression 1, expression 2, and expression 3 can be three child nodes directly obtained from the risk control logic expression; in other scenarios, expression 1 and expression 4 are two child nodes directly obtained from the risk control logic expression, while expression 2 and expression 3 are two more child nodes obtained by further splitting expression 4. Thus, after performing expression splitting on the risk control logic expression, the resulting expressions are the three strategy branch expressions: expression 1, expression 2, and expression 3.

[0092] Optionally, if the expression validation result is a validation failure, the process can return to step S206 to regenerate the risk control logic expression. Then, step S208 can be used to perform expression validation and expression splitting on the regenerated risk control logic expression. Alternatively, an expression validation error message can be generated and sent to the user terminal, allowing the user terminal to manually review the risk control logic expression generated in step S206. If the user on the user terminal confirms that the risk control logic expression is incorrect, the user terminal can manually rewrite the risk control logic expression. The user terminal then uploads the rewritten risk control logic expression to the electronic device, which performs expression validation and expression splitting on the uploaded risk control logic expression by executing step S208.

[0093] S210, Based on the strategy branch expression, perform branch coverage detection code generation processing on the target risk control strategy to obtain the branch expression detection code.

[0094] It is understood that branch expression detection code refers to functional code used to detect the coverage of a single strategy branch in a target risk control strategy. Branch expression detection code can be used to detect whether a strategy branch expression is hit, rather than simply detecting whether the entire risk control logic expression is hit. In the embodiments of this specification, branch expression detection code can specifically be interpreted execution code. Interpreted execution code means code that is executed by interpretation rather than compilation during program execution. Interpreted execution refers to the process where the interpreter reads the source code line by line, converts the source code into machine language, and executes it. Compiled execution, on the other hand, compiles the entire source code into machine code at once before execution.

[0095] In some embodiments, performing step S210 may specifically include the following steps:

[0096] A2: Obtain the logical operators of the risk control logic expression, and generate the target interpretation and execution code based on the logical operators and strategy branch expressions;

[0097] A4: Insert the first expression detection code for the strategy branch expression and the second expression detection code for the risk control logic expression into the target interpretation and execution code to obtain the branch expression detection code.

[0098] In step A2, when performing the step of generating target interpreted execution code based on logical operators and policy branch expressions, the first code generation task description information and the first output code description information can be determined according to the logical operators and policy branch expressions. The first prompt word is generated according to the logical operators, policy branch expressions, the first code generation task description information, and the first output code description information. The target interpreted execution code is obtained by using a large code generation model based on the first prompt word.

[0099] In step A4, the first expression detection code is used to detect whether the strategy branch expression is hit, and the second expression detection code is used to detect whether the risk control logic expression as a whole is hit. When executing step A4, second code generation task description information is generated based on the target interpretation and execution code, and second output code description information is determined. A second prompt word is generated based on the target interpretation and execution code, the second code generation task description information, and the second output code description information. Based on the second prompt word, a large code generation model is used to insert the first expression detection code for the strategy branch expression and the second expression detection code for the risk control logic expression into the target interpretation and execution code, resulting in the branch expression detection code.

[0100] In this way, by generating interpreted code such as branch expression detection code, it can not only be used to detect whether the strategy branch expression has been hit, but also, since the interpreter does not need to pre-generate executable files, it can write and test code faster, thus improving code generation efficiency.

[0101] S212 uses a large code generation model to generate coverage detection code based on strategy verification parameters and branch expressions to obtain target detection code.

[0102] Understandably, the target detection code can be used to detect whether the strategy verification parameters match the strategy branch expression and whether the strategy verification parameters match the risk control logic expression.

[0103] In some embodiments, performing step S312 may include the following steps:

[0104] B2: Based on strategy verification parameters and branch expressions, detect code to determine code generation prompts;

[0105] B4: Based on the code generation prompts, a large code generation model is used to parse and process the code task to obtain the target code generation task. Based on the target code generation task, coverage detection code generation is performed to obtain the target detection code.

[0106] In step B2, the code task description information for the policy verification parameters and branch expression detection code is determined, the code output description information is determined, and code generation prompts are generated, including the policy verification parameters, branch expression detection code, code task description information, and code output description information. The code task description information instructs the large model to generate detection code for detecting policy branch coverage based on the policy verification parameters and branch expression detection code.

[0107] In step B4, the code generation prompts are input into the code generation model. The code generation model performs code task parsing and processing to obtain the target code generation task. Based on the target code generation task, the code generation model performs coverage detection code generation processing to obtain the target detection code.

[0108] It is understood that, in the embodiments of this specification, the code generation model used refers to a large language model with strong programming capabilities, capable of understanding, generating, and processing code. The programming capabilities of the large code generation model are reflected in its ability to understand the syntax and structure of multiple programming languages ​​(such as Python, Java, JavaScript, etc.), to comprehend the intent of the code, and to automatically generate corresponding code based on natural language descriptions. The large code generation model can be fine-tuned from a basic large programming model, or it can directly use a basic large programming model; the large programming model is essentially a large model with strong programming capabilities.

[0109] S214, perform code execution processing on the target detection code to obtain risk control strategy coverage detection data.

[0110] It is understandable that the risk control strategy coverage test data includes the coverage test data of strategy verification parameters to strategy branch expressions and the coverage test data of strategy verification parameters to risk control logic expressions.

[0111] In some embodiments, performing step S214 may specifically include:

[0112] C2: Perform code execution processing on the target detection code to obtain the first coverage result of the strategy verification parameters on the risk control logic expression and the second coverage result of the strategy verification parameters on the strategy branch expression;

[0113] C4: Generate risk control strategy coverage detection data based on the first and second coverage results.

[0114] In step C2, during the execution of the target detection code by the processor, after judging the policy verification parameters through the policy branch expression, the execution status of the policy branch expression is recorded. If there is a parameter in the policy verification parameters that can match the policy branch expression, the execution status of the policy branch expression is a hit, and the second coverage result of the policy verification parameters on the policy branch expression is a hit type. If there is no parameter in the policy verification parameters that can match the policy branch expression, the execution status of the policy branch expression is a miss, and the second coverage result of the policy verification parameters on the policy branch expression is a miss type.

[0115] For example, if the logical operator of the risk control logic expression is the logical AND operator, then the first coverage result is a hit type when all second coverage results are of the hit type, and the first coverage result is a miss type when at least one second coverage result is of the miss type. If the logical operator of the risk control logic expression is the logical OR operator, then the first coverage result is a hit type when at least one second coverage result is of the hit type, and the first coverage result is a miss type when all second coverage results are of the miss type.

[0116] In step C4, for each second coverage result, if the second coverage result is a missed type, the branch coverage rate of the strategy branch expression corresponding to the second coverage result is 0; if the second coverage result is a hit type, the branch coverage rate of the strategy branch expression corresponding to the second coverage result is 100%. This allows for fine-grained coverage information of the strategy branch expressions. For the risk control logic expression corresponding to the first coverage result, the target number of hit-type second coverage results is determined, the total number of second coverage results is determined, and the target percentage of the target number to the total number is determined. This target percentage is the strategy branch coverage rate of the target risk control strategy represented by the risk control logic expression. Furthermore, risk control strategy coverage rate detection data can be generated, including the strategy branch coverage rate of the target risk control strategy represented by the risk control logic expression and the branch coverage rate of the strategy branch expression. The branch coverage rate of the strategy branch expression is used to characterize whether a single strategy branch in the target risk control strategy is hit by the strategy verification parameters.

[0117] Thus, the embodiments in this specification can provide the coverage of strategy branches in the risk control strategy verification process, providing finer-grained statistical information for risk control strategy verification, making it easier to discover branches that are missed in the risk control strategy verification process, thereby improving the strategy coverage of the risk control strategy verification process.

[0118] In the risk control strategy coverage detection method provided in this specification, after obtaining the target risk control strategy and the strategy verification parameters for the target risk control strategy in the risk control strategy verification scenario, the target risk control conditions are obtained by parsing the target risk control strategy, and the condition logic transformation is performed on the target risk control conditions to obtain the risk control logic expression. Thus, by parsing the target risk control strategy, a logically accurate and syntactically accurate risk control logic expression is obtained. Then, the risk control logic expression is split into strategy branches to obtain strategy branch expressions. Based on the strategy branch expressions, branch coverage detection code generation processing is performed on the target risk control strategy to obtain branch expression detection code. In this way, the risk control logic expression is split into multiple strategy branch expressions, facilitating the insertion of expression detection code, and the execution of strategy branches can be analyzed without additional manual intervention. The process involves several steps. First, a large-scale code generation model is used to generate coverage detection code based on strategy verification parameters and branch expression detection code. This generates target detection code, which is then executed to obtain risk control strategy coverage detection data. This large-scale model-generated detection code saves manpower on coding and improves generation efficiency. By executing the target detection code, the coverage statistics of strategy branches in the target risk control strategy and the execution status of each branch can be automatically obtained. Since the strategy verification parameters are obtained from the risk control verification scenario, no additional operations are required from risk control strategy developers. This not only increases the convenience of obtaining strategy branch coverage in the risk control strategy but also allows risk control strategy developers to improve strategy branch coverage based on branch execution status, thus better ensuring the accuracy of the risk control strategy.

[0119] The following will combine Figure 5 This document provides a detailed description of the risk control strategy coverage detection device provided in the embodiments of this manual. It should be noted that... Figure 5 The risk control strategy coverage detection device shown is used to execute this manual. Figures 2-4 The methods shown in the embodiments are illustrated for ease of explanation, showing only the parts related to the embodiments of this specification. For specific technical details not disclosed, please refer to this specification. Figures 2-4 The example shown.

[0120] Please see Figure 5 This diagram illustrates the structure of a risk control strategy coverage detection device according to an embodiment of this specification. The risk control strategy coverage detection device 1 can be implemented as all or part of a device through software, hardware, or a combination of both. According to some embodiments, the risk control strategy coverage detection device 1 includes a strategy acquisition module 11, a code generation module 12, and a branch detection module 13, specifically used for:

[0121] The strategy acquisition module 11 is used to acquire the target risk control strategy in the risk control strategy verification scenario and acquire the strategy verification parameters for the target risk control strategy.

[0122] Code generation module 12 is used to perform strategy parsing processing on the target risk control strategy to obtain a risk control logic expression, and to perform strategy branch detection code generation processing on the target risk control strategy based on the risk control logic expression to obtain a branch expression detection code;

[0123] The branch detection module 13 is used to perform strategy branch coverage detection processing on the target risk control strategy based on the strategy verification parameters and the branch expression detection code, and obtain risk control strategy coverage detection data.

[0124] Optionally, the code generation module 12 includes:

[0125] An expression splitting unit is used to perform strategy branch splitting on the risk control logic expression to obtain a strategy branch expression;

[0126] The code generation unit is used to perform branch coverage detection code generation processing on the target risk control strategy based on the strategy branch expression to obtain branch expression detection code.

[0127] Optional, code generation unit, specifically used for:

[0128] Obtain the logical operators of the risk control logic expression, and generate target interpretation and execution code based on the logical operators and the strategy branch expression;

[0129] Insert a first expression detection code for the strategy branch expression and a second expression detection code for the risk control logic expression into the target interpretation and execution code to obtain the branch expression detection code.

[0130] Optional, expression splitting units, specifically used for:

[0131] The risk control logic expression is subjected to expression verification processing to obtain the expression verification result;

[0132] If the expression verification result is a successful verification type, then the risk control logic expression is split into a strategy branch expression.

[0133] Optional, code generation module 12 includes:

[0134] The strategy parsing unit is used to perform strategy parsing processing on the target risk control strategy to obtain the target risk control conditions;

[0135] The expression generation unit is used to perform conditional logic transformation processing on the target risk control conditions to obtain a risk control logic expression.

[0136] Optionally, the branch detection module 13 includes:

[0137] The detection code generation unit is used to perform coverage detection code generation processing based on the strategy verification parameters and the branch expression detection code using a large code generation model to obtain the target detection code;

[0138] The branch detection unit is used to perform code execution processing on the target detection code to obtain risk control strategy coverage detection data.

[0139] Optional, a code generation unit is detected, specifically used for:

[0140] Based on the strategy verification parameters and the branch expression detection code, the code generation prompt words are determined;

[0141] Based on the code generation prompts, a large code generation model is used to parse and process the code task to obtain the target code generation task. Based on the target code generation task, coverage detection code generation is performed to obtain the target detection code.

[0142] Optional, branch detection unit, specifically used for:

[0143] The target detection code is subjected to code execution processing to obtain the first coverage result of the strategy verification parameters on the risk control logic expression and the second coverage result of the strategy verification parameters on the strategy branch expression;

[0144] Based on the first coverage result and the second coverage result, risk control strategy coverage detection data is generated.

[0145] The risk control strategy coverage detection device provided in this specification, after acquiring the target risk control strategy and the strategy verification parameters for the target risk control strategy in the risk control strategy verification scenario, parses the target risk control strategy to obtain a risk control logic expression. Then, based on the risk control logic expression, it performs strategy branch detection code generation processing on the target risk control strategy to obtain branch expression detection code. Finally, based on the strategy verification parameters and the branch expression detection code, it performs strategy branch coverage detection processing on the target risk control strategy to obtain risk control strategy coverage detection data. Therefore, by reusing the strategy verification parameters constructed in the risk control strategy verification scenario, the coverage statistics of strategy branches can be automatically performed based on the branch expression detection code, without requiring additional operations from risk control strategy developers. This increases the convenience of obtaining the strategy branch coverage in the risk control strategy and effectively improves the efficiency of obtaining the strategy branch coverage.

[0146] Please refer to Figure 6This diagram illustrates the structure of an electronic device provided in an exemplary embodiment of this specification. The electronic device in this specification may include one or more components such as a processor 110, a memory 120, an input device 130, an output device 140, and a bus 150. The processor 110, memory 120, input device 130, and output device 140 may be connected via the bus 150.

[0147] Processor 110 may include one or more processing cores. Processor 110 connects to various parts of the terminal using various interfaces and lines, and performs various functions and processes data of terminal 100 by running or executing instructions, programs, code sets, or instruction sets stored in memory 120, and by calling data stored in memory 120. Optionally, processor 110 may be implemented using at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). Processor 110 may integrate one or more of a central processing unit (CPU), graphics processing unit (GPU), and modem. The CPU mainly handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem is used for wireless communication. It is understood that the modem may also not be integrated into processor 110, but implemented separately through a communication chip.

[0148] The memory 120 may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory 120 may include a non-transitory computer-readable storage medium. The memory 120 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (e.g., touch function, sound playback function, image playback function, etc.), instructions for implementing the various method embodiments described below, etc. The operating system may be the Android system, including systems deeply developed based on the Android system, the iOS system developed by Apple Inc., including systems deeply developed based on the iOS system, or other systems.

[0149] In order for the operating system to distinguish the specific application scenarios of third-party applications, it is necessary to establish data communication between the third-party applications and the operating system. This would allow the operating system to obtain the current scenario information of the third-party applications at any time, and then perform targeted system resource adaptation based on the current scenario.

[0150] The input device 130 is used to receive input instructions or data, and includes, but is not limited to, a keyboard, mouse, camera, microphone, or touch device. The output device 140 is used to output instructions or data, and includes, but is not limited to, a display device and a speaker. In one example, the input device 130 and the output device 140 can be combined, and the input device 130 and the output device 140 can be a touch display screen.

[0151] The touch display screen can be designed as a full-screen, curved screen, or irregularly shaped screen. It can also be designed as a combination of a full-screen and a curved screen, or a combination of an irregularly shaped screen and a curved screen; however, this specification does not limit the specific design of the embodiments described herein.

[0152] In addition, those skilled in the art will understand that the structure of the electronic device shown in the above figures does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements. For example, the electronic device may also include radio frequency circuits, input units, sensors, audio circuits, Wireless Fidelity (WiFi) modules, power supplies, Bluetooth modules, etc., which will not be described in detail here.

[0153] In some embodiments, Figure 6In the illustrated electronic device, the processor 110 can be used to call the program for the risk control strategy coverage detection method stored in the memory 120, and specifically perform the following operations:

[0154] Obtain the target risk control strategy in the risk control strategy verification scenario, and obtain the strategy verification parameters for the target risk control strategy;

[0155] The target risk control strategy is parsed to obtain a risk control logic expression. Based on the risk control logic expression, the target risk control strategy is processed to generate a branch expression detection code.

[0156] Based on the strategy verification parameters and the branch expression detection code, the target risk control strategy is subjected to strategy branch coverage detection processing to obtain risk control strategy coverage detection data.

[0157] Optionally, when the processor 110 executes the step of generating branch expression detection code based on the risk control logic expression for the target risk control strategy, it specifically performs the following operations:

[0158] The risk control logic expression is split into strategy branches to obtain the strategy branch expression;

[0159] Based on the strategy branch expression, the target risk control strategy is processed to generate branch coverage detection code, thus obtaining branch expression detection code.

[0160] Optionally, when the processor 110 executes the step of generating branch coverage detection code for the target risk control strategy based on the strategy branch expression to obtain branch expression detection code, it specifically performs the following operations:

[0161] Obtain the logical operators of the risk control logic expression, and generate target interpretation and execution code based on the logical operators and the strategy branch expression;

[0162] Insert a first expression detection code for the strategy branch expression and a second expression detection code for the risk control logic expression into the target interpretation and execution code to obtain the branch expression detection code.

[0163] Optionally, when the processor 110 performs the step of splitting the risk control logic expression into a strategy branch expression, it specifically performs the following operations:

[0164] The risk control logic expression is subjected to expression verification processing to obtain the expression verification result;

[0165] If the expression verification result is a successful verification type, then the risk control logic expression is split into a strategy branch expression.

[0166] Optionally, when the processor 110 performs the step of parsing the target risk control strategy to obtain the risk control logic expression, it specifically performs the following operations:

[0167] The target risk control strategy is parsed to obtain the target risk control conditions;

[0168] The target risk control conditions are transformed into risk control logic expressions through conditional logic transformation.

[0169] Optionally, when the processor 110 executes the step of performing policy branch coverage detection processing on the target risk control policy based on the policy verification parameters and the branch expression detection code to obtain risk control policy coverage detection data, it specifically performs the following operations:

[0170] A code generation model is used to perform coverage detection code generation based on the strategy verification parameters and the branch expression detection code to obtain the target detection code.

[0171] The target detection code is processed by code execution to obtain risk control strategy coverage detection data.

[0172] Optionally, when the processor 110 executes the step of generating coverage detection code by using a large model to verify the parameters based on the strategy and the branch expression detection code to obtain target detection code, it specifically performs the following operations:

[0173] Based on the strategy verification parameters and the branch expression detection code, the code generation prompt words are determined;

[0174] Based on the code generation prompts, a large code generation model is used to parse and process the code task to obtain the target code generation task. Based on the target code generation task, coverage detection code generation is performed to obtain the target detection code.

[0175] Optionally, when the processor 110 executes the step of performing code execution processing on the target detection code to obtain risk control strategy coverage detection data, it specifically performs the following operations:

[0176] The target detection code is subjected to code execution processing to obtain the first coverage result of the strategy verification parameters on the risk control logic expression and the second coverage result of the strategy verification parameters on the strategy branch expression;

[0177] Based on the first coverage result and the second coverage result, risk control strategy coverage detection data is generated.

[0178] This specification also provides a computer-readable storage medium storing at least one instruction that is executed by a processor to implement the risk control strategy coverage detection method as described in the above embodiments.

[0179] This specification also provides a computer program product that stores at least one instruction, which is loaded and executed by the processor to implement the risk control strategy coverage detection method as described in the above embodiments.

[0180] Those skilled in the art will recognize that the functions described in the embodiments of this specification in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented in software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.

[0181] The above description is merely an optional embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification shall be included within the protection scope of this specification.

[0182] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

Claims

1. A method for detecting the coverage of risk control strategies, characterized in that, The method includes: Obtain the target risk control strategy in the risk control strategy verification scenario, and obtain the strategy verification parameters for the target risk control strategy; The target risk control strategy is parsed to obtain a risk control logic expression. The risk control logic expression is then split into strategy branches to obtain a strategy branch expression. Based on the strategy branch expression, the target risk control strategy is processed to generate branch coverage detection code to obtain branch expression detection code. Based on the strategy verification parameters and the branch expression detection code, the target risk control strategy is subjected to strategy branch coverage detection processing to obtain risk control strategy coverage detection data.

2. The method according to claim 1, characterized in that, The step of generating branch coverage detection code for the target risk control strategy based on the strategy branch expression to obtain branch expression detection code includes: Obtain the logical operators of the risk control logic expression, and generate target interpretation and execution code based on the logical operators and the strategy branch expression; Insert a first expression detection code for the strategy branch expression and a second expression detection code for the risk control logic expression into the target interpretation and execution code to obtain the branch expression detection code.

3. The method according to claim 1, characterized in that, The process of splitting the risk control logic expression into strategy branch expressions includes: The risk control logic expression is subjected to expression verification processing to obtain the expression verification result; If the expression verification result is a successful verification type, then the risk control logic expression is split into a strategy branch expression.

4. The method according to claim 1, characterized in that, The process of parsing the target risk control strategy to obtain the risk control logic expression includes: The target risk control strategy is parsed to obtain the target risk control conditions; The target risk control conditions are transformed into risk control logic expressions through conditional logic transformation.

5. The method according to claim 1, characterized in that, The process of performing strategy branch coverage detection on the target risk control strategy based on the strategy verification parameters and the branch expression detection code to obtain risk control strategy coverage detection data includes: A code generation model is used to perform coverage detection code generation based on the strategy verification parameters and the branch expression detection code to obtain the target detection code. The target detection code is processed by code execution to obtain risk control strategy coverage detection data.

6. The method according to claim 5, characterized in that, The code generation model uses the strategy verification parameters and the branch expression detection code to perform coverage detection code generation processing to obtain target detection code, including: Based on the strategy verification parameters and the branch expression detection code, the code generation prompt words are determined; Based on the code generation prompts, a large code generation model is used to parse and process the code task to obtain the target code generation task. Based on the target code generation task, coverage detection code generation is performed to obtain the target detection code.

7. The method according to claim 5, characterized in that, The step of executing the target detection code to obtain risk control strategy coverage detection data includes: The target detection code is subjected to code execution processing to obtain the first coverage result of the strategy verification parameters on the risk control logic expression and the second coverage result of the strategy verification parameters on the strategy branch expression; Based on the first coverage result and the second coverage result, risk control strategy coverage detection data is generated.

8. A risk control strategy coverage detection device, characterized in that, The device includes: The strategy acquisition module is used to acquire the target risk control strategy in the risk control strategy verification scenario and to acquire the strategy verification parameters for the target risk control strategy. The code generation module is used to perform strategy parsing on the target risk control strategy to obtain a risk control logic expression, perform strategy branch splitting on the risk control logic expression to obtain a strategy branch expression, and perform branch coverage detection code generation on the target risk control strategy based on the strategy branch expression to obtain branch expression detection code. The branch detection module is used to perform policy branch coverage detection processing on the target risk control policy based on the policy verification parameters and the branch expression detection code, and obtain risk control policy coverage detection data.

9. A computer storage medium, characterized in that, The computer storage medium stores a plurality of instructions, which are adapted to be loaded by a processor and executed as described in any one of claims 1 to 7.

10. A computer program product, characterized in that, The computer program product stores at least one instruction, which is loaded by a processor and executed as described in any one of claims 1 to 7.

11. An electronic device, characterized in that, include: A processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Code coverage analysis method and application server

    CN107797923A

  • A method and a device for risk control strategy and business risk control

    CN109002949A