Method and apparatus for blocking hypertext transfer protocol (HTTP) traffic

By using a policy-based parsing approach and defining data types and built-in functions in the Go language, malicious HTTP traffic can be blocked in a timely manner without code development or deployment. This solves the service stability problem caused by the frequent changes in the characteristics of malicious traffic in existing technologies and ensures the stability of the web server.

CN115396162BActive Publication Date: 2026-02-06BEIJING YUNSIZHIXUE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210956578.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-10
Publication Date
2026-02-06
Estimated Expiration
2042-08-10

AI Technical Summary

Technical Problem

Existing technologies cannot effectively block malicious HTTP traffic in a timely manner due to frequent code development and deployment, which affects the stability of web servers, especially during peak traffic periods.

Method used

By using a policy-based resolution method, we check whether HTTP requests conform to pre-configured blocking policies and return HTTP responses with custom content when a match is found. This avoids code development and deployment issues. We use the Go language to define data types and built-in functions for policy resolution.

Benefits of technology

It enables timely blocking of malicious traffic when its characteristics frequently change, ensuring service stability and reducing development costs and resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115396162B_ABST
    Figure CN115396162B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method and device for blocking HTTP traffic, and belongs to the technical field of WEB processing. The method comprises the following steps: checking whether the received HTTP request complies with the blocking policy, wherein the blocking policy is a pre-configured policy stored in a business module; if the HTTP request complies with the blocking policy, the HTTP request is blocked and a HTTP request response of custom content is returned. The blocking is based on policy analysis, and no code development and online are required, so as to achieve the purpose of timely blocking malicious traffic and ensuring service stability.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of WEB, and particularly relates to a method and device for blocking HyperText Transfer Protocol (HTTP) traffic. BACKGROUND

[0002] With the development of computer network technology and e-commerce platforms, people are increasingly choosing to transact online. This brings huge development space to e-commerce platforms. However, due to the openness and wide range of the network, the increasingly serious network security problems have greatly interfered with the normal operation and development of e-commerce platforms. Many e-commerce platforms are facing security threats such as malicious traffic batch registration of accounts for cashing, selling of user account passwords by brute force cracking, sending of SMS bombs to harass users, and the like.

[0003] Currently, the protection technology of web servers against the above problems mainly blocks the IP address of the traffic, the user agent in the HTTP protocol request header, and the like. However, when the malicious traffic frequently changes its characteristics without rules, the corresponding web server can only passively develop codes, go online, and the like to block the malicious traffic according to the new characteristics.

[0004] Frequent code development and going online not only increases the labor cost, but also affects the stability of the web server. In particular, during the traffic peak period and the promotion period, the service is blocked to ensure stability. During this period, the web server either tolerates the attack of malicious traffic to ensure stability, or fights against the malicious traffic, but reduces the stability. SUMMARY

[0005] The present disclosure provides a method and device for blocking HTTP traffic based on policy analysis, without code development and going online, so as to achieve the purpose of timely blocking malicious traffic and ensuring service stability. The technical solution of the present disclosure is as follows:

[0006] According to a first aspect of an embodiment of the present disclosure, a method for blocking HTTP traffic is provided, comprising:

[0007] checking whether the received HTTP request meets a blocking policy, the blocking policy being a pre-configured policy stored in a business module;

[0008] if the blocking policy is met, blocking the HTTP request and returning an HTTP request response of custom content.

[0009] In some embodiments of the present disclosure, the checking whether the received HTTP request meets the blocking policy comprises:

[0010] obtaining the blocking policy stored in the business module, the blocking policy including at least one blocking sub-policy.

[0011] parsing the HTTP request to obtain HTTP traffic characteristics;

[0012] traversing a ban sub-policy in the ban policy based on the HTTP traffic characteristics;

[0013] if the ban sub-policy matching the HTTP traffic characteristics is traversed, it is determined that the HTTP request meets the ban policy.

[0014] In some embodiments of the present disclosure, the parsing the HTTP request to obtain HTTP traffic characteristics comprises:

[0015] parsing the HTTP request through a predefined current request related built-in function to obtain the value of a specific KEY in the request header and request body of the HTTP request.

[0016] In some embodiments of the present disclosure, the traversing a ban sub-policy in the ban policy based on the HTTP traffic characteristics comprises:

[0017] according to the value of the specific KEY in the request header and request body of the HTTP request and the preprocessed global variable, calling a corresponding built-in function to traverse the ban sub-policy in the ban policy;

[0018] if the return result of the built-in function is true, it is determined that the ban sub-policy matching the HTTP traffic characteristics is traversed;

[0019] if the return result of the built-in function is false, it is determined that the ban sub-policy matching the HTTP traffic characteristics is not traversed.

[0020] In some embodiments of the present disclosure, before checking whether the received HTTP request meets the ban policy, further comprising:

[0021] receiving the ban policy configured by the policy configuration interface of the background through the API interface, the policy configuration interface comprising a ban policy display interface and a ban policy change interface;

[0022] storing the ban policy in the business module;

[0023] Preferably, the policy configuration interface at least comprises the following contents:

[0024] the business module using the ban policy, global variable, variable addition, variable deletion, policy name, policy addition, policy deletion, policy editing, policy copying, policy disabling, policy submission, and return content.

[0025] In some embodiments of the present disclosure, before traversing the blocking sub-policy in the blocking policy based on the HTTP traffic features, the method further comprises:

[0026] The acquired blocking policy stored in the service module is preprocessed, and the blocking policy is decomposed into N variables of Value data type, and then the above blocking policy preprocessing is performed according to a predetermined time period.

[0027] In some embodiments of the present disclosure, the method further comprises:

[0028] The data type, built-in function and syntax are defined using the golang language.

[0029] Preferably, the data type defined using the golang language comprises:

[0030] Basic type: the type name is Value, and the basic type comprises two attributes Type and Value; wherein the attribute Type represents the data type of the attribute Value, and the data type in golang is a string; and the attribute Value is used to save the value of the data under the corresponding Type type, and the data type in golang is an arbitrary value;

[0031] Rule type: representing a complete sub-policy, the Rule type comprises six attributes Title, Exps, ParsedExps, Proc, ParsedProd and Disabled; wherein the attribute Title is the title of the sub-policy, and the data type in golang is a string; the attribute Exps is the original data of the variable definition and judgment condition of the blocking sub-policy, and each one-dimensional array is actually a complete definition of a variable or a judgment condition, and the data type in golang is a two-dimensional array composed of arbitrary types; the attribute ParsedExps is used to store the preprocessing result of Exps, and the data type in golang is a one-dimensional array composed of Value types; the attribute Proc is used to store the original data of the custom response content of the blocking sub-policy, and the data type in golang is a one-dimensional array composed of arbitrary types; the attribute ParsedProd is used to store the preprocessing result of Proc, and the data type in golang is Value; and the attribute Disabled indicates that the blocking sub-policy is disabled when true, otherwise the blocking sub-policy is enabled, and the matching of the blocking sub-policy will be skipped when disabled;

[0032] Rules type: represents the whole blocking strategy configured by the background, including the definition of global variables and the configuration of each sub-strategy. The Rules type includes three attributes: Defs, ParsedDefs and Rules. The attribute Defs is the original data of the global variables configured by the background, and the data type in golang is a one-dimensional array composed of arbitrary types. The attribute ParsedDefs is the result of preprocessing Defs, and the data type in golang is a one-dimensional array composed of Value types. The attribute Rules is the original data and the preprocessed data of the whole sub-strategy configured by the background, and the data type in golang is a one-dimensional array composed of Rule types.

[0033] Variable scope Env type: all variables can be accessed in each sub-strategy, and the variables defined in the sub-strategy are only accessible within the sub-strategy. If the variable name in the sub-strategy and the global variable name are repeated, the variable in the sub-strategy is used first. The Env type includes two attributes: Outter and Data. The attribute Outter can form a linked list through this pointer, which is used for traversal and search. The data type in golang is a pointer type pointing to the memory address of an Env variable. The attribute Data stores the values of global variables and variables in each sub-strategy in the execution stage of the language. The data type in golang is a map (dictionary) type.

[0034] Preferably, the built-in function defined using the golang language includes:

[0035] The prototype of the built-in function is as follows: func(ctx, args []Value, e *Env) (Value, error). The function parameter list: ctx is the context of the current HTTP request, args is a one-dimensional array composed of Value types, and e is the environment variable. The function return value list: Value is the result calculated by the built-in function, and the data type of the calculation result is Value. Error is a golang native data type, indicating whether an error occurs during calculation. If there is no error, error is null value, and if there is an error, error will contain specific error information.

[0036] Preferably, the syntax defined using the golang language includes:

[0037] Define variable: define variable name built-in function built-in function parameter list;

[0038] Define judgment condition: built-in function built-in function parameter list;

[0039] Define HTTP response content: Built-in function Built-in function parameter list.

[0040] According to a second aspect of the embodiments of the present disclosure, a device for blocking HTTP traffic is provided, and the device comprises:

[0041] A checking unit is configured to check whether the received HTTP request meets a blocking policy, wherein the blocking policy is a preconfigured policy stored in a service module.

[0042] A blocking unit is configured to block the HTTP request and return an HTTP request response of custom content if the blocking policy is met.

[0043] According to a third aspect of the embodiments of the present disclosure, an electronic device is provided, and the electronic device comprises:

[0044] A processor;

[0045] A memory for storing instructions executable by the processor.

[0046] The processor is configured to execute the instructions to implement the method for blocking HTTP traffic according to the first aspect.

[0047] According to a fourth aspect of the embodiments of the present disclosure, a storage medium is provided, and when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method for blocking HTTP traffic according to the first aspect.

[0048] According to a fifth aspect of the embodiments of the present disclosure, a computer program product is provided, and the computer program product comprises a computer program, and the computer program is executed by a processor to implement the method for blocking HTTP traffic according to the first aspect.

[0049] The embodiments of the present disclosure provide at least the following beneficial effects: When an HTTP request is received, the embodiments of the present disclosure check whether the received HTTP request meets a blocking policy, wherein the blocking policy is a preconfigured policy stored in a service module. If the blocking policy is met, the HTTP request is blocked and an HTTP request response of custom content is returned. Based on policy analysis for blocking, when malicious traffic frequently changes its characteristics without rules, the blocking policy only needs to be modified, and the code development and online need not be redeveloped, so that the purpose of timely blocking malicious traffic and ensuring service stability is achieved. In the embodiments of the present disclosure, the golang language is used to check whether the received HTTP request meets the blocking policy function, and based on the characteristics of the golang language such as good stability, simple operation, and the like, the golang language is more convenient for implementing the function of whether the HTTP request meets the blocking policy, and development resources are saved.

[0050] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF DRAWINGS

[0051] The accompanying drawings, which are incorporated in and form a part of the specification, illustrate one example of the present disclosure and, together with the description, serve to explain the principles of the disclosure. The drawings are only for the purpose of illustrating one example of the present disclosure and are not to be construed as limiting the present disclosure.

[0052] Figure 1 is a schematic diagram of a system for blocking HTTP traffic according to an example embodiment;

[0053] Figure 2 is a schematic diagram of a blocking policy configuration interface according to an example embodiment;

[0054] Figure 3 is a schematic diagram of a blocking policy configuration interface according to an example embodiment;

[0055] Figure 4 is a flowchart of a method for blocking HTTP traffic according to an example embodiment;

[0056] Figure 5 is a flowchart of a method for blocking HTTP traffic according to an example embodiment;

[0057] Figure 6 is a flowchart of a method for blocking HTTP traffic according to an example embodiment;

[0058] Figure 7 is a flowchart of a pre-processing stage according to an example embodiment;

[0059] Figure 8 is a flowchart of a method Parse according to an example embodiment;

[0060] Figure 9 is a flowchart of a method ParseString according to an example embodiment;

[0061] Figure 10 is a flowchart of a method ParseNumber according to an example embodiment;

[0062] Figure 11 is a flowchart of a method ParseBool according to an example embodiment;

[0063] Figure 12 is a flowchart of a method ParseNil according to an example embodiment;

[0064] Figure 13 is a method flow chart of a method ParseSymbol according to an example embodiment;

[0065] Figure 14 is a method flow chart of a method ParseList according to an example embodiment;

[0066] Figure 15 is a post-preprocessing result schematic diagram according to an example embodiment;

[0067] Figure 16 is an API interface flow chart according to an example embodiment;

[0068] Figure 17 is a method flow chart of a ban policy execution module performing ban detection according to an example embodiment;

[0069] Figure 18 is a method flow chart of a method evalRule according to an example embodiment;

[0070] Figure 19 is a method flow chart of a method eval according to an example embodiment;

[0071] Figure 20 is a method flow chart of a built-in function according to an example embodiment;

[0072] Figure 21 is a method flow chart of a built-in function according to an example embodiment;

[0073] Figure 22 is a method flow chart of a built-in function according to an example embodiment;

[0074] Figure 23 is a method flow chart of a built-in function according to an example embodiment;

[0075] Figure 24 is a method flow chart of a built-in function according to an example embodiment;

[0076] Figure 25 is a method flow chart of a built-in function according to an example embodiment;

[0077] Figure 26 is a method flow chart of a built-in function according to an example embodiment;

[0078] Figure 27is a method flowchart of a built-in function according to an exemplary embodiment;

[0079] Figure 28 is a method flowchart of a built-in function according to an exemplary embodiment;

[0080] Figure 29 is a method flowchart of a built-in function according to an exemplary embodiment;

[0081] Figure 30 is a method flowchart of a built-in function according to an exemplary embodiment;

[0082] Figure 31 is a method flowchart of a built-in function according to an exemplary embodiment;

[0083] Figure 32 is a method flowchart of a built-in function according to an exemplary embodiment;

[0084] Figure 33 is a method flowchart of a built-in function according to an exemplary embodiment;

[0085] Figure 34 is a method flowchart of a built-in function according to an exemplary embodiment;

[0086] Figure 35 is a method flowchart of a built-in function according to an exemplary embodiment;

[0087] Figure 36 is a method flowchart of a built-in function according to an exemplary embodiment;

[0088] Figure 37 is a method flowchart of a built-in function according to an exemplary embodiment;

[0089] Figure 38 is a method flowchart of a built-in function according to an exemplary embodiment;

[0090] Figure 39 is a method flowchart of a built-in function according to an exemplary embodiment;

[0091] Figure 40 is a method flowchart of a built-in function according to an exemplary embodiment;

[0092] Figure 41 is a method flowchart of a built-in function according to an exemplary embodiment;

[0093] Figure 42 is a method flowchart of a built-in function according to an exemplary embodiment;

[0094] Figure 43 is a method flowchart of a built-in function according to an exemplary embodiment;

[0095] Figure 44 is a method flowchart of a built-in function according to an exemplary embodiment;

[0096] Figure 45 is a method flowchart of a built-in function according to an exemplary embodiment;

[0097] Figure 46 is a method flowchart of a built-in function according to an exemplary embodiment;

[0098] Figure 47 is a method flowchart of a built-in function according to an exemplary embodiment;

[0099] Figure 48 is a method flowchart of a built-in function according to an exemplary embodiment;

[0100] Figure 49 is a method flowchart of a built-in function according to an exemplary embodiment;

[0101] Figure 50 is a method flowchart of a built-in function according to an exemplary embodiment;

[0102] Figure 51 is a method flowchart of a built-in function according to an exemplary embodiment;

[0103] Figure 52 is a method flowchart of a built-in function according to an exemplary embodiment;

[0104] Figure 53 is a method flowchart of a built-in function according to an exemplary embodiment;

[0105] Figure 54 is a method flowchart of a built-in function according to an exemplary embodiment;

[0106] Figure 55 is a method flowchart of a built-in function according to an exemplary embodiment;

[0107] Figure 56 is a method flowchart of a built-in function according to an exemplary embodiment;

[0108] Figure 57 is a method flowchart of a built-in function according to an exemplary embodiment;

[0109] Figure 58 is a method flowchart of a built-in function according to an exemplary embodiment;

[0110] Figure 59 is a method flowchart of a built-in function according to an exemplary embodiment;

[0111] Figure 60 is a method flowchart of a built-in function according to an exemplary embodiment;

[0112] Figure 61 is a block diagram of an apparatus for blocking HTTP traffic according to an exemplary embodiment;

[0113] Figure 62 is a block diagram of an electronic device according to an exemplary embodiment;

[0114] Figure 63 is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0115] In order for those skilled in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings.

[0116] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Rather, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0117] To solve the above technical problems, the present application provides a method and apparatus for blocking HTTP traffic, which is based on policy analysis for blocking without code development and online, thereby achieving the purpose of timely blocking malicious traffic and ensuring service stability. The method for blocking HTTP traffic is based on the system flowchart as shown in Figure 1 The system includes a configuration background and a business module, the business module receives HTTP requests sent by a user through a WEB service, and intercepts and processes the HTTP requests. The configuration background is used for configuration and update of blocking policies. The configuration background includes two functional modules: blocking policy display and blocking policy change. The policy configuration interface includes at least the following contents:

[0118] Business module, global variable, variable addition, variable deletion, policy name, policy addition, policy deletion, policy editing, policy copy, policy disable, policy submission, return content, etc. using the ban strategy.

[0119] In addition to the above, embodiments of the present disclosure do not limit this, but can also be other.

[0120] In specific implementation, it can be but not limited to as Figure 2 and Figure 3 As shown in the figure, the Arabic numerals represent the following contents:

[0121] 1: Need to select the ban strategy to be applied to which business module first. Session represents a specific business module.

[0122] 2, 6: By clicking 6, multiple global variables can be defined in priority, reducing the number of variables in each ban strategy, reducing the workload and error probability of configuring the strategy.

[0123] 3: Clicking "Delete variable" can delete the variable.

[0124] 4: Clicking "UP" can raise the priority of the variable.

[0125] 5: Clicking "DOWN" can lower the priority of the variable.

[0126] 7: Clicking "Disable" can disable this ban strategy to take effect.

[0127] 8: Clicking "Copy" can clone a copy of this ban strategy, so as to quickly configure similar strategies.

[0128] 9: Clicking "Edit" can open the ban strategy configuration detail page to perform specific ban strategy configuration operations.

[0129] 10: Clicking "Delete" can delete the ban strategy.

[0130] 11: Clicking "Add strategy" can add a ban strategy.

[0131] 12: Clicking "Submit" can save all ban strategies and global variables.

[0132] Among them, clicking 9 to edit, as shown in 3, expands the editing page, including:

[0133] 21: The name of the ban strategy.

[0134] 22: Clicking "Add Variable" can add a new variable that will be used in the ban policy. The line 22 defines a new variable. The variable name is refer, and the variable value is the return value of the built-in function get-refer.

[0135] 25: Clicking "Delete" can delete the definition of this variable or condition.

[0136] 26: Clicking "UP" can increase the priority of this variable or condition. The higher the priority, the earlier the parsing action will be executed in the parsing layer of "Language SDK".

[0137] 27: Clicking "DOWN" can decrease the priority of this variable or condition. The lower the priority, the later the parsing action will be executed in the parsing layer of "Language SDK".

[0138] 28: The line defines a condition. Only when the condition is true, the parser will continue to execute the next line, otherwise, the ban policy will be exited and the next ban policy will be executed. 28 represents a built-in function that returns a bool value. 29 represents the variable refer defined above as the first function parameter passed to the method 28. 30 represents a string as the second function parameter passed to the method 28.

[0139] 31-33: Represents the definition of a new variable. The variable name is os, and the variable value is the return value of the built-in function get-form("os").

[0140] 34-36: Represents the definition of a condition. When the value of the variable os is the same as the string "pcweb", it will continue to execute the next line.

[0141] 37: Clicking "Add Condition" can continue to add new conditions.

[0142] 38: Clicking "Add Variable" can continue to add new variables.

[0143] 39: The line defines the response content returned to the HTTP request. 39 represents the use of the "return" built-in function to generate the response content. 40 defines the HTTP protocol status code. 41 represents the content of Content-Type in the HTTP response header, if it is "" (empty string) it means not to set. 42 represents the content of the HTTP response body, if it is "" (empty string) it means not to set. There are three built-in functions for generating response content: return, redirect-captcha, dryrun

[0144] 43: Clicking "Close" can close the detail page of this ban policy.

[0145] The above screenshot actually means that when the referer in the HTTP request header contains the string www.test.com and the value of os in the HTTP request parameter is pcweb, the HTTP request is blocked, and the HTTP status code 403 is returned to the client. By configuring the variables and judgment conditions of the blocking strategy in the background, HTTP malicious traffic can be marked, and the traffic that meets the judgment condition is returned to the custom response content, so as to achieve the purpose of blocking malicious traffic in time without code development and online and ensuring service stability.

[0146] Based on the configuration of the above blocking strategy, after the click submission is configured, the configured blocking strategy is sent to the business module through the API interface, the business module receives the blocking strategy through the API interface, and the blocking strategy is stored in the data storage module.

[0147] The business module receives the HTTP request sent by the user through the WEB service, the policy execution module of the business module obtains the blocking strategy stored in the data storage module, checks whether the received HTTP request meets the blocking strategy, if the HTTP request meets the blocking strategy, the HTTP request needs to be blocked and intercepted, and is not sent to the business module for processing, but returns an HTTP request response with custom content, if the HTTP request does not meet the blocking strategy, i.e. does not hit the blocking strategy, the HTTP request is sent to the corresponding business interface layer for processing of the HTTP request.

[0148] Based on the above architecture, the embodiment of the present disclosure provides a method for blocking HTTP traffic, as shown in Figure 4 The method comprises the following steps.

[0149] 101. Check whether the received HTTP request meets the blocking strategy, wherein the blocking strategy is a pre-configured strategy stored in the business module.

[0150] In the embodiment of the present disclosure, the blocking strategy is pre-set based on experience, and new blocking strategies can also be set based on intercepted HTTP requests during the implementation of the present scheme. The embodiment of the present disclosure does not limit this. The blocking strategy includes at least one blocking sub-strategy.

[0151] 102. If the HTTP request meets the blocking strategy, the HTTP request is blocked and an HTTP request response with custom content is returned.

[0152] In the embodiment of the present disclosure, it should be noted that the HTTP request response with custom content can be defined according to actual needs in order to express that the HTTP request is an abnormal request, and the embodiment of the present disclosure does not limit this.

[0153] Embodiments of the present disclosure, when receiving an HTTP request, check whether the received HTTP request conforms to a ban policy, the ban policy being a preconfigured policy stored in a business module; if the HTTP request conforms to the ban policy, the HTTP request is banned and a HTTP request response of custom content is returned. The ban is based on policy analysis. When malicious traffic frequently changes its characteristics irregularly to bypass security measures, only the ban policy needs to be modified, without the need to redevelop and put online the code, so as to achieve the purpose of timely banning malicious traffic and ensuring service stability.

[0154] In some embodiments of the present disclosure, when checking whether the received HTTP request conforms to the ban policy, the following method can be used, but is not limited to, for example, as shown in the following table: Figure 5 The method comprises the following steps:

[0155] 201. Obtain the ban policy stored in the business module, wherein the ban policy comprises at least one ban sub-policy.

[0156] It is to be noted that the ban policy stored in the data storage module in the business module is obtained in the embodiments of the present disclosure.

[0157] 202. Analyze the HTTP request to obtain the HTTP traffic characteristics.

[0158] When analyzing the HTTP request to obtain the HTTP traffic characteristics, the following method can be used, but is not limited to, for example, the method comprises: analyzing the HTTP request by using a pre-defined current request related built-in function to obtain the value of a specific KEY in the request header and the request body of the HTTP request.

[0159] The pre-defined current request related built-in function is pre-set, and the form of the built-in function can be set according to actual needs, which is not limited in the embodiments of the present disclosure.

[0160] 203. Traverse the ban sub-policy in the ban policy based on the HTTP traffic characteristics.

[0161] In the embodiments of the present disclosure, when traversing the ban sub-policy in the ban policy based on the HTTP traffic characteristics, the following method can be used, but is not limited to, for example, the method comprises:

[0162] According to the values of specific KEYs in the request header and the request body of the HTTP request and the preprocessed global variables, a corresponding built-in function is called to traverse the blocking sub-strategies in the blocking strategy. If the return result of the built-in function is true, it is determined that the blocking sub-strategy matching the HTTP traffic feature is traversed; if the return result of the built-in function is false, it is determined that the blocking sub-strategy matching the HTTP traffic feature is not traversed.

[0163] 204、If the blocking sub-strategy matching the HTTP traffic feature is matched, it is determined that the HTTP request meets the blocking strategy.

[0164] Embodiments of the present disclosure, when receiving an HTTP request, check whether the received HTTP request meets the blocking strategy, which is a pre-configured strategy stored in the service module; if it meets the blocking strategy, the HTTP request is blocked and an HTTP request response of custom content is returned. Based on policy analysis, no code development and online are required, thereby achieving the purpose of timely blocking malicious traffic and ensuring service stability.

[0165] Embodiments of the present disclosure, when performing the above-mentioned method of blocking HTTP traffic, can be developed through golang language, or can be developed through other languages, such as java, php, c, c++, python, etc., and the specific embodiments of the present disclosure do not limit this. The data storage scheme can use redis, or other data storage, such as mysql, tidb, etc., and the specific embodiments of the present disclosure do not limit this.

[0166] The following embodiments will be described in detail using golang language for development and redis for data storage.

[0167] First, the golang language needs to be used to define data types, built-in functions, and syntax.

[0168] When the golang language is used to define data types, the following data types are defined: basic type, Rule type, Rules type, and variable scope Env type.

[0169] Basic type: the type name is Value, and the basic type contains two attributes Type and Value; wherein, the attribute Type indicates the data type of the attribute Value, which is a string in golang; the attribute Value is used to save the value of the data under the corresponding Type type, which is an arbitrary value in golang; as shown in Table 1:

[0170] Table 1

[0171]

[0172] Rule type: represents a complete sub-policy, which contains 6 attributes Title, Exps, ParsedExps, Proc, ParsedProd, Disabled, as shown in Table 2, wherein the attribute Title is the title of the sub-policy, and the data type in golang is a string; the attribute Exps is the original data of the variable definition and judgment condition of the banned sub-policy, and each one-dimensional array is actually a complete definition of a variable or a judgment condition, and the data type in golang is a two-dimensional array composed of arbitrary types; the attribute ParsedExps is the result of preprocessing Exps, and the data type in golang is a one-dimensional array composed of Value types; the attribute Proc is the original data of the custom response content of the banned sub-policy, and the data type in golang is a one-dimensional array composed of arbitrary types; the attribute ParsedProd is the result of preprocessing Proc, and the data type in golang is Value; true in the attribute Disabled indicates that the banned sub-policy is disabled, otherwise the banned sub-policy is enabled, and the matching of the banned sub-policy will be skipped after being disabled.

[0173] Table 2

[0174]

[0175] Rule type: as shown in Table 3, represents all banned policies configured in the background, including the definition of global variables and the configuration of each sub-policy. The Rules type includes three attributes: Defs, ParsedDefs, Rules; wherein the attribute Defs is the original data of the global variable configured in the background, and the data type in golang is a one-dimensional array composed of arbitrary types; the attribute ParsedDefs is the result of preprocessing Defs, and the data type in golang is a one-dimensional array composed of Value types; the attribute Rules is the original data and the preprocessed data of all sub-policies configured in the background, and the data type in golang is a one-dimensional array composed of Rule types.

[0176] Table 3

[0177]

[0178] Variable scope Env type: As shown in Table 4, all variables are accessible in each sub-policy, and the variables defined in the sub-policy are only accessible in the sub-policy. If the variable name in the sub-policy and the global variable name are repeated, the variable in the sub-policy is used preferentially. The Env type includes Outter and Data two attributes. The attribute Outter can form a linked list through the pointer, which is used for traversal and search. In golang, the data type is a pointer type, which points to the memory address of an Env variable. The attribute Data stores the values of global variables and variables in each sub-policy in the execution stage of the language. In golang, the data type is a map dictionary type.

[0179] Table 4

[0180]

[0181] In the embodiments of the present disclosure, the definition of the built-in function using the golang language can be implemented by the following method, but is not limited to the following method. The method includes the following steps.

[0182] The prototype of the built-in function is defined as follows: func(ctx, args []Value, e *Env) (Value, error).

[0183] In the prototype, the function parameter list: ctx is the context of the current HTTP request, args is a one-dimensional array composed of Value types, and e is the environment variable. The function return value list: Value is the result after the built-in function calculation, the data type of the calculation result is Value, error is a golang native data type, indicating whether an error occurs in the calculation process. If there is no error, the error is empty, and if there is an error, the error will contain specific error information.

[0184] The parameter list and return value list of all built-in functions of the language are the same.

[0185] The specific function list is shown in Table 5.

[0186] Table 5

[0187]

[0188] In some embodiments of the present disclosure, the definition of the syntax using the golang language can be implemented by the following method, but is not limited to the following method. The method includes the following steps.

[0189] define variable: define variable_name builtin builtin_parameter_list;

[0190] define condition: builtin builtin_parameter_list;

[0191] define HTTP response content: builtin (return / redirect-captcha / dry-run) builtin_parameter_list.

[0192] Example: define a "def", which means to define a constant of type String, and its content is "def". In fact, it is to define a variable of type Value. Its attribute Type is String, and its attribute Value is the string "def".

[0193] Example: define b 101, which means to define a constant of type Integer, and its value is 101. In fact, it is to define a variable of type Value. Its attribute Type is Integer, and its attribute Value is the integer 101.

[0194] Example: define c true, which means to define a constant of type Bool, and its value is true. In fact, it is to define a variable of type Value. Its attribute Type is Bool, and its attribute Value is the boolean true.

[0195] Example: define refer get-refer, which means to define a variable named refer, and its value is the return value of the built-in function get-refer.

[0196] Example: define refer-in-whitelist str-contains-one refer "zybang.com" "zuoyebang.com", which means to define a variable named refer-in-whitelist, and its value is the return value of the built-in function str-contains-one(variable refer, "zybang.com", "zuoyebang.com").

[0197] Example: not refer-in-whitelist, which means a condition: when the built-in function not(variable refer-in-whitelist) returns true, continue to execute downward, otherwise exit. The actual meaning is: when refer is not in the defined list ("zybang.com", "zuoyebang.com"), it is necessary to continue to execute downward.

[0198] For example, str-not-eq refer "", indicates a judgment condition: when the built-in function str-not-eq (variable refer, "") returns true, continue to execute downward, otherwise exit. The practical significance is: when the value of refer is not equal to the empty string, it is necessary to continue to execute downward, otherwise exit.

[0199] For example, return 403 "" "", indicates to define the HTTP response content. Execute the built-in function return (403, "", ""). The practical significance is to return the response content of the HTTP status code 403. Do not set the Content-Type in the response header, and do not set the content of the response body.

[0200] Based on the above architecture, and the definition of data types, built-in functions and syntax in golang language, the embodiment of the present disclosure provides a method for blocking HTTP traffic, as shown in the method, which comprises the following steps: Figure 6

[0201] 1. Initialize the redis resource.

[0202] 2. Preprocess the blocking policy and load it into memory.

[0203] This step belongs to the preprocessing stage of the blocking policy. In this stage, the redis key for storing the blocking policy is specified, the blocking policy is preprocessed and loaded into memory.

[0204] Among them, in the preprocessing stage, the embodiment of the present disclosure can adopt but is not limited to Figure 7 The flow method, and the embodiment of the present disclosure does not limit this.

[0205] Among them, Figure 7 The detailed flow chart of the method Parse in Figure 8 The related description of the embodiment of the present disclosure does not limit this.

[0206] Figure 8 The flow chart of the method ParseString in Figure 9 The related description of the embodiment of the present disclosure does not limit this.

[0207] Figure 8 The flow chart of the method ParseNumber in Figure 10 The related description of the embodiment of the present disclosure does not limit this.

[0208] Figure 8 The flow chart of the method ParseBool in​Figure 11 The embodiments of the present disclosure are not limited in this regard.

[0209] Figure 8 The flow chart of the method ParseNil in the foregoing embodiment can refer to the related description of the method ParseNil in the foregoing embodiment, and the embodiments of the present disclosure are not limited in this regard. Figure 12 The embodiments of the present disclosure are not limited in this regard.

[0210] Figure 8 The flow chart of the method ParseSymbol in the foregoing embodiment can refer to the related description of the method ParseSymbol in the foregoing embodiment, and the embodiments of the present disclosure are not limited in this regard. Figure 13 The embodiments of the present disclosure are not limited in this regard.

[0211] Figure 8 The flow chart of the method ParseList in the foregoing embodiment can refer to the related description of the method ParseList in the foregoing embodiment, and the embodiments of the present disclosure are not limited in this regard. Figure 14 The embodiments of the present disclosure are not limited in this regard.

[0212] For example, a configuration item (a one-dimensional array composed of a golang arbitrary type) of a variable definition is array("define ", "testString", "\"str-abc\""). After the preprocessing of the Parse method, the result is as shown in Figure 15 .

[0213] 3. The API interface for operating the ban policy is injected into the routing rule of the also hungry module, and the change operation of the ban policy is completed by calling the API interface in the background.

[0214] In the embodiments of the present disclosure, when the API interface process is performed, the processing process shown in Figure 16 may be used, but the embodiments of the present disclosure are not limited thereto.

[0215] 4. The ban policy execution module executes ban detection.

[0216] The method of the ban policy execution module is injected into the middleware, and it is detected whether each HTTP request hits the ban policy. If it hits, the custom content is directly returned, and if it does not hit, it is processed by the business module itself.

[0217] In the embodiments of the present disclosure, when the ban policy execution module executes ban detection, the method shown in Figure 17 may be used, but the embodiments of the present disclosure are not limited thereto.

[0218] In the foregoing embodiment, the detailed flow chart of the method evalRule can refer to the related description of the method evalRule in the foregoing embodiment, and the embodiments of the present disclosure are not limited in this regard. Figure 17 Figure 18 The embodiments of the present disclosure are not limited in this regard.

[0219] ​wherein, Figure 17 The detailed flowchart of the method eval can refer to the related description of Figure 19 The embodiments of the present disclosure do not make any limitation in this regard.

[0220] Figure 19 The flowchart of the method evalList can refer to the related description of Figure 20 The embodiments of the present disclosure do not make any limitation in this regard.

[0221] Figure 20 In the above, the flowchart of each built-in function is as follows:

[0222] The flowchart of the method can refer to the related description of Figure 21 The embodiments of the present disclosure do not make any limitation in this regard.

[0223] The flowchart of the method can refer to the related description of Figure 22 The embodiments of the present disclosure do not make any limitation in this regard.

[0224] The flowchart of the method can refer to the related description of Figure 23 The embodiments of the present disclosure do not make any limitation in this regard.

[0225] The flowchart of the method can refer to the related description of Figure 24 The embodiments of the present disclosure do not make any limitation in this regard.

[0226] The flowchart of the method can refer to the related description of Figure 25 The embodiments of the present disclosure do not make any limitation in this regard.

[0227] The flowchart of the method can refer to the related description of Figure 26 The embodiments of the present disclosure do not make any limitation in this regard.

[0228] The flowchart of the method can refer to the related description of Figure 27 The embodiments of the present disclosure do not make any limitation in this regard.

[0229] The flowchart of the method can refer to the related description of Figure 28 The embodiments of the present disclosure do not make any limitation in this regard.

[0230] The flowchart of the method can refer to the related description of Figure 29 The embodiments of the present disclosure do not make any limitation in this regard.

[0231] The flowchart of the method can refer to the related description of Figure 30 The embodiments of the present disclosure do not make any limitation in this regard.

[0232] The flowchart of the method can refer to the related description of Figure 31The related description of the all method does not limit the embodiments of the present disclosure.

[0233] The flowchart of the is-false method can refer to Figure 32 The related description of the is-false method does not limit the embodiments of the present disclosure.

[0234] The flowchart of the is-true method can refer to Figure 33 The related description of the is-true method does not limit the embodiments of the present disclosure.

[0235] The flowchart of the is-inner-ip method can refer to Figure 34 The related description of the is-inner-ip method does not limit the embodiments of the present disclosure.

[0236] The flowchart of the is-black-ip method can refer to Figure 35 The related description of the is-black-ip method does not limit the embodiments of the present disclosure.

[0237] The flowchart of the get-form method can refer to Figure 36 The related description of the get-form method does not limit the embodiments of the present disclosure.

[0238] The flowchart of the get-ip method can refer to Figure 37 The related description of the get-ip method does not limit the embodiments of the present disclosure.

[0239] The flowchart of the get-path method can refer to Figure 38 The related description of the get-path method does not limit the embodiments of the present disclosure.

[0240] The flowchart of the get-refer method can refer to Figure 39 The related description of the get-refer method does not limit the embodiments of the present disclosure.

[0241] The flowchart of the redis-exists method can refer to Figure 40 The related description of the redis-exists method does not limit the embodiments of the present disclosure.

[0242] The flowchart of the redis-get method can refer to Figure 41 The related description of the redis-get method does not limit the embodiments of the present disclosure.

[0243] The flowchart of the redis-exists method can refer to Figure 42 The related description of the redis-exists method does not limit the embodiments of the present disclosure.

[0244] The flowchart of the redis-get method can refer to Figure 43 The related description of the redis-get method does not limit the embodiments of the present disclosure.

[0245] A flowchart of the redis-set method can refer to the related description of Figure 44 Embodiments of the present disclosure do not make any limitation in this regard.

[0246] A flowchart of the shal method can refer to the related description of Figure 45 Embodiments of the present disclosure do not make any limitation in this regard.

[0247] A flowchart of the join method can refer to the related description of Figure 46 Embodiments of the present disclosure do not make any limitation in this regard.

[0248] A flowchart of the str-contains method can refer to the related description of Figure 47 Embodiments of the present disclosure do not make any limitation in this regard.

[0249] A flowchart of the number-str method can refer to the related description of Figure 48 Embodiments of the present disclosure do not make any limitation in this regard.

[0250] A flowchart of the str-number method can refer to the related description of Figure 49 Embodiments of the present disclosure do not make any limitation in this regard.

[0251] A flowchart of the str-contains-one method can refer to the related description of Figure 50 Embodiments of the present disclosure do not make any limitation in this regard.

[0252] A flowchart of the str-eq method can refer to the related description of Figure 51 Embodiments of the present disclosure do not make any limitation in this regard.

[0253] A flowchart of the str-in method can refer to the related description of Figure 52 Embodiments of the present disclosure do not make any limitation in this regard.

[0254] A flowchart of the str-not-eq method can refer to the related description of Figure 53 Embodiments of the present disclosure do not make any limitation in this regard.

[0255] A flowchart of the concat method can refer to the related description of Figure 54 Embodiments of the present disclosure do not make any limitation in this regard.

[0256] A flowchart of the dry-run method can refer to the related description of Figure 55 Embodiments of the present disclosure do not make any limitation in this regard.

[0257] A flowchart of the return method can refer to the related description of Figure 56 Embodiments of the present disclosure do not make any limitation in this regard.

[0258] The flowchart for the redirect-captcha method can be found in [reference]. Figure 57 The embodiments disclosed herein do not limit the scope of the relevant descriptions.

[0259] The flowchart for the define method can be found in [reference]. Figure 58 The embodiments disclosed herein do not limit the scope of the relevant descriptions.

[0260] The flowchart for the NOT method can be found in [reference]. Figure 59 The embodiments disclosed herein do not limit the scope of the relevant descriptions.

[0261] The embodiments of this disclosure use the Golang language to implement the function of checking whether the received HTTP request conforms to the blocking policy. Based on the Golang language's good stability, simplicity and ease of operation, the implementation of the function of checking whether the HTTP request conforms to the blocking policy is more convenient and saves development resources.

[0262] Based on the above, such as Figure 61 As shown, Figure 61 This is a block diagram illustrating an apparatus for blocking HTTP traffic according to an exemplary embodiment. (Refer to...) Figure 61 The device includes:

[0263] The inspection unit 301 is used to check whether the received HTTP request conforms to the blocking policy. The blocking policy is a pre-configured policy stored in the business module.

[0264] The blocking unit 302 is used to block the HTTP request and return an HTTP request response with custom content if the blocking policy is met.

[0265] In some embodiments of this disclosure, the inspection unit 301 includes:

[0266] Obtain the blocking policies stored in the business module, wherein the blocking policies include at least one blocking sub-policy;

[0267] Parse the HTTP request to obtain HTTP traffic characteristics;

[0268] Based on the HTTP traffic characteristics, the blocking sub-policies in the blocking policy are traversed;

[0269] If a blocking sub-policy that matches the HTTP traffic characteristics is found during the iteration, then the HTTP request is determined to conform to the blocking policy.

[0270] In some embodiments of this disclosure, parsing the HTTP request to obtain HTTP traffic characteristics includes:

[0271] parsing the HTTP request by a predefined current request related built-in function to obtain a value of a specific KEY in a request header and a request body of the HTTP request.

[0272] In some embodiments of the present disclosure, the traversing the ban sub-policy in the ban policy based on the HTTP traffic feature comprises:

[0273] calling a corresponding built-in function to traverse the ban sub-policy in the ban policy according to the value of the specific KEY in the request header and the request body of the HTTP request and the preprocessed global variable;

[0274] if the return result of the built-in function is true, it is determined that the ban sub-policy matching the HTTP traffic feature is traversed;

[0275] if the return result of the built-in function is false, it is determined that the ban sub-policy matching the HTTP traffic feature is not traversed.

[0276] In some embodiments of the present disclosure, the apparatus further comprises:

[0277] a receiving unit configured to receive, before checking whether the received HTTP request meets the ban policy, a ban policy configured by a policy configuration background through a policy configuration interface via an API interface, the policy configuration interface comprising a ban policy display interface and a ban policy change interface;

[0278] a storage unit configured to store the ban policy in the business module.

[0279] In some embodiments of the present disclosure, the policy configuration interface comprises at least the following contents:

[0280] a business module using the ban policy, a global variable, variable addition, variable deletion, a policy name, policy addition, policy deletion, policy editing, policy copying, policy disabling, policy submission, and return content.

[0281] In some embodiments of the present disclosure, the apparatus further comprises:

[0282] a ban policy preprocessing unit configured to, before traversing the ban sub-policy in the ban policy based on the HTTP traffic feature, preprocess the ban policy stored in the business module to decompose the ban policy into N variables of a data type Value, and then perform the above ban policy preprocessing according to a predetermined time period.

[0283] In some embodiments of the present disclosure, the apparatus further comprises:

[0284] A definition unit is configured to define data types, built-in functions, and syntaxes using a golang language.

[0285] In some embodiments of the present disclosure, the definition unit is configured to define data types using the golang language, and the definition unit includes:

[0286] A basic type, which is of a type name Value and includes two attributes Type and Value. The attribute Type represents a data type of the attribute Value, and the data type in golang is a string. The attribute Value is configured to store a value of data in a corresponding Type, and the data type in golang is an arbitrary value.

[0287] A Rule type, which represents a complete sub-policy. The Rule type includes six attributes Title, Exps, ParsedExps, Proc, ParsedProd, and Disabled. The attribute Title is a title of the sub-policy, and the data type in golang is a string. The attribute Exps is configured to store original data of variable definitions and judgment conditions of the sub-policy. Each one-dimensional array is actually a complete definition of a variable or a judgment condition. The data type in golang is a two-dimensional array composed of arbitrary types. The attribute ParsedExps is configured to store a preprocessed result of the Exps in the attribute. The data type in golang is a one-dimensional array composed of Value types. The attribute Proc is configured to store original data of a custom response content of the sub-policy. The data type in golang is a one-dimensional array composed of arbitrary types. The attribute ParsedProd is configured to store a preprocessed result of the Proc in the attribute. The data type in golang is a Value type. The attribute Disabled is configured to indicate that the sub-policy is disabled when true, and the sub-policy is enabled when false. When the sub-policy is disabled, a matching of the sub-policy is skipped.

[0288] A Rules type, which represents all sub-policies configured in the background and includes definitions of global variables and configurations of the sub-policies. The Rules type includes three attributes Defs, ParsedDefs, and Rules. The attribute Defs is configured to store original data of global variables configured in the background. The data type in golang is a one-dimensional array composed of arbitrary types. The attribute ParsedDefs is configured to store a preprocessed result of the Defs in the attribute. The data type in golang is a one-dimensional array composed of Value types. The attribute Rules is configured to store original data and preprocessed data of all sub-policies configured in the background. The data type in golang is a one-dimensional array composed of Rule types.

[0289] Variable scope Env type: all variables are accessible in each sub-policy, variables defined in a sub-policy are only accessible in the sub-policy, if a variable name in a sub-policy is the same as a global variable name, the variable in the sub-policy is used, the Env type includes Outter and Data, Outter can form a linked list through the pointer to traverse and search, the data type in golang is a pointer type, which points to the memory address of an Env variable; Data stores the values of global variables and variables in sub-policies in the execution stage of the language, the data type in golang is a map dictionary type.

[0290] In some embodiments of the present disclosure, the definition unit defines the built-in function using the golang language, including:

[0291] The prototype of the defined built-in function is as follows: func(ctx, args []Value, e *Env) (Value, error).

[0292] Wherein, the function parameter list: ctx is the context of the current HTTP request, args is a one-dimensional array composed of Value types, and e is an environment variable; the function return value list: Value is the result after the built-in function calculation, the data type of the calculation result is Value, error is a golang native data type, indicating whether an error occurs in the calculation process, error is empty if there is no error, and error contains specific error information if there is an error.

[0293] In some embodiments of the present disclosure, the definition unit defines the syntax using the golang language, including:

[0294] Define variables: define variable name built-in function built-in function parameter list;

[0295] Define the judgment condition: built-in function built-in function parameter list;

[0296] Define the HTTP response content: built-in function (return / redirect-captcha / dry-run) built-in function parameter list.

[0297] In some embodiments of the present disclosure, the device further includes:

[0298] The execution unit is configured to execute the HTTP request if the blocking policy is not met.

[0299] The description of the related content of the embodiments of the present disclosure can refer to the description of the method, and the embodiments of the present application will not be repeated here.

[0300] Embodiments of the present disclosure, when receiving an HTTP request, check whether the received HTTP request conforms to a ban policy, the ban policy being a preconfigured policy stored in a service module; if the ban policy is met, the HTTP request is banned and a HTTP request response of custom content is returned. The ban is based on policy analysis, without code development and online, so as to achieve the purpose of timely banning malicious traffic and ensuring service stability.

[0301] Figure 62 is a block diagram of an electronic device 800 shown by the present disclosure. For example, the electronic device 800 can be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0302] Referring to Figure 62 The electronic device 800 can include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.

[0303] The processing component 802 usually controls overall operations of the electronic device 800, such as operations associated with displaying, making phone calls, data communications, camera operations and recording operations. The processing component 802 can include one or more processors 820 to execute instructions to complete all or part of the steps of the information platform selection method described in any embodiment. In addition, the processing component 802 can include one or more modules to facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.

[0304] The memory 804 is configured to store various types of data to support operations of the device 800. Examples of these data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage devices or a combination thereof, such as static random access memory (SRAM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0305] The power component 806 provides power to various components of the electronic device 800. The power component 806 can include a power management system, one or more power sources, and other components associated with generating, managing and distributing power for the electronic device 800.

[0306] The multimedia component 808 includes a screen to provide an output interface between the electronic device 800 and a user. In some embodiments, the screen can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense a touch, a slide, and a gesture on the touch panel. The touch sensor can not only sense a boundary of a touching or a sliding action, but also detect duration and intensity of the touching or sliding action. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capability.

[0307] The audio component 810 is configured to output and / or input an audio signal. For example, the audio component 810 includes a microphone (MIC) to receive an external audio signal when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 further includes a speaker to output an audio signal.

[0308] The I / O interface 812 provides an interface for the processing component 802 and a peripheral interface module, which can be a keypad, a click wheel, buttons, and the like. The buttons can include, but are not limited to, a home button, a volume button, a start button, and a lock button.

[0309] The sensor component 814 includes one or more sensors to provide various state assessments for the electronic device 800. For example, the sensor component 814 can detect an open / closed state of the device 800, relative positioning of components, such as a display and a keypad of the electronic device 800, a change in position of the electronic device 800 or a component of the electronic device 800, presence or absence of user contact with the electronic device 800, an orientation or acceleration / deceleration of the electronic device 800, and a temperature change of the electronic device 800. The sensor component 814 can include a proximity sensor configured to detect presence of a nearby object without any physical touch. The sensor component 814 can further include a light sensor, such as a CMOS or CCD image sensor, for use in an imaging application. In some embodiments, the sensor component 814 can further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0310] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, a cellular network standard (such as 2G, 3G, 4G, or 5G), or a combination thereof. In an example embodiment, the communication component 816 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In an example embodiment, the communication component 816 can further include a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) techniques, infrared data association (IrDA) techniques, ultra-wideband (UWB) techniques, Bluetooth (BT) techniques, and other techniques.

[0311] In an example embodiment, the electronic device 800 can be implemented with one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, micro-controllers, microprocessors, or other electronic elements to perform the information platform selection method described in any embodiment.

[0312] In an example embodiment, a non-transitory computer-readable storage medium including instructions, such as the memory 804 including instructions, is also provided. The instructions can be executable by the processor 820 of the electronic device 800 to implement the information platform selection method described in any embodiment. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disc, and an optical data storage device, etc.

[0313] In an example embodiment, a computer program product is also provided. The computer program product includes a readable program code executable by the processor 820 of the electronic device 800 to implement the information platform selection method described in any embodiment. Alternatively, the program code can be stored in a storage medium of the electronic device 800. The storage medium can be a non-transitory computer-readable storage medium, such as a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disc, and an optical data storage device, etc.

[0314] Figure 63 is a block diagram of an electronic device 1900 according to an example embodiment of the disclosure. For example, the electronic device 1900 can be provided as a server.

[0315] Referring to Figure 63The electronic device 1900 also includes a processing component 1922 configured to execute instructions and manipulate data, and a memory 1932, which is representative of a memory resource for storing instructions that are executable by the processing component 1922, such as being associated with an application. The memory 1932 can include one or more modules each corresponding to a set of instructions. The processing component 1922 is further configured to execute instructions to perform the information platform selection method as described in any of the embodiments.

[0316] The electronic device 1900 can also include a power supply component 1926 configured to provide power to the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output (I / O) interface 1958. The electronic device 1900 can operate based on an operating system stored in the memory 1932, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or the like.

[0317] Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the features disclosed herein. It is intended that the specification and examples be considered as exemplary only, with the true scope and spirit of the disclosure being indicated by the following claims.

[0318] It will be understood that the present disclosure is not limited to the precise structures herein described and illustrated in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the claims that follow.

Claims

1. A method for blocking Hypertext Transfer Protocol (HTTP) traffic, characterized in that it includes: A method for blocking Hypertext Transfer Protocol (HTTP) traffic is disclosed, applied to an HTTP traffic blocking system. The system includes a configuration backend and a business module. The configuration backend is used to configure and update blocking policies, and the business module is used to receive HTTP requests sent by users through a web service and intercept these requests. Check whether the received HTTP request conforms to the blocking policy, which is a pre-configured policy stored in the business module; including: Obtain the blocking policies stored in the business module, wherein the blocking policies include at least one blocking sub-policy; Parsing the HTTP request to obtain HTTP traffic characteristics includes: The HTTP request is parsed using predefined built-in functions related to the current request to obtain the value of a specific key in the request header and request body. Based on the HTTP traffic characteristics, traverse the blocking sub-policies in the blocking policy; including: calling the corresponding built-in function to traverse the blocking sub-policies in the blocking policy according to the value of a specific KEY in the request header and request body of the HTTP request and preprocessed global variables; If the built-in function returns true, then it is determined that the blocking sub-policy matching the HTTP traffic characteristics is traversed. If the built-in function returns false, it is determined that no blocking sub-policy matching the HTTP traffic characteristics was found. If a blocking sub-policy that matches the HTTP traffic characteristics is found during the iteration, then the HTTP request is determined to conform to the blocking policy; If the blocking policy is met, the HTTP request will be blocked and an HTTP request response with custom content will be returned. The blocking policy is received through the API interface from the policy configuration backend via the policy configuration interface, which includes a blocking policy display interface and a blocking policy change interface. The blocking policy is stored in the business module; The policy configuration interface includes at least the following: The business modules that use the aforementioned blocking policy include: global variables, variable addition, variable deletion, policy name, policy addition, policy deletion, policy editing, policy copying, policy disabling, policy submission, and returned content. Use the Go language to define data types, built-in functions, and syntax; The data types defined using the Golang language include: Basic type: The type name is Value. The basic type contains two properties: Type and Value. The Type property indicates the data type of the Value property, which is a string in Go. The Value property is used to store the value of the data under the corresponding Type type, which can be any value in Go. Rule type: Represents a complete sub-policy. The Rule type contains 6 properties: Title, Exps, ParsedExps, Proc, ParsedProd, and Disabled. The Title property is the title of the sub-policy, and its data type in Go is a string. The Exps property stores the raw data of the variable definitions and decision conditions for the blocking sub-policy; each one-dimensional array is actually a complete definition of a variable or decision condition, and its data type in Go is a two-dimensional array of any type. The ParsedExps property stores the preprocessed result of Exps, and its data type in Go is a one-dimensional array of Value types. The Proc property stores the raw data of the custom response content of the blocking sub-policy, and its data type in Go is a one-dimensional array of any type. The ParsedProd property stores the preprocessed result of Proc, and its data type in Go is Value type. The Disabled property, if true, disables the blocking sub-policy; otherwise, it enables the blocking sub-policy, and if disabled, the matching of the blocking sub-policy will be skipped. The `Rules` type represents all blocking policies configured in the backend, including the definition of global variables and the configuration of each sub-policy. The `Rules` type includes three properties: `Defs`, `ParsedDefs`, and `Rules`. The `Defs` property contains the raw data of the global variables configured in the backend, which in Go is a one-dimensional array of any data type. The `ParsedDefs` property stores the preprocessed result of `Defs`, which in Go is a one-dimensional array of `Value` types. The `Rules` property contains the raw and preprocessed data of all sub-policies configured in the backend, which in Go is a one-dimensional array of `Rule` types. The `Env` type specifies the scope of variables: all variables are accessible in all sub-strategies, while variables defined within a sub-strategy are only accessible within that sub-strategy. If a variable name within a sub-strategy and a global variable name are the same, the variable within the sub-strategy takes precedence. The `Env` type contains two properties: `Outter` and `Data`. The `Outter` property can be used to construct a linked list for traversal and lookup. In Go, it is a pointer type, pointing to the memory address of an `Env` variable. The `Data` property stores the values ​​of global variables and variables within sub-strategies during the execution phase of this language. In Go, it is a map dictionary type. The definition of built-in functions using the Golang language includes: The prototype of the built-in function is defined as follows: func(ctx, args[]Value, e *Env) (Value, error); The function parameter list includes: ctx, which is the context of the current HTTP request; args, which is a one-dimensional array of type Value; and e, which is the environment variable. The function return value list includes: Value, which is the result calculated by the built-in function, and the data type of the result is Value; and error, which is a native Go data type, indicating whether an error occurred during the calculation. If there is no error, error is empty; if there is an error, error will contain specific error information. The syntax defined using the Golang language includes: Define variables: define variable_name; built-in functions; list of parameters for built-in functions. Define the criteria for judgment: built-in functions and their parameter lists; Define the HTTP response content: Built-in functions and their parameter lists.

2. The method according to any one of claims 1, characterized in that, Before traversing the blocking sub-policies in the blocking policy based on the HTTP traffic characteristics, the method further includes: The blocking policies stored in the acquired business modules are preprocessed by decomposing the blocking policies into N variables of data type Value, and then the above blocking policy preprocessing is executed according to a predetermined time period.

3. A device for blocking Hypertext Transfer Protocol (HTTP) traffic, characterized in that, include: A method for blocking Hypertext Transfer Protocol (HTTP) traffic is applied to an HTTP traffic blocking system. The system includes a configuration backend and a business module. The configuration backend is used to configure and update blocking policies, and the business module is used to receive HTTP requests sent by users through web services and intercept the HTTP requests. The inspection unit is used to check whether the received HTTP request conforms to the blocking policy. The blocking policy is a pre-configured policy stored in the business module. The blocking unit is used to block the HTTP request and return an HTTP request response with custom content if the blocking policy is met. The policy configuration interface is used to receive blocking policies configured by the policy configuration backend through the policy configuration interface via the API interface. The policy configuration interface includes a blocking policy display interface and a blocking policy change interface. The blocking policy is stored in the business module; The policy configuration interface includes at least the following: The business modules that use the aforementioned blocking policy include: global variables, variable addition, variable deletion, policy name, policy addition, policy deletion, policy editing, policy copying, policy disabling, policy submission, and returned content. The Golang language is used to define data types, built-in functions, and syntax. The data types defined using the Golang language include: Basic type: The type name is Value. The basic type contains two properties: Type and Value. The Type property indicates the data type of the Value property, which is a string in Go. The Value property is used to store the value of the data under the corresponding Type type, which can be any value in Go. Rule type: Represents a complete sub-policy. The Rule type contains 6 properties: Title, Exps, ParsedExps, Proc, ParsedProd, and Disabled. The Title property is the title of the sub-policy, and its data type in Go is a string. The Exps property stores the raw data of the variable definitions and decision conditions for the blocking sub-policy; each one-dimensional array is actually a complete definition of a variable or decision condition, and its data type in Go is a two-dimensional array of any type. The ParsedExps property stores the preprocessed result of Exps, and its data type in Go is a one-dimensional array of Value types. The Proc property stores the raw data of the custom response content of the blocking sub-policy, and its data type in Go is a one-dimensional array of any type. The ParsedProd property stores the preprocessed result of Proc, and its data type in Go is Value type. The Disabled property, if true, disables the blocking sub-policy; otherwise, it enables the blocking sub-policy, and if disabled, the matching of the blocking sub-policy will be skipped. The `Rules` type represents all blocking policies configured in the backend, including the definition of global variables and the configuration of each sub-policy. The `Rules` type includes three properties: `Defs`, `ParsedDefs`, and `Rules`. The `Defs` property contains the raw data of the global variables configured in the backend, which in Go is a one-dimensional array of any data type. The `ParsedDefs` property stores the preprocessed result of `Defs`, which in Go is a one-dimensional array of `Value` types. The `Rules` property contains the raw and preprocessed data of all sub-policies configured in the backend, which in Go is a one-dimensional array of `Rule` types. The `Env` type specifies the scope of variables: all variables are accessible in all sub-strategies, while variables defined within a sub-strategy are only accessible within that sub-strategy. If a variable name within a sub-strategy and a global variable name are the same, the variable within the sub-strategy takes precedence. The `Env` type contains two properties: `Outter` and `Data`. The `Outter` property can be used to construct a linked list for traversal and lookup. In Go, it is a pointer type, pointing to the memory address of an `Env` variable. The `Data` property stores the values ​​of global variables and variables within sub-strategies during the execution phase of this language. In Go, it is a map dictionary type. The definition of built-in functions using the Golang language includes: The prototype of the built-in function is defined as follows: func(ctx, args[]Value, e *Env) (Value, error); The function parameter list includes: ctx, which is the context of the current HTTP request; args, which is a one-dimensional array of type Value; and e, which is the environment variable. The function return value list includes: Value, which is the result calculated by the built-in function, and the data type of the result is Value; and error, which is a native Go data type, indicating whether an error occurred during the calculation. If there is no error, error is empty; if there is an error, error will contain specific error information. The syntax defined using the Golang language includes: Define variables: define variable_name; built-in functions; list of parameters for built-in functions. Define the criteria for judgment: built-in functions and their parameter lists; Define the HTTP response content: Built-in functions and their parameter lists.

4. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the method for blocking Hypertext Transfer Protocol (HTTP) traffic as described in any one of claims 1 to 3.

5. A storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the method for blocking Hypertext Transfer Protocol (HTTP) traffic as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Abnormal traffic detection method and device, electronic equipment and storage medium

    CN114124563A

  • Enforcement method and device, electronic equipment, medium and computer program product

    CN114189383A