Parameter verification rule generation method and device

By adding annotation information to the API resource package and using reflection mechanism to generate parameter verification rules, the problems of high maintenance costs and low management efficiency in the microservice system are solved, and the automatic parameter verification rules function of the microservice gateway is realized. , improves efficiency and accuracy.

CN119031053APending Publication Date: 2024-11-26BAIDU ONLINE NETWORK TECH (BEIJIBG) CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310593730.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-23
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

In microservice systems, when business logic changes frequently and function iterations are rapid, manual configuration parameter verification rules are costly to maintain and low management efficiency, which can easily cause mismatch/compatibility of back-end services and parameter verification rules.

Method used

By adding annotation information to the API resource package, using the reflection mechanism to parse the meta information and annotation information, automatically generate parameter verification rules, and realize the automatic parameter verification rules function of the microservice gateway.

Benefits of technology

It shortens the time required for parameter verification rules to take effect, reduces the maintenance burden of back-end developers, avoids the problem of mismatch of parameter verification rules, and improves management efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119031053A_ABST
    Figure CN119031053A_ABST
Patent Text Reader

Abstract

The invention provides a parameter verification rule generation method and device, and relates to the field of cloud computing and the like. The specific implementation scheme is as follows: a micro-service gateway acquires an application programming interface (API) resource packet of a micro-service; wherein the API resource packet comprises annotation information, and the annotation information is used for labeling the to-be-verified field and a parameter verification rule of the to-be-verified field; the micro-service gateway analyzes the API resource packet based on a reflection mechanism to obtain meta-information and annotation information in the API resource packet; and the microservice gateway generates a parameter verification rule of the to-be-verified field according to the meta information and the annotation information. According to the method and the device, the micro-service gateway can have a function of automatically generating the parameter verification rule, and the micro-service gateway can conveniently verify the subsequent request parameter based on the generated parameter verification rule.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, in particular to fields such as cloud computing, and more particularly to a parameter verification rule generation method, device, electronic device, and storage medium. Background Art

[0002] With the rise of microservices, while microservices bring many benefits, there are also some problems that need to be solved. For example, with the splitting of business, the number of back-end services has increased dramatically, and front-end calls need to maintain a large number of back-end microservice addresses. Non-business functions such as login status, permission verification, current limiting control, load balancing, protocol conversion, etc. require a unified entry management, and the microservice gateway came into being.

[0003] The microservice gateway is the unified entrance of the microservice architecture, and is also responsible for the parameter verification function of the request field. In related technologies, the microservice gateway provides a configuration management platform, and the backend service developers maintain all field parameter verification rules through configuration or coding. However, for microservice systems with frequent business logic changes and rapid functional iterations, this configuration method has high maintenance costs and low management efficiency, and is prone to mismatch / compatibility issues between backend services and parameter verification rules. Summary of the invention

[0004] The present invention provides a method, apparatus, device and storage medium for generating parameter verification rules in a microservice gateway.

[0005] According to a first aspect of the present disclosure, a parameter verification rule generation method is provided, which is applied to a microservice gateway, and the method includes:

[0006] Obtain an application programming interface API resource package of the microservice; wherein the API resource package includes annotation information, and the annotation information is used to mark the fields to be checked and the parameter verification rules of the fields to be checked;

[0007] Parsing the API resource package based on a reflection mechanism to obtain the meta information and the annotation information in the API resource package;

[0008] Generate parameter verification rules for the field to be verified according to the meta information and the annotation information.

[0009] According to a second aspect of the present disclosure, a parameter verification rule generation device is provided, which is configured in a microservice gateway, and the device includes:

[0010] An acquisition module is used to acquire an application programming interface API resource package of a microservice; wherein the API resource package includes annotation information, and the annotation information is used to mark the fields to be checked and the parameter verification rules of the fields to be checked;

[0011] A parsing module, used to parse the API resource package based on a reflection mechanism to obtain the meta information and the annotation information in the API resource package;

[0012] A generation module is used to generate parameter verification rules for the field to be verified according to the meta information and the annotation information.

[0013] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0014] at least one processor; and

[0015] a memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in the first aspect above.

[0017] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described in the first aspect above.

[0018] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program implements the steps of the method described in the first aspect when executed by a processor.

[0019] According to the technical solution disclosed in the present invention, annotations are added to the resource package of the API so that the microservice gateway can parse the meta-information in the resource package through reflection, and generate parameter verification rules through the meta-information and annotation information, so that the microservice gateway has the function of automatically generating parameter verification rules, shortening the time required for the parameter verification rules to take effect, and facilitating the microservice gateway to verify subsequent request parameters based on the generated parameter verification rules.

[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0022] Figure 1 is a schematic diagram of a protocol between a business system and a gateway provided according to an embodiment of the present disclosure;

[0023] Figure 2A flow chart of a parameter verification rule generation method provided by an embodiment of the present disclosure;

[0024] Figure 3 A flowchart of another parameter verification rule generation method provided by an embodiment of the present disclosure;

[0025] Figure 4 A schematic diagram of the data structure of an API resource package provided in an embodiment of the present disclosure;

[0026] Figure 5 A schematic diagram of a process for determining a field to be checked provided in an embodiment of the present disclosure;

[0027] Figure 6 A block diagram of a parameter verification rule generation device provided by an embodiment of the present disclosure;

[0028] Figure 7 A block diagram of another parameter verification rule generation device provided by an embodiment of the present disclosure;

[0029] Figure 8 It is a block diagram of an electronic device used to implement the parameter verification rule generation method of the embodiment of the present disclosure. DETAILED DESCRIPTION

[0030] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0031] It should be noted that users can use the business system through a browser. Figure 1 As shown in the figure, the business system consists of multiple backend modules, all of which require a unified gateway to output to the outside world to complete basic functions such as authentication, flow control, and fuse. The browser interacts with the gateway through a text protocol (for example, JSON), while the gateway and the backend modules are deployed in the intranet and interact with each other through a higher-performance binary protocol (for example, ProtoBuf). An API (Application Programming Interface) needs to be deployed in the gateway system to connect these two protocols and facilitate the interaction between the browser and the backend service through the gateway.

[0032] With the rise of microservices, while microservices bring many benefits, there are also some problems that need to be solved. For example, with the splitting of business, the number of back-end services has increased dramatically, and front-end calls need to maintain a large number of back-end microservice addresses. Non-business functions such as login status, permission verification, current limiting control, load balancing, protocol conversion, etc. require a unified entry management, and the microservice gateway came into being.

[0033] The microservice gateway is the unified entrance of the microservice architecture, and is also responsible for the parameter verification function of the request field. In related technologies, the microservice gateway provides a configuration management platform, and the backend service developers maintain all field parameter verification rules through configuration or coding. Whenever the business changes or the service is upgraded, the backend developers are required to manually update the parameter verification rules on the gateway management platform according to the upgraded code.

[0034] However, for microservice systems with frequent business logic changes and rapid functional iterations, this configuration method has high maintenance costs and low management efficiency, and is prone to causing mismatch / compatibility issues between backend services and parameter verification rules.

[0035] To this end, the embodiments of the present disclosure provide a method, apparatus, device and storage medium for generating parameter verification rules in a microservice gateway, which can enable the microservice gateway to have the function of automatically generating parameter verification rules, shorten the time required for the parameter verification rules to take effect, and facilitate the microservice gateway to verify subsequent request parameters based on the generated parameter verification rules. It can solve the problem of high maintenance cost and low management efficiency of manual configuration methods in related technologies, which easily causes mismatch / compatibility between back-end services and parameter verification rules.

[0036] The following describes the parameter verification rule generation method, apparatus, device and storage medium of the embodiments of the present disclosure with reference to the accompanying drawings.

[0037] Figure 2 The following is a flow chart of a parameter verification rule generation method provided by an embodiment of the present disclosure. It should be noted that the method can be applied to a microservice gateway. Figure 2 As shown, the method may include but is not limited to the following steps.

[0038] In step 201, the API resource package of the microservice is obtained.

[0039] In the embodiment of the present disclosure, the API resource package may include annotation information, and the annotation information is used to mark the fields to be checked and the parameter verification rules of the fields to be checked.

[0040] In the embodiments of the present disclosure, the API resource package may be a jar (Java Archive File) package of the API. In addition to the above-mentioned annotation information, the jar package may also include but is not limited to at least one of the following: classes, properties and methods.

[0041] In the embodiments of the present disclosure, the microservice may be a microservice provided by a microservice system. As an example, the microservice system may adopt a distributed microservice architecture, such as the formation process of the microservice system may include: splitting the system into multiple microservices, assembling the multiple microservices after developing each microservice, and then completing the construction with other systems.

[0042] In one implementation, the API resource package can be obtained by the microservice gateway from the Maven repository. The API resource package can be understood as the latest jar package uploaded to the Maven repository. Optionally, the microservice gateway can download the latest API resource package from the Maven repository in an update push manner, or the microservice gateway can periodically download the latest API resource package from the Maven repository. The Maven repository can be a local repository or a remote repository.

[0043] In one possible implementation, the microservice gateway can obtain an API resource package from the warehouse based on the received update notification message. For example, when the business of the microservice system changes, and / or the service is upgraded, the developers of the microservice system can generate a corresponding API resource package based on the business change and / or service upgrade requirements. When generating the API resource package, annotation information can be added to the API to mark the fields to be checked and the parameter verification rules of the fields to be checked, that is, the annotation information can be used to mark which fields need to be parameter checked and what the specific parameter verification rules are. The API resource package is uploaded to the Maven warehouse, and an update notification message is pushed to the microservice gateway. After receiving the update notification message, the microservice gateway can download the API resource package associated with the update notification message from the Maven warehouse, so that the microservice gateway can automatically generate parameter verification rules using the annotation information in the API resource package.

[0044] In another possible implementation, the microservice gateway obtains the API resource package from the warehouse in response to the current time of the microservice gateway reaching the update time. For example, when the business of the microservice system changes, and / or the service is upgraded, the developers of the microservice system can generate corresponding API resource packages based on the business change and / or service upgrade requirements. When generating the API resource package, annotation information can be added to the API to mark the fields to be checked and the parameter verification rules of the fields to be checked, that is, the annotation information can be used to mark which fields need to be parameter checked and what are the specific parameter verification rules. The API resource package is uploaded to the Maven warehouse. The microservice gateway can periodically (or regularly) obtain the latest API resource package from the warehouse to update the locally stored parameter verification rules. For example, when the current time of the microservice gateway reaches the update time, the latest API resource package can be downloaded from the Maven warehouse so that the microservice gateway can automatically generate parameter verification rules using the annotation information in the latest API resource package.

[0045] In step 202, the API resource package is parsed based on the reflection mechanism to obtain the meta information and annotation information in the API resource package.

[0046] In an embodiment of the present disclosure, the microservice gateway may parse the API resource package through a reflection mechanism to obtain the meta information and annotation information in the API resource package.

[0047] In step 203, a parameter verification rule for the field to be verified is generated according to the meta information and the annotation information.

[0048] In an embodiment of the present disclosure, the field type in the meta information is recursively parsed through annotation information, the data structure of the API resource package is constructed, the field to be checked is screened out from the data structure, and the parameter verification rules of the field to be checked are generated through the annotation information.

[0049] In the disclosed embodiment, annotations are added to the resource package of the API so that the microservice gateway can parse the meta-information in the resource package through reflection, and generate parameter verification rules through the meta-information and annotation information, so that the microservice gateway has the function of automatically generating parameter verification rules, shortening the time required for the parameter verification rules to take effect, and facilitating the microservice gateway to verify subsequent request parameters based on the generated parameter verification rules.

[0050] It can be seen that when the interface field needs to be upgraded and published to the microservice gateway, there is no need to manually update the parameter verification rules of the server gateway, freeing up the time of backend developers and avoiding the introduction of unknown problems; when a large number of interface fields are updated, the gateway can automatically generate parameter verification rules, without manual processing, and will not block the API release and project progress; there is no need to manually write rules, the rules are in the backend service code, and are uniformly maintained, so there will be no mismatch problems. This can solve the problem of high maintenance cost and low management efficiency of manual configuration methods in related technologies, which easily causes mismatch / compatibility between backend services and parameter verification rules.

[0051] Figure 3 This is a flow chart of another parameter verification rule generation method provided by an embodiment of the present disclosure. It should be noted that this method can be applied to a microservice gateway. Figure 3 As shown, the method may include but is not limited to the following steps.

[0052] In step 301, the API resource package of the microservice is obtained.

[0053] Among them, in the embodiment of the present disclosure, the API resource package includes annotation information, and the annotation information is used to mark the fields to be checked and the parameter verification rules of the fields to be checked.

[0054] In the embodiments of the present disclosure, step 301 may be implemented in any manner in the embodiments of the present disclosure, and the embodiments of the present disclosure do not limit this and will not be described in detail.

[0055] In step 302, the API resource package is parsed based on the reflection mechanism to obtain the meta information and annotation information in the API resource package.

[0056] In the embodiment of the present disclosure, the annotation information includes first annotation information and second annotation information, the first annotation information is used to mark the field to be checked, and the second annotation information is used to mark the parameter verification rule of the field to be checked.

[0057] In one implementation, the first annotation information may be @APIMethod, which is used to extract the request type and parse the fields of the method marked by the annotation. The second annotation information may be @APIParam, which is used to automatically generate parameter verification rules for the field marked by the annotation.

[0058] In the embodiments of the present disclosure, step 302 may be implemented in any manner in the embodiments of the present disclosure, and the embodiments of the present disclosure do not limit this and will not be described in detail.

[0059] In step 303, according to the first annotation information, the interface to be parsed is obtained from the meta-information, and the type of request corresponding to the interface is obtained.

[0060] In the embodiment of the present disclosure, the first annotation information is used to parse the request types corresponding to all interfaces in the meta information into field types. Figure 4 As described above, the request type may include multiple fields, each field type may be a Java basic type, a Java package type, or a custom subtype; the subtype may also be an independent Java type, which may include multiple fields, and the data structure of the API resource package may be obtained by looping in this way.

[0061] In step 304, the requested type is parsed by field type to obtain the field to be checked.

[0062] In one implementation, the type is parsed. If the type is the first type, the second type associated with the first type is obtained from the meta-information, and the second type is used as the new type. The step of parsing the type is returned to perform recursive parsing. If the type is a custom type, the field list of the type is traversed to determine whether the type of the traversed field is a basic type of the object-oriented programming language Java. If the type of the field is a non-Java basic type, the type of the field is obtained, and the step of parsing the type is returned to perform; until the recursive parsing is completed, the field whose type is the Java basic type is determined as the field to be checked.

[0063] Among them, the custom type can be understood as the Class type in Java, which represents the custom Class or Java basic type and its packaging type; the Java basic type may include but is not limited to int type, long type, float type, etc., and the packaging type may include Integer type, Long type, Float type, String type, etc.

[0064] Among them, the first type can be understood as a type in Java other than a custom type, such as a parameterized generic type (ParameterizedType), an array type (including a generic array type (GenericArrayType) and a Class type array, the Class type represents a custom Class or a Java basic type and its packaging type), or a wildcard type (WildcardType), etc.; the second type can be understood as a type associated with the first type. For example, if the first type is a parameterized generic type, the second type is a generic RawType and GenericType. When the first type is an array type, the second type is the type of the array element. When the first type is a wildcard type, the second type is a wildcard-qualified type.

[0065] Optionally, the number of interfaces to be parsed can be one or more. When multiple interfaces to be parsed are determined through the first annotation information, the request type of each interface to be parsed can be obtained separately to obtain the field to be checked of the interface, and the parameter verification rules for the field to be checked in the interface can be generated through the second annotation information.

[0066] As an example of a possible implementation, Figure 5 As shown, taking a single interface to be parsed as an example, the process of determining the field to be checked from the API resource package is described as follows:

[0067] 1) Get the interface to be parsed through the @APIMethod annotation and get the request type of the interface.

[0068] 2) For this type, enter the type parsing process. The parsing process for each type is as follows:

[0069] If the type is a parameterized generic type, get the generic RawType and GenericType, and enter the type resolution process as a new type for recursive resolution;

[0070] If the type is an array type, the type of the array element is obtained and used as a new type to enter the type resolution process for recursive resolution;

[0071] If the type is a wildcard type, the wildcard qualified type is obtained and enters the type resolution process as a new type for recursive resolution;

[0072] If the type is a custom type, iterate through the field list of that type and loop through the following judgments on the type of each field:

[0073] If the field type is not a Java basic type, obtain the field type and enter the type resolution process;

[0074] If the field type is a Java basic type, the field whose type is a Java basic type is determined as the field to be checked.

[0075] If all current types have been recursively parsed, the process ends; otherwise, the next type is obtained and the type parsing process is re-entered.

[0076] In step 305, a parameter verification rule for the field to be verified is generated according to the second annotation information.

[0077] Optional, such as Figure 5 As shown, according to the @APIParam annotation, the corresponding parameter verification rules can be generated for the field type being a Java basic type. In one implementation, the parameter verification rules may include but are not limited to the following rules.

[0078]

[0079] Optionally, in some embodiments of the present disclosure, the microservice gateway may store the parameter verification rules as a local cache in the memory of the microservice gateway; wherein the parameter verification rules stored in the memory are used by the microservice gateway to perform parameter verification on received business requests.

[0080] For example, when a microservice gateway receives a business request, it can obtain parameter verification rules from the cache and use the parameter verification rules to perform parameter verification on the business request. If the parameter verification fails, the microservice gateway returns an error code. Otherwise, the verification is successful and the microservice gateway requests the backend service to obtain data.

[0081] In the disclosed embodiment, by adding the first annotation information and the second annotation information to the resource package of the API, the microservice gateway can automatically generate parameter verification rules through the first annotation information and the second annotation information, so that the microservice gateway has the function of automatically generating parameter verification rules, shortening the time required for the parameter verification rules to take effect, and facilitating the microservice gateway to verify subsequent request parameters based on the generated parameter verification rules.

[0082] Figure 6 This is a block diagram of a parameter verification rule generation device provided by an embodiment of the present disclosure. It should be noted that the parameter verification rule generation device can be configured in a microservice gateway. Figure 6 As shown, the parameter verification rule generating device may include: an acquisition module 601 , a parsing module 602 and a generating module 603 .

[0083] Among them, the acquisition module 601 is used to obtain the application programming interface API resource package of the microservice; wherein the API resource package includes annotation information, and the annotation information is used to mark the fields to be checked and the parameter verification rules of the fields to be checked.

[0084] In one implementation, the annotation information includes first annotation information and second annotation information, wherein the first annotation information is used to mark the field to be checked, and the second annotation information is used to mark the parameter checking rule of the field to be checked.

[0085] In one implementation, the acquisition module 601 is specifically used to: acquire the API resource package from the warehouse based on the received update notification message; or, in response to the current time of the microservice gateway reaching the update time, acquire the API resource package from the warehouse.

[0086] The parsing module 602 is used to parse the API resource package based on the reflection mechanism to obtain the meta information and annotation information in the API resource package.

[0087] The generation module 603 is used to generate parameter verification rules for the field to be verified according to the meta information and annotation information.

[0088] In one implementation, the generation module 603 is specifically used to: obtain the interface to be parsed from the metadata according to the first annotation information, and obtain the type of request corresponding to the interface; perform field type parsing on the type of the request to obtain the field to be checked; and generate parameter verification rules for the field to be checked according to the second annotation information.

[0089] In one possible implementation, the generation module 603 is specifically used to: parse the type; if the type is the first type, obtain the second type associated with the first type from the meta-information, use the second type as the new type, and return to the step of parsing the type for recursive parsing; if the type is a custom type, traverse the field list of the type to determine whether the type of the traversed field is a basic type of the object-oriented programming language Java; if the type of the field is a non-Java basic type, obtain the type of the field, and return to the step of parsing the type; until the recursive parsing is completed, the field of the Java basic type is determined as the field to be checked.

[0090] Optionally, in some embodiments of the present disclosure, Figure 7 As shown, the parameter verification rule generation device may further include: a storage module 704. The storage module 704 is used to store the parameter verification rules as a local cache in the memory of the microservice gateway; wherein the parameter verification rules stored in the memory are used by the microservice gateway to perform parameter verification on the received service request. Figure 7 801-703 and Figure 6 601-603 have the same function and structure.

[0091] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0092] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.

[0093] like Figure 8, is a block diagram of an electronic device according to a parameter verification rule generation method for implementing an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0094] like Figure 8 As shown, the electronic device includes: one or more processors 801, memory 802, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 8 A processor 801 is taken as an example.

[0095] The memory 802 is a non-transient computer-readable storage medium provided by the present disclosure. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the parameter verification rule generation method provided by the present disclosure. The non-transient computer-readable storage medium of the present disclosure stores computer instructions, which are used to enable a computer to perform the parameter verification rule generation method provided by the present disclosure.

[0096] The memory 802 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the parameter verification rule generation method in the embodiment of the present disclosure. The processor 801 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 802, that is, the parameter verification rule generation method in the above method embodiment is implemented.

[0097] The memory 802 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 802 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 802 may optionally include a memory remotely arranged relative to the processor 801, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0098] The electronic device may further include: an input device 803 and an output device 804. The processor 801, the memory 802, the input device 803 and the output device 804 may be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.

[0099] The input device 803 can receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick and other input devices. The output device 804 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.

[0100] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0101] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.

[0102] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0103] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.

[0104] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.

[0105] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in this disclosure can be achieved, and this document is not limited here.

[0106] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A parameter verification rule generation method, applied to a microservice gateway, the method include: Obtain an application programming interface API resource package of the microservice; wherein the API resource package includes annotation information, and the annotation information is used to mark the fields to be checked and the parameter verification rules of the fields to be checked; Parsing the API resource package based on a reflection mechanism to obtain the meta information and the annotation information in the API resource package; Generate parameter verification rules for the field to be verified according to the meta information and the annotation information.

2. The method according to claim 1, in, The annotation information includes first annotation information and second annotation information, the first annotation information is used to mark the field to be checked, and the second annotation information is used to mark the parameter verification rule of the field to be checked.

3. The method according to claim 2, in, The generating, according to the meta information and the annotation information, a parameter verification rule for the field to be verified comprises: According to the first annotation information, obtain the interface to be parsed from the meta information, and obtain the type of request corresponding to the interface; Perform field type parsing on the type of the request to obtain the field to be checked; Generate a parameter verification rule for the field to be verified according to the second annotation information.

4. The method according to claim 3, in, The performing field type parsing on the type of the request to obtain the field to be checked includes: Parse the type, and if the type is the first type, obtain the second type associated with the first type from the meta information, use the second type as a new type, and return to the step of parsing the type for recursive parsing; If the type is a user-defined type, traverse the field list of the type to determine whether the type of the traversed field is a basic type of the object-oriented programming language Java; If the type of the field is a non-Java basic type, the type of the field is obtained, and the step of parsing the type is returned to execute; Until the recursive parsing is completed, the field whose type is the Java basic type is determined as the field to be checked.

5. The method according to claim 1, in, The method of obtaining the application programming interface API resource package of the microservice includes: Based on the received update notification message, obtain the API resource package from the warehouse; or, In response to the current time of the microservice gateway reaching the update time, the API resource package is obtained from the warehouse.

6. The method according to claim 1, further comprising: include: The parameter verification rules are stored as local cache in the memory of the microservice gateway; wherein the parameter verification rules stored in the memory are used by the microservice gateway to perform parameter verification on received business requests.

7. A parameter verification rule generation device, configured in a microservice gateway, the device include: An acquisition module is used to acquire an application programming interface API resource package of a microservice; wherein the API resource package includes annotation information, and the annotation information is used to mark the fields to be checked and the parameter verification rules of the fields to be checked; A parsing module, used to parse the API resource package based on a reflection mechanism to obtain the meta information and the annotation information in the API resource package; A generation module is used to generate parameter verification rules for the field to be verified according to the meta information and the annotation information.

8. The device according to claim 7, in, The annotation information includes first annotation information and second annotation information, the first annotation information is used to mark the field to be checked, and the second annotation information is used to mark the parameter verification rule of the field to be checked.

9. The device according to claim 7, in, The generation module is specifically used for: According to the first annotation information, obtain the interface to be parsed from the meta information, and obtain the type of request corresponding to the interface; Perform field type parsing on the type of the request to obtain the field to be checked; Generate a parameter verification rule for the field to be verified according to the second annotation information.

10. The device according to claim 9, in, The generation module is specifically used for: Parse the type, and if the type is the first type, obtain the second type associated with the first type from the meta information, use the second type as a new type, and return to the step of parsing the type for recursive parsing; If the type is a user-defined type, traverse the field list of the type to determine whether the type of the traversed field is a basic type of the object-oriented programming language Java; If the type of the field is a non-Java basic type, the type of the field is obtained, and the step of parsing the type is returned to execute; Until the recursive parsing is completed, the field whose type is the Java basic type is determined as the field to be checked.

11. The device according to claim 7, in, The acquisition module is specifically used for: Based on the received update notification message, obtain the API resource package from the warehouse; or, In response to the current time of the microservice gateway reaching the update time, the API resource package is obtained from the warehouse.

12. The device according to claim 7, further comprising: include: A storage module is used to store the parameter verification rules as a local cache in the memory of the microservice gateway; wherein the parameter verification rules stored in the memory are used by the microservice gateway to perform parameter verification on the received business requests.

13. An electronic device, include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.

14. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 6.

15. A computer program product comprising a computer program, in, The computer program implements the steps of the method according to any one of claims 1 to 6 when executed by a processor.

Citation Information

Cited By

  • 5G network functions to prevent cyber security threats

    US12634334B2

  • 5g network functions to prevent cyber security threats

    US20250247417A1