Packet inspection method, apparatus, device, storage medium, and program product

By determining whether a matching target field exists in the set of regular fields in the web server, and performing compliance checks based on the target field or generated check rules, the problem of low message inspection efficiency in traditional technologies is solved, and more efficient message inspection is achieved.

CN119544836BActive Publication Date: 2026-04-14CHINA CONSTRUCTION BANK +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA CONSTRUCTION BANK
Filing Date
2024-11-06
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In traditional technologies, web servers are inefficient at performing compliance checks on request messages sent by different front-end devices, requiring the development of check code for each new request message.

Method used

In response to the message to be inspected, the server determines whether a matching target field exists in the set of regular fields for each field to be inspected, and performs a compliance check based on the inspection rules for the target field; if no target field exists, it generates inspection rules to perform a compliance check.

Benefits of technology

It improves the efficiency of message inspection, shortens the inspection time and the time to generate inspection rules, and enhances the inspection efficiency of messages to be inspected.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119544836B_ABST
    Figure CN119544836B_ABST
Patent Text Reader

Abstract

The application relates to the computer technical field, and particularly discloses a message checking method and device, computer equipment, a computer readable storage medium and a computer program product. The method comprises the following steps: in response to a to-be-checked message, for each to-be-checked field in the to-be-checked message, determining whether a target field matching the to-be-checked field exists in a conventional field set; the conventional field set comprises a plurality of conventional fields and a checking rule corresponding to each conventional field; in the case that the target field exists, performing compliance checking on the to-be-checked field according to the checking rule corresponding to the target field; in the case that the target field does not exist, generating a checking rule of the to-be-checked field according to each checking rule in the conventional field set, and performing compliance checking on the to-be-checked field by using the generated checking rule. The method can improve the checking efficiency of compliance checking on the message.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a message inspection method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology

[0002] In scenarios where a web server interacts with a front-end, the web server can receive request messages sent by the front-end. These request messages include information such as the request line, request headers, message body, status line, response headers, and message body. The web server needs to check the compliance of each piece of information in the request message. For example, it needs to check the content and format of the message to ensure that the message conforms to the corresponding processing specifications.

[0003] In traditional technology, because the business processes handled by the front end are different, the messages sent to the web server are also different. The web server needs to generate different inspection codes for different messages, so as to use different inspection codes to perform compliance checks on different messages.

[0004] Therefore, traditional technologies suffer from low efficiency when performing compliance checks on messages. Summary of the Invention

[0005] Therefore, it is necessary to provide a message inspection method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the efficiency of message compliance checks in response to the above-mentioned technical problems.

[0006] Firstly, this application provides a message inspection method, including:

[0007] In response to a message to be inspected, for each field to be inspected in the message to be inspected, it is determined whether there is a target field in the set of regular fields that matches the field to be inspected; the set of regular fields includes multiple regular fields and the inspection rules corresponding to each regular field;

[0008] If the target field exists, the field to be inspected is subjected to compliance checks according to the inspection rules corresponding to the target field;

[0009] In the absence of the target field, an inspection rule for the field to be inspected is generated based on each inspection rule in the set of regular fields, and the generated inspection rule is used to perform a compliance check on the field to be inspected.

[0010] In one embodiment, the compliance check of the field to be checked according to the check rule corresponding to the target field includes:

[0011] Determine whether annotation information exists in the inspection rules;

[0012] If the annotation information exists, a compliance check is performed on the field to be checked based on the annotation information;

[0013] If the annotation information is not present, the compliance check is not performed, and the field to be checked is determined to be a compliant field.

[0014] In one embodiment, the annotation information includes regular expressions and the range of field values. The compliance check on the field to be checked based on the annotation information includes:

[0015] Obtain the inspection value from the field to be inspected;

[0016] If the value being checked falls within the specified range, the compliance check is performed on the value according to the regular expression.

[0017] If the value being checked is not within the specified range, the field to be checked is determined to be a non-compliant field.

[0018] In one embodiment, the annotation information further includes default values, and the method further includes:

[0019] If the check value is empty, then the default value is used to assign a value to the check value.

[0020] In one embodiment, performing the compliance check on the check value according to the regular expression includes:

[0021] Obtain the first string type corresponding to the regular expression and the second string type corresponding to the check value;

[0022] If the first string type and the second string type are the same, the field to be checked is determined to be a compliant field;

[0023] If the first string type and the second string type are inconsistent, the field to be checked is determined to be a non-compliant field.

[0024] In one embodiment, the method further includes:

[0025] If the field to be inspected is a non-compliant field, an exception indication is generated. The exception indication includes an exception code, which is used to determine the reason for the non-compliance of the field to be inspected.

[0026] Secondly, this application also provides a message inspection device, comprising:

[0027] The determination module is used to, in response to the message to be inspected, determine whether there is a target field in the set of regular fields that matches the field to be inspected for each field to be inspected in the message to be inspected; the set of regular fields includes multiple regular fields and the inspection rules corresponding to each regular field;

[0028] The first inspection module is used to perform a compliance check on the field to be inspected according to the inspection rules corresponding to the target field when the target field exists.

[0029] The second inspection module is used to generate inspection rules for the field to be inspected based on the inspection rules in the set of regular fields when the target field does not exist, and to perform compliance checks on the field to be inspected using the generated inspection rules.

[0030] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method described in any of the first aspects above.

[0031] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any of the first aspects above.

[0032] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the method described in any of the first aspects above.

[0033] The aforementioned message inspection method, apparatus, computer equipment, computer-readable storage medium, and computer program product, in response to a message to be inspected, determine whether a target field matching the field to be inspected exists in a set of regular fields for each field to be inspected in the message to be inspected. The set of regular fields includes multiple regular fields and inspection rules corresponding to each regular field. Then, if a target field exists, a compliance check is performed on the field to be inspected according to the inspection rules corresponding to the target field. Since the inspection rules for the field to be inspected can be quickly determined from the set of regular fields, it is not necessary to generate inspection rules for the field to be inspected, thus improving the inspection efficiency and shortening the inspection time. If no target field exists, inspection rules for the field to be inspected are generated according to the inspection rules in the set of regular fields, and the generated inspection rules are used to perform a compliance check on the field to be inspected. Since the inspection rules in the set of regular fields are pre-generated, the inspection rules for the field to be inspected can be quickly generated using the inspection rules, thereby improving the efficiency of generating the inspection rules and shortening the time of generating the inspection rules, and thus improving the inspection efficiency of all fields to be inspected in the message to be inspected. Attached Figure Description

[0034] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0035] Figure 1 This is a diagram illustrating the application environment of a message inspection method in one embodiment.

[0036] Figure 2 This is a flowchart illustrating a message inspection method in one embodiment;

[0037] Figure 3 This is a flowchart illustrating step 202 in one embodiment;

[0038] Figure 4 This is a flowchart illustrating step 302 in one embodiment;

[0039] Figure 5 This is a flowchart illustrating step 402 in one embodiment;

[0040] Figure 6 This is a structural block diagram of a message inspection device in one embodiment;

[0041] Figure 7 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. It should be noted that existing industry solutions such as software, components, and models may be mentioned in the embodiments of this application. These should be considered exemplary and are intended only to illustrate the feasibility of implementing the technical solutions of this application, but do not imply that the applicant has already used or necessarily used such solutions.

[0043] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with relevant regulations. The acquisition, storage, use and processing of data in the technical solution of this application all comply with the relevant provisions of national laws and regulations.

[0044] In traditional technologies, when a web server interacts with a front-end, the front-end sends a new request message to the web server each time it processes a new business request. The web server then needs to develop inspection code for each new request message and use this code to perform compliance checks. This process suffers from low efficiency. Therefore, this application proposes a message inspection method that improves the efficiency of compliance checks.

[0045] The message inspection method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, server 102 communicates with front-end device 104 via a network. A data storage system can store the data that server 102 needs to process. The data storage system can be integrated onto server 102 or placed on a cloud or other network server. In response to a message to be inspected, server 102 determines whether a target field matching the field to be inspected exists in a set of regular fields for each field to be inspected in the message. The set of regular fields includes multiple regular fields and corresponding inspection rules for each regular field. If a target field exists, compliance checks are performed on the field to be inspected according to the inspection rules corresponding to the target field. If no target field exists, inspection rules for the field to be inspected are generated according to the inspection rules in the set of regular fields, and compliance checks are performed on the field to be inspected using the generated inspection rules. Front-end device 104 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. Server 102 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server providing cloud computing services.

[0046] In one exemplary embodiment, such as Figure 2 As shown, a message inspection method is provided, which is applied to... Figure 1 Taking the server in the example, the following steps are included:

[0047] Step 201: In response to the message to be inspected, for each field to be inspected in the message to be inspected, determine whether there is a target field in the set of regular fields that matches the field to be inspected; the set of regular fields includes multiple regular fields and the inspection rules corresponding to each regular field.

[0048] The message to be inspected is an HTTP request message sent by the front-end device to the server, containing the request information from the front-end device to the server. The server can respond to the message to be inspected and execute the operation corresponding to the message. The fields to be inspected refer to the fields in the message to be inspected that carry information. The server can perform compliance checks on these fields to determine whether the content of the message to be inspected meets the server's identification and processing requirements. It should be noted that the message to be inspected may include multiple fields to be inspected, and the server can perform compliance checks on each field separately. For example, the message inspection method provided in this application can be applied to a stock trading scenario. If the message to be inspected is sent by a user to the server via a front-end device such as a laptop or smartphone to instruct the server to perform a stock purchase operation, then the field to be inspected can be the stock name, or it can also be the quantity of stocks to be purchased.

[0049] Here, "regular fields" refers to fields that the server pre-determines based on historical packets received within a historical time period. It can be understood that the server can determine the fields requiring compliance checks based on compliance check records of fields in historical packets, then designate these fields as regular fields, and establish a regular field set based on the check rules for each regular field. In this embodiment, for each field to be checked, the server can determine the target field as the field in the regular field set that matches the field to be checked, thereby performing a compliance check on the target field.

[0050] In this embodiment, the server can receive the message to be inspected sent by the front-end device through the network, and then respond to the message to be inspected. Optionally, taking a field to be inspected in the message to be inspected as an example, the server can search for a field with the same name from multiple regular fields in the set of regular fields according to the field name of the field to be inspected, and determine the regular field with the same name as the field to be inspected as the target field; or, the server can also search for a field with the same type from multiple regular fields in the set of regular fields according to the field type of the field to be inspected, and determine the regular field with the same type as the field to be inspected as the target field.

[0051] Step 202: If a target field exists, perform a compliance check on the field to be checked according to the check rules corresponding to the target field.

[0052] The inspection rules corresponding to the target field are the inspection rules related to the target field set by the server. The inspection rules refer to the rules for performing compliance checks on the field. For example, the inspection rule can be to check the field, or it can be to not check the field; or, the inspection rule can be to check whether the value of the field is greater than a threshold; or, the inspection rule can be to check the string type of the field. The above are just some exemplary descriptions of the inspection rules in this embodiment. This embodiment does not limit the content of the inspection rules.

[0053] In this embodiment, if the target field exists in the set of regular fields, the server can directly obtain the inspection rule corresponding to the target field from the set of regular fields and use the inspection rule corresponding to the target field to perform a compliance check on the field to be inspected. For example, if the data information in the field to be inspected conforms to the inspection rule, the field to be inspected can be determined to be a compliant field; or, if the data information in the field to be inspected does not conform to the inspection rule, the field to be inspected can be determined to be a non-compliant field.

[0054] Step 203: In the absence of a target field, generate inspection rules for the field to be inspected based on the inspection rules in the set of regular fields, and use the generated inspection rules to perform compliance checks on the field to be inspected.

[0055] It should be noted that if the field to be checked is a newly set field in the message to be checked, no matching regular field can be found in the regular field set, and therefore compliance checks cannot be performed on that field. Therefore, a check rule matching the field to be checked can be generated, and the generated check rule can then be used to perform compliance checks on the field to be checked.

[0056] In this embodiment, if the target field is not found in the set of regular fields, the server can search for inspection rules related to the physical meaning, string type, and numerical range of the field to be inspected from the various inspection rules in the set of regular fields. Then, it generates inspection rules for the field to be inspected based on the found inspection rules and uses these rules to perform compliance checks on the field. Optionally, if the compliance check passes, the field to be inspected is a compliant field; otherwise, if the compliance check fails, the field to be inspected is a non-compliant field.

[0057] In the above message inspection method, the server responds to the message to be inspected and, for each field to be inspected in the message, determines whether there is a target field in the set of regular fields that matches the field to be inspected. The set of regular fields includes multiple regular fields and the inspection rules corresponding to each regular field. Then, if a target field exists, the compliance check of the field to be inspected is performed according to the inspection rules corresponding to the target field. Since the inspection rules for the field to be inspected can be quickly determined from the set of regular fields, it is not necessary to generate inspection rules for the field to be inspected, thus improving the inspection efficiency and shortening the inspection time. If no target field exists, the inspection rules for the field to be inspected are generated according to the inspection rules in the set of regular fields, and the generated inspection rules are used to perform a compliance check on the field to be inspected. Since the inspection rules in the set of regular fields are pre-generated, the inspection rules for the field to be inspected can be quickly generated using the inspection rules, thus improving the efficiency of generating the inspection rules and shortening the time of generating the inspection rules. In turn, the inspection efficiency of all fields to be inspected in the message to be inspected can be improved.

[0058] The compliance check of the field to be checked, based on the check rules corresponding to the target field, can be performed according to the annotation information in the check rules. In an exemplary embodiment, such as... Figure 3 As shown, step 202 includes steps 301 and 302. Wherein:

[0059] Step 301: Determine whether there is annotation information in the inspection rules.

[0060] The annotation information refers to the compliance check information corresponding to the target field. For example, the annotation information may include the check items, the value of each check item, and the format of each check item.

[0061] It should be noted that the server needs to check a large number of regular fields. To improve processing efficiency, some regular fields can be classified as requiring compliance checks, while others can be classified as not requiring compliance checks, based on their security level and priority level. Therefore, for regular fields that do not require compliance checks, there are no annotations in the check rules, while for regular fields that require compliance checks, there are annotations in the check rules.

[0062] In this embodiment, the server can obtain the inspection rules corresponding to the target field from the set of regular fields, identify the content included in the inspection rules, and determine whether the inspection rules include annotation information based on the identification results.

[0063] Step 302: If annotation information exists, perform compliance checks on the fields to be checked based on the annotation information.

[0064] It is understandable that when the inspection rules include annotation information, it indicates that a compliance check needs to be performed on the field to be inspected. In this embodiment, the server can perform a compliance check on the field to be inspected based on the annotation information.

[0065] For example, if the annotation information includes parameter types, the parameter types in the field to be checked can be checked. If the parameter types in the field to be checked are consistent with the parameter types in the annotation information, the field to be checked can be determined to be a qualified field; if the parameter types in the field to be checked are inconsistent with the parameter types in the annotation information, the field to be checked can be determined to be an unqualified field.

[0066] In this embodiment, the server can compare the annotation information with the content of the field to be checked one by one, and determine the result of the compliance check based on the comparison result.

[0067] Step 303: If no annotation information is available, no compliance check is performed, and the field to be checked is determined to be a compliant field.

[0068] It is understandable that if there is no annotation information in the inspection rules, it means that there is no need to perform compliance checks on the field to be inspected, and the field to be inspected can be assumed to be a compliant field. In this embodiment, the server can determine that the field to be inspected is a compliant field without performing compliance checks on the field to be inspected if no annotation information is found.

[0069] In this embodiment, by determining whether there is annotation information in the inspection rules, the server can perform compliance checks on the field to be inspected based on the annotation information if the annotation information exists, and not perform compliance checks and determine the field to be inspected as a compliant field if there is no annotation information. Since the presence or absence of annotation information can filter out the fields to be inspected that do not need to be inspected, the number of fields that need to be inspected in the message to be inspected is reduced, thereby shortening the inspection time of the message to be inspected and improving the inspection efficiency of the message to be inspected.

[0070] In the scenario described above where compliance checks are performed on the field to be inspected based on annotation information, the annotation information includes regular expressions and the range of field values. These regular expressions and value ranges can be used to perform compliance checks on the field to be inspected. In an exemplary embodiment, such as... Figure 4 As shown, step 302 includes steps 401 and 402, wherein:

[0071] Step 401: Obtain the check value from the field to be checked.

[0072] Here, the check value refers to the value of the attribute or feature in the field to be checked. For example, if the field to be checked is the number of shares held, the check value can be a value such as 0, 10, or 20. In this embodiment, the server can obtain numerical information from the information corresponding to the field to be checked and use the numerical information as the check value.

[0073] Step 402: If the value being checked is within a certain range, perform a compliance check on the value using a regular expression.

[0074] Here, field values ​​refer to the values ​​of the attributes or characteristics of each regular field, and the range of field values ​​refers to the maximum and minimum values ​​of the values ​​in the field to be checked. It can be understood that if the value being checked is within the range, the server can correctly identify the field value being checked and thus respond normally to the message being checked.

[0075] Regular expressions are a method of filtering strings by matching them against specific patterns. For example, regular expressions can be used to check whether a string contains a string that matches a certain rule. In this embodiment, regular expressions can be pre-set according to the regular expression rules supported by the server.

[0076] In this embodiment, the server can compare the check value with the range of values. If the check value is greater than or equal to the minimum value in the range and less than or equal to the maximum value in the range, the server can continue to perform a compliance check on the check value based on the regular expression to see if it meets the regular expression rules supported by the server.

[0077] Step 403: If the value being checked is outside the range of possible values, the field to be checked is determined to be a non-compliant field.

[0078] Understandably, if the value being checked is outside the range, the server cannot properly identify the value of the field to be checked, and therefore cannot properly respond to the message to be checked.

[0079] In this embodiment, the server can compare the check value with the range of values. If the check value is less than the minimum value in the range and greater than the maximum value in the range, it can be determined that the compliance check has failed.

[0080] In one possible implementation, the annotation information also includes default values, which are used to assign a value to the check value if the check value is empty.

[0081] The default value refers to a value that the server can use to respond correctly to the field being checked. For example, if the field to be checked is the number of shares held, the default value can be any integer greater than 0 and less than 100. For example, it could be 10, 20, or 30. Understandably, if the field to be checked does not include a check value, the server may not be able to correctly recognize the field value and will not be able to respond to the check message.

[0082] In this implementation, if the server cannot obtain the check value in the field to be checked when obtaining the check value, it can determine that the check value in the field to be checked is empty, and assign a value to the check value using the default value.

[0083] In this embodiment, the server obtains the check value from the field to be checked. If the value is within the specified range, the server performs a compliance check on the check value using a regular expression. Since the process of determining the comparison result between the check value and the specified range is relatively simple, the comparison result can be quickly determined, thereby improving the efficiency of compliance checks based on regular expressions. At the same time, if the value is outside the specified range, the field to be checked is determined to be a non-compliant field, which reduces the invalid work of compliance checks based on regular expressions, thereby improving the efficiency of compliance checks.

[0084] The following describes in detail the specific process of performing compliance checks on check values ​​based on regular expressions. In an exemplary embodiment, such as Figure 5 As shown, step 402 includes steps 501 and 502, wherein:

[0085] Step 501: Obtain the first string type corresponding to the regular expression and the second string type corresponding to the check value.

[0086] It's important to note that a string is a data type used to represent a series of characters. String types can include character strings, integer strings, floating-point strings, boolean strings, etc. If the string type of the check value differs from the string types supported by the server by default, the server will be unable to recognize the check value. Therefore, the compliance check can be determined by whether the string type of the check value matches the string type of the regular expression.

[0087] Here, the first string type refers to the string type corresponding to the regular expression rule, and the second string type refers to the string type corresponding to the check value.

[0088] In this embodiment, the server can obtain the first string type from the relevant information of the target field in the storage space, or directly identify the string type corresponding to the regular expression rule and obtain the first string type based on the identification result. Alternatively, the server can identify the string type corresponding to the check value and obtain the second string type based on the identification result.

[0089] Step 502: If the first string type and the second string type are the same, determine that the field to be checked is a compliant field.

[0090] In this embodiment, the server can compare the first string type and the second string type, determine whether the first string type and the second string type are consistent based on the comparison result, and determine that the compliance check is passed when the first string type and the second string type are consistent, and the field to be checked is a compliant field.

[0091] Step 502: If the first string type and the second string type are inconsistent, determine that the field to be checked is a non-compliant field.

[0092] In this embodiment, the server can compare the first string type and the second string type, determine whether the first string type and the second string type are consistent based on the comparison result, and determine that the compliance check has failed and the field to be checked is a non-compliant field when the first string type and the second string type are inconsistent.

[0093] In this embodiment, the server obtains the first string type corresponding to the regular expression and the second string type corresponding to the check value. It can determine that the field to be checked is a non-compliant field when the first string type and the second string type are the same, and it can also determine that the field to be checked is a non-compliant field when the first string type and the second string type are not the same. Since the process of determining whether the first string type and the second string type are the same is relatively simple, the comparison result can be determined quickly, and then the compliance check can be determined quickly based on the comparison result.

[0094] In an exemplary embodiment, the method further includes: if the field to be inspected is a non-compliant field, generating an exception indication, the exception indication including an exception code, the exception code being used to determine the non-compliance reason corresponding to the field to be inspected.

[0095] Understandably, if the field to be checked is a non-compliant field, it can be determined that the compliance check for that field has failed. An exception indication refers to the indication information generated by the server based on the reason for the failure when the compliance check fails. The exception code is an identifier set by the server according to different exception reasons; each exception code corresponds one-to-one with the exception reason. Therefore, when the compliance check fails, the corresponding exception code can be quickly identified, improving the efficiency of generating exception indications.

[0096] In this embodiment, when the field to be checked is a non-compliant field, the server can generate an exception indication including an exception code based on the corresponding exception reason for the failure of the compliance check.

[0097] As one possible implementation, after generating an exception indication including an exception code, the server can also return the exception indication to the front-end device that sent the message to be inspected, so as to notify the front-end device to modify the message to be inspected based on the reason for the exception.

[0098] In this embodiment, when the field to be checked is a non-compliant field, the server can generate an exception code based on the reason for non-compliance, and can provide the maintenance personnel with the reason for non-compliance of the field to be checked, so that the maintenance personnel can modify the field to be checked.

[0099] To facilitate understanding by those skilled in the art, the message inspection method provided in this application will be described in detail below. This method may include:

[0100] S1, in response to the message to be inspected, for each field to be inspected in the message to be inspected, determines whether there is a target field in the set of regular fields that matches the field to be inspected.

[0101] S2, if a target field exists, determine whether there is annotation information in the inspection rules corresponding to the target field.

[0102] S3, if annotation information exists, retrieve the check value from the field to be checked.

[0103] S4, if the value being checked is within the range, obtain the first string type corresponding to the regular expression and the second string type corresponding to the value being checked.

[0104] S5, if the first string type and the second string type are the same, determine that the field to be checked is a compliant field.

[0105] S6, if the first string type and the second string type are inconsistent, determine that the field to be checked is a non-compliant field.

[0106] S7. If the value being checked is outside the range of possible values, the field to be checked is determined to be a non-compliant field.

[0107] S8. If the check value is empty, then the default value is used to assign a value to the check value.

[0108] S9: In the absence of annotation information, no compliance check is performed, and the field to be checked is determined to be a compliant field.

[0109] S10, in the absence of a target field, generate inspection rules for the field to be inspected based on the inspection rules in the regular field set, and use the generated inspection rules to perform compliance checks on the field to be inspected.

[0110] It should be noted that the descriptions in S1-S10 above can be found in the relevant descriptions in the above embodiments, and their effects are similar, so they will not be repeated here.

[0111] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0112] Based on the same inventive concept, this application also provides a message inspection apparatus for implementing the message inspection method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more message inspection apparatus embodiments provided below can be found in the limitations of the message inspection method described above, and will not be repeated here.

[0113] In one exemplary embodiment, such as Figure 6 As shown, a message inspection device is provided, including: a determination module 601, a first inspection module 602, and a second inspection module 603, wherein:

[0114] The determination module 601 is used to determine, in response to the message to be inspected, whether there is a target field in the set of regular fields that matches the field to be inspected for each field to be inspected in the message to be inspected; the set of regular fields includes multiple regular fields and the inspection rules corresponding to each regular field;

[0115] The first inspection module 602 is used to perform compliance checks on the field to be inspected according to the inspection rules corresponding to the target field when a target field exists.

[0116] The second inspection module 603 is used to generate inspection rules for the field to be inspected based on the inspection rules in the regular field set when the target field does not exist, and to use the generated inspection rules to perform compliance checks on the field to be inspected.

[0117] The message inspection device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.

[0118] In one embodiment, the first inspection module described above includes:

[0119] The first determining unit is used to determine whether annotation information exists in the inspection rules;

[0120] The inspection unit is used to perform compliance checks on the fields to be inspected based on the annotation information when annotation information is available.

[0121] The second determining unit is used to not perform compliance checks in the absence of annotation information and to determine the field to be checked as a compliant field.

[0122] The message inspection device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.

[0123] In one embodiment, the above annotation information includes regular expressions and the range of field values, and the above checking unit is specifically used for:

[0124] Retrieve the check value from the field to be checked;

[0125] If the value being checked is within a certain range, a compliance check is performed on the value using a regular expression.

[0126] If the value being checked is outside the acceptable range, the field to be checked is determined to be non-compliant.

[0127] The message inspection device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.

[0128] In one embodiment, the annotation information further includes default values, and the device further includes:

[0129] The assignment module is used to assign a default value to the check value if the check value is empty.

[0130] The message inspection device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.

[0131] In one embodiment, the checking unit is specifically used for:

[0132] Get the first string type corresponding to the regular expression and the second string type corresponding to the check value;

[0133] If the first string type and the second string type are the same, the field to be checked is determined to be a compliant field;

[0134] If the first string type and the second string type are inconsistent, the field to be checked is determined to be a non-compliant field.

[0135] In one embodiment, the above-mentioned apparatus further includes:

[0136] The generation module is used to generate an exception indication if the field to be checked is a non-compliant field. The exception indication includes an exception code, which is used to determine the reason for the non-compliance of the field to be checked.

[0137] The message inspection device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.

[0138] Each module in the aforementioned message inspection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0139] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores inspection messages and routine field data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external front-end devices via a network connection. When executed by the processor, the computer program implements a message inspection method.

[0140] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0141] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0142] In response to the message to be inspected, for each field to be inspected in the message to be inspected, it is determined whether there is a target field in the set of regular fields that matches the field to be inspected; the set of regular fields includes multiple regular fields and the inspection rules corresponding to each regular field;

[0143] If a target field exists, the field to be inspected is subjected to compliance checks according to the inspection rules corresponding to the target field;

[0144] In the absence of a target field, inspection rules for the field to be inspected are generated based on the inspection rules in the set of regular fields, and the generated inspection rules are used to perform compliance checks on the field to be inspected.

[0145] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0146] Determine if any annotation information exists in the inspection rules;

[0147] If annotation information exists, perform compliance checks on the fields to be inspected based on the annotation information;

[0148] In the absence of annotation information, compliance checks are not performed, and the field to be checked is determined to be a compliant field.

[0149] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0150] Retrieve the check value from the field to be checked;

[0151] If the value being checked is within a certain range, a compliance check is performed on the value using a regular expression.

[0152] If the value being checked is outside the acceptable range, the field to be checked is determined to be non-compliant.

[0153] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0154] If the check value is empty, then the default value is used to assign a value to the check value.

[0155] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0156] Get the first string type corresponding to the regular expression and the second string type corresponding to the check value;

[0157] If the first string type and the second string type are the same, the field to be checked is determined to be a compliant field;

[0158] If the first string type and the second string type are inconsistent, the field to be checked is determined to be a non-compliant field.

[0159] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0160] If the field to be inspected is a non-compliant field, an exception indication is generated. The exception indication includes an exception code, which is used to determine the reason for the non-compliance of the field to be inspected.

[0161] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0162] In response to the message to be inspected, for each field to be inspected in the message to be inspected, it is determined whether there is a target field in the set of regular fields that matches the field to be inspected; the set of regular fields includes multiple regular fields and the inspection rules corresponding to each regular field;

[0163] If a target field exists, the field to be inspected is subjected to compliance checks according to the inspection rules corresponding to the target field;

[0164] In the absence of a target field, inspection rules for the field to be inspected are generated based on the inspection rules in the set of regular fields, and the generated inspection rules are used to perform compliance checks on the field to be inspected.

[0165] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0166] Determine if any annotation information exists in the inspection rules;

[0167] If annotation information exists, perform compliance checks on the fields to be inspected based on the annotation information;

[0168] In the absence of annotation information, compliance checks are not performed, and the field to be checked is determined to be a compliant field.

[0169] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0170] Retrieve the check value from the field to be checked;

[0171] If the value being checked is within a certain range, a compliance check is performed on the value using a regular expression.

[0172] If the value being checked is outside the acceptable range, the field to be checked is determined to be non-compliant.

[0173] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0174] If the check value is empty, then the default value is used to assign a value to the check value.

[0175] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0176] Get the first string type corresponding to the regular expression and the second string type corresponding to the check value;

[0177] If the first string type and the second string type are the same, the field to be checked is determined to be a compliant field;

[0178] If the first string type and the second string type are inconsistent, the field to be checked is determined to be a non-compliant field.

[0179] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0180] If the field to be inspected is a non-compliant field, an exception indication is generated. The exception indication includes an exception code, which is used to determine the reason for the non-compliance of the field to be inspected.

[0181] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0182] In response to the message to be inspected, for each field to be inspected in the message to be inspected, it is determined whether there is a target field in the set of regular fields that matches the field to be inspected; the set of regular fields includes multiple regular fields and the inspection rules corresponding to each regular field;

[0183] If a target field exists, the field to be inspected is subjected to compliance checks according to the inspection rules corresponding to the target field;

[0184] In the absence of a target field, inspection rules for the field to be inspected are generated based on the inspection rules in the set of regular fields, and the generated inspection rules are used to perform compliance checks on the field to be inspected.

[0185] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0186] Determine if any annotation information exists in the inspection rules;

[0187] If annotation information exists, perform compliance checks on the fields to be inspected based on the annotation information;

[0188] In the absence of annotation information, compliance checks are not performed, and the field to be checked is determined to be a compliant field.

[0189] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0190] Retrieve the check value from the field to be checked;

[0191] If the value being checked is within a certain range, a compliance check is performed on the value using a regular expression.

[0192] If the value being checked is outside the acceptable range, the field to be checked is determined to be non-compliant.

[0193] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0194] If the check value is empty, then the default value is used to assign a value to the check value.

[0195] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0196] Get the first string type corresponding to the regular expression and the second string type corresponding to the check value;

[0197] If the first string type and the second string type are the same, the field to be checked is determined to be a compliant field;

[0198] If the first string type and the second string type are inconsistent, the field to be checked is determined to be a non-compliant field.

[0199] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0200] If the field to be inspected is a non-compliant field, an exception indication is generated. The exception indication includes an exception code, which is used to determine the reason for the non-compliance of the field to be inspected.

[0201] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0202] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0203] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A message inspection method, characterized in that, The method includes: In response to a message to be inspected, for each field to be inspected in the message to be inspected, it is determined whether there is a target field in the set of regular fields that matches the field to be inspected; the set of regular fields includes multiple regular fields and the inspection rule corresponding to each regular field; the regular fields are determined based on the fields of historical messages received within a historical time period; If the target field exists, a compliance check is performed on the field to be checked according to the check rules corresponding to the target field, including: determining whether there is annotation information in the check rules; the annotation information includes a regular expression and a range of field values; if the annotation information exists, obtaining a check value from the field to be checked; if the size of the check value is within the range of values, performing the compliance check on the check value according to the regular expression; if the annotation information does not exist, not performing the compliance check, and determining that the field to be checked is a compliant field. In the absence of the target field, an inspection rule for the field to be inspected is generated based on each inspection rule in the set of regular fields, and the generated inspection rule is used to perform a compliance check on the field to be inspected.

2. The method according to claim 1, characterized in that, The method further includes: If the value being checked is not within the specified range, the field to be checked is determined to be a non-compliant field.

3. The method according to claim 1, characterized in that, The annotation information also includes default values, and the method further includes: If the check value is empty, then the default value is used to assign a value to the check value.

4. The method according to claim 1, characterized in that, The compliance check performed on the check value according to the regular expression includes: Obtain the first string type corresponding to the regular expression and the second string type corresponding to the check value; If the first string type and the second string type are the same, the field to be checked is determined to be a compliant field; If the first string type and the second string type are inconsistent, the field to be checked is determined to be a non-compliant field.

5. The method according to claim 4, characterized in that, The method further includes: If the field to be inspected is a non-compliant field, an exception indication is generated. The exception indication includes an exception code, which is used to determine the reason for the non-compliance of the field to be inspected.

6. A message inspection device, characterized in that, The device includes: The determination module is used to, in response to a message to be inspected, determine whether there is a target field in a set of regular fields that matches the field to be inspected for each field to be inspected in the message to be inspected; the set of regular fields includes multiple regular fields and an inspection rule corresponding to each regular field; the regular fields are determined based on the fields of historical messages received within a historical time period; The first inspection module is used to perform a compliance check on the field to be inspected according to the inspection rules corresponding to the target field when the target field exists. This includes: determining whether there is annotation information in the inspection rules; the annotation information includes a regular expression and a range of field values; if the annotation information exists, obtaining an inspection value from the field to be inspected; if the inspection value is within the specified range, performing the compliance check on the inspection value according to the regular expression; if the annotation information does not exist, not performing the compliance check, and determining the field to be inspected to be a compliant field. The second inspection module is used to generate inspection rules for the field to be inspected based on the inspection rules in the set of regular fields when the target field does not exist, and to perform compliance checks on the field to be inspected using the generated inspection rules.

7. The apparatus according to claim 6, characterized in that, The first inspection module is also used for: If the value being checked is not within the specified range, the field to be checked is determined to be a non-compliant field.

8. The apparatus according to claim 6, characterized in that, The annotation information also includes default values, and the device further includes: The assignment module is used to assign a value to the check value using the default value if the check value is empty.

9. The apparatus according to claim 6, characterized in that, The first inspection module is also used for: Obtain the first string type corresponding to the regular expression and the second string type corresponding to the check value; If the first string type and the second string type are the same, the field to be checked is determined to be a compliant field; If the first string type and the second string type are inconsistent, the field to be checked is determined to be a non-compliant field.

10. The apparatus according to claim 9, characterized in that, The device further includes: The generation module is used to generate an exception indication if the field to be inspected is a non-compliant field. The exception indication includes an exception code, which is used to determine the non-compliance reason corresponding to the field to be inspected.

11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and device for verifying interface packet

    CN109510824A

  • Data modification method and device, computer equipment and storage medium

    CN115357598A