A WAF rule loading method, device, electronic device and storage medium

By identifying and loading the updated WAF rule file, the problem of low loading efficiency after the WAF rule base is updated is solved, the loading efficiency is improved, and the system performance is improved.

CN114422234BActive Publication Date: 2024-08-30BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202210051298.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-17
Publication Date
2024-08-30
Estimated Expiration
2042-01-17

AI Technical Summary

Technical Problem

The existing technology has low loading efficiency after the WAF rule base is updated, especially in scenarios where only a small number of rules are updated, causing system performance to be affected.

Method used

By scanning the rule files in the specified rule base, the updated rule files are identified based on the target information and historical file information, and only the loading process is performed to avoid full loading.

Benefits of technology

It improves the efficiency of WAF rule loading, reduces redundant loading operations, and improves system performance, especially in WAF and CDN systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114422234B
    Figure CN114422234B
Patent Text Reader

Abstract

The embodiment of the present invention provides a WAF rule loading method, device, electronic device and storage medium, which are applied to the field of computer technology. The loading method includes: when the trigger condition for file loading is met, scanning each rule file in the specified rule base; wherein the specified rule base is a rule base for the Web application firewall WAF; for each rule file scanned, based on the target information of the rule file and the target information of each historical file, identifying whether the rule file is a file that has been updated relative to each historical file; wherein the historical file is a rule file that has been loaded, the target information includes a name and / or a specified attribute, and the specified attribute is an attribute that changes when the file content is updated; the identified updated rule file is loaded. This solution can solve the problem of low loading efficiency after the rule base is updated in the related technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a WAF rule loading method, device, electronic device and storage medium. Background Art

[0002] WAF (Web Application Firewall) devices, i.e. devices with WAF programs deployed, are used to detect and verify the content of various requests from Web applications to ensure their security and legality, and block illegal requests in real time, thereby effectively protecting various websites. Among them, the rule file that records the protection rules is saved in the rule library for WAF, and the WAF rule loading is realized by loading the rule file into the WAF engine. The WAF engine is the core module of the WAF program.

[0003] Since the protection requirements have changed, the rule files also need to be updated, and the updated rule files are stored in the rule base. In the related art, after the rule files are updated and stored in the rule base, when the WAF device receives the hot load command issued by the operation and maintenance personnel, it loads all the files in the rule base.

[0004] However, the use of related technologies will undoubtedly generate a large number of redundant loading operations, resulting in low loading efficiency. Especially in scenarios where only a small number of rules are updated, the problem of low loading efficiency is more obvious. Summary of the invention

[0005] The purpose of the embodiments of the present invention is to provide a WAF rule loading method, device, electronic device and storage medium to solve the problem of low loading efficiency after the rule base is updated in the related technology. The specific technical solution is as follows:

[0006] In a first aspect, an embodiment of the present invention provides a WAF rule loading method, including:

[0007] When the trigger condition for file loading is met, each rule file in the specified rule base is scanned; wherein the specified rule base is a rule base for the Web Application Firewall WAF;

[0008] For each rule file scanned, based on the target information of the rule file and the target information of each history file, identifying whether the rule file is a file that is updated relative to each history file; wherein the history file is a rule file that has been loaded, the target information includes a name and / or a specified attribute, and the specified attribute is an attribute that changes when the file content is updated;

[0009] The updated rule files that are identified are loaded.

[0010] Optionally, for each scanned rule file, based on target information of the rule file and target information of each history file, identifying whether the rule file is an updated file relative to each history file includes:

[0011] For each rule file scanned, detecting whether the target history file has the same specified attribute as the rule file; wherein the target history file is a history file with the same name as the rule file;

[0012] If they are different, the rule file is identified as an updated file; if they are the same, the rule file is identified as a non-updated file.

[0013] Optionally, before detecting whether the target history file has the same specified attribute as the rule file, the method further includes:

[0014] Find the name of the rule file from the names of each history file;

[0015] If found, the step of detecting whether the target history file has the same specified attribute as the rule file is executed;

[0016] If not found, the rule file is identified as the updated file.

[0017] Optionally, the trigger condition for file loading includes: reaching a preset timing time.

[0018] Optionally, after loading the identified updated rule file, the method further includes:

[0019] The target information of each history file is updated using the target information of the updated rule file.

[0020] In a second aspect, an embodiment of the present invention provides a WAF system, including a central control device and a Web application firewall WAF device;

[0021] The central control device is used to send the received rule file to the WAF device when receiving the updated rule file;

[0022] The WAF device is used to store the received rule file in a specified rule base when receiving the rule file sent by the central control device; wherein the specified rule base is a rule base for WAF;

[0023] The WAF device is also used to scan each rule file in the specified rule base when the trigger condition for file loading is met; for each scanned rule file, based on the target information of the rule file and the target information of each historical file, identify whether the rule file is an updated file relative to each historical file; and load the identified updated rule file.

[0024] The history file is a rule file that has been loaded, and the target information includes a name and / or a specified attribute, where the specified attribute is an attribute that changes when the file content is updated.

[0025] Optionally, the WAF device is a node in a content delivery network CDN system.

[0026] In a third aspect, an embodiment of the present invention provides a WAF rule loading device, the device comprising:

[0027] A scanning module, used for scanning each rule file in a specified rule base when a trigger condition for file loading is met; wherein the specified rule base is a rule base for a Web application firewall WAF;

[0028] an identification module, for identifying, for each scanned rule file, whether the rule file is a file updated relative to each history file based on target information of the rule file and target information of each history file; wherein the history file is a rule file that has been loaded, the target information includes a name and / or a specified attribute, and the specified attribute is an attribute that changes when the file content is updated;

[0029] The loading module is used to load the rule file that is identified to be updated.

[0030] Optionally, the identification module includes:

[0031] An identification submodule is used to detect, for each scanned rule file, whether a target history file is identical to a specified attribute of the rule file; wherein the target history file is a history file having the same name as the rule file; if they are different, the rule file is identified as an updated file; if they are identical, the rule file is identified as a non-updated file.

[0032] Optionally, the identification submodule is also used to: before detecting whether the target historical file is the same as the specified attribute of the rule file, search for the name of the rule file from the names of each historical file; if found, execute the step of detecting whether the target historical file is the same as the specified attribute of the rule file; if not found, identify the rule file as the file that has been updated.

[0033] Optionally, the device also includes:

[0034] The update module is used to update the target information of each historical file using the target information of the updated rule file after the loading module loads the updated rule file identified; wherein the historical file is a historical file with the same name as the rule file.

[0035] In a fourth aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0036] Memory, used to store computer programs;

[0037] The processor is used to implement the steps of any WAF rule loading method when executing the program stored in the memory.

[0038] In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any WAF rule loading method are implemented.

[0039] Beneficial effects of the embodiments of the present invention:

[0040] The solution provided by the embodiment of the present invention, when the trigger condition for file loading is met, scans each rule file in the specified rule base; wherein the specified rule base is a rule base for the Web application firewall WAF; for each rule file scanned, based on the target information of the rule file and the target information of each historical file, identifies whether the rule file is a file that has been updated relative to each historical file; wherein the historical file is a rule file that has been loaded, and the target information includes a name and / or a specified attribute, and the specified attribute is an attribute that changes when the file content is updated; the identified updated rule file is loaded. It can be seen that when loading WAF rules, this solution can automatically identify the rule files in the specified database that have been updated relative to each historical file, and only load the updated rule files, avoiding the full loading of the rule files for each hot load, so that when loading WAF rules, a large number of redundant loading operations will not be generated. Therefore, this solution can solve the problem of low loading efficiency of the related technology after the rule base is updated, and improve the loading efficiency.

[0041] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0043] Figure 1 A flowchart of a WAF rule loading method provided by an embodiment of the present invention;

[0044] Figure 2 Another flow chart of a WAF rule loading method provided by an embodiment of the present invention;

[0045] Figure 3 Another flow chart of a WAF rule loading method provided by an embodiment of the present invention;

[0046] Figure 4 A schematic diagram of the structure of a WAF rule loading device provided by an embodiment of the present invention;

[0047] Figure 5 Another structural schematic diagram of a WAF rule loading device provided by an embodiment of the present invention;

[0048] Figure 6 A schematic diagram of the structure of a WAF rule loading system provided by an embodiment of the present invention;

[0049] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0051] In the related technology, after the rule file is updated and stored in the rule base, when the WAF device receives the hot load command issued by the operation and maintenance personnel, it loads all the files in the rule base. However, the use of related technologies will undoubtedly generate a large number of redundant loading operations, resulting in low loading efficiency, especially in scenarios where only a small number of rules are updated, the problem of low loading efficiency is more obvious. In addition, for the system that combines WAF with CDN (Content Delivery Network), the WAF device serves as a node in the CDN network, that is, each node in the CDN network can be used as a WAF device. Then, due to the large number of nodes, if each node loads rules according to the related technology, the loading efficiency of each node is low, which has a serious impact on system performance.

[0052] In order to solve the problem of low WAF rule loading efficiency in the related art, an embodiment of the present invention provides a WAF rule loading method, device, electronic device and storage medium.

[0053] The following first introduces a WAF rule loading method provided by an embodiment of the present invention.

[0054] A WAF rule loading method provided in an embodiment of the present invention can be applied to a WAF device, wherein the WAF device is a device with a WAF program deployed. Furthermore, the method can be applied to a WAF device in any application scenario where a rule file can be updated. In practical applications, the WAF device can be any type of device that can deploy a WAF program, such as a server or a terminal device, which is reasonable.

[0055] The functional software for implementing the WAF rule loading method may be: a WAF program running on a WAF device. Specifically, the method may be implemented through a designated module set in the WAF program. The designated module may be named a real-time loading module, but is not limited thereto.

[0056] In addition, it is understandable that the rule file recording the protection rules is saved in the rule library for WAF, and the WAF rule loading is realized by loading the rule file into the WAF engine. Among them, the WAF engine is the core module of the WAF program. When the WAF device receives any network request, the WAF engine can detect and verify the network request based on the protection rules in the pre-loaded rule file to ensure its security and legality. It should be noted that the content of the rules recorded in the rule file is different in different protection scenarios, and the embodiment of the present invention does not limit the specific content of the rules.

[0057] In order to solve the problems of the related art, an embodiment of the present invention provides a WAF rule loading method, which may include the following steps:

[0058] When the trigger condition for file loading is met, each rule file in the specified rule base is scanned; wherein the specified rule base is a rule base for the Web Application Firewall WAF;

[0059] For each rule file scanned, based on the target information of the rule file and the target information of each history file, identifying whether the rule file is a file that is updated relative to each history file; wherein the history file is a rule file that has been loaded, the target information includes a name and / or a specified attribute, and the specified attribute is an attribute that changes when the file content is updated;

[0060] The updated rule files that are identified are loaded.

[0061] It can be seen that when loading WAF rules, this solution can automatically identify the rule files in the specified database that have been updated relative to each historical file, and only load the updated rule files, avoiding loading the rule files in full every time hot loading, so that when loading WAF rules, a large number of redundant loading operations will not be generated. Therefore, this solution can solve the problem of low loading efficiency after the rule base is updated in related technologies, and improve loading efficiency. In addition, for a system that combines WAF with CDN, when the solution provided by the present invention is used to load rule files, the system performance can be greatly improved.

[0062] In the following, a WAF rule loading method provided by an embodiment of the present invention is specifically described in conjunction with the accompanying drawings.

[0063] Figure 1 A flowchart of a WAF rule loading method provided by an embodiment of the present invention is shown as follows: Figure 1 As shown, the method may include the following steps S101-S103:

[0064] S101: When a trigger condition for file loading is met, scanning each rule file in a specified rule base;

[0065] Wherein, the specified rule base is a rule base for WAF;

[0066] In order to solve the problems existing in the related technology, the WAF device can detect whether the trigger conditions for file loading are met. If it is detected that the trigger conditions for file loading are met, in order to load the updated rule file, each rule file in the specified rule base can be scanned, and then subsequent processing can be performed based on the scanned rule file.

[0067] It is understandable that there may be multiple triggering conditions for file loading.

[0068] Exemplarily, in one implementation, the trigger condition may include: receiving a hot load command. For this implementation, after the updated rule file is sent to the WAF device, the operation and maintenance personnel may issue a hot load command to the WAF device, and accordingly, the WAF device may receive the hot load command, thereby detecting that the trigger condition for file loading is met.

[0069] For example, in another implementation, the trigger condition may include: reaching a preset timer. Through this implementation, the WAF device can implement a scheduled scan of the WAF device without the need for the operation and maintenance personnel to issue a hot load command, thereby reducing the operation and maintenance cost and ensuring the quality of online services. In a scenario where there are a large number of WAF devices, this implementation can greatly reduce the operation and maintenance cost.

[0070] The above description of the triggering conditions is merely an example and should not be construed as limiting the embodiments of the present invention.

[0071] Furthermore, there are multiple ways to scan each rule file in a specified rule base. For example, scanning in ascending order of file size, scanning in chronological order of file storage time, or scanning according to the category to which the file belongs. It should be noted that the above description of the method for scanning each rule file in a rule base is merely an example and should not constitute a limitation on the embodiments of the present invention.

[0072] In addition, after receiving any rule file sent by the sender, the WAF device can directly store the rule file in the specified rule base, and any rule file can be an updated rule file. In one implementation, the central control device used to manage each WAF device can act as a sender to send updated rule files to the WAF device. Specifically: when the central control device receives an updated rule file, it sends the received rule file to the WAF device. In this way, when the WAF device receives the rule file sent by the central control device, it directly stores the received rule file in the specified rule base; wherein, the updated rule file can be uploaded to the central control device by the configuration personnel through the front end, of course, it is not limited to this. It should be emphasized that the above-mentioned specific implementation method of sending updated rule files to the WAF device is merely an example and should not constitute a limitation on the embodiments of the present invention.

[0073] S102: for each scanned rule file, based on the target information of the rule file and the target information of each history file, identifying whether the rule file is an updated file relative to each history file;

[0074] The history file is a rule file that has been loaded, and the target information includes a name and / or a specified attribute, and the specified attribute is an attribute that changes when the file content is updated. It should be noted that each history file is a rule file that has been loaded into the WAF engine.

[0075] In the process of scanning the designated rule base, for each rule file scanned, it is possible to analyze whether the rule file is an updated file relative to each historical file, and perform different processing on the rule file according to the analysis result.

[0076] Since there may be at least one of two update methods when updating a rule file: updating the content of an existing rule file in the WAF device, and adding a new rule file, the so-called files updated relative to each historical file may include: files whose content is updated relative to any historical file, or files that are newly added relative to each historical file.

[0077] Based on the above update method, in the embodiment of the present invention, the specified attribute and / or name is used as the target information, and for each rule file, based on the target information of the rule file and the target information of each historical file, it is identified whether the rule file is a file updated relative to each historical file. Exemplarily, the specified attribute may include the file modification time or the file version, but is certainly not limited thereto.

[0078] In actual applications, if there is only one update method when updating the rule file: updating the content of the rule file that already exists in the WAF device, or both update methods exist, then for this application scenario, since the file needs to be located by name, and the specified attribute is the attribute that changes when the content is updated, the target information can specifically include the name and the specified attribute. In order to make the solution clear and the layout clear, the specific identification method will be explained in conjunction with other embodiments later.

[0079] If there is only one update method when updating a file: adding a new rule file, then for this application scenario, the target information can specifically include a name. In this way, by detecting whether the name of the rule file exists in the names of each historical file, it can be identified whether the rule file is a file that has been updated relative to each historical file.

[0080] In addition, if in certain scenarios, if the specified attribute has the function of locating the file, then no matter what kind of update method exists, the target information can only include the specified attribute, for example: the rule files with different names have differences in the description form of the specified attribute, that is, the files with different description methods of the specified attribute have different names of the representation files; at this time, the purpose of locating the file can be achieved by specifying the attribute. In this implementation method, if it is detected that the description form of the specified attribute of a rule file is different from the description methods of the specified attributes of each historical file, it indicates that the rule file is a newly added file, that is, the rule file is an updated file; if it is detected that the description form of the specified attribute of a rule file is the same as the description method of the specified attribute of a historical file but the specific content is different, it indicates that the rule file is a file with updated content, that is, the rule file is an updated file.

[0081] S103: Loading the updated rule file identified;

[0082] In this embodiment, the identified updated rule file is loaded and processed specifically as follows: the identified updated rule file is loaded into the WAF engine. When the updated rule file is loaded into the WAF engine, if a history file with the same name as the updated rule file has been loaded into the WAF engine, the history file with the same name as the updated rule file will be replaced.

[0083] In addition, after loading the updated rule file, the target information of each historical file can be updated using the target information of the updated rule file. In this way, it can be ensured that each time a rule file is updated, the rule file updated this time can be accurately detected compared to the last time the loading is completed.

[0084] It is understandable that updating the target information of each historical file may include multiple ways, for example: after the updated rule file is loaded, the operation and maintenance personnel record the updated rule file and replace the target information of each historical file with the target information of each updated rule file, or the WAF device automatically records the updated rule file and replaces the target information of each historical file with the target information of each updated rule file, which are all reasonable.

[0085] It can be seen that the solution provided by this embodiment can automatically identify the rule files in the specified database that have been updated relative to each historical file when loading WAF rules, and only load the updated rule files, avoiding loading all rule files in each hot load, so that when loading WAF rules, a large number of redundant loading operations will not be generated. Therefore, this solution can solve the problem of low loading efficiency after the rule base is updated in related technologies, and improve loading efficiency.

[0086] In conjunction with another embodiment, the WAF rule loading method provided by an embodiment of the present invention is described below. In this embodiment, the updating method for the file is: updating the content of the rule file already existing in the WAF device.

[0087] like Figure 2 As shown, a WAF rule loading method provided by an embodiment of the present invention may include the following steps:

[0088] S201, when a trigger condition for file loading is met, scanning each rule file in a specified rule base;

[0089] In this embodiment, S201 is the same as S101 in the above embodiment, and will not be described in detail here.

[0090] S202, for each rule file scanned, detecting whether the target history file has the same specified attribute as the rule file; if they are different, identifying the rule file as an updated file; if they are the same, identifying the rule file as a non-updated file;

[0091] The target history file is a history file with the same name as the rule file.

[0092] In this embodiment, since there is only a content update and no new rule files are added, after scanning each rule file, we can first determine the target historical file with the same name as the rule file, and then detect whether the target historical file is the same as the specified attribute of the rule file, and determine different analysis results based on different detection results.

[0093] S203, loading the updated rule file identified.

[0094] In this embodiment, S203 is the same as S103 in the above embodiment, and will not be described in detail here.

[0095] It can be seen that when the solution provided by this embodiment is loading WAF rules, for the scenario where only rule files with updated content exist, it can automatically identify the rule files in the specified database that have been updated relative to each historical file, and only load the updated rule files, avoiding loading the rule files in full every time hot loading, so that when loading WAF rules, a large number of redundant loading operations will not be generated. Therefore, this solution can solve the problem of low loading efficiency after the rule base is updated in related technologies, and improve loading efficiency.

[0096] The following is a description of a WAF rule loading method provided by an embodiment of the present invention in conjunction with another embodiment. In this embodiment, the file update method includes: updating the content of the rule file already existing in the WAF device, and adding a new rule file.

[0097] like Figure 3 As shown, a WAF rule loading method provided by an embodiment of the present invention may include the following steps:

[0098] S301, when the trigger condition for file loading is met, scanning each rule file in the specified rule base;

[0099] In this embodiment, S301 is the same as S101 in the above embodiment, and will not be described in detail here.

[0100] S302, for each rule file scanned, search for the name of the rule file from the names of various historical files, if found, execute S303, if not found, execute S304;

[0101] Since when a file is updated, it may be that the file content is updated or a new file is added, in this embodiment, when each rule file is scanned, the name of the rule file can be first searched from the names of each historical file, that is, it can be identified whether the rule file is a newly added file, and different operations can be performed according to different search results.

[0102] Specifically, if the name of the rule file is not found, it indicates that the rule file is a newly added file relative to each historical file, and therefore, S304 can be executed; if the name of the rule file exists, it indicates that the rule file is not a newly added file relative to each historical file, and at this time, it is possible to continue to identify whether the rule file is a file with updated content, and therefore, S303 can be executed.

[0103] S303, detecting whether the target history file has the same specified attribute as the rule file; if they are different, identifying the rule file as an updated file; if they are the same, identifying the rule file as a non-updated file;

[0104] The target history file is a history file with the same name as the rule file.

[0105] In this embodiment, S303 is the same as S202 in the above embodiment, and will not be described in detail here.

[0106] S304, identifying that the rule file is an updated file;

[0107] S305: Load the updated rule file that has been identified.

[0108] In this embodiment, S305 is the same as S103 in the above embodiment, and will not be described in detail here.

[0109] It can be seen that when the solution provided by this embodiment is loading WAF rules, for scenarios where there are rule files with updated content and newly added rule files, it can automatically identify the rule files in the specified database that have been updated relative to each historical file, and only load the updated rule files, avoiding loading the rule files in full every time hot loading, so that when loading WAF rules, a large number of redundant loading operations will not be generated. Therefore, this solution can solve the problem of low loading efficiency after the rule base is updated in related technologies, and improve loading efficiency.

[0110] With respect to the above method embodiment, Figure 4 As shown, an embodiment of the present invention provides a WAF rule loading device, the device comprising:

[0111] The scanning module 401 scans each rule file in a specified rule base when a trigger condition for file loading is met; wherein the specified rule base is a rule base for a Web application firewall WAF;

[0112] The identification module 402 identifies, for each scanned rule file, whether the rule file is a file updated relative to each history file based on the target information of the rule file and the target information of each history file; wherein the history file is a rule file that has been loaded, the target information includes a name and / or a specified attribute, and the specified attribute is an attribute that changes when the file content is updated;

[0113] The loading module 403 loads the identified updated rule file.

[0114] It can be seen that when loading WAF rules, this solution can automatically identify the rule files in the specified database that have been updated relative to the historical files, and only load the updated rule files, avoiding loading all rule files in each hot load, so that when loading WAF rules, a large number of redundant loading operations will not be generated. Therefore, this solution can solve the problem of low loading efficiency after the rule base is updated in related technologies, and improve loading efficiency.

[0115] Optionally, the identification module includes:

[0116] An identification submodule is used to detect, for each scanned rule file, whether a target history file is identical to a specified attribute of the rule file; wherein the target history file is a history file having the same name as the rule file; if they are different, the rule file is identified as an updated file; if they are identical, the rule file is identified as a non-updated file.

[0117] Optionally, the identification submodule is also used to: before detecting whether the target historical file is the same as the specified attribute of the rule file, search for the name of the rule file from the names of each historical file; if found, execute the step of detecting whether the target historical file is the same as the specified attribute of the rule file; if not found, identify the rule file as the file that has been updated.

[0118] Alternatively, if Figure 5 As shown, the device also includes:

[0119] The update module 404 is used to update the target information of each historical file using the target information of the updated rule file after the loading module 403 loads the updated rule file identified; wherein the historical file is a historical file with the same name as the rule file.

[0120] With respect to the above method embodiment, Figure 6 As shown, the embodiment of the present invention further provides a WAF device loading system, a central control device 610 and a WAF device 620;

[0121] The central control device 610 is used to send the received rule file to the WAF device when receiving the updated rule file;

[0122] The WAF device 620 is used to store the received rule file in a specified rule base when receiving the rule file sent by the central control device; wherein the specified rule base is a rule base for WAF;

[0123] The WAF device 620 is also used to scan each rule file in the specified rule base when the trigger condition for file loading is met; for each scanned rule file, based on the target information of the rule file and the target information of each historical file, identify whether the rule file is an updated file relative to each historical file; and load the identified updated rule file.

[0124] The history file is a rule file that has been loaded, and the target information includes a name and / or a specified attribute, where the specified attribute is an attribute that changes when the file content is updated.

[0125] Optionally, the WAF device is a node in a content delivery network CDN system.

[0126] For the specific implementation steps of the central control device 610 and the WAF device 620 in this embodiment, reference may be made to the steps in the above embodiments, and no further details will be given here.

[0127] It can be seen that when loading WAF rules, this solution can automatically identify the rule files in the specified database that have been updated relative to the historical files, and only load the updated rule files, avoiding loading all rule files in each hot load, so that when loading WAF rules, a large number of redundant loading operations will not be generated. Therefore, this solution can solve the problem of low loading efficiency after the rule base is updated in related technologies, and improve loading efficiency.

[0128] The embodiment of the present invention further provides an electronic device, such as Figure 7 As shown, it includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704.

[0129] Memory 703, used for storing computer programs;

[0130] The processor 701 is used to implement the steps of any WAF rule loading method when executing the program stored in the memory 703.

[0131] 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.

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

[0133] The memory may include a random access memory (RAM) 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 aforementioned processor.

[0134] 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.

[0135] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the above-mentioned WAF rule loading methods are implemented.

[0136] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes any one of the WAF rule loading methods in the above embodiments.

[0137] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0138] 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.

[0139] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for devices and electronic devices, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0140] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A WAF rule loading method, characterized in that: The method is applied to a WAF program of a WAF device; the WAF program includes a WAF engine; the method includes: When the trigger condition for file loading is met, each rule file in the specified rule base is scanned; wherein the specified rule base is a rule base for the Web Application Firewall WAF; For each rule file scanned, based on the target information of the rule file and the target information of each historical file, identify whether the rule file is a file updated relative to each historical file; wherein the historical file is a rule file that has been executed and loaded for the WAF engine, and the target information includes a specified attribute, the specified attribute is an attribute that changes when the file content is updated, and the description form of the specified attribute is different for each rule file with different names, so as to locate the file through the specified attribute; the method of identifying whether the rule file is a file updated relative to each historical file includes: if it is detected that the description form of the specified attribute of the rule file is different from the description form of the specified attribute of each historical file, it is determined that the rule file is a file updated relative to each historical file; if it is detected that the description form of the specified attribute of the rule file is the same as the description form of the specified attribute of a historical file but the content is different, it is determined that the rule file is a file updated relative to each historical file; otherwise, it is determined that the rule file is not a file updated relative to each historical file; The identified updated rule file is loaded; wherein the loading process includes loading the identified updated rule file into the WAF engine.

2. The method according to claim 1, characterized in that The specified attributes include: file modification time or file version.

3. The method according to claim 1, characterized in that The triggering condition for file loading includes: reaching a preset timing time.

4. The method according to claim 1, characterized in that: After loading the identified updated rule file, the method further includes: The target information of each history file is updated using the target information of the updated rule file.

5. A WAF system, characterized in that: It includes a central control device and a Web application firewall WAF device; the WAF device includes a WAF program; the WAF program includes a WAF engine; The central control device is used to send the received rule file to the WAF device when receiving the updated rule file; The WAF device is used to store the received rule file in a specified rule base when receiving the rule file sent by the central control device; wherein the specified rule base is a rule base for WAF; The WAF device is further configured to scan each rule file in the specified rule base when a trigger condition for file loading is met; for each scanned rule file, based on target information of the rule file and target information of each historical file, identify whether the rule file is an updated file relative to each historical file; and load the identified updated rule file; Wherein, the history file is a rule file that has been loaded for the WAF engine, and the target information includes a specified attribute, which is an attribute that changes when the file content is updated, and the description forms of the specified attributes of the rule files with different names are different, so that the file is located by the specified attribute; the method of identifying whether the rule file is a file updated relative to each history file includes: if it is detected that the description form of the specified attribute of the rule file is different from the description form of the specified attribute of each history file, the rule file is determined to be a file updated relative to each history file; if it is detected that the description form of the specified attribute of the rule file is the same as the description form of the specified attribute of a history file but the content is different, the rule file is determined to be a file updated relative to each history file; otherwise, the rule file is determined not to be a file updated relative to each history file; wherein, the loading process includes loading the identified updated rule file into the WAF engine.

6. The system according to claim 5, characterized in that The WAF device is a node in the content distribution network CDN system.

7. A WAF rule loading device, characterized in that: The device is applied to the WAF program of the WAF device; The WAF program includes a WAF engine; the device includes: A scanning module, used for scanning each rule file in a specified rule base when a trigger condition for file loading is met; wherein the specified rule base is a rule base for a Web application firewall WAF; An identification module is used to identify, for each scanned rule file, whether the rule file is a file updated relative to each historical file based on the target information of the rule file and the target information of each historical file; wherein the historical file is a rule file that has been executed and loaded for the WAF engine, and the target information includes a specified attribute, the specified attribute is an attribute that changes when the file content is updated, and the description form of the specified attribute is different for each rule file with different names, so as to locate the file through the specified attribute; the method of identifying whether the rule file is a file updated relative to each historical file includes: if it is detected that the description form of the specified attribute of the rule file is different from the description form of the specified attribute of each historical file, the rule file is determined to be a file updated relative to each historical file; if it is detected that the description form of the specified attribute of the rule file is the same as the description form of the specified attribute of a historical file but the content is different, the rule file is determined to be a file updated relative to each historical file; otherwise, the rule file is determined not to be a file updated relative to each historical file; The loading module is used to load the identified updated rule file; wherein the loading process includes loading the identified updated rule file into the WAF engine.

8. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 4 when executing a program stored in a memory.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Rule file updating method and device

    CN105426748A

  • A rule file updating method

    CN109359093A

  • WAF rule analysis method and device

    CN112351020A

  • Rule updating method and device, electronic equipment and storage medium

    CN112446707A

  • Rule base updating method, device and equipment

    CN113708959A