A rule matching method and device

By using compiled PCRE options and matching types in network security devices for rule matching, the problem of performance degradation of traditional security protection technology is solved, and rapid and accurate matching performance improvement is achieved.

CN115277087BActive Publication Date: 2024-12-06NEW H3C SECURITY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210721879.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-24
Publication Date
2024-12-06
Estimated Expiration
2042-06-24

AI Technical Summary

Technical Problem

Traditional security protection technology cannot meet the increasingly complex network security threats by relying on network layer and transmission layer detection, resulting in the performance of network security devices degraded during deep message detection, especially due to the long matching time and cache usage caused by the increase in the scale of the feature library. question.

Method used

By using compiled PCRE options and matching types in network security devices, rules are directly matched, and the rule compilation process is avoided, offline compilation is used to generate rule feature libraries, and the matching algorithm is determined based on the matching type when matching, improving matching speed and accuracy Spend.

Benefits of technology

It significantly improves the matching performance of network security devices, reduces rule compilation time, improves matching speed and accuracy, avoids excessive memory usage by the rule feature library, and ensures the processing performance of network security devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115277087B_ABST
    Figure CN115277087B_ABST
Patent Text Reader

Abstract

The present application provides a rule matching method and device, which relates to the field of communication technology. The method is: obtaining a message to be identified; identifying and processing the message to be identified according to the current rule feature library, the rule feature library includes compiled PCRE options, and the PCRE options include compiled rules and matching types; confirming the target PCRE option hit by the message to be identified; according to the matching type in the target PCRE option and the compiled rules, using the rule matching algorithm corresponding to the matching type to match the message to be identified. As a result, when performing security detection, the matching speed is improved and the processing performance of the network security equipment is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a rule matching method and device. Background Art

[0002] Deep Packet Inspection (DPI) is a security mechanism that detects and controls network traffic passing through network security devices based on application layer information. In the increasingly complex network security threats, many malicious behaviors (such as worms, spam, vulnerabilities, etc.) are hidden in the application layer payload of data packets. Traditional security protection technology that relies solely on network layer and transport layer security detection technology can no longer meet network security requirements. Therefore, network security devices must have DPI functions to detect and control network application layer information, thereby ensuring the security of data content and network security.

[0003] The service identification of the DPI function is to match the characteristic string of the message. The current DPI engine is implemented through the multi-pattern matching (AC) algorithm and the PCRE (Perl Compatible Regular Expressions) algorithm when performing security detection. As the scale of the feature library related to the DPI service (such as the IPS feature library, anti-virus feature library, etc.) gradually increases, the throughput performance of the network security equipment will drop a lot. At the same time, when using the aforementioned feature library for matching, due to the large scale of the feature library, it will take a lot of time to match, and the matching process will occupy a lot of cache, which will limit the processing performance of the network security equipment.

[0004] Therefore, how to improve the matching speed and the processing performance of network security equipment when conducting security testing is one of the technical issues worth considering. Summary of the invention

[0005] In view of this, the present application provides a rule matching method and apparatus for improving the matching speed and the processing performance of network security equipment when performing security detection.

[0006] Specifically, the present application is implemented through the following technical solutions:

[0007] According to a first aspect of the present application, a rule matching method is provided, comprising:

[0008] Obtain the message to be identified;

[0009] Performing identification processing on the message to be identified according to a current rule feature library, wherein the rule feature library includes compiled PCRE options, and the PCRE options include compiled rules and matching types;

[0010] Confirming the target PCRE option hit by the message to be identified;

[0011] According to the match type in the target PCRE option and the compiled rules, the message to be identified is matched with rules using a rule matching algorithm corresponding to the match type.

[0012] According to a second aspect of the present application, a rule matching device is provided, comprising:

[0013] An acquisition module, used for acquiring a message to be identified;

[0014] An identification module, used for identifying and processing the message to be identified according to a current rule feature library, wherein the rule feature library includes compiled PCRE options, and the PCRE options include compiled rules and matching types;

[0015] A confirmation module, used for confirming the target PCRE option hit by the message to be identified;

[0016] The matching module is used to perform rule matching on the message to be identified according to the matching type in the target PCRE option and the compiled rules by using the rule matching algorithm corresponding to the matching type.

[0017] According to the third aspect of the present application, an electronic device is provided, including a processor and a machine-readable storage medium, the machine-readable storage medium storing a computer program that can be executed by the processor, and the processor is prompted by the computer program to execute the method provided in the first aspect of the embodiment of the present application.

[0018] According to the fourth aspect of the present application, a machine-readable storage medium is provided, which stores a computer program. When called and executed by a processor, the computer program prompts the processor to execute the method provided in the first aspect of the embodiment of the present application.

[0019] Beneficial effects of the embodiments of the present application:

[0020] In the rule matching method and device provided in the embodiment of the present application, after obtaining the message to be identified, the message to be identified is identified and processed according to the current rule feature library, so that the target PCRE option hit by the message to be identified can be confirmed; then, according to the matching type in the hit target PCRE option and the compiled rules, the message to be identified is rule matched using the rule matching algorithm corresponding to the matching type. By adopting the above method, since the rule feature library provided in the embodiment of the present application includes compiled PCRE options, the compiled PCRE options include compiled rules. In this way, when performing rule identification, there is no need to execute the rule compilation process after hitting the PCRE option, thereby greatly saving the rule compilation time; in addition, the compiled PCRE options in the rule feature library provided in this embodiment include matching types. In this way, when performing rule matching, the matching algorithm can be directly determined based on the matching type in the hit PCRE option, and then the corresponding matching algorithm is called to match the message to be identified, and the matching type in each PCER option is a matching algorithm that matches the rule in the PCRE option. In this way, when using the corresponding matching algorithm to perform rule matching, not only is the accuracy high, but the matching speed is also fast, thereby improving the matching performance of the network security device. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 It is a flowchart of a rule matching method provided in an embodiment of the present application;

[0022] Figure 2 is a structural schematic diagram of a rule matching device provided in an embodiment of the present application;

[0023] Figure 3 It is a hardware structure diagram of an implementation rule matching method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0024] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application.

[0025] The terms used in this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in this article refers to and includes any or all possible combinations of one or more corresponding listed items.

[0026] It should be understood that although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0027] The rule matching method provided in this application is described in detail below.

[0028] See also Figure 1 , Figure 1 This is a flowchart of a rule matching method provided by the present application. The method can be applied to network security devices, which may include but are not limited to firewalls, gateways, servers that need to perform security detection, and other devices. When the network security device implements the above method, it may include the following steps:

[0029] S101: Obtain a message to be identified.

[0030] In this step, the network security device will continue to receive network messages flowing into the network it is connected to, which are recorded as the above-mentioned messages to be identified; in order to improve the security of the network, the received network messages will be identified.

[0031] S102: Identify and process the message to be identified according to the current rule feature library.

[0032] The rule feature library includes compiled PCRE options, and the PCRE options include compiled rules and matching types.

[0033] In this step, the network security device uses the feature library to identify the string features of the application layer traffic. The feature library is a resource library that is updated as the Internet changes. In addition, application layer services such as application identification, intrusion detection, URL filtering, and antivirus all require the help of feature libraries, and each service has its own independent feature library. In view of this, in order to match the rules of the message in this embodiment, the network security device will obtain the current rule feature library, and then identify the message to be identified based on the rule feature library.

[0034] It should be noted that when the message to be identified is identified based on the current rule feature library, step S102 may be performed according to the following process: extracting message features from the message to be identified; and identifying the message features using the current rule feature library.

[0035] Specifically, after the message features are extracted from the message to be identified, the message features can be mapped based on the mapping relationship between the message features and the rules, so that the target rules hit by the message features can be obtained. If the target rules are in the current rule feature library, it can be determined that the message to be identified hits the current rule feature library.

[0036] S103: Confirm the target PCRE option hit by the message to be identified.

[0037] In this step, after the target rule hit by the message to be identified is confirmed, the PCRE option where the target rule hit by the message can be determined, that is, the target PCRE option mentioned above.

[0038] It should be noted that the message to be identified may hit more than one target PCRE option. When multiple target PCRE options are hit, the rule matching process of step S104 is executed for each target PCRE option.

[0039] S104: According to the match type in the target PCRE option and the compiled rules, use a rule matching algorithm corresponding to the match type to perform rule matching on the message to be identified.

[0040] In this step, since the PCRE options in the rule feature library provided in this embodiment generally also include a matching type, when the target PCRE option hit by the message to be identified is identified, the matching type in the target PCRE option can be used to determine the matching algorithm corresponding to the matching type, and then the matching algorithm can be called to execute the compiled rules included in the target PCRE option to perform rule matching on the message to be identified, thereby identifying whether the message to be identified contains a virus. Moreover, since the rules in the PCRE options included in the rule feature library provided in this embodiment are compiled rules, there is no need to perform the compilation process when using the rules for identification, which reduces the time required for rule compilation, thereby speeding up the rule matching speed of the message.

[0041] In addition, when configuring a matching type for a rule in each PCRE option in the rule feature library, the matching type is a type corresponding to a matching algorithm that matches the rule in the PCRE option, that is, when matching the PCRE option, a suitable matching algorithm is set for the rule in the PCRE option, and then the matching type to which the suitable matching algorithm belongs is written into the PCRE option, that is, when the matching algorithm is used to perform matching of the rule in the PCRE option, not only the speed is fast but also the accuracy is high. In this way, after the target PCRE option is confirmed, when executing step S104, not only can the rule matching be performed quickly on the to-be-identified file, but also a rule matching result with a relatively high accuracy can be obtained.

[0042] By implementing the rule matching method provided in the present application, after obtaining the message to be identified, the message to be identified is identified and processed according to the current rule feature library, so that the target PCRE option hit by the message to be identified can be confirmed; then, according to the matching type in the hit target PCRE option and the compiled rules, the message to be identified is rule matched using the rule matching algorithm corresponding to the matching type. By adopting the above method, since the rule feature library provided in the embodiment of the present application includes compiled PCRE options, the compiled PCRE options include compiled rules. In this way, when performing rule identification, there is no need to execute the rule compilation process after hitting the PCRE option, thereby greatly saving the rule compilation time; in addition, the compiled PCRE options in the rule feature library provided in this embodiment include matching types. In this way, when performing rule matching, the matching algorithm can be directly determined based on the matching type in the hit PCRE option, and then the corresponding matching algorithm is called to match the message to be identified, and the matching type in each PCER option is a matching algorithm that matches the rule in the PCRE option. In this way, when using the corresponding matching algorithm to perform rule matching, not only is the accuracy high, but the matching speed is also fast, thereby improving the matching performance of the network security device.

[0043] Optionally, based on the above embodiment, the rule feature library in this embodiment is generated by an offline compilation method, and the offline compilation method is: compile the regular expression in each initial PCRE option in the initial feature library to obtain compiled rules; determine the matching algorithm used for rule matching of the compiled rules; construct a new PCRE option with the matching identifier of the compiled rules and the determined matching algorithm; and generate the rule feature library based on the constructed new PCRE options.

[0044] Specifically, when performing offline compilation, the network security device will provide an interface, and then complete the offline compilation of the rule feature library by calling the interface. That is, for each initial PCRE rule in the initial feature library, the regular expression in the initial PCRE rule can be compiled to obtain a compiled rule. For example, the format of an initial PCRE option is as follows.

[0045] Rule ID:1

[0046] Rule_Name:IPS_Rule

[0047] L4protocol:tcp

[0048] Direction: request

[0049] Application:http

[0050] [Pattern:windidkey=,Position:Http_uri]

[0051] [Pcre:uid=\d{1,10}\x26password=,Position:Http_uri]

[0052] On this basis, the regular expression uid=\d{1,10}\x26password= in the initial PCRE rule, the network security device can call the above interface to compile the regular expression, so as to obtain the compiled content buf. Assuming that the compiled content is: 0101111111111010101011111122122564asdfeeefccc1234564555458522545658522254452, the regular expression in the initial PCRE rule is replaced by the compiled content to obtain the compiled rule, and then the matching algorithm for matching the compiled rule is determined, and then the matching type corresponding to the determined matching algorithm and the compiled rule obtained by the above compilation constitute a new PCRE option. For example, if the above determined matching algorithm is the DFA algorithm, the value of the corresponding matching type can be configured as 1. For the convenience of description, it can be expressed as Pcre_type:1, and the corresponding new PCRE option is as follows:

[0053] Rule ID:1

[0054] Rule_Name:IPS_Rule

[0055] L4protocol:tcp

[0056] Direction: request

[0057] Application:http

[0058] [Pattern:windidkey=,Position:Http_uri]

[0059] [Pcre:0101111111111010101011111122122564asdfeeefccc1234564555458522545658522254452,Position:Http_uri,Pcre_type: 1]

[0060] It should be noted that different matching algorithms correspond to different matching types, but the specific values ​​can be configured according to the specific situation, and this embodiment does not limit this. For the convenience of illustration and better understanding of this embodiment, the following example is used to represent the corresponding relationship between the matching algorithm and the matching type:

[0061] Pcre_Type: 0---Exhaustive method

[0062] 1----DFA state machine algorithm

[0063] 2----NFA state machine algorithm

[0064] Thus, each new PCRE option corresponding to each initial PCRE option can be determined, and then a rule feature library is generated based on each new PCRE option. In this way, the rule feature library obtained is the compiled rule, and then when performing online rule matching, there is no need to perform the rule compilation step, which greatly saves the matching time of rule matching.

[0065] Furthermore, since the size of the rule feature library may become relatively large after the regular expression in the initial PCRE option is compiled offline, in order to avoid occupying too much memory resources of the network security device, this embodiment proposes that before executing the above-mentioned matching algorithm for matching the compiled rules, the following process may also be included: determining the rule length of the compiled rules; determining that the rule length is not greater than the set length threshold.

[0066] Specifically, after compiling the regular expression in each initial PCRE option to obtain the compiled rule, the rule length of the compiled rule can be determined. When the rule length is not greater than the set length threshold, the matching algorithm and subsequent steps for matching the compiled rule are executed to generate a new PCRE option corresponding to the initial PCRE option.

[0067] It should be noted that the above-mentioned set length threshold is set according to the memory size of the network security device. When the rule length of each rule is not greater than the above-mentioned set threshold, it can be ensured that the final rule feature library will not be particularly large, so it will not cause storage burden on the network security device.

[0068] However, when the rule length of the compiled rule obtained after compiling the regular expression in a certain initial PCRE option is greater than the above-mentioned set length threshold, if a new compiled rule is continued to be constructed based on the compiled rule, the rule feature library may be relatively large, which may in turn cause a heavy memory burden on the network security device. In order to avoid this problem, this embodiment proposes that when the rule length of the compiled rule is greater than the set length threshold, the initial PCRE option corresponding to the compiled rule is retained; and the rule feature library is generated based on the retained initial PCRE option and a new PCRE option constructed based on the compiled rule whose rule length is not greater than the set length threshold.

[0069] Specifically, when the regular expression in a certain initial PCRE option is compiled and the rule length of the compiled rule is greater than the set length threshold, the initial PCRE option is retained and no new PCRE option is constructed for the initial PCRE option. In this way, the retained initial PCRE option and the new PCRE option can be determined, and then a rule feature library is generated based on the retained initial PCRE option and the new PCRE option.

[0070] On this basis, when the rule feature library includes the initial PCRE rule, the rule matching method provided in this embodiment may also include the following method: when the message to be identified hits the initial PCRE option, the regular expression in the initial PCRE option is compiled online to obtain the compiled rule; the message to be identified is subjected to rule matching processing using the compiled rule and the matching algorithm corresponding to the compiled rule.

[0071] Specifically, when the message to be identified hits the initial PCRE option in the rule feature library, it is necessary to compile the regular expression in the initial PCRE option when matching the rules. Then, the compiled rules are obtained, and the matching algorithm corresponding to the compiled rules is used to execute the compiled rules to perform rule matching on the message to be identified. In this way, although the online compilation traffic is executed, it is only executed for the initial PCRE option whose rule length is greater than the set length threshold. Compared with the method of performing online compilation on the regular expressions in all the initial PCRE options, the total compilation time is saved, thereby ensuring that the rule feature library will not cause a large memory burden on the network security device, and the rule matching speed can be improved to a certain extent.

[0072] It should be noted that when performing online compilation for the initial PCRE options, the compilation process can be performed using an exhaustive method, which will not be described in detail here.

[0073] After the rule feature library is generated based on any of the above embodiments, it can be loaded onto the network security device by way of upgrading, so that the network security device can execute the rule matching process of the message.

[0074] Optionally, any of the above rule feature libraries is dynamically updated, and after offline update compilation of the rule feature library is executed, it is loaded into the network security device by way of an upgrade.

[0075] Optionally, based on any of the above embodiments, the rule matching method provided in this embodiment may also include the following process: when the message to be identified does not hit the PCRE option in the rule feature library, the exhaustive method and / or the non-deterministic finite automaton NFA algorithm are used to perform rule matching on the message to be identified.

[0076] Specifically, when the message to be identified does not hit any PCRE option in the rule feature library, in order to ensure the security of the traffic flowing into the network, this embodiment proposes to use the exhaustive method and / or NFA algorithm to match the rules of the message to be identified, which will not be described in detail here. In this way, the security of the message flowing into the network and the security of the network are guaranteed.

[0077] Optionally, based on any of the above embodiments, in this embodiment, in order to ensure the integrity of the process, before executing step S102, the rule matching method provided in this embodiment may also include the following process: performing application identification based on the message to be identified, and then using the protocol plug-in to parse each required field from the message to be identified, and then using file identification to extract message features in the message to be identified, and then executing step S102.

[0078] At this point, by implementing the rule matching method provided in any embodiment of the present application, the rule matching method adopted in the present application can achieve a significant improvement in matching speed, at least 3 times faster than the rule matching method based on regular expressions.

[0079] In addition, the offline compilation method in this application has little effect on the upgrade speed, and the rule feature library obtained by the method provided by this application will not cause a large memory burden on the network security device, and solves the defects of the PCRE exhaustive method of caching messages, thereby improving the overall performance of the network security device.

[0080] Based on the same inventive concept, the present application also provides a rule matching device corresponding to the above rule matching method. The implementation of the rule matching device can refer to the above description of the rule matching method, which will not be discussed here one by one.

[0081] See also Figure 2 , Figure 2 A rule matching device provided by an exemplary embodiment of the present application includes:

[0082] An acquisition module 201 is used to acquire a message to be identified;

[0083] An identification module 202, configured to identify the message to be identified according to a current rule feature library, wherein the rule feature library includes compiled PCRE options, and the PCRE options include compiled rules and matching types;

[0084] A confirmation module 203 is used to confirm the target PCRE option hit by the message to be identified;

[0085] The matching module 204 is used to perform rule matching on the message to be identified according to the matching type in the target PCRE option and the compiled rules by using the rule matching algorithm corresponding to the matching type.

[0086] Optionally, the rule feature library is generated by an offline compilation method. On this basis, the rule matching device provided by this embodiment further includes:

[0087] An offline compilation module (not shown in the figure) is used to compile the regular expression in each initial PCRE option in the initial feature library to obtain compiled rules;

[0088] A first determination module (not shown in the figure), used to determine a matching algorithm for matching the compiled rules;

[0089] A construction module (not shown in the figure), used for constructing a new PCRE option from the compiled rules and the determined matching type of the matching algorithm;

[0090] A generation module (not shown in the figure) is used to generate the rule feature library based on each new PCRE option constructed.

[0091] Optionally, on this basis, the rule matching device provided in this embodiment may further include:

[0092] A second determination module (not shown in the figure), used for determining the rule length of the compiled rule before the first determination module determines the matching algorithm for matching the compiled rule;

[0093] The third determination module (not shown in the figure) is used to determine that the rule length is not greater than a set length threshold.

[0094] Optionally, on this basis, the rule matching device provided in this embodiment may further include:

[0095] A retaining module (not shown in the figure), configured to retain the initial PCRE option corresponding to the compiled rule when the third determining module determines that the rule length is greater than a set length threshold;

[0096] The generation module (not shown in the figure) is also used to generate the rule feature library according to the retained initial PCRE options and new PRCE options composed of compiled rules whose rule length is not greater than the set length threshold.

[0097] Optionally, the rule matching device provided in this embodiment may further include:

[0098] A compiling module (not shown in the figure), which is used for compiling the regular expression in the initial PCRE option online to obtain the compiled rule when the rule feature library includes the initial PCRE rule and when the message to be identified hits the initial PCRE option;

[0099] The matching module 204 is further configured to perform rule matching processing on the message to be identified by using the compiled rules and the matching algorithm corresponding to the compiled rules.

[0100] Optionally, based on any of the above embodiments, in this embodiment, the identification module 202 is specifically used to extract message features from the message to be identified; and identify the message features using the current rule feature library.

[0101] By providing the rule matching device provided by any of the above embodiments, after obtaining the message to be identified, the message to be identified is identified and processed according to the current rule feature library, so that the target PCRE option hit by the message to be identified can be confirmed; then, according to the matching type in the hit target PCRE option and the compiled rules, the message to be identified is rule matched using the rule matching algorithm corresponding to the matching type. By adopting the above method, since the rule feature library provided in the embodiment of the present application includes compiled PCRE options, the compiled PCRE options include compiled rules. In this way, when performing rule identification, there is no need to execute the rule compilation process after hitting the PCRE option, thereby greatly saving the rule compilation time; in addition, the compiled PCRE options in the rule feature library provided in this embodiment include matching types. In this way, when performing rule matching, the matching algorithm can be directly determined based on the matching type in the hit PCRE option, and then the corresponding matching algorithm is called to match the message to be identified, and the matching type in each PCER option is a matching algorithm that matches the rule in the PCRE option. In this way, when using the corresponding matching algorithm to perform rule matching, not only is the accuracy high, but the matching speed is also fast, thereby improving the matching performance of the network security device.

[0102] Based on the same inventive concept, an embodiment of the present application provides an electronic device, which can be but is not limited to the above-mentioned network security device. Figure 3 As shown, the electronic device includes a processor 301 and a machine-readable storage medium 302, the machine-readable storage medium 302 stores a computer program that can be executed by the processor 301, and the processor 301 is prompted by the computer program to execute the rule matching method provided by any embodiment of the present application. In addition, the electronic device also includes a communication interface 303 and a communication bus 304, wherein the processor 301, the communication interface 303, and the machine-readable storage medium 302 communicate with each other through the communication bus 304.

[0103] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0104] The communication interface is used for communication between the above electronic device and other devices.

[0105] The machine-readable storage medium 302 may be a memory, which may include a random access memory (RAM), a DDR SRAM (Double Data Rate Synchronous Dynamic Random Access Memory), or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the processor.

[0106] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0107] As for the electronic device and machine-readable storage medium embodiments, since the method contents involved are basically similar to the aforementioned method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0108] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0109] The implementation process of the functions and effects of each unit / module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0110] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are merely schematic, wherein the units / modules described as separate components may or may not be physically separated, and the components displayed as units / modules may or may not be physical units / modules, that is, they may be located in one place, or they may be distributed on multiple network units / modules. Some or all of the units / modules may be selected according to actual needs to achieve the purpose of the present application. A person of ordinary skill in the art can understand and implement it without creative work.

[0111] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A rule matching method, characterized in that: include: Obtain the message to be identified; Performing identification processing on the message to be identified according to a current rule feature library, wherein the rule feature library includes compiled PCRE options, and the PCRE options include compiled rules and matching types; Confirming the target PCRE option hit by the message to be identified; According to the match type in the target PCRE option and the compiled rules, the message to be identified is matched by using a rule matching algorithm corresponding to the match type; The rule feature library is generated by an offline compilation method, wherein the offline compilation method comprises: compiling the regular expression in each initial PCRE option in the initial feature library to obtain compiled rules; determining a matching algorithm for matching the compiled rules; forming a new PCRE option with the compiled rules and the matching type of the determined matching algorithm; and generating the rule feature library based on each formed new PCRE option; Before determining the matching algorithm for matching the compiled rule, the method further includes: determining the rule length of the compiled rule; determining that the rule length is not greater than a set length threshold; When the rule length is greater than the set length threshold, the initial PCRE option corresponding to the compiled rule is retained; Generate the rule feature library according to the retained initial PCRE options and new PRCE options formed based on compiled rules whose rule length is not greater than the set length threshold; When the rule feature library includes an initial PCRE rule, the method further includes: when the message to be identified hits the initial PCRE option, compiling the regular expression in the initial PCRE option online to obtain a compiled rule; and performing rule matching processing on the message to be identified using the compiled rule and the matching algorithm corresponding to the compiled rule.

2. The method according to claim 1, characterized in that Using the current rule feature library to identify the message to be identified, specifically includes: Extracting message features from the message to be identified; The message features are identified using the current rule feature library.

3. A rule matching device, characterized in that: include: An acquisition module, used for acquiring a message to be identified; An identification module, used for identifying and processing the message to be identified according to a current rule feature library, wherein the rule feature library includes compiled PCRE options, and the PCRE options include compiled rules and matching types; A confirmation module, used for confirming the target PCRE option hit by the message to be identified; A matching module, configured to perform rule matching on the message to be identified using a rule matching algorithm corresponding to the match type according to the match type in the target PCRE option and the compiled rules; The rule feature library is generated by an offline compilation method, and the device further includes: An offline compilation module is used to compile the regular expressions in each initial PCRE option in the initial feature library to obtain compiled rules; A first determination module, used to determine a matching algorithm for matching the compiled rules; A construction module, used for forming a new PCRE option by combining the compiled rule and the determined matching type of the matching algorithm; A generating module, used for generating the rule feature library based on each new PCRE option constructed; The device further comprises: A second determination module, configured to determine a rule length of the compiled rule before the first determination module determines a matching algorithm for matching the compiled rule; A third determination module, used to determine that the rule length is not greater than a set length threshold; The device further comprises: A retaining module, configured to retain the initial PCRE option corresponding to the compiled rule when the third determining module determines that the rule length is greater than a set length threshold; The generating module is further used to generate the rule feature library according to the retained initial PCRE options and the new PRCE options formed based on the compiled rules whose rule length is not greater than the set length threshold; The device further comprises: A compiling module, for compiling the regular expression in the initial PCRE option online to obtain the compiled rule when the rule feature library includes the initial PCRE rule and when the message to be identified hits the initial PCRE option; The matching module is further used to perform rule matching processing on the message to be identified by using the compiled rules and the matching algorithm corresponding to the compiled rules.

4. The device according to claim 3, characterized in that The identification module is specifically used to extract message features from the message to be identified; and identify the message features using the current rule feature library.