Methods, apparatus, media, and computer equipment for adjusting the execution location of detection rules
By performing security checks on both the hardware and CPU sides and dynamically adjusting the execution location of the detection rules, the latency and resource consumption problems of traditional detection methods in high-frequency AI interaction scenarios are solved, and real-time optimization and accuracy improvement of detection rules are achieved.
Patent Information
- Application Number
- CN202611623230.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-19
- Publication Date
- 2026-11-17
AI Technical Summary
Traditional detection methods suffer from high detection latency, high resource consumption, and high detection error in high-frequency AI interaction scenarios, making it impossible to achieve flexible deployment and real-time optimization of detection rules.
By performing security checks on both the hardware and CPU sides, obtaining the results and performing asynchronous security checks, and dynamically adjusting the execution position of the detection rules using detection quality indicators, the detection rules can be flexibly switched between software and hardware, reducing detection latency and resource consumption.
In high-frequency AI interaction scenarios, real-time detection quality optimization of detection rules is achieved, reducing detection latency, reducing resource consumption, and improving detection accuracy, thus balancing detection acceleration and accuracy assurance.
Smart Images

Figure CN123114899A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network security technology, and more specifically, to a method, apparatus, medium, and computer device for adjusting the execution location of detection rules. Background Technology
[0002] With the rapid development of artificial intelligence (AI) technology, enterprise users are increasingly using external AI services. Therefore, in order to ensure the security of enterprise users' use of AI services, it is necessary to use an egress security gateway to perform security checks on the interaction content between the enterprise and the AI service, such as relying on various detection rules to realize sensitive data detection and policy decision-making.
[0003] However, some traditional detection methods, such as software detection using the CPU according to various detection rules or hardware detection using rule logic circuits burned into the hardware, have obvious drawbacks when facing high-frequency AI interaction scenarios. These drawbacks include either high detection latency and high resource consumption, or high detection errors due to resource constraints. Summary of the Invention
[0004] In view of this, this application provides a method, apparatus, medium, and computer device for adjusting the execution position of detection rules, so as to dynamically adjust the deployment position of detection rules between software and hardware, thereby reducing detection latency, reducing resource consumption, and improving detection accuracy.
[0005] Specifically, this application is implemented through the following technical solution: In a first aspect, embodiments of this disclosure provide a method for adjusting the execution location of a detection rule, including: On the hardware side, security detection is performed on each target interaction content in the AI traffic according to the first rules currently deployed inside the hardware, and the first detection result of each target interaction content is obtained. On the central processing unit (CPU) side, security detection is performed on the target interaction content according to the second rules currently deployed inside the CPU, and the second detection result of each target interaction content is obtained. On the CPU side, a real-time processing strategy for the target interactive content is determined based on the first detection result and / or the second detection result, and asynchronous security detection is performed on the sampled interactive content sampled from the artificial intelligence traffic according to the detection rule set to obtain a reference detection result; the detection rule set includes each of the first rule and each of the second rule; In response to the arrival of the judgment period, the detection quality index of the target detection rule related to the sampled interaction content is determined based on the reference detection results, the first detection result and the second detection result of each sampled interaction content within the judgment period; Based on the detection quality indicators of the target detection rules and the current deployment location, determine the rules to be migrated and the target execution location of the rules to be migrated from the target detection rules; The rules to be migrated are deployed to the target execution location without interrupting the execution of the rules at the current deployment location. If the deployment is successful, the rules to be migrated at the current deployment location are removed.
[0006] Secondly, embodiments of this disclosure also provide a device for adjusting the execution position of a detection rule, comprising: The first detection module is used to perform security detection on each target interaction content in the artificial intelligence traffic according to the first rules currently deployed inside the hardware on the hardware side, and obtain the first detection result of each target interaction content; and to perform security detection on the target interaction content according to the second rules currently deployed inside the CPU on the central processing unit (CPU) side, and obtain the second detection result of each target interaction content. The second detection module is configured to, on the CPU side, determine a real-time processing strategy for the target interactive content based on the first detection result and / or the second detection result, and perform asynchronous security detection on the sampled interactive content sampled from the artificial intelligence traffic according to the detection rule set to obtain a reference detection result; the detection rule set includes each of the first rule and each of the second rule; The judgment module is used to determine the detection quality index of the target detection rule related to the sampled interaction content in response to the arrival of the judgment period, based on the reference detection results, the first detection result and the second detection result of each sampled interaction content within the judgment period. The determination module is used to determine the rule to be migrated and the target execution location of the rule to be migrated from the target detection rules based on the detection quality index of the target detection rules and the current deployment location. The migration module is used to deploy the rules to be migrated to the target execution location in a manner that does not interrupt the execution of the rules to be migrated at the current deployment location, and, if the deployment is successful, remove the rules to be migrated from the current deployment location.
[0007] Thirdly, an optional implementation of this disclosure also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the steps in the first aspect described above.
[0008] Fourthly, an optional implementation of this disclosure also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps in the first aspect described above.
[0009] The method, apparatus, medium, and computer equipment for adjusting the execution location of detection rules provided in this disclosure, for AI traffic, while performing full-scale security detection and real-time processing strategy decisions using the first rule currently deployed on the hardware side and the second rule currently deployed on the software side, simultaneously performs a small-scale sampling of the full AI traffic on the CPU side and detects the sampled interaction content using a detection rule set, obtaining a reference detection result for the sampled interaction content. Since the interaction content detected by the CPU side using the detection rule set is only a small portion of the traffic, the computational overhead of the CPU on the sampled traffic can be reduced. Moreover, the CPU strictly adheres to the rule content when executing each detection rule in the detection rule set, so the reference detection result of the sampled interaction content can be used as the detection truth value. Then, by comparing the reference detection result of the sampled interaction content with the first and second detection results corresponding to the sampled interaction content on the hardware side and the software side, the detection quality of the first rule running on the hardware side and the second rule running on the CPU side can be accurately determined, obtaining the detection quality index of the target detection rule at the current deployment location. Finally, the current deployment location of the target detection rules is migrated without interruption using detection quality indicators. This enables flexible switching between the software (CPU side) and hardware sides of detection rules based on the real-time detection quality of each rule. It achieves both hardware-side acceleration and software-side accuracy assurance. In summary, this application provides a closed loop of "detection quality indicator collection → detection rule deployment location evaluation → execution location adjustment → online migration → continuous optimization." It dynamically adjusts the execution location of detection rules based on their real-time detection quality, fully leveraging the acceleration effect of hardware-side execution and the accuracy assurance of software-side execution. In scenarios with high-frequency AI interaction, it achieves a comprehensive balance in reducing detection latency, resource consumption, and detection errors.
[0010] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0011] Figure 1 This is a flowchart illustrating an exemplary embodiment of the present application of a method for adjusting the execution position of a detection rule; Figure 2 This is a flowchart illustrating a detection rule migration process according to an exemplary embodiment of this application; Figure 3 This is a flowchart illustrating a byte-by-byte detection process for streaming content, as shown in an exemplary embodiment of this application. Figure 4This is a schematic diagram of the architecture of a security gateway shown in an exemplary embodiment of this application; Figure 5 This is a schematic diagram of an execution position adjustment device for a detection rule, as illustrated in an exemplary embodiment of this application; Figure 6 This is a schematic diagram of the structure of a computer device shown in an exemplary embodiment of this application. Detailed Implementation
[0012] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0013] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0014] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0015] Research has revealed that when egress security gateways perform security checks on interactive content during AI access by enterprises, they typically rely on rule-based operations such as regular expression matching, keyword matching, dictionary matching, and feature scanning. Currently, common rule deployment and detection methods fall into two categories: pure software detection deployed on the Central Processing Unit (CPU) and pure hardware detection deployed on hardware chips. In the pure software detection method, all rule matching, execution, and policy decisions are handled by the CPU. While this method ensures detection accuracy, the high frequency of AI access from thousands to tens of thousands of terminals in actual enterprise deployments leads to high CPU consumption due to the need for frequent rule execution. This results in limited throughput and high tail latency under high-concurrency AI traffic. Furthermore, the pure software detection method requires the execution location of each detection rule to be fixed on the CPU, lacking flexibility in rule execution and preventing the use of hardware chips for detection acceleration. For pure hardware detection (such as detection using Application Specific Integrated Circuits (ASICs) or Field Programmable Gate Arrays (FPGAs), all detection rules need to be programmed into the hardware. While this method can accelerate detection by leveraging hardware parallel processing capabilities, it is unsuitable for handling complex strategy decisions requiring multi-dimensional context and variable logic. Furthermore, rule updates require resynthesis or reprogramming, resulting in poor flexibility and the inability to migrate rules online without interruption. Additionally, pure hardware detection methods are prone to issues such as rule pruning (e.g., simplifying or reducing rules), approximate rule matching, or rule matching state compression due to limited hardware resources, leading to detection biases and affecting detection accuracy.
[0016] Furthermore, both pure hardware and pure software detection methods ignore data such as detection time, hit rate, false alarms, and tail latency, making it difficult to achieve optimization based on these data to drive rule execution.
[0017] Therefore, there is an urgent need for a detection acceleration mechanism that can be driven by detection quality feedback and dynamically adjust the rule execution position, so that the attribution of detection rules between hardware execution position and software execution position can be continuously optimized with the detection quality.
[0018] Based on the above research, this disclosure provides a method, apparatus, medium, and computer device for adjusting the execution location of detection rules. For AI traffic, while performing full-scale security detection and real-time processing strategy decisions using the first rule currently deployed on the hardware side and the second rule currently deployed on the software side, a small proportion of the full AI traffic is sampled on the CPU side, and the sampled interaction content is detected using a detection rule set to obtain a reference detection result for the sampled interaction content. Since the interaction content detected by the CPU side using the detection rule set is only a small portion of the traffic, the computational overhead of the CPU on the sampled traffic can be reduced. Moreover, the CPU strictly adheres to the rule content when executing each detection rule in the detection rule set, so the reference detection result of the sampled interaction content can be used as the detection truth. Then, by comparing the reference detection result of the sampled interaction content with the first and second detection results corresponding to the sampled interaction content on the hardware and software sides, the detection quality of the first rule running on the hardware side and the second rule running on the CPU side can be accurately determined, obtaining the detection quality index of the target detection rule at the current deployment location. Finally, the current deployment location of the target detection rules is migrated without interruption using detection quality indicators. This enables flexible switching between the software (CPU side) and hardware sides of detection rules based on the real-time detection quality of each rule. It achieves both hardware-side acceleration and software-side accuracy assurance. In summary, this application provides a closed loop of "detection quality indicator collection → detection rule deployment location evaluation → execution location adjustment → online migration → continuous optimization." It dynamically adjusts the execution location of detection rules based on their real-time detection quality, fully leveraging the acceleration effect of hardware-side execution and the accuracy assurance of software-side execution. In scenarios with high-frequency AI interaction, it achieves a comprehensive balance in reducing detection latency, resource consumption, and detection errors.
[0019] The shortcomings of the above solutions are the result of the inventor's practical experience and careful research. Therefore, the discovery process of the above problems and the solutions proposed in this disclosure below are all contributions made by the inventor to this disclosure.
[0020] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0021] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0022] It should be noted that the specific terms mentioned in the embodiments of this disclosure include: The Aho-Corasick automaton is a multi-pattern matching algorithm proposed by Bell Labs. It is based on a trie structure combined with the idea of failure pointers.
[0023] To facilitate understanding of this embodiment, a detailed description of the method for adjusting the execution position of a detection rule disclosed in this disclosure embodiment will be provided first. The execution subject of the method for adjusting the execution position of a detection rule provided in this disclosure embodiment is generally a terminal device or other processing device with certain computing capabilities. The terminal device may be a user equipment (UE), a mobile device, a terminal, a personal digital assistant (PDA), a handheld device, a computer device, a gateway device, etc. In some possible implementations, the method for adjusting the execution position of a detection rule can be implemented by the processor calling computer-readable instructions stored in the memory.
[0024] The following describes the method for adjusting the execution location of detection rules provided in this embodiment, taking a security gateway as the execution subject as an example.
[0025] like Figure 1 The flowchart shown is a method for adjusting the execution position of a detection rule according to an embodiment of this disclosure, which may include the following steps: S101: On the hardware side, according to the first rules currently deployed inside the hardware, security detection is performed on each target interaction content in the AI traffic to obtain the first detection result of each target interaction content. On the central processing unit (CPU) side, according to the second rules currently deployed inside the CPU, security detection is performed on the target interaction content to obtain the second detection result of each target interaction content.
[0026] Here, the hardware side can specifically refer to the hardware chips configured in the security gateway, such as FPGA chips or ASIC chips. The hardware side can be called the hardware execution side or hardware execution location. The detection rules deployed on this side can be called the first rules, which are the detection rules included in the detection rule set. When the first rules are executed by the hardware side, hardware detection is achieved. The CPU side can specifically refer to the CPU configured in the security gateway. The CPU side can be called the software execution side or software execution location. The detection rules deployed on this side can be called the second rules, which are the detection rules included in the detection rule set. All the first rules and all the second rules constitute the complete detection rule set.
[0027] The currently deployed first rules are the detection rules deployed on the hardware side at the current moment. Similarly, the currently deployed second rules are the detection rules deployed on the CPU at the current moment. Because this application can flexibly switch the execution location of detection rules—that is, switch between software and hardware execution locations—the first rules deployed in real-time on the hardware side and the second rules deployed on the CPU side are dynamically changing. For example, detection rule 1, deployed on the hardware side at one moment, can be migrated to the CPU side at the next moment.
[0028] Each currently deployed first rule can be a rule acceleration core region located on the hardware side, which can be defined as the target acceleration core region. Specifically, each currently deployed first rule can be a detection rule compiled and deployed within the target acceleration core region. Different types of detection rules require different compilation types; for example, regular expression rules can be compiled into deterministic finite state machines, keyword set rules can be compiled into Aho-Corasick automata, dictionary rules can be compiled into trie, and feature rules can be compiled into fingerprints. Each currently deployed second rule can be a rule compiled and deployed on the CPU side, and these rules can be executed by the detection thread in the CPU.
[0029] At initialization, the first rule to be deployed on the hardware side and the second rule to be deployed on the CPU side can be defined by the developers. For example, all detection rules can be deployed as the first rule on the hardware side, or all detection rules can be deployed as the second rule on the CPU side. Alternatively, based on the importance of each detection rule or its compatibility with the hardware and software sides, the detection rules can be divided into first rules or second rules and deployed in the corresponding locations. As the detection process progresses, the detection rules deployed on the hardware and software sides will change dynamically.
[0030] Artificial intelligence traffic (AI traffic) can be the interactive traffic between any terminal within an enterprise and any external AI service. This traffic can be an access request initiated by the terminal or a return result from an external AI service. The target interactive content is the interactive content carried in the AI traffic, which can be the request content of the access request or the return content carried in the return result of the external AI service.
[0031] The first detection result is the result obtained on the hardware side after the target interactive content is matched with each of the first rules. This result can be used to indicate whether the target interactive content matches any of the first rules, and the specific first rule matched when it matches (such as the identifier of the matched rule, the position of the match, and the matching status). The second detection result is the result obtained on the CPU side after the target interactive content is matched with each of the second rules. This result can be used to indicate whether the target interactive content matches any of the second rules, and the specific second rule matched when it matches (such as the identifier of the matched rule, the position of the match, and the matching status).
[0032] For any given AI traffic, the matching order on the hardware and software sides can be predefined. For example, the AI traffic can first be allocated to the hardware side for matching the target interaction content with the first rule to obtain the first detection result. Then, the target interaction content in the AI traffic can be passed through to the CPU side, where the CPU performs matching with the second rule to obtain the second detection result. Alternatively, the AI traffic can first be allocated to the CPU side for matching the target interaction content with the second rule to obtain the second detection result. Then, the target interaction content in the AI traffic can be passed through to the hardware side, where the hardware performs matching with the first rule to obtain the first detection result.
[0033] In practical implementation, during the interaction between any enterprise terminal and any external AI service, the security gateway can acquire the AI traffic during the interaction. Then, utilizing the hardware rule execution unit within the hardware acceleration core area on the hardware side, it performs rule matching and detection on each target interaction content in the AI traffic according to the currently deployed first rules within the hardware, obtaining the first detection result for each target interaction content on the hardware side. Based on the hardware's parallel processing capability, the hardware can perform the matching of the first rules and target interaction content in parallel. The hardware can then transmit each target interaction content to the CPU side, where the software rule execution unit on the CPU performs matching and detection on each target interaction content against the currently deployed second rules, obtaining the second detection result. The hardware side can then transmit each first detection result to the policy decision unit on the CPU side. The policy decision unit receives the first detection results from the hardware side and / or the second detection results from the CPU side and makes control policy decisions. In other words, the aforementioned hardware rule execution unit is deployed on the hardware rule acceleration core, serving as the first execution location. It performs security detection on the target interactive content in the AI traffic based on the currently deployed first rules and outputs the detection results. The software rule execution unit is deployed in the CPU, serving as the second execution location. It performs main path matching on the target interactive content based on the second rules uploaded by the hardware rule acceleration core (i.e., detection rules not deployed on the hardware side) and outputs the detection results. The policy decision unit is deployed in the CPU, used to receive the detection results from the hardware rule execution unit and / or the software rule execution unit and determine the appropriate action.
[0034] S102: On the CPU side, based on the first detection result and / or the second detection result, a real-time processing strategy for the target interactive content is determined, and asynchronous security detection is performed on the sampled interactive content sampled from the artificial intelligence traffic according to the detection rule set to obtain a reference detection result; the detection rule set includes each first rule and each second rule.
[0035] Here, the CPU deploys the aforementioned policy decision unit and reference detection unit. The reference detection unit is used to sample a small proportion of AI traffic in a bypass asynchronous manner, and only performs high-precision, resource-unconstrained security detection on the sampled traffic according to the detection rules in the detection rule set. It does not make policy decisions or intercept the sampled traffic. For any AI traffic, if the traffic is sampled, it will be subjected to security detection by both the hardware rule execution unit and the software rule execution unit. The policy decision unit will then make a policy decision based on the detection results of the two execution units. Simultaneously, the reference detection unit will also perform bypass asynchronous detection based on the detection rule set. However, the detection result is only used as a reference detection result to determine the detection error of the software / hardware, and will not be used for policy decisions or traffic interception. The small sampling proportion can be preset, for example, one percent.
[0036] The reason for setting up a reference detection unit in this application is that the hardware rule acceleration core is limited by on-chip resources. The first rule implementation deployed inside it may have rule pruning, approximate matching or state compression, which may result in errors compared with the software implementation without resource constraints. Therefore, by setting up a reference detection unit in the CPU to perform unconstrained detection of the sampled traffic on the software side, the detection results of the sampled traffic under the reference detection unit can be compared with the detection results of the sampled traffic on the hardware side, thereby determining the detection quality of the first rule deployed on the hardware side.
[0037] Real-time processing policies are used to indicate access control policies for AI traffic, with each AI traffic instance corresponding to one real-time processing policy. The detection rule set includes all first rules and all second rules. It is understood that any detection rule executed on the software side will produce reliable and accurate results. When any detection rule is executed on the hardware side, if there are no on-chip resource limitations, the detection results are often reliable and faster; however, if there are on-chip resource limitations, the detection results may contain errors.
[0038] The sampled interaction content refers to the AI interaction content carried in the sampled traffic. The reference detection result is the detection result obtained by the reference detection unit on the software side after matching the sampled interaction content with each detection rule. This result can be used to indicate whether the sampled interaction content hits any detection rule, and if so, the specific detection rule hit (such as the identifier of the hit rule, the hit position, and the matching status). Asynchronous security detection means that the detection process does not affect the original detection process of the sampled traffic on the hardware and software sides. The reference detection result can be used as a reference benchmark (i.e., the detection truth value) to determine the detection quality of the detection rules on the software or hardware side.
[0039] In practical implementation, on the CPU side, the policy decision unit can obtain the first and / or second detection results of each AI traffic flow. Based on the first and / or second detection results, combined with the contextual information of the AI traffic (such as the user identity, department, type of external AI service accessed, and category of the hit rule of the AI traffic's end user), a real-time processing strategy for the AI traffic can be determined. For example, the real-time processing strategy can be to allow, block, de-identify, or issue an alarm. For instance, if both the first and second detection results indicate that no rule is hit, and the end user's identity is an authenticated user, the real-time processing strategy can be determined to be to allow; if either the first or second detection result indicates that a rule is hit, and the end user's identity is an authenticated user, the real-time processing strategy can be determined to be to block; if both the first and second detection results indicate that a rule is hit, and the end user's department is the security department, the real-time processing strategy can be determined to be to block and issue an alarm. Furthermore, on the CPU side, a reference detection unit can be used to randomly sample a small proportion of the received AI traffic within each sampling period, according to the sampling cycle and a preset small proportion. This yields the sampled traffic for each sampling period. By executing the detection rules in the detection rule set on the software side, resource-unconstrained security detection is performed on the sampled interaction content in the sampled traffic, and the software detection result of the sampled interaction content is obtained as a reference detection result. For example, the reference detection result could indicate whether the sampled interaction content hits any detection rule in the detection rule set, and the specific hit details when it does.
[0040] In one embodiment, when the reference detection unit performs small-scale traffic sampling, it can also determine the detection rules that need to be evaluated for detection quality indicators based on the deployment duration of each detection rule at its corresponding deployment location and the number of times it has been used as a target detection rule in each historical judgment period. For example, the detection rules can be those that have been deployed at the deployment location for a long time and / or have not undergone detection quality indicator evaluation for a long time. Then, during sampling, AI traffic with high correlation to the detection rules is collected first, thereby achieving continuous accumulation of random judgment periods and covering the determination of detection quality indicators for all detection rules in the detection rule set.
[0041] S103: In response to the arrival of the judgment period, based on the reference detection results, the first detection result and the second detection result of each sampled interaction content within the judgment period, determine the detection quality index of the target detection rule related to the sampled interaction content.
[0042] Here, the judgment period is the period used to determine whether the current deployment location (i.e., the current execution location) of the detection rule needs to be adjusted. This period needs to be larger than the above sampling period and usually needs to cover multiple sampling periods.
[0043] Detection quality metrics characterize the detection quality of detection rules when executed on the hardware side or the software side. Higher detection quality indicates more reliable detection accuracy and efficiency, eliminating the need for execution location relocation; conversely, lower detection quality indicates less reliable detection accuracy and efficiency, necessitating execution location relocation. Execution location includes both hardware and software execution locations; a detection rule is executed only at the deployment location. For example, detection quality metrics may include, but are not limited to, online false positive rate, online hit rate, online false negative rate, detection time, and tail latency.
[0044] The target detection rules related to the sampled interaction content can be the set of each hit detection rule indicated by the reference detection result of each sampled interaction content within the judgment period, each hit first rule indicated by the first detection result of each sampled interaction content, and each hit second rule indicated by the second detection result of each sampled interaction content. In each judgment period, the target detection rules related to the sampled interaction content can be some or all of the detection rules in the detection rule set.
[0045] In practical implementation, on the CPU side, a trigger for the judgment cycle can be set. Upon reaching each judgment cycle, reference detection results of the sampled interaction content in each sampled traffic segment sampled within the judgment cycle can be obtained, along with the first detection result on the hardware side and the second detection result on the software side. Then, using the reference detection unit, the reference detection results of each sampled interaction content sampled within the judgment cycle can be compared with the first and second detection results of each sampled interaction content to determine the detection quality index of each target detection rule. For example, if the reference detection result of a sampled interaction content indicates a hit on a certain detection rule, but the first detection result does not indicate a hit on that rule, then it can be determined that the detection rule has a false negative; if the first detection result of a sampled interaction content indicates a hit on a target first rule, but the reference detection result does not indicate a hit on that first rule, then it can be determined that the first rule has a false positive; if the first detection result of a sampled interaction content indicates a hit on a target first rule, and the reference detection result also indicates a hit on that first rule, then it can be determined that the first rule has a hit. Normally, if the second detection result of a certain sampled interaction content indicates that a certain second rule is hit, the reference detection result of the sampled interaction content will also indicate that the second rule is hit. At this time, the detection latency and other indicators when the second rule is executed on the CPU side can be used as the detection quality indicators of the second rule.
[0046] Optionally, an independent observable unit can be set on the CPU side. This observable unit is used to obtain the reference detection results of the sampled interaction content in each sampled traffic sampled within the judgment period, as well as the first detection result on the hardware side and the second detection result on the software side of the sampled interaction content in each sampled traffic sampled within the judgment period. The reference detection results of each sampled interaction content sampled within the judgment period are compared with the first and second detection results of each sampled interaction content to determine the detection quality index of each target detection rule.
[0047] Understandably, for any sampled interaction content within any judgment period, if the target detection rule related to that sampled interaction content is currently deployed on the hardware side, then the online false alarm rate, online false negative rate, and hardware detection latency of that target detection rule within the judgment period can be determined as detection quality indicators. If the target detection rule related to that sampled interaction content is currently deployed on the software side, then the software detection latency of that target detection rule within the judgment period can be determined as detection quality indicators.
[0048] In this way, the reference detection unit does not undertake real-time interception of AI traffic on the main path (real-time interception is completed by the hardware rule acceleration core and the policy decision unit). Instead, it uses minimal CPU overhead to perform small-sample statistical calculations of the drift error and false positive rate of the first rule within the hardware rule acceleration core, providing decision input for subsequent task adjustments. This asynchronous, non-aligned statistical sampling design allows the reference detection unit to establish an online error evaluation benchmark for the hardware implementation without causing a rebound in overall detection latency.
[0049] In one embodiment, the above-described S103 can be implemented according to the following steps: S103-1: Based on the reference detection results of each sampled interaction content within the judgment period, determine whether they are consistent with the first detection result, determine the detection error of the target first rule related to each sampled interaction content, and collect the hardware detection delay of each target first rule within the judgment period.
[0050] Here, the target first rule can include the reference detection result indicating the first rule that was hit for each sampled interaction content and the first detection result indicating the first rule that was hit. Detection error can include the online false alarm rate, online false negative rate, online hit rate, etc., of the target first rule. Hardware detection latency is used to characterize the detection time and tail latency of the target first rule being executed by hardware.
[0051] In practical implementation, at the arrival of each judgment period, a reference detection unit or observable unit can be used to determine whether the target first rule related to each sampled interaction content within that judgment period has been hit, falsely detected, or missed, based on whether the reference detection result and the first detection result of that sampled interaction content are consistent. Then, based on the consistency comparison between the reference detection result and the first detection result of each sampled interaction content within that judgment period, the detection error of each target first rule related to each sampled interaction content within that judgment period can be determined. Simultaneously, for each target first rule within that judgment period, information such as the detection latency and tail latency when the target first rule is executed by the hardware within that judgment period can be collected as the hardware detection latency of that target first rule.
[0052] In one embodiment, the determination of the "detection error" in S103-1 above can also be carried out according to the following steps: S103-1-1: Divide the judgment period into multiple sub-periods, and for each sampled interaction content in the sub-period, determine the sub-detection error of the target first rule related to the sampled interaction content in the sub-period based on whether the reference detection result of the sampled interaction content is consistent with the first detection result.
[0053] Here, the period length of a sub-period can be greater than the period length of the sampling period, and a sub-period can include at least one sampling interaction content.
[0054] In practice, when each judgment period arrives, the judgment period can be divided into multiple sub-periods using a reference detection unit or an observable unit. For each sub-period, the consistency between the reference detection result and the first detection result of each sampled interaction content within that sub-period can be used to determine whether the target first rule related to each sampled interaction content has a hit, false alarm, or missed detection. This determines the sub-detection error of the target first rule related to each sampled interaction content within that sub-period in that sub-period.
[0055] S103-1-2: Based on the sub-detection errors of the first rule for each target in each sub-period, determine the mean detection error and error fluctuation range of the first rule for each target.
[0056] In practical implementation, for any target first rule within any judgment period, the average detection error of the rule in that judgment period can be determined based on the average of the sub-detection errors in each sub-period within that judgment period. For example, the average false alarm rate, average false negative rate, and average hit rate of the target first rule in that judgment period can be determined based on the average online false alarm rate, average online false negative rate, and average online hit rate of the sub-detection errors in each sub-period within that judgment period. Simultaneously, the error fluctuation range of the target first rule in that judgment period can be determined based on the sub-detection errors and the average detection error in each sub-period within that judgment period. For example, the fluctuation of the online false alarm rate (or the fluctuation of the online false negative rate or the fluctuation of the online hit rate) of the target first rule in that judgment period can be determined based on the online false alarm rate and the average online false alarm rate (or the online false negative rate and the average online false negative rate, or the online hit rate and the average online hit rate) of the target first rule in each sub-period within that judgment period.
[0057] S103-1-3: The mean detection error and the error fluctuation range are used as the detection error of the first rule of the target.
[0058] For example, for any target first rule within any judgment period, the mean detection error and error fluctuation amplitude of the target first rule under that judgment period can be used together as the detection error of the target first rule under that judgment period.
[0059] In this way, by statistically analyzing the average detection error and error fluctuation range of the first target rule within the judgment period, the detection error of the first target rule can better characterize the overall error situation when the first target rule is executed on the hardware side.
[0060] S103-2: Use detection error and hardware detection delay as the detection quality indicators of the first objective rule.
[0061] For example, the detection error and hardware detection latency of each target first detection rule within the judgment period can be used as the detection quality index of the target first rule within the judgment period.
[0062] S103-3: Collect and judge the software detection delay of the target second rule related to each sampled interaction content within the collection and judgment period, and use the software detection delay as the detection quality index of the target second rule.
[0063] Here, the target second rule can include the second rule indicating a hit based on the reference detection results of each sampled interaction content, and the second rule indicating a hit based on the second detection results. Software detection latency is used to characterize the detection time and tail latency of the target second rule executed on the software side.
[0064] Since the execution of the second rule on the CPU side and the execution of the reference detection unit are essentially both executed on the software side, the detection results of the two executions are usually consistent for the same sampled interaction content. Therefore, the second rule deployed on the software side often does not have detection errors such as false positives or false negatives. Thus, only the software detection latency information of the second rule deployed on the software side can be statistically analyzed in each judgment cycle. In specific implementation, for any judgment cycle, the reference detection unit or observable unit can be used to determine each target second rule in that judgment cycle based on the reference detection results indicating the hit second rule for each sampled interaction content in that judgment cycle, and the second detection results indicating the hit second rule for each sampled interaction content in that judgment cycle. The detection latency and tail latency information of each target second rule when executed on the software side in that judgment cycle are collected as the software detection latency of each target second rule. Furthermore, the software detection latency of each target second rule can be used as the detection quality index of each target second rule in that judgment cycle.
[0065] S103-4: Take the first rule and the second rule of each target as the target detection rules.
[0066] In practice, for each judgment period, the first rule and the second rule for each target within that judgment period can be combined as the target detection rule for that judgment period. Therefore, the detection quality index of each first rule and each second rule for each target within that period is the detection quality index of the target detection rule for that judgment period.
[0067] S104: Based on the detection quality indicators of the target detection rules and the current deployment location, determine the rules to be migrated and the target execution location of the rules to be migrated from the target detection rules.
[0068] Here, the current deployment location is the location where the target detection rule is currently deployed, which is also the execution location of the target detection rule. This location is either on the hardware side or the software side.
[0069] Rules to be migrated are target detection rules that need to be moved from their current deployment location to a target execution location for execution. The target execution location differs from the current deployment location; one is a software execution location, and the other is a hardware execution location. Rules to be migrated are typically those whose detection quality does not meet detection requirements when executed at the current deployment location. For example, if a target detection rule is determined to be a rule to be migrated and its current deployment location is on the hardware side, then the target execution location for that rule is on the software side (CPU side); conversely, if a target detection rule is determined to be a rule to be migrated and its current deployment location is on the software side, then the target execution location for that rule is on the hardware side.
[0070] In practical implementation, the task allocation adjustment unit set in the CPU can be used to determine whether the detection quality of each target detection rule meets the preset quality standards based on the detection quality indicators of each target detection rule. For example, whether the online false alarm rate of the target detection rule is less than the preset false alarm rate, and whether the detection latency of the target detection rule is less than the preset latency. If so, it can be determined that the detection quality of the target detection rule at the current deployment location is reliable, and no migration is needed; therefore, the target detection rule will not be considered as a rule to be migrated. If not, it can be determined that the detection quality of the target detection rule at the current deployment location is poor, and migration is required. Therefore, the target detection rule will be considered as a rule to be migrated, and the execution location that is different from the current deployment location of the target detection rule (either the software execution location or the hardware execution location) can be used as the target execution location. In this way, the task allocation adjustment unit can dynamically adjust the assignment of each detection rule between the software execution location and the hardware execution location based on the detection quality indicators of the target detection rule.
[0071] In one embodiment, S104 described above can be implemented according to the following steps: S104-1: For any target detection rule, determine the execution position of the target detection rule in the target indicator range based on the target indicator range in which the detection quality index of the target detection rule is located.
[0072] Here, different indicator ranges can be pre-defined for each indicator type, and different indicator ranges can be associated with different execution positions. The target indicator range is the indicator range in which the detection quality indicator falls, and the execution position to be used is the execution position associated with the target indicator range. For example, multiple indicator ranges can be set for online false alarm rate / average false alarm rate / error fluctuation range / software and hardware detection latency. When the online false alarm rate / average false alarm rate / error fluctuation range falls into different ranges, different execution positions are corresponding to them. Taking the average online false positive rate and the fluctuation of the online false positive rate as examples, when the fluctuation of the online false positive rate of the target detection rule within the judgment period is not greater than the first threshold (i.e., it is located in the index interval (0, first threshold)) and the average online false positive rate is not greater than the second threshold (i.e., it is located in the index interval (0, second threshold)), the target detection rule is determined to migrate to the hardware rule acceleration kernel, that is, the execution position to be used by the target detection rule is determined to be the hardware execution position; when the average online false positive rate of the target detection rule within the judgment period is higher than the third threshold (i.e., it is located in the index interval (third threshold, ∞)) and / or the fluctuation of the online false positive rate is greater than the fourth threshold (i.e., it is located in the index interval (fourth threshold, ∞)), the target detection rule is determined to migrate to the software execution side, that is, the execution position to be used by the target detection rule is determined to be the software execution position. Taking software detection latency as an example, when the software detection latency of the target detection rule within the judgment period is less than that in the index range (0, first latency threshold), the attribute of the target detection rule is determined to migrate to the software execution side. When the software detection latency of the target detection rule within the judgment period is in the second index range (first latency threshold, ∞), the attribute of the target detection rule is determined to migrate to the hardware rule acceleration kernel.
[0073] In practical implementation, a task allocation adjustment unit can be used to determine the target indicator interval for each type of indicator from multiple indicator intervals, based on the specific values of various indicators in the detection quality index of any target detection rule within any judgment period. Then, based on the execution positions associated with the target indicator intervals of each type of indicator, the corresponding execution positions to be used for each type of indicator are determined. Here, if the execution positions to be used for multiple types of indicators are different, the execution position with the most hits can be used as the final execution position, or the execution position corresponding to the most important indicator can be used as the final execution position.
[0074] If the current deployment location of the target detection rule is different from the execution location to be used, the target detection rule will be used as the rule to be migrated, and the execution location to be used will be used as the target execution location of the rule to be migrated.
[0075] S104-2: When the current deployment location of a target detection rule is different from the execution location to be used, the target detection rule will be used as the rule to be migrated, and the execution location to be used will be used as the target execution location of the rule to be migrated.
[0076] In practice, for any target detection rule, the task allocation adjustment unit can determine whether the current deployment location of the target detection rule is consistent with the execution location to be used. If they are consistent, it can be determined that the execution location of the target detection rule does not need to be adjusted, and the target detection rule will not be regarded as a rule to be migrated. If they are inconsistent, the target detection rule can be regarded as a rule to be migrated, and the execution location to be used for the target detection rule can be regarded as the target execution location of the rule to be migrated.
[0077] For example, for any target detection rule, if it is determined to be a rule to be migrated and the current deployment location of the rule is the CPU side, it can be determined that the rule needs to be migrated from the software side to the hardware side; if it is determined to be a rule to be migrated and the current deployment location of the rule is the hardware side, it can be determined that the rule needs to be migrated from the hardware side to the software side.
[0078] S105: Deploy the rules to be migrated to the target execution location without interrupting the execution of the rules to be migrated at the current deployment location, and remove the rules to be migrated at the current deployment location if the deployment is successful.
[0079] Here, the method of not interrupting the execution of the rule to be migrated at the current deployment location means that during the process of migrating the rule to be migrated to the target execution location, the security detection of newly arriving AI traffic during the process is not affected by the rule to be migrated at the current deployment location.
[0080] In practice, after using the task allocation adjustment unit in the CPU to determine each rule to be migrated within the judgment cycle, for each rule to be migrated, the task allocation adjustment unit can deploy the rule to be migrated to the target execution location without affecting its execution at the current deployment location during the migration process. This continues until deployment is successful, confirming that the execution location migration of the rule to be migrated is complete, and the rule to be migrated at the current deployment location is removed. Conversely, if deployment fails, the migration of the execution location of the rule to be migrated can be rejected, and the rule to be migrated can continue to execute at its current deployment location.
[0081] Understandably, if no rule to be migrated is determined within a certain judgment period, we can continue to wait for the judgment in the next period.
[0082] In this way, based on the above process, a closed loop can be formed for each detection rule: "collection of detection quality indicators → evaluation of detection rule deployment location → adjustment of execution location → online migration → continuous optimization". This achieves the goal of dynamically adjusting the execution location of detection rules based on the real-time detection quality of the detection rules, and completes the dynamic adjustment of rule execution location driven by detection quality feedback.
[0083] In one embodiment, the above-described S105 can be implemented according to the following steps: S105-1: Based on the current rule version at the target execution location, compile the rule to be migrated to obtain the execution implementation of the new rule version corresponding to the target execution location, and perform available resource verification on the execution implementation of the new rule version at the target execution location.
[0084] Here, both software execution locations (i.e., CPU side) and hardware execution locations (i.e., hardware side) can have rule versions. The rule version indicates the currently deployed detection rules at that execution location under that rule version. Different rule versions can indicate different deployed detection rules. For any given execution location, the rule version for that execution location will be updated each time a rule to be migrated is successfully migrated to that location.
[0085] Available resource verification is used to check whether there are sufficient resources at the target execution location to deploy and execute the rules to be migrated. The resources required for available resource verification differ depending on the target execution location. For example, if the target execution location is a hardware execution location, the resources required for available resource verification may include lookup table resources, register resources, and Block Random Access Memory (BRAM) resources; if the target execution location is a software execution location, the resources required for available resource verification may include CPU computing power resources and memory resources.
[0086] In practical implementation, a task allocation adjustment unit can be used to determine the rules that need to be migrated to the same execution location based on the target execution location of each rule to be migrated. For each execution location that needs to be migrated, the original rule content of each rule to be migrated to that execution location can be compiled separately in the detection rule set according to the current rule version of the target execution location, resulting in the execution implementation of the new rule version corresponding to the target execution location. The new rule version can include the execution implementation of each rule to be migrated to the target execution location and the execution implementation of each original rule to be retained in the target execution location. That is, during migration, the new execution implementation of the rule to be migrated can be pre-compiled, carrying the overall rule version number of the target execution location to be migrated. This version number is the overall configuration version of the target execution location to be migrated, rather than the independent version number of the rule to be migrated. Among them, when migrating from the software execution side to the hardware rule acceleration core, hardware adaptation compilation is performed based on the original complete business rules, fully preserving the semantics of the original rules, without actively pruning rules or compressing states, thereby realizing the conversion of the rule to be migrated from syntax to hardware circuit, and obtaining the execution implementation of the new rule version. When migrating from the hardware rule acceleration core to the software execution side, the FPGA local dynamic reconstruction and local bitstream programming operations are not performed. During the migration, the original complete business rule corresponding to the rule to be migrated is retrieved, and a new execution implementation on the software side is generated. This new execution implementation carries the total version number of the software execution side.
[0087] Furthermore, after obtaining the new execution implementation, available resources can be verified at the target execution location. Specifically, if the target execution location is a hardware execution location, the required resources such as lookup table resources, register resources, and BRAM resources for the new rule version's execution implementation can be determined first. Then, it can be determined whether the available resources on the hardware side meet the requirements. If so, the target execution location can be determined to pass the available resource verification; otherwise, it can be determined that the target execution location has failed the available resource verification. If the target execution location is a software execution location, the required resources such as CPU computing power and memory resources for the new rule version's execution implementation can be determined first. Then, it can be determined whether the available resources on the CPU side meet the requirements. If so, the target execution location can be determined to pass the available resource verification; otherwise, it can be determined that the target execution location has failed the available resource verification.
[0088] S105-2: If the available resources are verified, deploy the execution implementation of the new rule version to the target execution location and perform an equivalence check compared with the execution implementation of the old rule version to be migrated.
[0089] Here, the execution implementation of the old rule version of the rule to be migrated is the execution implementation of the current rule version of the rule to be migrated in the current deployment location.
[0090] Equivalence checks are used to verify whether the semantics of the rule to be migrated after being migrated to the target execution location are equivalent to the semantics of the rule to be migrated in the current deployment location. If the semantics are equivalent, it means that the semantic expression of the rule to be migrated is complete before and after the migration; otherwise, it is incomplete.
[0091] In practice, the task allocation adjustment unit, after determining that the execution implementation of the new rule version passes the available resource verification, can deploy the execution implementation of the new rule version to the target execution location and perform an equivalence verification between the execution implementation of the new rule version and the execution implementation of the old rule version of the rule to be migrated. For example, if the target execution location is a hardware execution location, the task allocation adjustment unit can schedule a reference detection unit, using historical AI traffic and online bypass sampling traffic, to compare the detection results of the old rule version execution implementation on the software side with the detection results of the new rule version execution implementation on the hardware side. Even if the original complete rule is compiled into a hardware circuit, due to inherent hardware factors such as parallel reading, cache alignment, and automaton jump timing, there will still be an acceptable hit position offset between the old and new implementations, but the rule semantics cannot be changed. Therefore, the equivalence judgment condition for the equivalence verification can be: if the detection rule identifiers hit by the old and new execution implementations are consistent, and the hit position deviation is within the fault tolerance range (such as the preset sub-word length), then the equivalence verification is deemed to have passed. If a mismatch occurs in the hit detection rule identifier, a missed hit, a false hit, or a hit position offset exceeding a threshold, the equivalence check is deemed unsuccessful, and the migration terminates. The fault tolerance threshold is used to accommodate position offsets introduced by the hardware implementation, and changes to the rule semantics are strictly prohibited. That is, due to rule pruning and approximate matching in the hardware rule acceleration core, the hit results of the old and new versions may have slight and acceptable deviations. Therefore, the hit equivalence check allows for a preset reasonable error range. For example, when the hit rule identifiers are consistent and the hit position offset is within a preset sub-word length threshold, the equivalence condition is satisfied, thus preventing the migration process from indefinitely stalling or rolling back due to fine-tuning of approximate matching.
[0092] If the target execution location is a software execution location, the reference detection unit can be scheduled using the task allocation adjustment unit. Historical AI traffic and online bypass sampling traffic will be used to compare the detection results of the old rule version execution implementation on the hardware side with the detection results of the new rule version execution implementation on the software side. If the detection rule identifiers of the old and new versions are consistent, and the hit location deviation is within the preset sub-word length threshold, then the equivalence check is passed; otherwise, the equivalence check is considered to have failed.
[0093] S105-3: If the equivalence check is passed, the execution implementation of the old rule version and the execution implementation of the new rule version are run in parallel, and the new artificial intelligence traffic is gradually switched to the execution implementation of the new rule version according to the preset traffic switching method until the switching ratio reaches the preset ratio. Then, it is determined whether the detection quality index of the execution implementation of the new rule version meets the preset index.
[0094] Here, the new AI traffic refers to the AI traffic newly collected during the migration process. The preset traffic switching method can be to gradually switch the new AI traffic by a preset percentage change. A preset percentage of 100% indicates that all new AI traffic has been switched to the new version of the execution implementation for detection. Preset indicators can be criteria that allow migration, such as all indicators of various rules within the detection quality indicators of the new rule version's execution implementation meeting the minimum threshold, or all indicators of various rules within the detection quality indicators of the new rule version's execution implementation falling within the indicator range corresponding to the target execution location.
[0095] In practice, once it is confirmed that the implementation of the new rule version passes the equivalence check, the implementations of the old rule version and the new rule version can be run in parallel. The new AI traffic is gradually switched to the implementation of the new rule version according to a preset traffic switching method (such as a switching ratio of 0%→10%→50%→80%→100%) until the switching ratio reaches the preset ratio. The detection quality index of the implementation of the new rule version is then determined, and it is determined whether the detection quality index meets the preset index.
[0096] In this process, assuming the new rule version's implementation passes equivalence verification, the original rule version's implementation and the new rule version's implementation run in parallel, gradually switching traffic according to a preset ratio. When switching new AI traffic to the new rule version's implementation, the stateful matching state of the original implementation (such as deterministic finite state machine state vectors, automaton node pointers, sliding window overlapping cache content, etc.) can be transferred to the new implementation at the traffic switching moment. Specifically, the traffic switching can be implemented according to the following steps: determine the current switching ratio according to the preset traffic switching method, and determine the traffic to be switched from the new AI traffic that meets the current switching ratio; if the traffic to be switched belongs to an existing session, obtain the session matching state information of the existing session under the old rule version's implementation, and synchronously distribute the session matching state information and the traffic to be switched to the new rule version's implementation.
[0097] Here, the current switching ratio can be the real-time switching ratio indicated by the preset traffic switching method. For example, if the switching ratio is 0%→10%→50%→80%→100%, then the current switching ratios are 0%, 10%, 50%, 80%, and 100% respectively. The traffic to be switched belongs to an existing session, meaning that the traffic to be switched is not a newly created session. At the time of switching the traffic to be switched, the session matching status information needs to be switched. The session matching status information may include, but is not limited to, intermediate stateful matching status, automaton node pointers, and overlapping cached content of the sliding window.
[0098] In other words, when switching new AI traffic to the execution implementation of the new rule version, for any traffic to be switched that meets the preset switching method, the stateful matching state of the traffic to be switched under the execution implementation of the old rule version can be switched based on whether the traffic to be switched belongs to an existing session (i.e., whether the traffic to be switched is a new session). For example, when switching new AI traffic, if the traffic to be switched is a new session, then all traffic to be switched under the current switching ratio can be directly sent to the execution implementation of the new rule version, while other AI traffic except for the current switching ratio can be sent to the execution implementation of the old rule version. The traffic to be switched can create a new session and initialize the stateful matching state context under the corresponding execution implementation without the need for state handover. If the traffic to be switched belongs to an existing session (i.e., the traffic to be switched is a live streaming sharded long session (with intermediate state matching states, sliding window overlapping buffers, etc.)), either of the following two strategies can be used to perform the switch: Strategy A: Session emptying strategy, that is, the live old session continues to run in the old version of the execution implementation until all shards are received and the session ends naturally, without actively performing state handover; 100% grayscale can represent that all new sessions enter the execution implementation of the new rule version, and wait for all sessions in the old rule version of the execution implementation to be empty before taking offline the execution implementations related to the rule to be migrated in the old rule version of the execution implementation. Strategy B: Active session state handover: at the session shard boundary (the moment of traffic switching: one shard is completed and the next shard has not yet arrived), the intermediate state matching state vector, automaton node pointer, sliding window overlapping buffer, and traffic to be switched are copied and handed over from the execution implementation of the old rule version to the execution implementation of the new rule version, and subsequent shards are handed over to the execution implementation of the new rule version for continued processing. The traffic switching time can be at the shard boundary of a single session, not necessarily at the moment when the global grayscale reaches 100%. It can occur at any stage of the grayscale. Stateless short message sessions do not trigger state handover. In the parallel phase, the reference detection unit can observe the detection quality indicators of the execution implementation of the new rule version. That is, after the equivalence check passes, the execution implementation of the old rule version and the execution implementation of the new rule version run in parallel, and the traffic is switched gradually according to a preset ratio. For streaming sharded long sessions, at the traffic switching time at the session shard boundary, the stateful matching state of the execution implementation of the old rule version, including the deterministic finite state machine state vector, automaton node pointers, and sliding window overlapping cache content, is handed over to the execution implementation of the new rule version. Finally, after the switch is completed, the old rule version execution implementation can be taken offline or rolled back based on the detection quality indicators after the switch.
[0099] S105-4: If so, then the rule to be migrated has been successfully deployed at the target execution location.
[0100] In practice, if the detection quality indicators of the new rule version's execution implementation meet the preset indicators, it can be determined that the rule to be migrated has been successfully deployed at the target execution location, and the execution implementation of the rule to be migrated in the original deployment location will be removed. Taking the target execution location as the hardware execution location as an example, if the detection quality indicators of the new rule version's execution implementation meet the preset indicators, the execution implementation of the rule to be migrated in the old version's execution implementation on the software side can be uninstalled after the legacy session has been processed by the old version's execution implementation. Taking the target execution location as the software execution location as an example, if the detection quality indicators of the new rule version's execution implementation meet the preset indicators, the execution implementation of the rule to be migrated in the old version's execution implementation on the hardware side can be uninstalled after the legacy session has been processed by the old version's execution implementation.
[0101] In another embodiment, if the detection quality index of the new rule version's execution implementation does not meet the preset index, the execution implementation is reverted to the old rule version and the new rule version's execution implementation is deleted.
[0102] In practical implementation, if the detection quality indicators of the new rule version's execution implementation fail to meet the preset indicators, and / or if the new rule version's execution implementation fails the equivalence check, a rollback to the old rule version's execution implementation can be performed, and the new rule version's execution implementation can be deleted, thus achieving version rollback. Taking the target execution location as the hardware execution location as an example, if the detection quality indicators of the new rule version's execution implementation fail to meet the preset indicators or fail the equivalence check, the hardware-side execution implementation of the new rule version can be deleted, and subsequent AI traffic can be switched to the hardware-side execution implementation of the previous rule version. Taking the target execution location as the software execution location as an example, if the detection quality indicators of the new rule version's execution implementation fail to meet the preset indicators or fail the equivalence check, the software-side execution implementation of the new rule version can be deleted, and a software-side version rollback can be performed. That is, based on the above S105-1~S105-4, online, uninterrupted migration of the rules to be migrated can be achieved.
[0103] In one embodiment, regarding the step of "deploying the execution implementation of the new rule version to the target execution location" in S105-2 above, different uninterrupted switching methods can be implemented depending on the target execution location. Specifically, when the target execution location is a hardware execution location, a new core dynamic reconfiguration area, different from the target acceleration core area, is partitioned from the hardware side. The execution implementation of the new rule version is deployed to the new core dynamic reconfiguration area by burning the bitstream related to the execution implementation of the new rule version into the new core dynamic reconfiguration area. The target acceleration core area is the running area of each of the currently deployed first rules inside the hardware.
[0104] Here, when the target execution location is a hardware execution location, i.e., when migrating from the software side to the hardware side, it can be achieved at the hardware level through partial reconfiguration (PR) of the hardware chip. The target acceleration core region is the acceleration core running region of each first rule currently deployed inside the hardware before the rule migration. The new core dynamic reconfiguration region is a core region in the hardware that is different from the target acceleration core region.
[0105] For example, when the target execution location is a hardware execution location, a new dynamic reconfiguration area, different from the target acceleration core region, can be first partitioned from the FPGA / ASIC using a task allocation adjustment unit. Then, via the high-speed serial computer extension bus standard (PCI-Express, PCIe) of the security gateway, a local dynamic bit stream corresponding to the execution implementation of the new rule version is distributed. PR reconstruction is performed only on the new dynamic reconfiguration area, burning the hardware circuitry of the target acceleration core region without modification, continuously carrying service traffic without interruption. After the FPGA / ASIC completes the local reconfiguration configuration, a complete hardware matching circuit corresponding to the execution implementation of the new rule version is generated within the new dynamic reconfiguration area, thereby deploying the execution implementation of the new rule version to the new dynamic reconfiguration area. Furthermore, after successfully deploying the execution implementation of the new rule version in the new dynamic reconfiguration area, the new dynamic reconfiguration area can be used as the new target acceleration core region. Alternatively, after successfully deploying the execution implementation of the new rule version in the new dynamic reconfiguration area, the original target acceleration core region can be interchanged with the new dynamic reconfiguration area for reuse in the next migration. If the detection quality indicators implemented in the new rule version fail to meet the preset indicators, a rollback can be triggered. All AI traffic will be switched back to the original target acceleration core area and the new core dynamic reconstruction area will be disabled. The hardware circuit of the original target acceleration core area will not be modified, and the business will not be affected. The configuration of this version will be discarded, and the migration will be confirmed as a failure.
[0106] In other words, when migrating detection rules from the software side to the hardware side, the online, uninterrupted migration provided in this application can be achieved at the hardware level through partial dynamic reconfiguration of the FPGA, rather than blue-green deployment or canary release in the software domain. Specifically, by dividing the FPGA into a "original core logic area" and a "new core dynamic reconfiguration area," during migration, the gateway only executes the corresponding partial dynamic bitstream by burning the new rule version to the new core dynamic reconfiguration area via the PCIe bus, thereby achieving "hot-plugging" of the underlying hardware circuit. This allows the original core and the new core to run in parallel and be compared on the same hardware, which is different from software process-level version switching.
[0107] Alternatively, if the target execution location is a software execution location, the new rule version's execution implementation can be deployed there by directing the CPU-side detection thread to that implementation. For example, when the target execution location is a software execution location (i.e., migrating from hardware to software), there is no FPGA PR programming. Therefore, the target acceleration core area on the hardware side can continue executing services, and the corresponding new version's execution implementation on the software side is already ready. Thus, a seamless online migration from hardware to software can be achieved by directly directing the CPU-side detection thread to the new rule version's execution implementation. When the switching ratio of new AI traffic reaches 100% and the detection quality index of the new rule version's execution implementation reaches the preset index, the rule migration can be considered complete. Then, the task allocation adjustment unit can be used to stop the service access of the original rules in the target acceleration core area, unload the corresponding rule entries / finite state machines on the hardware side, release FPGA hardware resources, and complete the migration. If the detection quality index of the new rule version's execution implementation does not reach the preset index, all AI traffic can be switched back to the original FPGA hardware implementation, the new software-side execution implementation can be disabled, and software CPU and memory resources can be released. At this point, the hardware-side rule entries and logic remain completely unchanged, and the business is unaffected; discard the current software-side overall version configuration, and the migration is confirmed to have failed.
[0108] In one embodiment, after verifying the available resources of the new rule version's execution implementation at the target execution location, if the verification fails, different methods can be used for migration processing depending on the target execution location. Specifically, if the available resource verification fails and the target execution location is a hardware execution location, the rule hit rate of each first rule currently deployed within the hardware is determined under a preset historical duration. The first rule with the lowest rule hit rate is migrated from the hardware execution location to the software execution location. If the migration is successful, the process returns to the target execution location to perform available resource verification on the new rule version's execution implementation until the new rule version's execution implementation passes the available resource verification or the preset number of iterations is reached.
[0109] Here, the preset historical duration is a certain period of time in the past. This duration can be set based on experience, and this embodiment does not impose a specific limitation. The rule hit rate is used to indicate the detection hit rate of each first rule currently deployed on the hardware side over a past period of time. The preset number of times can be set based on experience, and this embodiment does not impose a specific limitation either. For example, the preset number of times can be 2 times, 3 times, etc.
[0110] In practice, if the target execution location is a hardware execution location and the available resource verification fails, it indicates that the rule to be migrated needs to be migrated from the software side to the hardware side. At this time, resource circuit breaking and reverse degradation can be triggered. Specifically, the task adjustment unit can determine the rule hit rate of each first rule currently deployed in the hardware under a preset historical time period, migrate the first rule with the lowest rule hit rate from the hardware execution location to the software execution location, and if the migration is successful (that is, if the first rule with the lowest rule hit rate is successfully deployed to the software side), re-execute the available resource verification of the execution implementation of the new rule version corresponding to the rule to be migrated, until the execution implementation of the new rule version passes the available resource verification. Following the steps of S105-2 to S105-4 above, the execution location of the rule to be migrated is adjusted, or the number of loops reaches the preset number. At this time, it indicates that multiple first rules have been reverse migrated from the hardware execution location to the software side. If there are still not enough available resources on the hardware side, the migration of the rule to be migrated can be rejected. The specific process of migrating the first rule with the lowest rule hit rate from the hardware execution location to the software execution location can be referred to in the above embodiments, and will not be repeated here.
[0111] Furthermore, when the rule with the lowest hit rate is reverse-degraded from the hardware rule acceleration core to the software execution side, the security gateway can read the active state vector of the current FPGA register and the current scan offset through a PCIe bus, deserialize them, and feed them into the corresponding software state machine running on the CPU side. This ensures that there is no content omission or service interruption during the reverse migration process, thus forming a closed loop of state handover between software and hardware.
[0112] Thus, when the task allocation adjustment unit determines that a certain high-frequency first rule should be migrated from the software side to the hardware side, but the available resource verification shows that the resources (such as lookup tables and block storage) of the hardware rule acceleration core have been exhausted, the security gateway does not simply report an error, but triggers resource replacement: the first rule with the lowest recent hit rate in the hardware rule acceleration core is reverse-migrated back to the software execution side to make room for the high-frequency and high-risk first rule to be migrated, forming a closed loop of dynamic throughput replacement between software and hardware.
[0113] like Figure 2 The diagram shown is a flowchart of a detection rule migration process provided in an embodiment of this application, which may include the following steps: S1: Based on the detection quality indicators of the target detection rules and the current deployment location, determine the rules to be migrated and the target execution location of the rules to be migrated.
[0114] S2: Pre-compile the rules to be migrated to obtain the execution implementation of the new rule version corresponding to the target execution location.
[0115] S3: At the target execution location, determine whether the execution implementation of the new rule version passes the available resource verification.
[0116] If yes, then execute S4 below; if no, then if the target execution location is a hardware execution location, execute S9 below; if the target execution location is a software execution location, reject the migration.
[0117] S4: Deploy the implementation of the new rule version to the target execution location and determine whether it passes the equivalence check.
[0118] If yes, then execute S5 below; otherwise, reject the migration.
[0119] S5: Run the execution implementations of the old rule version and the new rule version in parallel, and gradually switch the new artificial intelligence traffic to the execution implementation of the new rule version according to the preset traffic switching method until the switching ratio reaches the preset ratio.
[0120] S6: Determine whether the detection quality indicators of the new rule version's execution implementation meet the preset indicators.
[0121] If yes, then execute S7 below; if no, then execute S8 below.
[0122] S7: Confirm that the rule to be migrated has been successfully deployed at the target execution location, and take the original execution implementation of the rule to be migrated offline.
[0123] S8: Revert to the execution implementation of the old rule version and delete the execution implementation of the new rule version.
[0124] S9: Resource circuit breaking and reverse degradation.
[0125] S10: Continuously optimize and collect detection quality indicators under the new judgment cycle.
[0126] For the specific implementation process of the above steps S1 to S10, please refer to the above embodiments, which will not be repeated here.
[0127] In one embodiment, during the interaction between an enterprise terminal and an external AI service, the interaction content returned by the external AI service may be long. This long content may be continuously fed back in the form of streaming chunks, resulting in the AI traffic received by the security gateway potentially consisting of various streaming chunks. Existing detection methods either require waiting for all streaming chunks to arrive before detection, causing additional latency, or directly detect each streaming chunk separately, which is prone to missed or false detections. Furthermore, external AI service segmenters often divide the detection target (such as sensitive words) into different data blocks or different tokens. Existing detection methods that directly use data blocks or tokens as boundaries lack cross-layer processing between semantic tokens and byte streams, further exacerbating the problem of missed or false detections. In other words, the streaming output of AI models has two inherent characteristics: 1. Streaming chunked arrival: AI models stream according to the Server-Sent Events (SSE) protocol, and their complete output is cut into multiple independent streaming data chunks and returned in segments. Sensitive strings may be cut at the boundaries of two chunks. 2. Token segmentation and byte stream misalignment: The AI model internally uses a tokenizer to generate output in units of tokens. Tokens are sub-word units encoded by the model's tokenizer according to the Byte Pair Encoding (BPE) rule. Token boundaries and byte / character boundaries are not perfectly aligned. Sensitive content may be segmented between two different tokens; at the same time, a multi-byte character may also be split into two tokens. Faced with these two output characteristics of AI models, traditional detection methods using chunk boundary detection are prone to directly missing sensitive segments cut between two chunks; token boundary detection relies on tokenizer segmentation, which may break sensitive sequences across tokens, making them unrecognizable. More seriously, some sensitive strings may cross both chunk blocks and large model token boundaries. With these two layers of segmentation overlapping, the problem of missed detection by traditional detection solutions will be even more severe.
[0128] Therefore, for the streaming content returned by external AI services, this application establishes a cross-data block state detection method for large model streaming output. This method, through a streaming content scanning module deployed on the hardware side, does not perform detection according to the token boundaries of the content returned by the AI model, but instead reverts to a byte-level, byte-by-byte scanning detection method, thereby fundamentally avoiding the token segmentation impact of the AI model's word segmenter. Specifically, for the step in S101 above, "on the hardware side, according to the first rules currently deployed inside the hardware, perform security detection on each target interaction content in the AI traffic to obtain the first detection result of each target interaction content," it can be implemented according to the following steps B1~B3: B1: On the hardware side, for any target interaction content in the AI traffic, if the target interaction content is a streaming data block returned by the AI model, the maximum number of sub-word bytes of the AI model is determined according to the byte pair encoding rules corresponding to the AI model's word segmenter, and the overlap window length is determined according to the maximum number of sub-word bytes.
[0129] Here, the artificial intelligence model refers to the AI model used by the external AI service accessed by the enterprise terminal; this model also serves as the AI model for providing feedback on the target interactive content. Streaming data blocks are the data blocks (chunks) segmented from the complete output to be generated by the AI model. These streaming data blocks constitute the complete output fed back by the AI model. The maximum sub-word byte count indicates the maximum byte length of various words segmented by the word segmenter. Specifically, the sub-word unit output by the AI model's word segmenter can be multiple characters concatenated together. For example, the BPE dictionary trained by the AI model can contain sub-words of length 6 bytes or 8 bytes. The overlap window length indicates the byte length to be truncated from the end of the previous streaming data block in the current streaming data block. Different word segmenters correspond to different byte pair encoding rules, and different AI models use different word segmenters.
[0130] In practice, for any target interactive content in the AI traffic input to the hardware side, if the target interactive content is not a streaming data block, the sensitive field matching module in the hardware rule execution unit can be used on the hardware side to perform content security detection on the target interactive content according to the first rules currently deployed inside the hardware, and obtain the first detection result of the target interactive content on the hardware side.
[0131] If the target interaction content is a streaming data block returned by an AI model, the hardware side can utilize a streaming content scanning module to first obtain the service identifier of the currently accessed AI model, and then obtain the dictionary features (such as byte pair encoding rules (BPE)) of the AI model based on this service identifier. Then, based on these dictionary features, the maximum number of bytes for a sub-word in the AI model is determined, and a length of bytes not less than this maximum number of bytes is used as the overlap window length. For example, if the maximum number of bytes for a certain AI model is 4 bytes, then the overlap window length for that AI model can be any length greater than or equal to 4 bytes; if the maximum number of bytes for another AI model is 6 bytes, then the overlap window length for that AI model can be any length greater than or equal to 6 bytes. By setting different overlap window lengths for different AI models, flexible and accurate adaptation to the detection boundaries of different AI models can be achieved, avoiding the impact of using a fixed overlap window length on detection accuracy.
[0132] B2: If a previous data block exists in the streaming data block, obtain the active state set of the automaton saved after the detection of the previous data block, as well as the last byte stream in the previous data block that is within the length of the overlapping window; the active state set of the automaton is used to maintain the current matching status of each first rule under the previous data block.
[0133] Here, the previous data block refers to the data block acquired before the currently acquired streaming data block, and this data block belongs to the same output of the AI model as the currently acquired streaming data block. The active state set of the automaton is used to maintain the current matching state of the first rule after performing a byte-by-byte scan detection of the first rule on the previous data block. For example, the current matching state of a stateful automaton (such as a deterministic finite automaton (DFA), Aho-Corasick automaton (AC), etc.) represents "which position of the first rule has been matched", and whether it has ended depends on whether the current matching state returns to the original state. Example: A stateful automaton needs to detect the phone number 13X1234567X. When the stateful automaton uses a certain rule for matching, it can be understood as follows: Matching state S0: No information matched; Matching state S1: Matched 1; Matching state S2: Matched 13; Matching state S3: Matched 13X; ...; Matching state S11: Matched the complete phone number, thus confirming that the first rule has been hit, and the current matching state jumps to S0. If the current acquired streaming data block 1 ends with: chunk1: My phone number is 13X, the current matching state of the automaton stops at S3. This current matching state has neither returned to S0 nor reached the final hit state S11, so it can be determined that the current state is not "missing the first rule" but "matching halfway". At this time, the current matching state S3 can be saved to the active state set of the automaton. When the next streaming data block 2 (chunk2: 1234567X) arrives, the automaton can continue to follow the first rule from the current matching state S3 stored in the active state of the automaton. Finally, the matching state is transferred to S11, and the mobile number is determined to be matched, that is, the first rule is matched.
[0134] In practice, a streaming content scanning module can be used to determine whether the currently acquired streaming data block has a previous data block. If not, it means that the current streaming data block is the first data block, and the stateful automaton is in the original matching state. At this time, the automaton can be used directly to scan and detect the byte stream to be detected corresponding to the first data block byte by byte according to the first rules currently deployed in the hardware. The first detection result of the streaming data block and the latest current matching state corresponding to each first rule are obtained. The current matching states that have not returned to the original matching state are saved to the active state set of the automaton to provide an effective active state set for the detection of the next data block.
[0135] If the currently acquired streaming data block contains a previous data block, then the active automaton state set saved after the previous data block detection was completed, as well as the last byte stream within the overlap window length of the previous data block, can be acquired first. For example, if the overlap window length is 6 bytes, then the last 6 bytes of the previous data block can be acquired.
[0136] B3: Concatenate the last byte stream and the streaming data block to obtain the byte stream to be detected. Then, using an automaton, scan the byte stream to be detected byte by byte according to the current matching state saved in the automaton's active state set and the first rules currently deployed in the hardware. Obtain the first detection result of the streaming data block and the updated automaton active state set and save them.
[0137] In practical implementation, a streaming content scanning module can be used to concatenate the last byte stream within the overlap window length with the byte stream corresponding to the current streaming data block, obtaining the byte stream to be detected. For example, if the last byte stream corresponding to the previous data block chunk(x-1) is "abcd" and the complete byte stream corresponding to the current streaming data block is "XYZOPQA", then the concatenated byte stream to be detected is "abcdXYZOPQA". Furthermore, a stateful automaton can be used to scan the byte stream to be detected byte by byte according to the current matching state of each first rule stored in the automaton's active state set and the first rules currently deployed within the hardware, obtaining the first detection result of the current streaming data block. The active state set of the automaton is then updated and saved based on the current matching state of each first rule under the automaton. In this way, by sliding the overlap window, an overlap area can be maintained between adjacent streaming data blocks (i.e., the beginning of the next data block includes the last N bytes of the previous data block). By re-scanning the overlap area byte by byte, it is ensured that sensitive data cut at the boundary of adjacent data blocks is not missed. The length of the overlap area is not a fixed empirical value, but is determined according to the maximum number of sub-word bytes of the AI model.
[0138] In another embodiment, a byte-level rollback method is proposed when multi-byte characters (such as Chinese characters, special code characters, etc., corresponding to multiple bytes) are fragmented at token boundaries, or when multi-byte characters are segmented into different streaming data blocks. This method avoids missed detections caused by character segmentation across tokens / blocks by saving the incomplete bytes at the end of the previous data block and concatenating them with the starting bytes of the next data block. Specifically, during the byte-by-byte scanning and detection of the byte stream to be detected, if the detected current byte belongs to a byte of a multi-byte character and the subsequent bytes of the multi-byte character belong to different tokens from the current byte, the current scan pointer and current matching state of the automaton are rolled back to the byte position and matching state corresponding to the first byte of the multi-byte character. Using the automaton, from the rolled-back scan pointer position and matching state, each byte of the multi-byte character is scanned and the matching state is updated according to the first rules currently deployed within the hardware, ignoring tokens.
[0139] For example, a Chinese character can occupy 3 bytes (0xE6 0xB1 0x89). Suppose that 0xE6 belongs to Token-A and 0xB1 0x89 belongs to the next Token-B. This would result in the same Chinese character being split into two different Tokens. However, since the byte stream received by the streaming content scanning module is continuous and complete, if the Token boundaries of the AI model are used as the byte stream for scanning, two incomplete byte fragments will appear, resulting in missed detections. Therefore, in the process of scanning the byte stream to be detected byte by byte, if the detected current byte belongs to a byte of a multi-byte character and the subsequent bytes of the multi-byte character belong to different terms than the current byte, the current scanning pointer of the state automaton of each first rule can be rolled back to the byte position corresponding to the first byte of the multi-byte character, and the current matching state of the state automaton of each first rule can be rolled back to the matching state corresponding to the first byte of the multi-byte character. Then, using the automaton, from the rolled-back scanning pointer position and matching state, according to each first rule, a complete scan of each byte of the multi-byte character is performed, ignoring terms, and the matching state is updated, thereby solving the problem of missed detection when multi-byte characters are segmented.
[0140] For example, assume that the sensitive word is "confidential document". After BPE tokenization by the AI model, the 3 Unicode Transformation Format-8 (UTF-8) bytes of the Chinese character "ji" (机) are exactly split into two tokens: Token1 outputs: "mi" (秘) + the first byte of the Chinese character "han" (汉); Token2 outputs: the last 2 bytes of the Chinese character "ji" (机) + "mi wen jian" (密文件). From the perspective of the byte stream, the bytes are complete and continuous, but the token metadata splits the Chinese character "ji" (机) into two tokens. If detection is performed by token: the end of Token1 is an incomplete byte, and the start of Token2 is an incomplete byte, neither side can match the complete Chinese character "ji" (机), resulting in direct missed detection of the sensitive word "confidential document". However, the streaming content scanning module of the present application can read the byte stream to be detected, and simultaneously obtain the token attribution label of each byte in the byte stream to be detected, so as to identify that the multi-byte character of the Chinese character "ji" (机) crosses the token boundary (that is, the detected current byte (the first byte of the Chinese character "ji" (机)) belongs to one byte in the multi-byte character, and the subsequent bytes of the multi-byte character (i.e., the last 2 bytes of the Chinese character "ji" (机)) belong to different tokens from the current byte), and determine that a token fragment occurs. At this time, the streaming content scanning module can roll back the current scanning pointer of the automaton to the first byte of the Chinese character "ji" (机), and roll back the current matching state of the automaton to the matching state corresponding to the first byte of the Chinese character "ji" (机). Then, detection that ignores token segmentation can be performed, the complete 3 bytes of the Chinese character "ji" (机) are sent to the automaton, and the automaton can perform byte-by-byte scanning detection on the complete 3 bytes of the Chinese character "ji" (机) and the subsequent bytes "mi wen jian" (密文件) according to the rolled-back matching state and each first rule, thereby successfully identifying the complete sensitive word "confidential document".
[0141] As Figure 3 shown, it is a flowchart of a byte-by-byte level detection process for streaming content provided by an embodiment of the present application, which may include the following steps: If the target interactive content acquired by the streaming content scanning module is a streaming data block, it determines whether a previous data block exists. If so, it determines the overlap window length based on the maximum number of sub-word bytes in the AI model, and obtains the last byte stream within the overlap window length of the previous data block, as well as the automaton active state set saved after the detection of the previous data block. The last byte stream and the current byte stream corresponding to the streaming data block are concatenated to form the byte stream to be detected. Using the automaton, according to the current matching state saved in the automaton active state set and the currently deployed first rules within the hardware, the byte stream to be detected is scanned byte by byte to determine whether any first rule is matched. If matched, the first detection result of the streaming data block (i.e., the match result) is output, the automaton active state set is updated, and saved. This ensures that even if sensitive content in the streaming data block is assigned to adjacent data blocks, it can still be accurately detected. If not matched, the automaton active state set is updated and saved. If there is no previous data block in the streaming data block, the current byte stream corresponding to the streaming data block can be used as the byte stream to be detected. Then, the automaton is used to scan and detect the byte stream to be detected byte by byte according to the original matching state of each first rule and each first rule, so as to obtain the first detection result of the streaming data block and update and save the active state set of the automaton.
[0142] Furthermore, embodiments of this application also provide, as follows: Figure 4The diagram illustrates the architecture of a security gateway that matches a method for adjusting the execution location of detection rules. This security gateway internally includes a software execution side (i.e., the CPU side) and a hardware execution side (such as an FPGA). The hardware execution side includes a hardware rule acceleration core configured for each currently deployed first rule. This core specifically includes a hardware rule execution unit, which may include a streaming content scanning module and a sensitive content matching module. The streaming content scanning module performs byte-by-byte scanning detection on streaming data blocks. The sensitive content matching module performs security detection on target interactive content that does not belong to a streaming data block, according to the currently deployed first rules. During the migration of detection rules, the hardware rule acceleration core can achieve parallel execution of the old and new rule versions based on the new core's dynamic reconstruction area, thus completing the uninterrupted online migration of detection rules. The software execution side internally includes a software rule execution unit, a policy decision unit, a reference detection unit, an observable unit, and a task adjustment unit. The software rule execution unit performs security detection on the target interactive content according to the currently deployed second rule and outputs the second detection result. The reference detection unit samples AI traffic in a bypass asynchronous manner on a small scale, and performs high-precision, resource-unconstrained security detection only on the sampled traffic according to the detection rules in the detection rule set, obtaining reference detection results. The policy decision unit receives the first detection result from the hardware side and / or the second detection result from the CPU side and makes control policy decisions. The observability unit determines the detection quality index of each target detection rule at each judgment cycle. The task allocation adjustment unit determines the rule to be migrated and adjusts the execution position of the rule to be migrated on the software execution side and the hardware execution side.
[0143] Based on the above architecture, the execution location of detection rules can be dynamically adjusted by feedback from detection quality indicators, allowing the deployment location of detection rules to be continuously optimized in both software and hardware as detection quality improves. Through a non-disruptive online migration method, detection rules can be migrated between two execution locations without interrupting detection. By compiling execution implementations with rule versions for rule migration, seamless rollback of the old version execution implementation can be achieved if the detection quality is substandard after the rule migration, improving the rationality of detection rule migration. By referencing the detection unit's detection, an online error evaluation benchmark can be established for resource-constrained hardware with minimal CPU overhead, making online detection quality indicators predictable. Cross-data block state detection through a streaming content scanning module effectively avoids missed detections caused by word segmentation in the AI model's streaming output.
[0144] In summary, the method for adjusting the execution position of detection rules provided in this application firstly implements a detection acceleration mechanism driven by the detection quality indicators of the detection rules to dynamically adjust the rule execution position, enabling the attribution of detection rules between hardware and software execution positions to be continuously optimized as detection quality changes. Secondly, it implements a method for uninterrupted online migration of detection rules between two execution positions, solving the problem that existing detection schemes require restarting when changing the position of detection rules. Finally, it implements a cross-data block state detection mechanism for large-scale model streaming output, effectively avoiding the missed detection problem caused by the AI model word segmenter splitting sensitive data into different data blocks and / or different tokens.
[0145] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0146] Based on the same inventive concept, this disclosure also provides a detection rule execution position adjustment device corresponding to the detection rule execution position adjustment method. Since the principle of the device in this disclosure for solving the problem is similar to the detection rule execution position adjustment method described above in this disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0147] like Figure 5 The diagram shown is a schematic of an execution position adjustment device for a detection rule provided in an embodiment of this disclosure, comprising: The first detection module 501 is used to perform security detection on each target interaction content in the artificial intelligence traffic according to each first rule currently deployed inside the hardware on the hardware side, and obtain the first detection result of each target interaction content; and to perform security detection on the target interaction content according to each second rule currently deployed inside the CPU on the central processing unit (CPU) side, and obtain the second detection result of each target interaction content. The second detection module 502 is used on the CPU side to determine a real-time processing strategy for the target interactive content based on the first detection result and / or the second detection result, and to perform asynchronous security detection on the sampled interactive content sampled from the artificial intelligence traffic according to the detection rule set to obtain a reference detection result; the detection rule set includes each of the first rule and each of the second rule; The judgment module 503 is used to determine the detection quality index of the target detection rule related to the sampled interaction content in response to the arrival of the judgment period, based on the reference detection results, the first detection result and the second detection result of each sampled interaction content within the judgment period. The determination module 504 is used to determine the rule to be migrated and the target execution location of the rule to be migrated from the target detection rules based on the detection quality index of the target detection rules and the current deployment location. The migration module 505 is used to deploy the rule to be migrated to the target execution location in a manner that does not interrupt the execution of the rule to be migrated at the current deployment location, and remove the rule to be migrated at the current deployment location if the deployment is successful.
[0148] In one possible implementation, the determining module 503 is specifically used for: Based on the reference detection results of each sampled interaction content within the judgment period, and whether they are consistent with the first detection result, the detection error of the target first rule related to each sampled interaction content is determined, and the hardware detection delay of each target first rule within the judgment period is collected. The detection error and the hardware detection delay are used as the detection quality indicators of the first rule for the target. The software detection delay of the target second rule related to each sampled interaction content within the judgment period is collected, and the software detection delay is used as the detection quality index of the target second rule. Each of the first target rule and each of the second target rule shall be used as the target detection rule.
[0149] In one possible implementation, the determining module 503 is specifically used for: The judgment period is divided into multiple sub-periods, and for each sampled interaction content in the sub-period, the sub-detection error of the target first rule related to the sampled interaction content in the sub-period is determined based on whether the reference detection result of the sampled interaction content is consistent with the first detection result. Based on the sub-detection error of each target first rule in each sub-period, determine the mean detection error and error fluctuation amplitude of each target first rule; The mean detection error and the error fluctuation amplitude are used as the detection error of the first rule for the target.
[0150] In one possible implementation, the determining module 504 is specifically used for: For any of the target detection rules, the execution position of the target detection rule in the target indicator range is determined according to the target indicator range in which the detection quality index of the target detection rule is located; If the current deployment location of the target detection rule is different from the execution location to be used, the target detection rule will be used as the rule to be migrated, and the execution location to be used will be used as the target execution location of the rule to be migrated.
[0151] In one possible implementation, the migration module 505 is specifically used for: Based on the current rule version at the target execution location, the rule to be migrated is compiled to obtain the execution implementation of the new rule version corresponding to the target execution location, and the available resources of the execution implementation of the new rule version are verified at the target execution location. If the available resources are verified, the execution implementation of the new rule version is deployed to the target execution location, and an equivalence check is performed compared with the execution implementation of the old rule version of the rule to be migrated. If the equivalence check is passed, the execution implementation of the old rule version and the execution implementation of the new rule version are run in parallel, and the new artificial intelligence traffic is gradually switched to the execution implementation of the new rule version according to the preset traffic switching method until the switching ratio reaches the preset ratio. Then, it is determined whether the detection quality index of the execution implementation of the new rule version reaches the preset index. If so, then the rule to be migrated is determined to have been successfully deployed at the target execution location.
[0152] In one possible implementation, the migration module 505 is specifically used for: If the detection quality index of the new rule version's execution implementation fails to meet the preset index, the execution implementation will revert to the old rule version's execution implementation and the new rule version's execution implementation will be deleted.
[0153] In one possible implementation, the migration module 505 is specifically used for: When the target execution location is a hardware execution location, a new core dynamic reconfiguration area, different from the target acceleration core area, is divided from the hardware side. The execution implementation of the new rule version is deployed to the new core dynamic reconfiguration area by burning bitstreams related to the execution implementation of the new rule version into the new core dynamic reconfiguration area. The target acceleration core area is the running area of each of the first rules currently deployed inside the hardware. Alternatively, if the target execution location is a software execution location, the execution implementation of the new rule version can be deployed to the software execution location by pointing the detection thread on the CPU side to the execution implementation of the new rule version.
[0154] In one possible implementation, the migration module 505 is specifically used for: According to the preset traffic switching method, determine the current switching ratio, and determine the traffic to be switched from the new artificial intelligence traffic that meets the current switching ratio; If the traffic to be switched belongs to an existing session, obtain the session matching status information of the existing session under the execution implementation of the old rule version, and synchronously distribute the session matching status information and the traffic to be switched to the execution implementation of the new rule version.
[0155] In one possible implementation, the migration module 505 is further configured to: If the target execution location is a hardware execution location and the available resources verification fails, the rule hit rate of each first rule currently deployed inside the hardware under a preset historical duration is determined. The first rule with the lowest hit rate is migrated from the hardware execution location to the software execution location. If the migration is successful, the process returns to the step of verifying the available resources of the new rule version at the target execution location until the execution of the new rule version passes the available resource verification or the number of loops reaches a preset number.
[0156] In one possible implementation, the first detection module 501 is specifically used for: On the hardware side, for any target interaction content in the AI traffic, if the target interaction content is a streaming data block returned by the AI model, the maximum number of sub-word bytes of the AI model is determined according to the byte pair encoding rules corresponding to the word segmenter of the AI model, and the length of the overlapping window is determined according to the maximum number of sub-word bytes. If a previous data block exists in the streaming data block, obtain the active state set of the automaton saved after the detection of the previous data block is completed, and the last byte stream in the previous data block that is within the length of the overlapping window; the active state set of the automaton is used to maintain the current matching state of each first rule under the previous data block. The last byte stream and the streaming data block are concatenated to obtain the byte stream to be detected. Then, using an automaton, the byte stream to be detected is scanned byte by byte according to the current matching state stored in the automaton active state set and the first rules currently deployed in the hardware. The first detection result of the streaming data block and the updated automaton active state set are obtained and saved.
[0157] In one possible implementation, the first detection module 501 is further configured to: During the byte-by-byte scanning and detection of the byte stream to be detected, if the detected current byte belongs to one byte of a multi-byte character and the subsequent bytes of the multi-byte character belong to different words than the current byte, then the current scanning pointer and the current matching state of the automaton are rolled back to the byte position and matching state corresponding to the first byte of the multi-byte character. Using the automaton, starting from the backtracked scan pointer position and matching state, the multi-byte character is scanned and its matching state is updated according to the first rules currently deployed within the hardware, ignoring words.
[0158] The specific implementation process of the functions and roles of each unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0159] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0160] Based on the same technical concept, embodiments of this application also provide a computer device. (Refer to...) Figure 6 The diagram shown is a structural schematic of a computer device provided in an embodiment of this application, comprising: The processor 601, memory 602, and bus 603 are included. Memory 602 stores machine-readable instructions executable by the processor 601. The processor 601 executes the machine-readable instructions stored in memory 602. When the machine-readable instructions are executed by the processor 601, the processor 601 performs the following steps: S101~S105.
[0161] The aforementioned memory 602 includes a main memory 6021 and an external memory 6022. The main memory 6021, also known as internal memory, is used to temporarily store the computational data in the processor 601, as well as the data exchanged with external memory such as a hard disk 6022. The processor 601 exchanges data with the external memory 6022 through the main memory 6021. When the computer device is running, the processor 601 and the memory 602 communicate through the bus 603, so that the processor 601 executes the execution instructions mentioned in the above method embodiments.
[0162] This disclosure also provides a computer-readable storage medium storing a computer program. When a processor runs the computer program, it executes the steps of the method for adjusting the execution position of the detection rule described in the above-described method embodiments. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0163] This disclosure also provides a computer program product carrying program code. The program code includes instructions that can be used to execute the steps of the method for adjusting the execution position of the detection rule described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0164] The computer program product can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0165] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it can be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0166] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0167] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0168] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0169] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, with clear signs / information informing users of the personal information processing rules, authorization is obtained from the user through pop-up information or by asking the user to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.
[0170] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A method for adjusting the execution position of a detection rule, characterized in that, The method includes: On the hardware side, security detection is performed on each target interaction content in the AI traffic according to the first rules currently deployed inside the hardware, and the first detection result of each target interaction content is obtained. On the central processing unit (CPU) side, security detection is performed on the target interaction content according to the second rules currently deployed inside the CPU, and the second detection result of each target interaction content is obtained. On the CPU side, a real-time processing strategy for the target interactive content is determined based on the first detection result and / or the second detection result, and asynchronous security detection is performed on the sampled interactive content sampled from the artificial intelligence traffic according to the detection rule set to obtain a reference detection result; the detection rule set includes each of the first rule and each of the second rule; In response to the arrival of the judgment period, the detection quality index of the target detection rule related to the sampled interaction content is determined based on the reference detection results, the first detection result and the second detection result of each sampled interaction content within the judgment period; Based on the detection quality indicators of the target detection rules and the current deployment location, determine the rules to be migrated and the target execution location of the rules to be migrated from the target detection rules; The rules to be migrated are deployed to the target execution location without interrupting the execution of the rules at the current deployment location. If the deployment is successful, the rules to be migrated at the current deployment location are removed.
2. The method according to claim 1, characterized in that, The step of determining the detection quality index of the target detection rule related to the sampled interaction content based on the reference detection results, the first detection result, and the second detection result of each sampled interaction content within the judgment period includes: Based on the reference detection results of each sampled interaction content within the judgment period, and whether they are consistent with the first detection result, the detection error of the target first rule related to each sampled interaction content is determined, and the hardware detection delay of each target first rule within the judgment period is collected. The detection error and the hardware detection delay are used as the detection quality indicators of the first rule for the target. The software detection delay of the target second rule related to each sampled interaction content within the judgment period is collected, and the software detection delay is used as the detection quality index of the target second rule. Each of the first target rule and each of the second target rule shall be used as the target detection rule.
3. The method according to claim 2, characterized in that, The step of determining the detection error of the target first rule related to each sampled interaction content based on whether the reference detection results of each sampled interaction content within the judgment period are consistent with the first detection result includes: The judgment period is divided into multiple sub-periods, and for each sampled interaction content in the sub-period, the sub-detection error of the target first rule related to the sampled interaction content in the sub-period is determined based on whether the reference detection result of the sampled interaction content is consistent with the first detection result. Based on the sub-detection error of each target first rule in each sub-period, determine the mean detection error and error fluctuation amplitude of each target first rule; The mean detection error and the error fluctuation amplitude are used as the detection error of the first rule for the target.
4. The method according to claim 1, characterized in that, The step of determining the rule to be migrated and the target execution location of the rule to be migrated from the target detection rules based on the detection quality indicators and the current deployment location of the target detection rules includes: For any of the target detection rules, the execution position of the target detection rule in the target indicator range is determined according to the target indicator range in which the detection quality index of the target detection rule is located; If the current deployment location of the target detection rule is different from the execution location to be used, the target detection rule will be used as the rule to be migrated, and the execution location to be used will be used as the target execution location of the rule to be migrated.
5. The method according to claim 1, characterized in that, Deploying the rule to be migrated to the target execution location in a manner that does not interrupt the execution of the rule to be migrated at the current deployment location includes: Based on the current rule version at the target execution location, the rule to be migrated is compiled to obtain the execution implementation of the new rule version corresponding to the target execution location, and the available resources of the execution implementation of the new rule version are verified at the target execution location. If the available resources are verified, the execution implementation of the new rule version is deployed to the target execution location, and an equivalence check is performed compared with the execution implementation of the old rule version of the rule to be migrated. If the equivalence check is passed, the execution implementation of the old rule version and the execution implementation of the new rule version are run in parallel, and the new artificial intelligence traffic is gradually switched to the execution implementation of the new rule version according to the preset traffic switching method until the switching ratio reaches the preset ratio. Then, it is determined whether the detection quality index of the execution implementation of the new rule version reaches the preset index. If so, then the rule to be migrated is determined to have been successfully deployed at the target execution location.
6. The method according to claim 5, characterized in that, The method further includes: If the detection quality index of the new rule version's execution implementation fails to meet the preset index, the execution implementation will revert to the old rule version's execution implementation and the new rule version's execution implementation will be deleted.
7. The method according to claim 5, characterized in that, Deploying the execution implementation of the new rule version to the target execution location includes: When the target execution location is a hardware execution location, a new core dynamic reconfiguration area, different from the target acceleration core area, is divided from the hardware side. The execution implementation of the new rule version is deployed to the new core dynamic reconfiguration area by burning bitstreams related to the execution implementation of the new rule version into the new core dynamic reconfiguration area. The target acceleration core area is the running area of each of the first rules currently deployed inside the hardware. Alternatively, if the target execution location is a software execution location, the execution implementation of the new rule version can be deployed to the software execution location by pointing the detection thread on the CPU side to the execution implementation of the new rule version.
8. The method according to claim 5, characterized in that, The implementation of gradually switching new AI traffic to the new rule version according to a preset traffic switching method includes: According to the preset traffic switching method, determine the current switching ratio, and determine the traffic to be switched from the new artificial intelligence traffic that meets the current switching ratio; If the traffic to be switched belongs to an existing session, obtain the session matching status information of the existing session under the execution implementation of the old rule version, and synchronously distribute the session matching status information and the traffic to be switched to the execution implementation of the new rule version.
9. The method according to claim 5, characterized in that, At the target execution location, after verifying the availability of resources for the execution implementation of the new rule version, the method further includes: If the target execution location is a hardware execution location and the available resources verification fails, the rule hit rate of each first rule currently deployed inside the hardware under a preset historical duration is determined. The first rule with the lowest hit rate is migrated from the hardware execution location to the software execution location. If the migration is successful, the process returns to the step of verifying the available resources of the new rule version at the target execution location until the execution of the new rule version passes the available resource verification or the number of loops reaches a preset number.
10. The method according to claim 1, characterized in that, The process involves performing security checks on each target interaction content within the AI traffic according to the currently deployed first rules on the hardware side, obtaining the first detection results for each target interaction content, including: On the hardware side, for any target interaction content in the AI traffic, if the target interaction content is a streaming data block returned by the AI model, the maximum number of sub-word bytes of the AI model is determined according to the byte pair encoding rules corresponding to the word segmenter of the AI model, and the length of the overlapping window is determined according to the maximum number of sub-word bytes. If a previous data block exists in the streaming data block, obtain the active state set of the automaton saved after the detection of the previous data block is completed, and the last byte stream in the previous data block that is within the length of the overlapping window; the active state set of the automaton is used to maintain the current matching state of each first rule under the previous data block. The last byte stream and the streaming data block are concatenated to obtain the byte stream to be detected. Then, using an automaton, the byte stream to be detected is scanned byte by byte according to the current matching state stored in the automaton active state set and the first rules currently deployed in the hardware. The first detection result of the streaming data block and the updated automaton active state set are obtained and saved.
11. The method according to claim 10, characterized in that, The method further includes: During the byte-by-byte scanning and detection of the byte stream to be detected, if the detected current byte belongs to one byte of a multi-byte character and the subsequent bytes of the multi-byte character belong to different words than the current byte, then the current scanning pointer and the current matching state of the automaton are rolled back to the byte position and matching state corresponding to the first byte of the multi-byte character. Using the automaton, starting from the backtracked scan pointer position and matching state, the multi-byte character is scanned and its matching state is updated according to the first rules currently deployed within the hardware, ignoring words.
12. A device for adjusting the execution position of a detection rule, characterized in that, The device includes: The first detection module is used to perform security detection on each target interaction content in the artificial intelligence traffic according to the first rules currently deployed inside the hardware on the hardware side, and obtain the first detection result of each target interaction content; and to perform security detection on the target interaction content according to the second rules currently deployed inside the CPU on the central processing unit (CPU) side, and obtain the second detection result of each target interaction content. The second detection module is configured to, on the CPU side, determine a real-time processing strategy for the target interactive content based on the first detection result and / or the second detection result, and perform asynchronous security detection on the sampled interactive content sampled from the artificial intelligence traffic according to the detection rule set to obtain a reference detection result; the detection rule set includes each of the first rule and each of the second rule; The judgment module is used to determine the detection quality index of the target detection rule related to the sampled interaction content in response to the arrival of the judgment period, based on the reference detection results, the first detection result and the second detection result of each sampled interaction content within the judgment period. The determination module is used to determine the rule to be migrated and the target execution location of the rule to be migrated from the target detection rules based on the detection quality index of the target detection rules and the current deployment location. The migration module is used to deploy the rules to be migrated to the target execution location in a manner that does not interrupt the execution of the rules to be migrated at the current deployment location, and, if the deployment is successful, remove the rules to be migrated from the current deployment location.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the method for adjusting the execution position of the detection rule as described in any one of claims 1 to 11.
14. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method for adjusting the execution position of the detection rule as described in any one of claims 1 to 11.
