WO2019134277A1 - 数据过滤方法、装置、服务器及可读存储介质 - Google Patents

数据过滤方法、装置、服务器及可读存储介质 Download PDF

Info

Publication number
WO2019134277A1
WO2019134277A1 PCT/CN2018/081388 CN2018081388W WO2019134277A1 WO 2019134277 A1 WO2019134277 A1 WO 2019134277A1 CN 2018081388 W CN2018081388 W CN 2018081388W WO 2019134277 A1 WO2019134277 A1 WO 2019134277A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
http
form data
type
protocol header
Prior art date
Application number
PCT/CN2018/081388
Other languages
English (en)
French (fr)
Inventor
廖嘉东
张文明
陈少杰
Original Assignee
武汉斗鱼网络科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 武汉斗鱼网络科技有限公司 filed Critical 武汉斗鱼网络科技有限公司
Publication of WO2019134277A1 publication Critical patent/WO2019134277A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/953Querying, e.g. by the use of web search engines
    • G06F16/9535Search customisation based on user profiles and personalisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/22Procedural

Definitions

  • the present application relates to the field of computer technologies, and in particular, to a data filtering method, apparatus, server, and readable storage medium.
  • HTTP form data such as XSS filtering, SQL injection filtering, etc.
  • a common method of security filtering currently is to split the data of the HTTP request by a fixed length and perform a regular match. If an illegal character is matched, the HTTP request is intercepted.
  • the form data may include data types such as file data, picture data, and text data, the above method cannot classify and filter the HTTP form data, which may cause the data that the user needs to view (for example, picture data or file data) to be Mistaken interception.
  • the present application aims to provide a data filtering method, apparatus, server, and readable storage medium, which can classify and filter HTTP form data, improve the accuracy of data security filtering, and prevent The data that the user needs to view is blocked by mistake.
  • the embodiment of the present application provides a data filtering method, which is applied to a server, and the method includes:
  • HTTP form data includes form data of a plurality of data types
  • the HTTP form data is classified according to the parsed data separator to obtain form data of the corresponding data type, and the form data of the corresponding data type in the HTTP form data is filtered based on the pre-configured data filtering rule.
  • the parsing the HTTP protocol header to obtain a data separator in the HTTP protocol header includes:
  • the regular matching function is called to match the data separator from the HTTP protocol header.
  • the step of parsing the HTTP protocol header to obtain a data separator in the HTTP protocol header includes:
  • the first value of the array of the table type is assigned to the HTTP protocol header http_header, and the regular matching function is called to match the data separator from the HTTP protocol header.
  • the step of calling the regular matching function to match the data separator from the HTTP protocol header includes:
  • the HTTP protocol header http_header and the boundary matching parameter are input into Lua's regular matching function match, and the data separator of the HTTP request is matched.
  • the categorizing the HTTP form data according to the parsed data separator to obtain form data of a corresponding data type, and corresponding to the HTTP form data based on the pre-configured data filtering rule Filter the form data of the data type including:
  • the form data is divided into multiple pieces of data according to the data separator, and each piece of data is regularly matched, the data type of each piece of data is obtained, and the data type of each piece of data is determined to be a data type to be filtered. ;
  • the data of the corresponding data type in the form data is filtered based on the pre-configured data filtering rule.
  • the method further includes:
  • the form data is filtered based on a pre-configured data filtering rule.
  • the step of acquiring the form data of the preset data length from the HTTP form data in sequence includes:
  • Forming according to the total length of the form data and the preset data length, form data of a preset data length from the form data;
  • the form data of the preset data length is divided by the data separator.
  • the step of performing regular matching on each piece of data, obtaining a data type of each piece of data, and determining whether the data type of each piece of data is a data type to be filtered includes:
  • the loop extracts data from the array, performs regular matching on the data type of the extracted data, and determines whether the type of each data is a preset filtered data type.
  • the method further includes:
  • data filtering rules of various form data types are configured, and the data filtering rules include an intercepting rule and a release rule.
  • the embodiment of the present application further provides a data filtering apparatus, which is applied to a server, and the apparatus includes:
  • Obtaining a module configured to obtain an HTTP protocol header and HTTP form data from the HTTP request when receiving an HTTP request, where the HTTP form data includes form data of multiple data types;
  • a parsing module configured to parse the HTTP protocol header to obtain a data separator in the HTTP protocol header
  • a classification filtering module configured to classify the HTTP form data according to the parsed data separator to obtain form data of a corresponding data type, and filter form data of a corresponding data type in the HTTP form data based on a pre-configured data filtering rule .
  • the embodiment of the present application further provides a server, where the server includes:
  • a data filtering device the device being stored in the storage medium and comprising a software function module executed by the processor, the device comprising:
  • Obtaining a module configured to obtain an HTTP protocol header and HTTP form data from the HTTP request when receiving an HTTP request, where the HTTP form data includes form data of multiple data types;
  • a parsing module configured to parse the HTTP protocol header to obtain a data separator in the HTTP protocol header
  • a classification filtering module configured to classify the HTTP form data according to the parsed data separator to obtain form data of a corresponding data type, and filter form data of a corresponding data type in the HTTP form data based on a pre-configured data filtering rule .
  • the embodiment of the present application further provides a readable storage medium, where the readable storage medium stores a computer program, and when the computer program is executed, the data filtering method described above is implemented.
  • the embodiment of the present application provides a data filtering method, apparatus, server, and readable storage medium.
  • an HTTP protocol header and HTTP form data are obtained from the HTTP request when an HTTP request is received, and the HTTP protocol header is obtained.
  • the form data of the corresponding data type in the data is filtered.
  • the HTTP form data can be classified and filtered, the accuracy of data security filtering is improved, and the error interception of the picture data or the file data is prevented.
  • FIG. 1 is a schematic flowchart of a data filtering method according to an embodiment of the present application
  • step S230 shown in FIG. 1;
  • FIG. 3 is a functional block diagram of a data filtering apparatus according to an embodiment of the present application.
  • FIG. 4 is a schematic structural block diagram of a server according to an embodiment of the present application.
  • Icon 100-server; 110-bus; 120-processor; 130-storage medium; 140-bus interface; 150-network adapter; 160-user interface; 200-data filtering device; 210-acquisition module; 220-analysis module ; 230-classification filter module.
  • FIG. 1 is a schematic flowchart of a data filtering method provided by an embodiment of the present application. It should be noted that the data filtering method provided by the embodiment of the present application is not limited to the specific order described in FIG. 1 and the following. The specific process of the method is as follows:
  • Step S210 when receiving the HTTP request, obtain an HTTP protocol header and HTTP form data from the HTTP request.
  • the HTTP body data in the HTTP request includes the HTTP protocol header and the HTTP form data. For details, see the HTTP body data structure as follows:
  • the data separator boundary is located in the HTTP protocol header.
  • the data separator is ------------------------------------7d33a816d302b6.
  • the data separator is automatically generated randomly by the HTTP request, and the data in the HTTP body is determined by the protocol.
  • the data separators in the header are separated by the HTTP body data.
  • the HTTP form data is separated by the separator -------------------------------------------------------- The -7d33a816d302b6 is separated so that data can be classified according to the data separator.
  • the HTTP protocol header in the HTTP request needs to be obtained first.
  • the HTTP protocol header HTTP_header can be obtained by calling Lua's get_headers()["content-type"] function.
  • the HTTP form data may include form data of a data type such as file data, picture data, and text data.
  • Step S220 parsing the HTTP protocol header to obtain a data separator in the HTTP protocol header.
  • the regular matching function in Lua is called to match the data separator from the HTTP protocol header.
  • the first parameter is filled in the HTTP protocol header http_header
  • the final match value is the data separator in the HTTP request.
  • match to boundary --------------------------- ---7d33a816d302b6, which indicates that the data separator boundary is ---------------------------------------------7d33a816d302b6.
  • the data separator boundary is implemented. Get.
  • Lua is a small scripting language that provides flexible extensions and customizations for applications.
  • Lua is written in standard C prophecy and can be compiled and run on almost all operating systems and platforms.
  • Lua does not provide a powerful library, which is determined by its positioning. So Lua is not suitable as a language for developing standalone applications.
  • Lua has a simultaneous JIT project that provides instant compilation on a specific platform.
  • Step S230 classifying the HTTP form data according to the parsed data separator to obtain form data of a corresponding data type, and filtering form data of a corresponding data type in the HTTP form data based on a pre-configured data filtering rule.
  • the step S230 may include the following sub-steps:
  • Step S231 obtaining form data of a preset data length from the HTTP form data in sequence.
  • the form data obtaining function (for example, ngx.req.socket()) can be used to obtain the HTTP form data Luasocket sock, wherein the sock is used for network communication, and the case is obtained by using the sock communication to obtain the HTTP request.
  • Form data can be used to obtain the HTTP form data Luasocket sock, wherein the sock is used for network communication, and the case is obtained by using the sock communication to obtain the HTTP request.
  • Form data use the form data length acquisition function (for example, the function ngx.req.get_headers()['content-length'] of the nginx Lua module) to get the total length of the HTTP form data content_length.
  • the preset data length chunk_size is smaller than the data length content_length of the HTTP form data.
  • the HTTP form data is processed in multiple times according to the preset data length, which can improve processing efficiency and reduce performance pressure.
  • Step S232 judging whether there is a data separator in the form data for each form data acquired.
  • the form data may be separated by a data separator boundary by calling a split function in Lua. If a data separator exists in the form data, step S233 is performed:
  • Step S233 dividing the form data into a plurality of pieces of data according to a data separator, performing regular matching on each piece of data, obtaining a data type of each piece of data, and determining whether the data type of each piece of data is a data type to be filtered.
  • step S234 is performed:
  • Step S234 filtering data of a corresponding data type in the form data based on a pre-configured data filtering rule.
  • the multi-segment data separated by the data separator boundary may be cyclically processed.
  • the data type of the form data to be matched is file data
  • Regularly match each piece of data to determine whether the data type of each piece of data is a file type if If the data of the segment is matched to the file data, the segment data is file-filtered based on the pre-configured data filtering rule.
  • step S235 is performed:
  • Step S235 Perform regular matching on the form data, obtain a data type of the form data, and determine whether the data type of the form data is a data type to be filtered.
  • the split function is used to obtain an array corresponding to each piece of data after the segmentation
  • the loop extracts data from the array, performs regular matching on the data type of the extracted data, and determines whether the type of each data is a preset filtered data type.
  • step S236 is performed:
  • Step S236 filtering the form data based on a pre-configured data filtering rule.
  • the form data is file data, and the form data is file-filtered based on a pre-configured data filtering rule.
  • the data filtering rule may be configured in advance. Of course, the configured data filtering rule may be adjusted at any time.
  • the server 100 configures data filtering rules of various form data types by responding to the configuration request of the user data filtering rule.
  • the data filtering rules may include an interception rule and a release rule.
  • the data filtering rules of the text data, the file data, and the image data may be respectively configured to intercept, release, and release, so that the data classification and filtering of the HTTP form data may be performed by using the data separator in the HTTP request protocol header.
  • the accuracy of security filtering prevents accidental interception of images and files.
  • the embodiment of the present application further provides a data filtering apparatus 200, where the apparatus may include:
  • the obtaining module 210 is configured to obtain an HTTP protocol header and HTTP form data from the HTTP request when the HTTP request is received, where the HTTP form data includes multiple types of form data.
  • the parsing module 220 is configured to parse the HTTP protocol header to obtain a data separator in the HTTP protocol header.
  • the classification filtering module 230 is configured to classify the HTTP form data according to the parsed data separator to obtain form data of a corresponding data type, and perform form data of a corresponding data type in the HTTP form data based on a pre-configured data filtering rule. filter.
  • the parsing module 220 is further configured to determine whether the data type of the HTTP protocol header is a table type, and when the determination result is no, invoke a regular matching function from the HTTP protocol. The data separator is matched in the header.
  • the HTTP form data is classified according to the parsed data separator to obtain form data of a corresponding data type, and the corresponding data type in the HTTP form data is based on a pre-configured data filtering rule.
  • Ways to filter form data including:
  • the form data is divided into multiple pieces of data according to the data separator, and each piece of data is regularly matched, the data type of each piece of data is obtained, and the data type of each piece of data is determined to be a data type to be filtered. ;
  • the data of the corresponding data type in the form data is filtered based on the pre-configured data filtering rule.
  • the parsing module 220 is specifically configured to:
  • the first value of the array of the table type is assigned to the HTTP protocol header http_header, and the regular matching function is called to match the data separator from the HTTP protocol header.
  • the parsing module 220 is further configured to: input an HTTP protocol header http_header and a boundary matching parameter into Lua's regular matching function match, and match the data separator of the HTTP request.
  • the classification filtering module 230 is further configured to:
  • the form data acquisition function can be implemented using the ngx.req.socket() function in Lua, and the ngx.req.socket() method can obtain the form data from the HTTP request.
  • the form data length acquisition function can be implemented by using the ngx.req.get_headers()['content-length'] function in Lua.
  • Forming according to the total length of the form data and the preset data length, form data of a preset data length from the form data;
  • the form data of the preset data length is divided by the data separator.
  • FIG. 4 is a schematic block diagram of a structure of a server 100 according to an embodiment of the present application.
  • the server 100 is a web server.
  • the server 100 should be understood to provide a service point for processing, database, and communication facilities.
  • server 100 may refer to a single physical processor with associated communication and data storage and repository facilities, or it may refer to a networked or aggregated processor, a collection of related networks and storage devices, and for software and The application software of one or more database systems and services provided by the support server 100 operates.
  • Server 100 may vary greatly in configuration or performance, but server 100 may generally include one or more central processing units and storage units.
  • Server 100 may also include one or more large storage area devices, one or more power supplies, one or more wired or wireless network components, one or more input/output components, or one or more operating systems, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD.
  • Windows Server Mac OS X, Unix, Linux, FreeBSD.
  • server 100 can be implemented by bus 110 as a general bus architecture.
  • bus 110 may include any number of interconnecting buses and bridges.
  • Bus 110 connects various circuits together, including processor 120, storage medium 130, and bus interface 140.
  • the server 100 may connect the network adapter 150 or the like via the bus 110 using the bus interface 140.
  • the network adapter 150 can be used to implement signal processing functions of the physical layer in the server 100, and transmit and receive radio frequency signals through an antenna.
  • the user interface 160 can be connected to an external device such as a keyboard, a display, a mouse, or a joystick.
  • the bus 110 can also be connected to various other circuits, such as timing sources, peripherals, voltage regulators, or power management circuits, etc., which are well known in the art and therefore will not be described in detail.
  • server 100 can also be configured as a general purpose processing system, such as generally referred to as a chip, including: one or more microprocessors providing processing functionality, and external memory providing at least a portion of storage medium 130, all These are all connected to other support circuits through an external bus architecture.
  • a general purpose processing system such as generally referred to as a chip, including: one or more microprocessors providing processing functionality, and external memory providing at least a portion of storage medium 130, all These are all connected to other support circuits through an external bus architecture.
  • the server 100 can be implemented using an ASIC (application specific integrated circuit) having a processor 120, a bus interface 140, a user interface 160, and at least a portion of the storage medium 130 integrated in a single chip, or a server 100 can be implemented using one or more of the following: one or more FPGAs (field programmable gate arrays), PLDs (programmable logic devices), controllers, state machines, gate logic, discrete hardware components, any other suitable circuitry, or Any combination of circuits capable of performing the various functions described throughout this application.
  • ASIC application specific integrated circuit
  • the processor 120 is responsible for managing the bus 110 and general processing (including executing software stored on the storage medium 130).
  • Processor 120 can be implemented using one or more general purpose processors and/or special purpose processors. Examples of processor 120 include a microprocessor, a microcontroller, a DSP processor, and other circuitry capable of executing software.
  • Software should be interpreted broadly to mean instructions, data, or any combination thereof, whether referred to as software, firmware, middleware, microcode, hardware description language, or otherwise.
  • Storage medium 130 is shown separate from processor 120 in FIG. 4, however, those skilled in the art will readily appreciate that storage medium 130, or any portion thereof, may be located external to server 100.
  • storage medium 130 may include transmission lines, carrier waveforms modulated with data, and/or computer products separate from wireless nodes, all of which may be accessed by processor 120 through bus interface 140.
  • storage medium 130, or any portion thereof, may be integrated into processor 120, for example, may be a cache and/or a general purpose register.
  • the processor 120 may be configured as described above. Specifically, the data filtering device 200 may be stored in the storage medium 130, and the processor 120 may be configured to execute the data filtering device 200.
  • each block of the flowchart or block diagram can represent a module, a program segment, or a portion of code that includes one or more of the Executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the blocks may also occur in a different order than those illustrated in the drawings.
  • each block of the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts can be implemented in a dedicated hardware-based system that performs the specified function or function. Or it can be implemented by a combination of dedicated hardware and computer instructions.
  • each functional module in each embodiment of the present application may be integrated to form a separate part, or each module may exist separately, or two or more modules may be integrated to form a separate 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 transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be from a website site, computer, server or data center Transfer to another website site, computer, server, or data center by wire (eg, coaxial cable, fiber optic, digital subscriber line (DSL), or wireless (eg, infrared, wireless, microwave, etc.).
  • the computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as an electronic device, server, data center, or the like that includes one or more available media.
  • the usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
  • the data filtering method, device, server and readable storage medium provided by the application can classify and filter HTTP form data, improve the accuracy of data security filtering, and prevent misinterpretation of picture data or file data.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本申请实施例提供一种数据过滤方法、装置、服务器及可读存储介质。该方法包括:在接收到HTTP请求时,从所述HTTP请求中获得HTTP协议头和HTTP表单数据,所述HTTP表单数据中包括有多种数据类型的表单数据;对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符;根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤。由此,能够对HTTP表单数据进行分类过滤,提高了数据安全过滤的准确率,防止了图片数据或者文件数据的误拦截。

Description

数据过滤方法、装置、服务器及可读存储介质
本申请要求于2018年01月02日提交中国专利局的申请号为201810000895.7名称为“数据过滤方法、装置、服务器及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,具体而言,涉及一种数据过滤方法、装置、服务器及可读存储介质。
背景技术
在Web开发领域中,经常会需要对HTTP表单数据进行安全过滤,例如XSS过滤、SQL注入过滤等,这些操作能够有效保障产品的安全。目前安全过滤的一种常用的方法是,对HTTP请求的数据以定长分割,并进行正则匹配,如果匹配到非法字符,则将该HTTP请求拦截。但是由于表单数据中可能包含文件数据、图片数据、文本数据等数据类型,而上述方法不能对HTTP表单数据进行分类过滤,这可能会导致用户需要查看的数据(比如,图片数据或者文件数据)被误拦截。
发明内容
为了克服现有技术中的上述不足,本申请的目的在于提供一种数据过滤方法、装置、服务器及可读存储介质,能够对HTTP表单数据进行分类过滤,提高了数据安全过滤的准确率,防止用户需要查看的数据被误拦截。
为了实现上述目的,本申请实施例采用的技术方案如下:
本申请实施例提供一种数据过滤方法,应用于服务器,所述方法包括:
在接收到HTTP请求时,从所述HTTP请求中获得HTTP协议头和HTTP表单数据,所述HTTP表单数据中包括有多种数据类型的表单数据;
对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符;
根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤。
可选地,在本申请实施例中,所述对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符,包括:
判断所述HTTP协议头的数据类型是否是table类型;
在判断结果为否时,调用正则匹配函数从所述HTTP协议头中匹配出 数据分隔符。
可选地,在本申请实施例中,所述对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符的步骤,包括:
判断所述HTTP协议头的数据类型是否是table类型;
在判断结果为是时,将table类型的数组的第一个值赋值给HTTP协议头http_header,调用正则匹配函数从所述HTTP协议头中匹配出数据分隔符。
可选地,在本申请实施例中,所述调用正则匹配函数从所述HTTP协议头中匹配出数据分隔符的步骤,包括:
将HTTP协议头http_header及边界匹配参数输入到Lua的正则匹配函数match中,匹配得到该HTTP请求的数据分隔符。
可选地,在本申请实施例中,所述根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤,包括:
依次从所述HTTP表单数据中获取预设数据长度的表单数据,所述预设数据长度小于所述HTTP表单数据的数据长度;
针对每次获取的表单数据,判断所述表单数据中是否存在数据分隔符;
如果存在,则根据数据分隔符将所述表单数据分为多段数据,并对每段数据进行正则匹配,获取每段数据的数据类型,并判断每段数据的数据类型是否为需要过滤的数据类型;
在判断结果为是时,基于预先配置的数据过滤规则将所述表单数据中相应数据类型的数据进行过滤。
可选地,在本申请实施例中,在针对每次获取的表单数据,判断所述表单数据中是否存在数据分隔符之后,所述方法还包括:
如果不存在,则对所述表单数据进行正则匹配,获取所述表单数据的数据类型,并判断所述表单数据的数据类型是否为需要过滤的数据类型;
在判断结果为是时,基于预先配置的数据过滤规则将所述表单数据进行过滤。
可选地,在本申请实施例中,所述依次从所述HTTP表单数据中获取预设数据长度的表单数据的步骤,包括:
使用表单数据获取函数获取表单数据;
采用表单数据长度获取函数获得所述表单数据的总长度;
根据表单数据的总长度及预设数据长度,从所述表单数据中循环获取预设数据长度的表单数据;
将预设数据长度的表单数据以数据分割符进行分割。
可选地,在本申请实施例中,所述对每段数据进行正则匹配,获取每段数据的数据类型,并判断每段数据的数据类型是否为需要过滤的数据类型的步骤,包括:
采用split函数得到分割后每段数据对应的数组;
循环从所述数组中取出数据,对取出数据的数据类型进行正则匹配,判断每段数据的类型是否为预设的过滤数据类型。
可选地,在本申请实施例中,所述方法还包括:
响应数据过滤规则的配置请求,配置各种表单数据类型的数据过滤规则,所述数据过滤规则包括拦截规则和放行规则。
本申请实施例还提供一种数据过滤装置,应用于服务器,所述装置包括:
获得模块,用于在接收到HTTP请求时,从所述HTTP请求中获得HTTP协议头和HTTP表单数据,所述HTTP表单数据中包括有多种数据类型的表单数据;
解析模块,用于对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符;
分类过滤模块,用于根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤。
本申请实施例还提供一种服务器,所述服务器包括:
存储介质;
处理器;以及
数据过滤装置,所述装置存储于所述存储介质中并包括由所述处理器执行的软件功能模块,所述装置包括:
获得模块,用于在接收到HTTP请求时,从所述HTTP请求中获得HTTP协议头和HTTP表单数据,所述HTTP表单数据中包括有多种数据类型的表单数据;
解析模块,用于对所述HTTP协议头进行解析,得到所述HTTP协议 头中的数据分隔符;
分类过滤模块,用于根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤。
本申请实施例还提供一种可读存储介质,所述可读存储介质中存储有计算机程序,所述计算机程序被执行时实现上述的数据过滤方法。
相对于现有技术而言,本申请具有以下有益效果:
本申请实施例提供一种数据过滤方法、装置、服务器及可读存储介质,首先,在接收到HTTP请求时从所述HTTP请求中获得HTTP协议头和HTTP表单数据,并对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符,而后根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤。由此,能够对HTTP表单数据进行分类过滤,提高了数据安全过滤的准确率,防止了图片数据或者文件数据的误拦截。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。
图1为本申请实施例提供的数据过滤方法的一种流程示意图;
图2为图1中所示的步骤S230包括的各个子步骤的一种流程示意图;
图3为本申请实施例提供的数据过滤装置的一种功能模块图;
图4为本申请实施例提供的服务器的一种结构示意框图。
图标:100-服务器;110-总线;120-处理器;130-存储介质;140-总线接口;150-网络适配器;160-用户接口;200-数据过滤装置;210-获得模块;220-解析模块;230-分类过滤模块。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本申请实施例的组件可以以各种不同的配置来布置和设计。
因此,以下对在附图中提供的本申请的实施例的详细描述并非旨在限制要求保护的本申请的范围,而是仅仅表示本申请的选定实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。
请参阅图1,为本申请实施例提供的数据过滤方法的一种流程示意图。所应说明的是,本申请实施例提供的数据过滤方法不以图1及以下所述的具体顺序为限制。所述方法的具体流程如下:
步骤S210,在接收到HTTP请求时,从所述HTTP请求中获得HTTP协议头和HTTP表单数据。
HTTP请求中HTTP body数据包括HTTP协议头及HTTP表单数据。具体可以参见如下的HTTP body数据结构:
POST/upload_file/UploadFile HTTP/1.1
Accept:text/plain,*/*
Accept-Language:zh-cn
Host:192.168.29.65:80
Content-Type:multipart/form-data;boundary=---------------------------7d33a
816d302b6
User-Agent:Mozilla/4.0(compatible;OpenOffice.org)
Content-Length:424
Connection:Keep-Alive-----------------------------7d33a816d302b6
Content-Disposition:form-data;
name="userfile1";
filename="E:/s"Content-Type:
application/octet-stream abbXXXccc
-----------------------------7d33a816d302b6
Content-Disposition:form-data;
name="text1"foo
-----------------------------7d33a816d302b6
Content-Disposition:form-data;
name="password1"bar
-----------------------------7d33a816d302b6
数据分割符boundary位于HTTP协议头中,在收到HTTP请求时,利用Lua的正则匹配函数match在HTTP协议头中匹配";%s*boundary=\"([^\"]+)\"",匹配出来的值就是http请求中的数据分隔符,例如匹配到boundary=---------------------------7d33a816d302b6,则说明数据分隔符为---------------------------7d33a816d302b6。数据分隔符由HTTP请求自动随机生成,HTTP body中的数据由协议头中匹配的数据分隔符分隔,由上面HTTP body数据可以看出,HTTP表单数据由分隔符---------------------------7d33a816d302b6分隔开,因此可以依据数据分隔符进行数据分类。
本实施例中,首先需要获取所述HTTP请求中的HTTP协议头,具体地,可以通过调用Lua的get_headers()["content-type"]函数,获得所述HTTP协议头HTTP_header。
所述HTTP表单数据中可以包括有文件数据、图片数据、文本数据等数据类型的表单数据。
步骤S220,对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符。
本实施例中,首先需要判断所述HTTP协议头的数据类型是否是table类型,如果不是table类型,则调用Lua中的正则匹配函数从所述HTTP协议头中匹配出数据分隔符。
具体地,可通过调用Lua中的type()函数来获取所述HTTP协议头http_header的数据类型,type的参数为http_header。如果type(http_header)等于table类型,表示http_header是一个数组,则令http_header=http_header[1],将数组的第一个值重新赋给http_header。如果type(http_header)不等于table类型,则不用操作。
接着,可通过调用Lua的正则匹配函数match,将第一个参数填入上述HTTP协议头http_header,第二个参数填入匹配参数";%s*boundary=\"([^\"]+)\"",最终匹配得到的值boundary则为该HTTP请求中的数据分隔符。例如匹配到boundary=---------------------------7d33a816d302b6,则表明数据分隔符boundary为---------------------------7d33a816d302b6。由此,实现了数据分隔 符boundary的获取。
其中,Lua是一个小巧的脚本语言,其可以为应用程序提供灵活的扩展和定制功能。Lua由标准C预言编写而成,几乎在所有操作系统和平台上都可以编译,运行。Lua并没有提供强大的库,这是由它的定位决定的。所以Lua不适合作为开发独立应用程序的语言。Lua有一个同时进行的JIT项目,提供在特定平台上的即时编译功能。
步骤S230,根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤。
作为本步骤的一种实现方式,请参阅图2,所述步骤S230可以包括以下子步骤:
步骤S231,依次从所述HTTP表单数据中获取预设数据长度的表单数据。
本实施例中,首先可以使用表单数据获取函数(比如,ngx.req.socket())来获取HTTP表单数据Luasocket sock,其中,sock用于进行网络通信,本案通过sock通信来获取HTTP请求中的表单数据。接着,利用表单数据长度获取函数(比如,nginx Lua模块的函数ngx.req.get_headers()['content-length'])来获取HTTP表单数据的总长度content_length。另外,预先定义每次处理的预设数据长度chunk_size=4096,也即每次处理的数据长度chunk_size为4个字节长度。其中,所述预设数据长度chunk_size小于所述HTTP表单数据的数据长度content_length。由此,通过定义每次处理的预设数据长度,将所述HTTP表单数据按照预设数据长度分多次进行处理,能够提高处理效率,降低性能压力。
步骤S232,针对每次获取的表单数据,判断所述表单数据中是否存在数据分隔符。
本实施例中,可以通过调用Lua中的split函数,将所述表单数据以数据分隔符boundary进行分隔,如果所述表单数据中存在数据分隔符,则执行步骤S233:
步骤S233,根据数据分隔符将所述表单数据分为多段数据,并对每段数据进行正则匹配,获取每段数据的数据类型,并判断每段数据的数据类型是否为需要过滤的数据类型。
在判断结果为是时,执行步骤S234:
步骤S234,基于预先配置的数据过滤规则将所述表单数据中相应数据类型的数据进行过滤。
本实施例中,可以对使用数据分隔符boundary分隔后的多段数据进行循环处理,例如,需要进行匹配的表单数据的数据类型为文件数据,则可以通过调用ngxmatch(data,[[Content-Disposition:form-data;(.+)filename="(.+)\.(.*)"]],'ijo')对每段数据进行正则匹配,判断每段数据的数据类型是否是文件类型,如果匹配到该段数据为文件数据,则基于预先配置的数据过滤规则将该段数据进行文件过滤。
如果所述表单数据中不存在数据分隔符,则执行步骤S235:
步骤S235,对所述表单数据进行正则匹配,获取所述表单数据的数据类型,并判断所述表单数据的数据类型是否为需要过滤的数据类型。
在本实施例中,采用split函数得到分割后每段数据对应的数组;
循环从所述数组中取出数据,对取出数据的数据类型进行正则匹配,判断每段数据的类型是否为预设的过滤数据类型。
在判断结果为是时,执行步骤S236:
步骤S236,基于预先配置的数据过滤规则将所述表单数据进行过滤。
本实施例中,如果所述表单数据中不存在数据分隔符,则表明所述表单数据中只包括有一种类型的数据,因此可以直接调用ngxmatch(data,[[Content-Disposition:form-data;(.+)filename="(.+)\.(.*)"]],'ijo')对所述表单数据进行正则匹配,判断所述表单数据的数据类型是否是文件类型,如果匹配到所述表单数据为文件数据,则基于预先配置的数据过滤规则将所述表单数据进行文件过滤。
其中,上述数据过滤规则可以预先进行配置,当然也可以在任何时候对配置的数据过滤规则进行调整,服务器100通过响应用户的数据过滤规则的配置请求,配置各种表单数据类型的数据过滤规则。所述数据过滤规则可以包括拦截规则和放行规则。例如,可以分别配置文本数据、文件数据、图片数据的数据过滤规则分别为拦截、放行、放行,从而可以通过上述利用HTTP请求协议头中的数据分隔符,对HTTP表单数据进行数据分类过滤,提高了安全过滤的准确率,防止了图片和文件误拦截。
进一步地,请参阅图3,本申请实施例还提供一种数据过滤装置200,所述装置可以包括:
获得模块210,用于在接收到HTTP请求时,从所述HTTP请求中获得 HTTP协议头和HTTP表单数据,所述HTTP表单数据中包括有多种类型的表单数据。
解析模块220,用于对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符。
分类过滤模块230,用于根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤。
进一步地,在一种实施方式中,所述解析模块220,还用于判断所述HTTP协议头的数据类型是否是table类型,并在判断结果为否时,调用正则匹配函数从所述HTTP协议头中匹配出数据分隔符。
进一步地,在一种实施方式中,根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤的方式,包括:
依次从所述HTTP表单数据中获取预设数据长度的表单数据,所述预设数据长度小于所述HTTP表单数据的数据长度;
针对每次获取的表单数据,判断所述表单数据中是否存在数据分隔符;
如果存在,则根据数据分隔符将所述表单数据分为多段数据,并对每段数据进行正则匹配,获取每段数据的数据类型,并判断每段数据的数据类型是否为需要过滤的数据类型;
在判断结果为是时,基于预先配置的数据过滤规则将所述表单数据中相应数据类型的数据进行过滤。
进一步地,在本实施例中,所述解析模块220具体用于:
判断所述HTTP协议头的数据类型是否是table类型;
在判断结果为是时,将table类型的数组的第一个值赋值给HTTP协议头http_header,调用正则匹配函数从所述HTTP协议头中匹配出数据分隔符。
进一步地,在本实施例中,所述解析模块220还用于:将HTTP协议头http_header及边界匹配参数输入到Lua的正则匹配函数match中,匹配得到该HTTP请求的数据分隔符。
进一步地,在本实施例中,所述分类过滤模块230还用于:
使用表单数据获取函数获取表单数据;
在本实施例中,表单数据获取函数可以采用Lua中的ngx.req.socket()函数实现,ngx.req.socket()从HTTP请求中获取表单数据。
采用表单数据长度获取函数获得所述表单数据的总长度;
在本实施例中,表单数据长度获取函数可以采用Lua中的ngx.req.get_headers()['content-length']函数实现。
根据表单数据的总长度及预设数据长度,从所述表单数据中循环获取预设数据长度的表单数据;
将预设数据长度的表单数据以数据分割符进行分割。
可以理解的是,本实施例中的各功能模块的具体操作方法可参照上述方法实施例中相应步骤的详细描述,在此不再重复赘述。
进一步地,请参阅图4,为本申请实施例提供的服务器100的一种结构示意框图。本实施例中,所述服务器100为Web服务器。所述服务器100应被理解为提供处理、资料库、通讯设施的业务点。举例而言,服务器100可以指具有相关通信和资料存储和资料库设施的单个的物理处理器,或它可以指联网或集聚的处理器、相关网路和存放装置的集合体,并且对软体和一个或多个资料库系统和支援服务器100所提供的服务的应用软体进行操作。服务器100可以在配置或性能上差异很大,但是服务器100一般可以包括一个或多个中央处理单元和存储单元。服务器100还可以包括一个或多个大型存放区设备、一个或多个电源、一个或多个有线或无线网络组件、一个或多个输入/输出组件、或一个或多个作业系统,诸如,Windows Server、Mac OS X、Unix、Linux、FreeBSD。
如图4所示,服务器100可以由总线110作一般性的总线体系结构来实现。根据服务器100的具体应用和整体设计约束条件,总线110可以包括任意数量的互连总线和桥接。总线110将各种电路连接在一起,这些电路包括处理器120、存储介质130和总线接口140。可选地,服务器100可以使用总线接口140将网络适配器150等经由总线110连接。网络适配器150可用于实现服务器100中物理层的信号处理功能,并通过天线实现射频信号的发送和接收。用户接口160可以连接外部设备,例如:键盘、显示器、鼠标或者操纵杆等。总线110还可以连接各种其它电路,如定时源、外围设备、电压调节器或者功率管理电路等,这些电路是本领域所熟知的,因此不再详述。
可以替换的,服务器100也可配置成通用处理系统,例如通称为芯片, 该通用处理系统包括:提供处理功能的一个或多个微处理器,以及提供存储介质130的至少一部分的外部存储器,所有这些都通过外部总线体系结构与其它支持电路连接在一起。
可替换的,服务器100可以使用下述来实现:具有处理器120、总线接口140、用户接口160的ASIC(专用集成电路);以及集成在单个芯片中的存储介质130的至少一部分,或者,服务器100可以使用下述器件来实现:一个或多个FPGA(现场可编程门阵列)、PLD(可编程逻辑器件)、控制器、状态机、门逻辑、分立硬件部件、任何其它适合的电路、或者能够执行本申请通篇所描述的各种功能的电路的任意组合。
其中,处理器120负责管理总线110和一般处理(包括执行存储在存储介质130上的软件)。处理器120可以使用一个或多个通用处理器和/或专用处理器来实现。处理器120的例子包括微处理器、微控制器、DSP处理器和能够执行软件的其它电路。应当将软件广义地解释为表示指令、数据或其任意组合,而不论是将其称作为软件、固件、中间件、微代码、硬件描述语言还是其它。
在图4中存储介质130被示为与处理器120分离,然而,本领域技术人员很容易明白,存储介质130或其任意部分可位于服务器100之外。举例来说,存储介质130可以包括传输线、用数据调制的载波波形、和/或与无线节点分离开的计算机制品,这些介质均可以由处理器120通过总线接口140来访问。可替换地,存储介质130或其任意部分可以集成到处理器120中,例如,可以是高速缓存和/或通用寄存器。
所述处理器120可执行上述实施例,具体地,所述存储介质130中可以存储有所述数据过滤装置200,所述处理器120可以用于执行所述数据过滤装置200。
在本申请所提供的实施例中,应该理解到,所揭露的装置和方法,也可以通过其它的方式实现。以上所描述的装置和方法实施例仅仅是示意性的,例如,附图中的流程图和框图显示了根据本申请的多个实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,所述模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现方式中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的 方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
另外,在本申请各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。
可以替换的,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其它可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的电子设备、服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。
需要说明的是,在本文中,术语"包括"、"包含"或者其任何其它变体意在涵盖非排它性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其它要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句"包括一个……"限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其它的具体形式实现本申请。因此,无论从哪一点来看,均应将实施例看作是示范性 的,而且是非限制性的,本申请的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化囊括在本申请内。不应将权利要求中的任何附图标记视为限制所涉及的权利要求。
工业实用性
本申请提供的一种数据过滤方法、装置、服务器及可读存储介质,能够对HTTP表单数据进行分类过滤,提高了数据安全过滤的准确率,防止了图片数据或者文件数据的误拦截。

Claims (17)

  1. 一种数据过滤方法,其特征在于,应用于服务器,所述方法包括:
    在接收到HTTP请求时,从所述HTTP请求中获得HTTP协议头和HTTP表单数据,所述HTTP表单数据中包括有多种数据类型的表单数据;
    对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符;
    根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤。
  2. 根据权利要求1所述的数据过滤方法,其特征在于,所述对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符,包括:
    判断所述HTTP协议头的数据类型是否是table类型;
    在判断结果为否时,调用正则匹配函数从所述HTTP协议头中匹配出数据分隔符。
  3. 根据权利要求1所述的数据过滤方法,其特征在于,所述对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符的步骤,包括:
    判断所述HTTP协议头的数据类型是否是table类型;
    在判断结果为是时,将table类型的数组的第一个值赋值给HTTP协议头http_header,调用正则匹配函数从所述HTTP协议头中匹配出数据分隔符。
  4. 如权利要求2或3所述的数据过滤方法,其特征在于,所述调用正则匹配函数从所述HTTP协议头中匹配出数据分隔符的步骤,包括:
    将HTTP协议头http_header及边界匹配参数输入到Lua的正则匹配函数match中,匹配得到该HTTP请求的数据分隔符。
  5. 根据权利要求1所述的数据过滤方法,其特征在于,所述根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤,包括:
    依次从所述HTTP表单数据中获取预设数据长度的表单数据,所述预设数据长度小于所述HTTP表单数据的数据长度;
    针对每次获取的表单数据,判断所述表单数据中是否存在数据分隔符;
    如果存在,则根据数据分隔符将所述表单数据分为多段数据,并对每 段数据进行正则匹配,获取每段数据的数据类型,并判断每段数据的数据类型是否为需要过滤的数据类型;
    在判断结果为是时,基于预先配置的数据过滤规则将所述表单数据中相应数据类型的数据进行过滤。
  6. 根据权利要求5所述的数据过滤方法,其特征在于,在针对每次获取的表单数据,判断所述表单数据中是否存在数据分隔符之后,所述方法还包括:
    如果不存在,则对所述表单数据进行正则匹配,获取所述表单数据的数据类型,并判断所述表单数据的数据类型是否为需要过滤的数据类型;
    在判断结果为是时,基于预先配置的数据过滤规则将所述表单数据进行过滤。
  7. 如权利要求5所述的数据过滤方法,其特征在于,依次从所述HTTP表单数据中获取预设数据长度的表单数据的步骤,包括:
    使用表单数据获取函数获取表单数据;
    采用表单数据长度获取函数获得所述表单数据的总长度;
    根据表单数据的总长度及预设数据长度,从所述表单数据中循环获取预设数据长度的表单数据;
    将预设数据长度的表单数据以数据分割符进行分割。
  8. 如权利要求7所述的数据过滤方法,其特征在于,对每段数据进行正则匹配,获取每段数据的数据类型,并判断每段数据的数据类型是否为需要过滤的数据类型的步骤,包括:
    采用split函数得到分割后每段数据对应的数组;
    循环从所述数组中取出数据,对取出数据的数据类型进行正则匹配,判断每段数据的类型是否为预设的过滤数据类型。
  9. 根据权利要求1所述的数据过滤方法,其特征在于,所述方法还包括:
    响应数据过滤规则的配置请求,配置各种表单数据类型的数据过滤规则,所述数据过滤规则包括拦截规则和放行规则。
  10. 一种数据过滤装置,其特征在于,应用于服务器,所述装置包括:
    获得模块,配置成在接收到HTTP请求时,从所述HTTP请求中获得HTTP协议头和HTTP表单数据,所述HTTP表单数据中包括有多种数据类型的表单数据;
    解析模块,配置成对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符;
    分类过滤模块,配置成根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤。
  11. 根据权利要求10所述的数据过滤装置,其特征在于:
    所述解析模块,还配置成判断所述HTTP协议头的数据类型是否是table类型,并在判断结果为否时,调用正则匹配函数从所述HTTP协议头中匹配出数据分隔符。
  12. 根据权利要求10所述的数据过滤装置,其特征在于,所述分类过滤模块具体配置成:
    依次从所述HTTP表单数据中获取预设数据长度的表单数据,所述预设数据长度小于所述HTTP表单数据的数据长度;
    针对每次获取的表单数据,判断所述表单数据中是否存在数据分隔符;
    如果存在,则根据数据分隔符将所述表单数据分为多段数据,并对每段数据进行正则匹配,获取每段数据的数据类型,并判断每段数据的数据类型是否为需要过滤的数据类型;
    在判断结果为是时,基于预先配置的数据过滤规则将所述表单数据中相应数据类型的数据进行过滤。
  13. 根据权利要求10所述的数据过滤装置,其特征在于,所述解析模块配置成:
    判断所述HTTP协议头的数据类型是否是table类型;
    在判断结果为是时,将table类型的数组的第一个值赋值给HTTP协议头http_header,调用正则匹配函数从所述HTTP协议头中匹配出数据分隔符。
  14. 根据权利要求11或13所述的数据过滤装置,其特征在于,所述解析模块进一步配置成:
    将HTTP协议头http_header及边界匹配参数输入到Lua的正则匹配函数match中,匹配得到该HTTP请求的数据分隔符。
  15. 根据权利要求12所述的数据过滤装置,其特征在于,所述分类过滤模块进一步配置成:
    使用表单数据获取函数获取表单数据;
    采用表单数据长度获取函数获得所述表单数据的总长度;
    根据表单数据的总长度及预设数据长度,从所述表单数据中循环获取预设数据长度的表单数据;
    将预设数据长度的表单数据以数据分割符进行分割。
  16. 一种服务器,其特征在于,所述服务器包括:
    存储介质;
    处理器;以及
    数据过滤装置,所述装置存储于所述存储介质中并包括由所述处理器执行的软件功能模块,所述装置包括:
    获得模块,配置成在接收到HTTP请求时,从所述HTTP请求中获得HTTP协议头和HTTP表单数据,所述HTTP表单数据中包括有多种数据类型的表单数据;
    解析模块,配置成对所述HTTP协议头进行解析,得到所述HTTP协议头中的数据分隔符;
    分类过滤模块,配置成根据解析出的数据分隔符对所述HTTP表单数据进行分类得到相应数据类型的表单数据,并基于预先配置的数据过滤规则对HTTP表单数据中相应数据类型的表单数据进行过滤。
  17. 一种可读存储介质,其特征在于,所述可读存储介质中存储有计算机程序,所述计算机程序被执行时实现权利要求1-9中任意一项所述的数据过滤方法。
PCT/CN2018/081388 2018-01-02 2018-03-30 数据过滤方法、装置、服务器及可读存储介质 WO2019134277A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810000895.7A CN108108471A (zh) 2018-01-02 2018-01-02 数据过滤方法、装置、服务器及可读存储介质
CN201810000895.7 2018-01-02

Publications (1)

Publication Number Publication Date
WO2019134277A1 true WO2019134277A1 (zh) 2019-07-11

Family

ID=62218402

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/081388 WO2019134277A1 (zh) 2018-01-02 2018-03-30 数据过滤方法、装置、服务器及可读存储介质

Country Status (2)

Country Link
CN (1) CN108108471A (zh)
WO (1) WO2019134277A1 (zh)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040117488A1 (en) * 2002-12-12 2004-06-17 Mcnamee Kevin Dynamic callback packet filtering gateway
CN102098331A (zh) * 2010-12-29 2011-06-15 北京锐安科技有限公司 一种还原web类应用内容的方法及其系统
CN102364897A (zh) * 2011-09-30 2012-02-29 北京亿赞普网络技术有限公司 一种网关级在线网络报文检测过滤方法及装置
CN106095772A (zh) * 2016-05-18 2016-11-09 厦门市美亚柏科信息股份有限公司 一种http协议信息提取的方法和装置
CN107026821A (zh) * 2016-02-01 2017-08-08 阿里巴巴集团控股有限公司 报文的处理方法及装置
CN107404486A (zh) * 2017-08-04 2017-11-28 厦门市美亚柏科信息股份有限公司 解析Http数据的方法、装置、终端设备及存储介质

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1972292B (zh) * 2005-10-17 2012-09-26 飞塔公司 一种电子数据处理系统及其方法
WO2016085412A1 (en) * 2014-11-28 2016-06-02 Pte Ltd, Expert Team Systems and methods for intercepting, filtering and blocking content from internet in real-time
CN106060090A (zh) * 2016-07-29 2016-10-26 广州市乐商软件科技有限公司 网站脚本攻击防范方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040117488A1 (en) * 2002-12-12 2004-06-17 Mcnamee Kevin Dynamic callback packet filtering gateway
CN102098331A (zh) * 2010-12-29 2011-06-15 北京锐安科技有限公司 一种还原web类应用内容的方法及其系统
CN102364897A (zh) * 2011-09-30 2012-02-29 北京亿赞普网络技术有限公司 一种网关级在线网络报文检测过滤方法及装置
CN107026821A (zh) * 2016-02-01 2017-08-08 阿里巴巴集团控股有限公司 报文的处理方法及装置
CN106095772A (zh) * 2016-05-18 2016-11-09 厦门市美亚柏科信息股份有限公司 一种http协议信息提取的方法和装置
CN107404486A (zh) * 2017-08-04 2017-11-28 厦门市美亚柏科信息股份有限公司 解析Http数据的方法、装置、终端设备及存储介质

Also Published As

Publication number Publication date
CN108108471A (zh) 2018-06-01

Similar Documents

Publication Publication Date Title
US9456229B2 (en) Parsing single source content for multi-channel publishing
WO2020062793A1 (zh) 基于消息队列的请求处理方法、装置、设备及存储介质
CN109218336B (zh) 漏洞防御方法及系统
US10423594B2 (en) Systems and methods for indexing source code in a search engine
WO2021218143A1 (zh) 数据同步方法、装置、服务器及存储介质
WO2021012568A1 (zh) 一种数据处理方法及相关设备
US11019128B2 (en) Identity service management in limited connectivity environments
US10043220B2 (en) Method, device and storage medium for data processing
WO2019196239A1 (zh) 一种线程接口的管理方法、终端设备及计算机可读存储介质
CN105518673B (zh) 管理数据摄取
WO2022048422A1 (zh) 数据处理的方法、装置、设备及存储介质
US8447857B2 (en) Transforming HTTP requests into web services trust messages for security processing
US8515732B2 (en) Opening a message catalog file for a language that is not installed
US10019185B2 (en) System and method for copying directory structures
CN111694677A (zh) 消息队列的管理方法、装置、终端和计算机可读存储介质
CN110086836B (zh) 获取元数据的方法和装置
CN113268955A (zh) 报文转换的方法和装置
US20130066943A1 (en) Application-Aware Quality Of Service In Network Applications
CN112883088B (zh) 一种数据处理方法、装置、设备及存储介质
WO2019134277A1 (zh) 数据过滤方法、装置、服务器及可读存储介质
WO2022171190A1 (zh) 固定执行顺序的交易方法和装置
CN104079493A (zh) 基于下载资源名的流量识别方法和设备、管控方法和设备
CN113032477A (zh) 基于gtid的长距离数据同步方法、装置及计算设备
WO2021147375A1 (zh) 数据管理方法、装置、设备、计算机可读存储介质及系统
WO2023071857A1 (zh) 回放方法、录制方法以及相关设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18898232

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18898232

Country of ref document: EP

Kind code of ref document: A1