Network security data interception method and system
By configuring global interceptors in the business system to convert and operate request data, the problem of high data leakage risk in the HTTP communication protocol is solved, safe interception and accurate processing of data are achieved, and network security and user experience are improved.
Patent Information
- Application Number
- CN202410412847.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-08
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-04-08
AI Technical Summary
In the existing technology, when the business system transmits data through the HTTP communication protocol, the full amount of data is returned, resulting in a high risk of data leakage, low network security, and poor test accuracy.
Use the Spring Cloud microservice gateway to configure the global interceptor, configure the rules for the request resource address of the business system, convert and operate the original message string, convert the json data object into new text data, and package it into buffer byte settings into the response data stream to implement data interception processing.
It achieves unified interception and processing of all requests, improves data security and accuracy, reduces the risk of data leakage, and improves the overall security and user experience of the system.
Smart Images

Figure CN118337428B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network information transmission, and in particular to a network security data interception method and system. Background Art
[0002] Business system refers to a software system used to support and manage specific business activities. It is usually composed of a series of interrelated applications and databases, and is used to process and manage various business processes and operations of an enterprise or organization. In the current business system, information transmission is achieved through communication between the server and the client. Information transmission mainly uses the HTTP communication protocol. The HTTP communication protocol is a front-end and back-end separation architecture. The back-end (server side) provides a rest api interface and responds to the front-end in json format. Especially for the business systems that were used earlier, a data interface often returns the full amount of data. Whether the data is displayed is based on the front-end UI rendering to implement data permissions, and the front-end UI components are controlled by the front-end code. The data interface will present the complete information. If the returned response data is parsed and viewed, it will definitely cause corresponding data leakage, and the network security risk is very high.
[0003] Prior art 1, application number: CN202311248713.5 discloses a method for realizing intercommunication between sass platform and business system database based on local client, wherein the method for intercommunication between sass platform and business system data includes: the user installs the client locally, configures the data source link address, writes the sql script for operating the database, starts the client, the client establishes a websocket connection with the sass platform, the sass platform calls the client http interface to obtain the business system data and saves it to the sass platform database; after the sass platform generates the invoice data, it notifies the client to obtain the return data through the websocket connection established with the client, and the client calls the http interface of the sass platform through the notification message to obtain the invoice information and return it to the business system; wherein the data source supports three databases: Mysql, Oracle and sqlServer. Although the cross-platform operation of multiple operating systems now reduces the development cost; and calling the locally installed client reduces the maintenance cost of the software and improves the user experience; but the risk of data leakage is relatively high, resulting in a low network security coefficient.
[0004] Prior art 2, application number: CN202310582369.7 discloses a testing method, device, storage medium and electronic device to automatically generate HTTP test scripts according to the code, and perform business testing according to the generated HTTP test scripts. The testing method includes: obtaining the branch code to be tested in the business system; determining the interface information of the HTTP interface corresponding to the branch code, the interface information including the basic information, input parameter information, output parameter information and annotation configuration information of the HTTP interface; generating a test script based on the interface information of the HTTP interface; and performing business testing on the business system according to the test script. Although the HTTP test script can be automatically generated according to the source code of the business system, and the business test is performed according to the generated HTTP test script, the generation efficiency of the HTTP test script and the accuracy of the test script are improved, thereby improving the test efficiency and accuracy of the business system; however, the structure of the HTTP communication protocol needs to return the full amount of data, resulting in a large amount of business test data, which makes the test accuracy poor.
[0005] Prior art three, application number: CN202310539582.X discloses a method for calling a blocking client library in a JVM non-blocking system, which is applied to a JVM virtual machine configured with a Kotlin language library, and generates an Sdk non-blocking encapsulation based on a third-party component in a non-blocking business system. The Sdk non-blocking encapsulation based on the third-party component is provided with a non-blocking API interface of the corresponding Sdk and a general request calling component; that is, the blocking API in the third-party Sdk is bypassed by a disguised Http client, so as to be called by the non-blocking business system. The present invention uses a specific Sdk provided by a third-party open source component, such as apachehttpclient and okhttp encapsulation based on blocking, to call the Http server of the corresponding component, thereby realizing a method for calling a blocking Http client library in a JVM non-blocking system. Although it is ensured that the performance of the non-blocking system will not be seriously degraded during the call to the Http server; however, since HTTP is transmitted in plain text, attackers on the network can use packet capture tools to intercept and view network request and response data; if the data is not properly encrypted or securely protected, attackers can easily obtain sensitive information.
[0006] Currently, the data interfaces in the prior art one, prior art two and prior art three will present complete information. If the returned response data is parsed and viewed, corresponding data leakage will certainly occur, which will lead to a very high network security risk. Therefore, the present invention provides a network security data interception method and system. No changes need to be made to the old system. Only the network security data interception system needs to be used. After the data interface is configured, the system request response is allowed to pass through the network security data interception system first, and then necessary safe response information can be obtained, thereby improving the overall security of the system. Summary of the invention
[0007] In order to solve the above technical problems, the present invention provides a network security data interception method, comprising the following steps:
[0008] Use the Spring Cloud Microservice Gateway to configure a global interceptor so that all requests pass through the global interceptor;
[0009] Sort out the request resource addresses of the business system, use the request resource addresses as interception targets, and configure multiple rules for the request resource addresses when configuring the business system;
[0010] Operate the json data object node converted from the original message string, convert the json data object into new text data, and then convert the new text data into a byte array, and set the byte array into the response data stream by packaging it as a buffer byte; the data obtained by the user is the data after interception processing.
[0011] Optionally, the process of passing all requests through a global interceptor consists of the following steps:
[0012] Find a filter method defined in the interceptor method Spring Cloud Gateway; call its get response method through the server Web exchange to obtain the server HTTP response object and get the response object of the request;
[0013] Instantiate the obtained server HTTP response object into a server HTTP response decorator, and rewrite the server HTTP response decorator with the write method;
[0014] Convert the data format of the response body, convert the XML format to the JSON format, or convert the plain text to the HTML format.
[0015] Optionally, the process of overriding the server HTTP response decorator with the write method includes the following steps:
[0016] Convert the method body into a Flux object, that is, the gateway adopts responsive development, obtains the buffer stream of flux, and converts the buffer stream into a buffer data object;
[0017] Convert the buffered data object to a byte array, read the byte array and convert it to a raw message string, and convert the raw message string to a JSON data object.
[0018] Optionally, the process of converting the data format of the response body includes the following steps:
[0019] The target data format is sent to the response body by using the callback function, the format of the original data is identified, and the corresponding conversion program is triggered according to the format. The conversion program includes a first conversion program and a second conversion program. The first conversion program converts the XML format into the JSON format, and the second conversion program converts the ordinary text into the HTML format.
[0020] When the original data format is XML, use the parsing library to parse the XML data in the response body, use Jackson to construct it according to the XML structure, and map it to the JSON object; output the data in JSON format, convert the constructed JSON object into a string, and return it as the response body; when the original data format is ordinary text, create an HTML frame, insert the text content in the response body into the HTML frame, convert the constructed HTML content into a string, and return it as the response body;
[0021] The response body outputs data having the target data format.
[0022] Optionally, the process of configuring multiple rules includes the following steps:
[0023] Configure rules based on roles or other conditions, and after configuration is complete, the user sends a request to the server;
[0024] The server network exchange calls its get request method to obtain the server HTTP request object;
[0025] The server HTTP request object calls to obtain the uniform resource identifier to obtain the uniform resource identifier URI object. The URI object calls to obtain the path to obtain the request resource address when the current request accesses the server. At this time, the request resource address requested by the user is matched with the configured request resource address. If the match is successful, the corresponding rule is executed.
[0026] Optionally, the configuration rule definition process includes the following steps:
[0027] In the configuration rules, part of the configuration rules are assigned to a management processor coupled to a predefined group of joint user devices of the user device partition, the management processor is assigned a role, administrator or paid user; the auxiliary management processor is directed to configure the manageability module of the user device as a support role, and is coupled to the management processor;
[0028] After determining that the joint user equipment has been configured according to the configuration rule, start initializing the joint user equipment so that the joint user equipment works together and acts as a single user equipment;
[0029] According to the configuration rules, the federated user devices are reordered to match the user device partitions, or according to the configuration rules, the federated user devices are divided into multiple parts; after the rules are configured according to the role or other conditions, when the configuration is completed, the user sends a request to the server.
[0030] Optional, role refers to administrator or paid user, and other conditions refer to the user's permission level, access device, and access time.
[0031] Optionally, the process of operating the JSON data object node converted from the original message string includes the following steps:
[0032] Call the key collection method through the json object to get all the json key nodes;
[0033] Traverse each json node and get its value from the json data for each traversed node;
[0034] After all the rule matching processes are completed, a new JSON data object is obtained after the JSON data object nodes are removed. The JSON data object is converted into new text data, and then the new text data is converted into a byte array. The byte array is packaged as a buffer byte and set into the response data stream. The data obtained by the user is the data after interception processing.
[0035] Optionally, if the value is in array form, its value is traversed by json node. If the json node matches the nodes in the configuration rule in sequence, the delete key-value pair is called to remove the json node for the matched json data object.
[0036] The present invention provides a network security data interception system, comprising:
[0037] The global interceptor configuration module is responsible for configuring the global interceptor using the spring cloud microservice gateway spring cloud gateway so that all requests pass through the global interceptor;
[0038] The rule configuration module is responsible for sorting out the request resource address URL of the business system and taking the request resource address URL as the target of interception. When configuring the business system, multiple rules are configured for the request resource address URL.
[0039] The data interception processing module is responsible for operating the json data object node converted from the original message string, converting the json data object into new text data, and then converting the new text data into a byte array, and setting the byte array into a buffer byte by packaging it into the response data stream; the data obtained by the user is the data after interception processing.
[0040] The present invention first uses the spring cloud microservice gateway spring cloud gateway to configure a global interceptor, so that all requests pass through the global interceptor; obtain the configured global interceptor; secondly, sort out the request resource address URL of the business system, use the request resource address URL as the target of interception, and configure multiple rules for the request resource address URL when configuring the business system; finally, operate the json data object node converted from the original message string, convert the json data object into new text data, and then convert the new text data into a byte array, and set the byte array into a buffer byte by packaging it into a response data stream; the data obtained by the user is the data after interception processing (for the specific principle, refer to the attached Figure 2 ). The above solution intercepts and processes requests by configuring global interceptors in the business system and Spring Cloud Gateway, realizes the conversion and operation of the original message, and thus achieves some specific purposes. The significance includes: unified interception and processing: by configuring the global interceptor, unified interception and processing of all requests can be realized, which can avoid the duplication of interception and processing in each business system, and improve the reusability and maintainability of the code. Flexibility in configuring the request resource address URL: by taking the request resource address URL as the target of interception and configuring multiple rules for the URL, different requests can be flexibly customized for interception and processing, which can meet the specific interception logic under different business requirements. Message conversion and operation: by converting the original message string into a json data object, and performing operations and conversions, the message content can be flexibly processed. According to business needs, the message can be added, modified, deleted and filtered to meet specific business logic requirements. Response data processing: by converting the converted new text data into a byte array and setting it in the response data stream, it can be ensured that the data obtained by the user is the data after interception and processing, which can ensure the consistency and accuracy of the data and improve the user experience.
[0041] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0042] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0044] Figure 1 This is a flow chart of the network security data interception method in Embodiment 1 of the present invention;
[0045] Figure 2 This is a schematic diagram of the network security data interception method in Embodiment 1 of the present invention;
[0046] Figure 3 This is a process diagram of allowing all requests to pass through the global interceptor in Example 2 of the present invention;
[0047] Figure 4 This is a process diagram of rewriting the server HTTP response decorator using the writeWith method in Example 3 of the present invention;
[0048] Figure 5 This is a process diagram for converting the data format of a response body in Embodiment 4 of the present invention;
[0049] Figure 6 A process diagram for configuring multiple rules in Embodiment 5 of the present invention;
[0050] Figure 7 This is a diagram of the definition process of configuration rules in Embodiment 6 of the present invention;
[0051] Figure 8 This is a process diagram of operating a json data object node converted from an original message string in embodiment 7 of the present invention;
[0052] Fig. 9 This is a block diagram of a network security data interception system in Embodiment 8 of the present invention;
[0053] Fig.10 This is a block diagram of the global interceptor configuration module in Example 9 of the present invention;
[0054] Fig.11 This is a block diagram of a rule configuration module in Embodiment 10 of the present invention;
[0055] Fig.12 This is a block diagram of the data interception processing module in Example 11 of the present invention. DETAILED DESCRIPTION
[0056] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0057] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the embodiments of the present application. The singular forms of "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0058] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims. In the description of the present application, it should be understood that the terms "first", "second", "third", etc. are only used to distinguish similar objects, and do not have to be used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances.
[0059] Example 1: Figure 1 As shown, an embodiment of the present invention provides a network security data interception method, comprising the following steps:
[0060] S100: Use the Spring Cloud Microservice Gateway Spring Cloud Gateway to configure a global interceptor so that all requests pass through the global interceptor;
[0061] S200: sorting out the request resource address URL of the business system, taking the request resource address URL as the target of interception, and configuring multiple rules for the request resource address URL when configuring the business system;
[0062] S300: operate the json data object node converted from the original message string, convert the json data object into new text data, and then convert the new text data into a byte array, and set the byte array into a buffer byte by packaging it into a response data stream; the data obtained by the user is the data after interception processing.
[0063] The working principle and beneficial effects of the above technical solution are as follows: In this embodiment, the global interceptor is configured by using the spring cloud microservice gateway spring cloud gateway to allow all requests to pass through the global interceptor; the configured global interceptor is obtained; secondly, the request resource address URL of the business system is sorted out, and the request resource address URL is used as the target of interception. Multiple rules are configured for the request resource address URL when the business system is configured; finally, the json data object node converted from the original message string is operated to convert the json data object into new text data, and then the new text data is converted into a byte array, and the byte array is packaged as a buffer byte and set into the response data stream; the data obtained by the user is the data after interception processing (for specific principles, refer to the attached Figure 2 ). The above solution intercepts and processes requests by configuring global interceptors in the business system and Spring CloudGateway, realizes the conversion and operation of the original message, and thus achieves some specific purposes. The significance includes: unified interception and processing: by configuring the global interceptor, unified interception and processing of all requests can be realized, which can avoid the duplication of interception and processing in each business system, and improve the reusability and maintainability of the code. Flexibility in configuring the request resource address URL: by taking the request resource address URL as the target of interception and configuring multiple rules for the URL, different requests can be flexibly customized for interception and processing, which can meet the specific interception logic under different business requirements. Message conversion and operation: by converting the original message string into a json data object, and performing operations and conversions, the message content can be flexibly processed. According to business needs, the message can be added, modified, deleted and filtered to meet specific business logic requirements. Response data processing: by converting the converted new text data into a byte array and setting it in the response data stream, it can be ensured that the data obtained by the user is the data after interception and processing, which can ensure the consistency and accuracy of the data and improve the user experience.
[0064] In summary, this embodiment realizes unified interception processing, flexible request interception configuration, message conversion and operation, and response data processing, thereby meeting specific business needs and improving the scalability, flexibility and user experience of the system; in the current web-based information system, the main data transmission method is HTTP carrying JSON format text data for transmission; limited by the concept of interface reuse, when people of different identities obtain the same interface resource data, the return data format is always the same, and at most the data field-level permissions are implemented by shielding controls in the UI display layer to not display the data, thereby improving security; but in fact, when the web interface information is returned, it carries the full amount of data, and the complete information can be easily parsed using professional packet capture tools or browser plug-ins, and the security of data with different permissions is not guaranteed at all; and the use of this json node pruning and removal method can easily modify the web interface return data format, and shield key information according to permissions to ensure that the information does not leave the server at all and is not transmitted, thereby greatly improving the security of system data.
[0065] Example 2: Figure 3 As shown, based on Example 1, the process of allowing all requests to pass through the global interceptor provided by the embodiment of the present invention includes the following steps:
[0066] S101: Find a filter method defined in the interceptor method Spring Cloud Gateway (publicMono <void>filter(ServerWebExchange exchange,GatewayFilterChain chain)); Call the getResponse() method of the server Web exchange ServerWebExchange to obtain the server HTTP response ServerHttpResponse object and get the response object of the request;
[0067] S102: Instantiate the obtained server HTTP response ServerHttpResponse object into a server HTTP response decorator ServerHttpResponseDecorator, and rewrite the server HTTP response decorator using the writeWith method;
[0068] S103: Convert the data format of the response body, convert the XML format into the JSON format, or convert the ordinary text into the HTML format.
[0069] The working principle and beneficial effects of the above technical solution are as follows: This embodiment first finds a filter method defined in the interceptor method SpringCloud Gateway (public Mono <void>filter(ServerWebExchange exchange,GatewayFilterChain chain)); call its getResponse() method through the server Web exchange ServerWebExchange to get the server HTTP response ServerHttpResponse object and get the response object of the request; then instantiate the obtained server HTTP response ServerHttpResponse object into the server HTTP response decorator ServerHttpResponseDecorator, and rewrite it with the writeWith method; finally, convert the data format of the response body, convert the xml format to the json format, or convert the ordinary text to the html format. The above scheme uses filters in Spring Cloud Gateway to modify the HTTP response of the server to realize the processing and format conversion of the response data. Specifically, the filter's `filter` method first obtains the server's HTTP response `ServerHttpResponse` object through `ServerWebExchange`, which is the original data of the response; then, by instantiating `ServerHttpResponseDecorator`, `ServerHttpResponse` is decorated to give it additional functions, such as rewriting the response body with the `writeWith` method. In this process, the most critical part may be the format conversion of the response body data. For example, if the original data is in XML format, but the client expects to receive it in JSON format, you can convert the XML data to JSON data in this filter. Similarly, if the original data is plain text, but the client expects it to be in HTML format, you can also convert it here.
[0070] In summary, this example shows how to use filters in Spring Cloud Gateway to process and transform the server's HTTP response so that it can meet the needs of different clients. This is essential for building a flexible API gateway that can adapt to different needs.
[0071] Example 3: Figure 4 As shown, based on Example 2, the process of rewriting the server HTTP response decorator using the writeWith method provided by the embodiment of the present invention includes the following steps:
[0072] S2021: Convert the method body into a Flux object. That is, the gateway adopts responsive development, obtains the buffer stream of flux, and converts the buffer stream into a buffer data object.
[0073] S2022: Convert the buffered data object into a byte array, read the byte array and convert it into an original message string, and convert the original message string into a JSON data object.
[0074] The working principle and beneficial effects of the above technical solution are as follows: In this embodiment, the method body is first converted into a Flux object, that is, the gateway adopts responsive development, obtains the buffer stream of flux, and converts the buffer stream into a buffer data object; secondly, the buffer data object is converted into a byte array, the byte array is read and converted into a raw message string, and the raw message string is converted into a json data object. The above scheme is based on the responsive programming model, and converts the method body (body) into a Flux object, which is a responsive stream for processing large amounts of data; this conversion enables responsive processing of data streams, such as filtering, conversion, and aggregation, to meet business needs. Specifically, the method body is first converted, the buffer stream of Flux (that is, the data stream) is obtained, and converted into a buffer data object. The advantage of this is that a large amount of data can be processed asynchronously and streamed, improving processing efficiency. Then, the buffer data object is converted into a byte array, so that the data can be read and processed specifically. Next, the byte array is read and converted into a raw message string, which enables the original content of the data to be viewed and understood. Finally, the raw message string is converted into a JSON data object. JSON is a data format that has good readability and usability and is widely used for data exchange. The advantage of this is that the data can be standardized for easy processing and transmission.
[0075] In summary, this embodiment converts the method body into a responsive stream to perform asynchronous and streaming data processing, and then formats the data into a JSON object through a series of conversions, so that data processing is more efficient, data transmission and use are more convenient, and the needs of responsive programming are met.
[0076] Example 4: Figure 5 As shown, based on Example 3, the process of converting the data format of the response body provided in this embodiment of the present invention includes the following steps:
[0077] S2031: using the callback function to send the target data format to the response body, identifying the format of the original data, and triggering a corresponding conversion program according to the format, the conversion program includes a first conversion program and a second conversion program, the first conversion program converts the xml format into the json format, and the second conversion program converts the ordinary text into the html format;
[0078] S2032: When the original data format is XML, use the parsing library to parse the XML data in the response body, use Jackson to construct according to the XML structure, and map it to the JSON object; output JSON format data, convert the constructed JSON object into a string, and return it as the response body; when the original data format is ordinary text, create an HTML frame, insert the text content in the response body into the HTML frame, convert the constructed HTML content into a string, and return it as the response body;
[0079] S2033: The response body outputs data in the target data format.
[0080] The working principle and beneficial effects of the above technical solution are as follows: the present embodiment first uses a callback function to send the target data format to the response body, identifies the format of the original data, triggers the corresponding conversion program according to the format, and the conversion program includes a first conversion program and a second conversion program. The first conversion program converts the XML format to the JSON format, and the second conversion program converts the ordinary text to the HTML format; secondly, when the original data format is XML, the XML data in the response body is parsed using the parsing library, and Jackson is used to construct it according to the structure of XML and mapped to the JSON object; outputs the JSON format data, converts the constructed JSON object into a string, and returns it as the response body; when the original data format is ordinary text, creates an HTML frame, inserts the text content in the response body into the HTML frame, converts the constructed HTML content into a string, and returns it as the response body; finally, the response body outputs data with the target data format. The above scheme provides a flexible and dynamic way to process and convert data in different formats. Specifically, by using callback functions and specialized conversion programs for different data formats, the processing strategy can be dynamically adjusted according to the format of the original data, so that it can adapt to various different data formats and conversion requirements. The conversion programs are modular and independent. More conversion programs can be added as needed to handle more types of data formats, making it very scalable and easy to adapt to future changes in demand. By breaking down complex data processing and conversion logic into multiple independent conversion programs, the readability and maintainability of the code are improved. Each conversion program has its specific responsibilities, which makes troubleshooting and feature updates easier. By converting data into the format expected by the user, the user experience can be improved. For example, converting XML data to JSON can make the data easier to process and display in a Web environment, while converting normal text to HTML can provide a richer and more user-friendly interface.
[0081] In summary, this embodiment is very useful for processing and converting various data formats, especially in the case of dynamically adapting to different data sources and user requirements.
[0082] Example 5: Figure 6 As shown, based on Example 1, the process of configuring multiple rules provided in this embodiment of the present invention includes the following steps:
[0083] S201: configuring rules according to roles or according to other conditions, after which the user sends a request to the server; the role refers to an administrator or a paying user, etc., and the other conditions refer to the user's authority level, access device, access time, etc.;
[0084] S202: the server network exchange ServerWebExchange calls its getRequest() method to obtain the server HTTP request ServerHttpRequest object;
[0085] S203: The server HTTP request ServerHttpRequest object calls getURI() to obtain a URI object. The URI object calls getPath() to obtain the request resource address URL of the current request to access the server. At this time, the request resource address URL requested by the user is matched with the configured request resource address URL. If the match is successful, the corresponding rule is executed.
[0086] The working principle and beneficial effects of the above technical solution are as follows: In this embodiment, first, according to the role configuration rules or according to other conditions, the configuration is completed, and the user sends a request to the server; secondly, the server network exchange ServerWebExchange calls its getRequest() method to obtain the server HTTP request ServerHttpRequest object. The server network exchange ServerWebExchange and the server HTTP request ServerHttpRequest are Spring The two core classes in the WebFlux framework are used to handle non-blocking requests and responses based on ReactiveStreams; the server network exchange ServerWebExchange encapsulates all information of HTTP requests and responses, including request headers, request bodies, response headers, response bodies, etc. It plays a central role in the entire process, responsible for transmitting and exchanging request and response data; the server HTTP request ServerHttpRequest encapsulates detailed information of the HTTP request, including request method, request URI, request header, etc.; in this process, its main function is to provide detailed information of the request for use by other parts (such as route matching, rule execution, etc.); finally, the server HTTP request ServerHttpRequest object calls getURI() to obtain the uniform resource identifier URI object, and the URI object calls getPath() to obtain the request resource address URL when the current request accesses the server. At this time, the request resource address URL requested by the user is matched with the configured request resource address URL. If the match is successful, the corresponding rule is executed. The above solution manages and controls access to server resources by configuring rules. It provides a flexible access control mechanism that can flexibly configure access rules according to user roles or other conditions, thereby better protecting server resources and preventing unauthorized access. At the same time, through URL matching, it can ensure that only requests that meet specific conditions can access specific resources, thereby improving the security of the system.
[0087] Example 6: Figure 7 As shown, based on Example 5, the definition process of the configuration rule provided in the embodiment of the present invention includes the following steps:
[0088] S2011: In the configuration rules, part of the configuration rules are assigned to management processors coupled to a predefined group of joint user devices partitioned with the user device, and the management processors are assigned roles, such as administrator or paying user; the auxiliary management processor is directed to configure the manageability module of the user device as a supporting role and coupled to the management processor;
[0089] S2012: after determining that the joint user equipment has been configured according to the configuration rule, start initializing the joint user equipment so that the joint user equipment works together and acts as a single user equipment;
[0090] S2013: According to the configuration rules, the federated user devices are reordered to match the user device partitions, or according to the configuration rules, the federated user devices are divided into multiple parts; after the rules are configured according to the role or other conditions, when the configuration is completed, the user sends a request to the server.
[0091] The working principle and beneficial effects of the above technical solution are as follows: firstly, in the configuration rules of this embodiment, part of the configuration rules are assigned to the management processor coupled with a predefined group of joint user devices of the user device partition, and the management processor is assigned a role, such as an administrator or a paying user; the auxiliary management processor is instructed to configure the manageability module of the user device as a supporting role and coupled with the management processor; secondly, after determining that the joint user devices have been configured according to the configuration rules, these joint user devices are initialized so that the joint user devices work together and act as a single user device; finally, according to the configuration rules, the joint user devices are reordered to match the user device partition, or according to the configuration rules, the joint user devices are divided into multiple parts; after the rules are configured according to the roles or other conditions, when the configuration is completed, the user sends a request to the server. The above scheme provides a flexible and efficient method for managing and configuring user devices; first, configuration rules are assigned to management processors partitioned with user devices, and management processors are assigned roles, such as administrators or paying users, which enables the management processors to perform specific operations according to their roles; in addition, auxiliary management processors are guided to configure manageability modules of user devices to support roles, which increases the flexibility and configurability of the system, enabling the system to be configured according to different role requirements; after determining that the joint user devices have been configured according to the configuration rules, the system begins to initialize these devices so that they can work together and act as a single user device; this step can improve the operating efficiency of the system because the joint user devices can be operated as a whole, rather than operating each device separately. Finally, the system reorders or divides the joint user devices according to the configuration rules, so that the system can reorganize and allocate the devices as needed.
[0092] In summary, this embodiment provides a flexible and efficient way to manage and configure user devices, so that the devices can be configured according to roles and other conditions, and the devices can be operated and managed as a whole, thereby improving the operating efficiency of the system.
[0093] Example 7: Figure 8 As shown, based on Example 1, the process of operating the JSON data object node converted from the original message string provided by the embodiment of the present invention includes the following steps:
[0094] S301: Call the keySet() method of obtaining the key set through the json object to obtain all json key nodes;
[0095] S302: traverse each json node, and obtain the value of each traversed node from the json data. If the value is in array form, traverse the value according to the json node. If the json node matches the nodes in the configuration rule in sequence, call the remove key-value pair remove(key) on the matched json data object to remove the json node.
[0096] S303: After all the rule matching processes are completed, a new JSON data object is obtained after the JSON data object nodes are removed, the JSON data object is converted into new text data, and then the new text data is converted into a byte array. The byte array is packaged as a buffer byte and set into the response data stream. The data obtained by the user is the data after the interception process.
[0097] The working principle and beneficial effects of the above technical solution are as follows: the embodiment first calls the keySet() method of obtaining the key set through the json object to obtain all the json key nodes; secondly, traverse each json node, obtain its value from the json data for each traversed node, and traverse its value according to the json node if the value is in array form, and if the json node matches the node in the configuration rule in turn, the json data object matched by it calls the delete key value pair remove(key) to remove the json node; finally, after all the rule matching processes are completed, a new json data object after the json data object node is removed is obtained, the json data object is converted into new text data, and then the new text data is converted into a byte array, and the byte array is packaged as a buffer byte and set into the response data stream, and the data obtained by the user is the data after the interception process. The above scheme performs customized processing on the json data, removes unnecessary data for specific needs, so as to reduce the complexity of data transmission and improve efficiency. Specifically, by screening the json data and removing unnecessary data, a more streamlined data set can be obtained, which can save bandwidth and storage space during data transmission and storage. Dynamically process json data according to configuration rules so that it can adapt to various data processing requirements. Users only get the data they really need, avoiding unnecessary data confusion, allowing users to focus more on the data they care about, and improving user experience. In some cases, json data may contain some sensitive information. Through this embodiment, this sensitive information can be removed during data transmission to protect user privacy. Reducing the transmission and processing of unnecessary data can reduce the load on the server and client and optimize system performance.
[0098] In summary, this embodiment has great application value in processing a large amount of json data, especially in scenarios where data needs to be screened and eliminated. By analyzing the characteristics of json object data, this embodiment can learn that json objects are mainly key-value types, and value types are divided into three types: a specific single value, which continues to be composed of multiple key-value types and an array composed of a group of key-values. According to the results of the analyzed json object, the user can only see the data that matches the user through the configuration of rules, and the remaining data that does not match the user will not be transmitted to the current user; thus, different users get different data, which improves the security of the system and prevents attacks such as network packet capture from the root.
[0099] Example 8: Fig. 9 As shown, based on Embodiment 1 to Embodiment 7, the network security data interception system provided by the embodiment of the present invention includes:
[0100] The global interceptor configuration module is responsible for configuring the global interceptor using the spring cloud microservice gateway spring cloud gateway so that all requests pass through the global interceptor;
[0101] The rule configuration module is responsible for sorting out the request resource address URL of the business system and taking the request resource address URL as the target of interception. When configuring the business system, multiple rules are configured for the request resource address URL.
[0102] The data interception processing module is responsible for operating the json data object node converted from the original message string, converting the json data object into new text data, and then converting the new text data into a byte array, and setting the byte array into a buffer byte by packaging it into the response data stream; the data obtained by the user is the data after interception processing.
[0103] The working principle and beneficial effects of the above technical solution are as follows: the global interceptor configuration module of this embodiment uses the spring cloud microservice gateway spring cloud gateway to configure a global interceptor, so that all requests pass through the global interceptor; the rule configuration module combs the request resource address URL of the business system, takes the request resource address URL as the target of interception, and configures multiple rules for the request resource address URL when configuring the business system; the data interception processing module operates the json data object node converted from the original message string, converts the json data object into new text data, and then converts the new text data into a byte array, and sets the byte array into a buffer byte by packaging it into the response data stream; the data obtained by the user is the data after interception processing. . The above solution configures a global interceptor in the business system and Spring Cloud Gateway to intercept and process the request, realize the conversion and operation of the original message, and thus achieve some specific purposes. The significance includes: unified interception processing: by configuring a global interceptor, unified interception and processing of all requests can be achieved, which can avoid the duplication of interception processing in each business system, and improve the reusability and maintainability of the code. Flexibility in configuring the request resource address URL: By using the request resource address URL as the target for interception and configuring multiple rules for the URL, you can flexibly customize the interception processing for different requests to meet the specific interception logic under different business needs. Message conversion and operation: By converting the original message string into a json data object and performing operations and conversions, you can achieve flexible processing of the message content. You can add, modify, delete, and filter the message according to business needs to meet specific business logic requirements. Processing of response data: By converting the converted new text data into a byte array and setting it in the response data stream, you can ensure that the data obtained by the user is intercepted and processed, which can ensure the consistency and accuracy of the data and improve the user experience.
[0104] In summary, this embodiment realizes unified interception processing, flexible request interception configuration, message conversion and operation, and response data processing, thereby meeting specific business needs and improving the scalability, flexibility and user experience of the system; in the current web-based information system, the main data transmission method is HTTP carrying JSON format text data for transmission; limited by the concept of interface reuse, when people of different identities obtain the same interface resource data, the return data format is always the same, and at most the data field-level permissions are implemented by shielding controls in the UI display layer to not display the data, thereby improving security; but in fact, when the web interface information is returned, it carries the full amount of data, and the complete information can be easily parsed using professional packet capture tools or browser plug-ins, and the security of data with different permissions is not guaranteed at all; and the use of this json node pruning and removal method can easily modify the web interface return data format, and shield key information according to permissions to ensure that the information does not leave the server at all and is not transmitted, thereby greatly improving the security of system data.
[0105] Example 9: Fig.10 As shown, based on Example 8, the global interceptor configuration module provided by the embodiment of the present invention includes:
[0106] The response object acquisition submodule is responsible for finding a filter method defined in the interceptor method Spring Cloud Gateway (public Mono <void>filter(ServerWebExchange exchange,GatewayFilterChain chain)); Call the getResponse() method of the server Web exchange ServerWebExchange to obtain the server HTTP response ServerHttpResponse object and get the response object of the request;
[0107] The response decorator rewriting submodule is responsible for instantiating the obtained server HTTP response ServerHttpResponse object into the server HTTP response decorator ServerHttpResponseDecorator, and rewriting the server HTTP response decorator with the writeWith method;
[0108] The data format conversion submodule is responsible for converting the data format of the response body, converting the XML format to the JSON format, or converting ordinary text to the HTML format.
[0109] The working principle and beneficial effects of the above technical solution are as follows: the response object acquisition submodule of this embodiment finds a filter method defined in the interceptor method Spring Cloud Gateway, (public Mono <void>filter(ServerWebExchange exchange,GatewayFilterChain chain)); get the server HTTP response ServerHttpResponse object by calling its getResponse() method through the server Web exchange ServerWebExchange, and get the response object of the request; the response decorator rewriting submodule instantiates the obtained server HTTP response ServerHttpResponse object into the server HTTP response decorator ServerHttpResponseDecorator, and rewrites the server HTTP response decorator with the writeWith method; the data format conversion submodule converts the data format of the response body, converting the xml format to the json format, or converting the ordinary text to the html format. The above scheme uses filters in Spring Cloud Gateway to modify the HTTP response of the server to realize the processing and format conversion of the response data. Specifically, the filter's `filter` method first obtains the server's HTTP response `ServerHttpResponse` object through `ServerWebExchange`, which is the original data of the response; then, by instantiating `ServerHttpResponseDecorator`, `ServerHttpResponse` is decorated to give it additional functions, such as rewriting the response body with the `writeWith` method. In this process, the most critical part may be the format conversion of the response body data. For example, if the original data is in XML format, but the client expects to receive it in JSON format, you can convert the XML data to JSON data in this filter. Similarly, if the original data is plain text, but the client expects it to be in HTML format, you can also convert it here.
[0110] In summary, this example shows how to use filters in Spring Cloud Gateway to process and transform the server's HTTP response so that it can meet the needs of different clients. This is essential for building a flexible API gateway that can adapt to different needs.
[0111] Example 10: Fig.11 As shown, based on Example 8, the rule configuration module provided in this embodiment of the present invention includes:
[0112] The rule object definition submodule is responsible for configuring rules based on roles or other conditions. After the configuration is completed, the user sends a request to the server; the role refers to administrator or paying user, etc., and other conditions refer to the user's permission level, access device, and access time, etc.;
[0113] The request object acquisition submodule is responsible for the server network exchange ServerWebExchange calling its getRequest() method to obtain the server HTTP request ServerHttpRequest object;
[0114] The identification object acquisition submodule is responsible for the server HTTP request ServerHttpRequest object calling getURI() to obtain the uniform resource identifier URI object. The URI object calls getPath() to obtain the request resource address URL when the current request accesses the server. At this time, the request resource address URL requested by the user is matched with the configured request resource address URL. If the match is successful, the corresponding rule is executed.
[0115] The working principle and beneficial effects of the above technical solution are as follows: the rule object definition submodule of this embodiment configures the rules according to the role or according to other conditions. After the configuration is completed, the user sends a request to the server; the role refers to the administrator or the paying user, etc., and the other conditions refer to the user's authority level, access device and access time, etc.; the request object acquisition submodule server network exchange ServerWebExchange calls its getRequest() method to obtain the server HTTP request ServerHttpRequest object; the identification object acquisition submodule server HTTP request ServerHttpRequest object calls the getURI() method to obtain the uniform resource identifier URI object, and the URI object calls the getPath() method to obtain the request resource address URL when the current request accesses the server. At this time, the request resource address URL requested by the user is matched with the configured request resource address URL. If the match is successful, the corresponding rule is executed. . The above scheme manages and controls access to server resources by configuring rules; provides a flexible access control mechanism, which can flexibly configure access rules according to the user's role or other conditions, so as to better protect server resources and prevent unauthorized access; at the same time, through URL matching, it can ensure that only requests that meet specific conditions can access specific resources, thereby improving the security of the system.
[0116] Example 11: Fig.12 As shown, based on Example 8, the data interception processing module provided by the embodiment of the present invention includes:
[0117] The node acquisition submodule is responsible for calling the keySet() method of the json object to obtain the key set and obtain all json key nodes;
[0118] The node matching submodule is responsible for traversing each json node, obtaining the value of each traversed node from the json data, and traversing its value according to the json node if the value is in array form. If the json node matches the nodes in the configuration rule in sequence, the remove key-value pair remove(key) is called to remove the json node from the matched json data object;
[0119] The data conversion submodule is responsible for obtaining a new JSON data object after removing the JSON data object nodes after all rule matching processes are completed, converting the JSON data object into new text data, and then converting the new text data into a byte array. By packaging the byte array as a buffer byte and setting it into the response data stream, the data obtained by the user is the data after interception processing.
[0120] The working principle and beneficial effects of the above technical scheme are as follows: the node acquisition submodule of this embodiment calls the keySet() method of acquiring the key set through the json object to obtain all the json key nodes; the node matching submodule traverses each json node, obtains its value from the json data for each traversed node, and traverses its value according to the json node if the value is in the form of an array, and if the json node matches the node in the configuration rule in turn, the json data object matched on it is called to remove the json node by deleting the key value pair remove(key); the data conversion submodule waits for all rule matching processes to obtain a new json data object after the json data object node is removed, converts the json data object into new text data, and then converts the new text data into a byte array, and by packaging the byte array as a buffer byte and setting it in the response data stream, the data obtained by the user is the data after the interception process. The above scheme performs customized processing on the json data, removes unnecessary data for specific needs, so as to reduce the complexity of data transmission and improve efficiency. Specifically, by screening the json data and removing unnecessary data, a more streamlined data set can be obtained, which can save bandwidth and storage space during data transmission and storage. Dynamically process json data according to configuration rules so that it can adapt to various data processing requirements. Users only get the data they really need, avoiding unnecessary data confusion, allowing users to focus more on the data they care about, and improving user experience. In some cases, json data may contain some sensitive information. Through this embodiment, this sensitive information can be removed during data transmission to protect user privacy. Reducing the transmission and processing of unnecessary data can reduce the load on the server and client and optimize system performance.
[0121] In summary, this embodiment has great application value in processing a large amount of json data, especially in scenarios where data needs to be screened and eliminated. By analyzing the characteristics of json object data, this embodiment can learn that json objects are mainly key-value types, and value types are divided into three types: a specific single value, which continues to be composed of multiple key-value types and an array composed of a group of key-values. According to the results of the analyzed json object, the user can only see the data that matches the user through the configuration of rules, and the remaining data that does not match the user will not be transmitted to the current user; thus, different users get different data, which improves the security of the system and prevents attacks such as network packet capture from the root.
[0122] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.< / void> < / void> < / void> < / void>
Claims
1. A network security data interception method, characterized in that: The following steps are involved: Use the Spring Cloud Microservice Gateway to configure a global interceptor so that all requests pass through the global interceptor; Sort out the request resource addresses of the business system, use the request resource addresses as interception targets, and configure multiple rules for the request resource addresses when configuring the business system; Operate the json data object node converted from the original message string, convert the json data object into new text data, and then convert the new text data into a byte array, and then wrap the byte array into a buffer byte and set it into the response data stream; the data obtained by the user is the data after interception processing; The process of passing all requests through the global interceptor includes the following steps: Find a filter method defined in the interceptor method Spring Cloud Gateway; call its get response method through the server Web exchange to obtain the server HTTP response object and get the response object of the request; Instantiate the obtained server HTTP response object into a server HTTP response decorator, and rewrite the server HTTP response decorator with the write method; Convert the data format of the response body, convert the XML format to the JSON format, or convert the ordinary text to the HTML format; The process of rewriting the server HTTP response decorator with the write method includes the following steps: Convert the method body into a Flux object, that is, the gateway adopts responsive development, obtains the buffer stream of flux, and converts the buffer stream into a buffer data object; Convert the buffered data object into a byte array, read the byte array and convert it into a raw message string, and convert the raw message string into a json data object; The process of operating the JSON data object node converted from the original message string includes the following steps: Call the key collection method through the json object to get all the json key nodes; Traverse each json node and get its value from the json data for each traversed node; After all the rule matching processes are completed, a new JSON data object is obtained after the JSON data object nodes are removed, and the new text data is converted into a byte array; If the value is in array form, its value is traversed according to the json node. If the json node matches the nodes in the configuration rule in sequence, the delete key-value pair is called to remove the json node for the matched json data object.
2. The network security data interception method according to claim 1, characterized in that: The process of converting the data format of the response body includes the following steps: The target data format is sent to the response body by using the callback function, the format of the original data is identified, and the corresponding conversion program is triggered according to the format. The conversion program includes a first conversion program and a second conversion program. The first conversion program converts the XML format into the JSON format, and the second conversion program converts the ordinary text into the HTML format. When the original data format is XML, use the parsing library to parse the XML data in the response body, use Jackson to construct it according to the XML structure, and map it to the JSON object; output the data in JSON format, convert the constructed JSON object into a string, and return it as the response body; when the original data format is ordinary text, create an HTML frame, insert the text content in the response body into the HTML frame, convert the constructed HTML content into a string, and return it as the response body; The response body outputs data having the target data format.
3. The network security data interception method according to claim 1, characterized in that: The process of configuring multiple rules includes the following steps: Configure rules based on roles or other conditions, and after configuration is complete, the user sends a request to the server; The server network exchange calls its get request method to obtain the server HTTP request object; The server HTTP request object calls to obtain the uniform resource identifier to obtain the uniform resource identifier URI object. The URI object calls to obtain the path to obtain the request resource address when the current request accesses the server. At this time, the request resource address requested by the user is matched with the configured request resource address. If the match is successful, the corresponding rule is executed.
4. The network security data interception method according to claim 3, characterized in that: The process of defining configuration rules includes the following steps: In the configuration rules, part of the configuration rules are assigned to a management processor coupled to a predefined group of joint user devices of the user device partition, and the management processor is assigned a role, an administrator or a paid user; The auxiliary management processor is directed to configure a manageability module of the user device in a support role and coupled to the management processor; After determining that the joint user equipment has been configured according to the configuration rule, start initializing the joint user equipment so that the joint user equipment works together and acts as a single user equipment; According to the configuration rules, the federated user devices are reordered to match the user device partitions, or according to the configuration rules, the federated user devices are divided into multiple parts; after the rules are configured according to the role or other conditions, when the configuration is completed, the user sends a request to the server.
5. The network security data interception method according to claim 3, characterized in that: Role refers to administrator or paid user, and other conditions refer to the user's permission level, access device and access time.
6. A network security data interception system, characterized in that: Include: The global interceptor configuration module is responsible for using the spring cloud microservice gateway spring cloud gateway to configure the global interceptor so that all requests pass through the global interceptor; The rule configuration module is responsible for sorting out the request resource address URL of the business system and taking the request resource address URL as the target of interception. When configuring the business system, multiple rules are configured for the request resource address URL. The data interception processing module is responsible for operating the json data object node converted from the original message string, converting the json data object into new text data, and then converting the new text data into a byte array, and setting the byte array into a buffer byte by packaging it into the response data stream; the data obtained by the user is the data after interception processing; The process of making all requests pass through the global interceptor in the global interceptor configuration module includes: Find a filter method defined in the interceptor method Spring Cloud Gateway; call its get response method through the server Web exchange to obtain the server HTTP response object and get the response object of the request; Instantiate the obtained server HTTP response object into a server HTTP response decorator, and rewrite the server HTTP response decorator with the write method; Convert the data format of the response body, convert the XML format to the JSON format, or convert the ordinary text to the HTML format; The process of rewriting the server HTTP response decorator with the write method includes: Convert the method body into a Flux object, that is, the gateway adopts responsive development, obtains the buffer stream of flux, and converts the buffer stream into a buffer data object; Convert the buffered data object into a byte array, read the byte array and convert it into a raw message string, and convert the raw message string into a json data object; The process of the data interception processing module operating the JSON data object node converted from the original message string includes: Call the key collection method through the json object to get all the json key nodes; Traverse each json node and get its value from the json data for each traversed node; After all the rule matching processes are completed, a new JSON data object is obtained after the JSON data object nodes are removed, and the new text data is converted into a byte array; If the value is in array form, its value is traversed according to the json node. If the json node matches the nodes in the configuration rule in sequence, the delete key-value pair is called to remove the json node for the matched json data object.
