Method and apparatus for generating and validating the legality of regular expressions of application system parameters
By extracting common information from the historical parameter configuration data of the application system, the problem of high cost and complexity of parameter configuration detection in the prior art is solved, and more efficient parameter legality verification is achieved.
Patent Information
- Application Number
- CN202210539375.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-17
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2042-05-17
AI Technical Summary
In the prior art, when the parameter configuration does not comply with the specifications, the application system needs to be detected by running the application system, which leads to an increase in time and calculation costs, and the number of regular expressions generated is large and complex, which affects performance.
By extracting common information from the historical parameter configuration data of the application system, a regular expression is generated for each parameter, rather than a regular expression per parameter configuration data, reducing the number of regular expressions and shortening its length.
It reduces the matching complexity of parameter legality verification, improves efficiency and accuracy, and reduces the number and length of regular expressions generated.
Smart Images

Figure CN114924780B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of this specification generally relate to the field of computer technologies, and in particular, to a method and apparatus for generating regular expressions for parameters of an application system, a method and apparatus for performing legality verification on parameters of an application system, and a system for performing legality verification on parameters of an application system. Background Art
[0002] An application system can be implemented using application program code, and code blocks with independent functions in the implemented application program code can be organized as methods to implement specific functions. Each method for implementing a specific function can include multiple parameters, and when implementing the code (writing the code), values can be assigned to each parameter, that is, parameter configuration is performed. In addition, in the case where the application system has been implemented as application program code, the parameter configuration data in the already implemented application program code can also be adjusted to optimize the application system or adjust the application scenario of the application system. When the application system is running, if a certain function needs to be executed, the corresponding method in the application program can be called to implement the function.
[0003] The parameter configuration in the method needs to conform to the specification. Once the configured parameters do not conform to the specification, an operation failure and an error will occur when the application system calls the method. For the judgment of whether the parameter configuration conforms to the specification, the currently adopted method is usually to run the application system to call the corresponding method and judge according to whether the application system reports an error. If it is necessary to wait until the application system reports an error each time to identify that the method parameters do not conform to the specification, it will increase the time cost and calculation cost. As the application system gradually grows, the number of methods in the application system also gradually increases, and this problem will have a very adverse impact on the performance of the application system.
[0004] To solve the above problems, a parameter legality verification method based on regular expressions is proposed. The regular expressions used are directly generated based on the original data of the historical parameter configuration data of the parameters, and a regular expression is generated for each parameter configuration data. However, when the application system is applied to a business scenario, the number of parameters used is very large, and the corresponding parameter content is diverse. In this case, if a regular expression is generated for each parameter configuration data of each parameter, the number of generated regular expressions will be very large, which is not conducive to later verification. Moreover, since the original data of the parameter configuration data is relatively long, the generated regular expressions will also be relatively long, resulting in an increase in the matching complexity when performing parameter legality verification. Summary of the Invention
[0005] In view of the above, the embodiments of the present specification provide a regular expression generation scheme for the parameters of an application system and a parameter legalization verification scheme based on the regular expressions generated by the regular expression generation scheme. Using this regular expression generation scheme, for each parameter in each method of the application system, common information can be extracted from the historical configuration data of the parameter, and based on the common information, a regular expression for the parameter can be generated, rather than generating a regular expression for each piece of parameter configuration data of each parameter, thereby reducing the number of regular expressions corresponding to each parameter and shortening the length of the generated regular expressions, thus reducing the matching complexity during parameter legalization verification.
[0006] According to one aspect of the embodiments of the present specification, a method for generating a regular expression for a parameter of an application system is provided, including: obtaining the parameter values of each parameter in each method code block from the historical application program implementation of the application system; for each parameter in each method code block, respectively extracting common information from the corresponding parameter values; and for each parameter in each method code block, respectively generating a corresponding regular expression according to the extracted common information.
[0007] Optionally, in an example of the above aspect, respectively extracting common information from the corresponding parameter values for each parameter in each method code block may include: for each parameter in each method code block, respectively performing parameter format parsing on the parameter value of the parameter to determine the parameter category of the parameter, and each parameter category corresponds to an information extraction method; and for each parameter category of each parameter, using the information extraction method corresponding to the parameter category, extracting the common information corresponding to the parameter category from the parameter values of the parameter having the parameter category.
[0008] Optionally, in an example of the above aspect, each parameter category has a corresponding template style, and the template style includes template information composition and the record format of each template information. Respectively extracting the common information corresponding to the parameter category from the parameter values of the parameter having the parameter category using the information extraction method corresponding to the parameter category may include: for each parameter category of each parameter, respectively performing template extraction on the parameter values of the parameter having the parameter category according to the corresponding template style, and the template information in the extracted template style is used as the common information corresponding to the parameter category. Respectively generating a corresponding regular expression according to the extracted common information for each parameter in each method code block may include: for each template corresponding to each parameter in each method code block, generating a corresponding regular expression according to the template information of the template.
[0009] Optionally, in an example of the above aspect, each parameter category has a corresponding regular expression generation method. Generating a corresponding regular expression according to the template information of each template corresponding to each parameter in each method code block may include: for each template corresponding to each parameter in each method code block, generating a corresponding regular expression according to the template information according to the regular expression generation method corresponding to the parameter category of the parameter.
[0010] Optionally, in an example of the above aspect, the parameter categories include a first category in which all parameter contents of the parameter value can be format-parsed, a second category in which all parameter contents of the parameter value cannot be format-parsed, and a third category in which some parameter contents of the parameter value can be format-parsed but some parameter contents cannot be format-parsed. For each parameter category of each parameter, adopting an information extraction method corresponding to the parameter category to extract common information corresponding to the parameter category from the parameter value having the parameter category of the parameter may include: in response to the parameter category being the first category, extracting common information from the parameter value having the first category according to the information extraction method corresponding to the first category; in response to the parameter category being the second category, extracting common information from the parameter value having the second category according to the information extraction method corresponding to the second category; in response to the parameter category being the third category, dividing each parameter value having the third category into a first parameter part having the parameter category of the first category and a second parameter part having the parameter category of the second category, and extracting common information from each first parameter part according to the information extraction method corresponding to the first category, and extracting common information from each second parameter part according to the information extraction method corresponding to the second category.
[0011] Optionally, in an example of the above aspect, the parameter categories include a first category in which all parameter contents of the parameter value can be parsed in format, a second category in which all parameter contents of the parameter value cannot be parsed in format, and a third category in which some parameter contents of the parameter value can be parsed in format but some parameter contents cannot be parsed in format. For each template corresponding to each parameter in each method code block, generating a corresponding regular expression according to the regular expression generation method corresponding to the parameter category of the parameter based on the template information of the template may include: for a template whose parameter category of the corresponding parameter is the first category, generating a regular expression based on the template information according to the regular expression generation method corresponding to the first category; for a template whose parameter category of the corresponding parameter is the second category, generating a regular expression based on the template information according to the regular expression generation method corresponding to the second category; for a template whose parameter category of the corresponding parameter is the third category, generating a first regular expression based on the template information extracted according to the information extraction method corresponding to the first category in the template information according to the regular expression generation method corresponding to the first category, generating a second regular expression based on the template information extracted according to the information extraction method corresponding to the second category in the template information according to the regular expression generation method corresponding to the second category, and combining the obtained first regular expression and the second regular expression in pairs to obtain the regular expression corresponding to the template.
[0012] Optionally, in an example of the above aspect, the format parsing includes JSON format parsing. For a template whose parameter category of the corresponding parameter is the second category, generating a regular expression based on the template information according to the regular expression generation method corresponding to the second category may include: for a template whose parameter category of the corresponding parameter is the second category, using a double-pointer access method to obtain a character value and a numeric value from the template information, and generating a regular expression based on the obtained character value and numeric value according to the regular expression generation method corresponding to the second category.
[0013] Optionally, in an example of the above aspect, the method may further include: storing the generated regular expression in a regular expression database in a manner associated with both the method code block and the parameter.
[0014] According to another aspect of the embodiments of the present specification, a method for verifying the legality of parameters of an application system is provided, including: intercepting the parameter value of a parameter to be verified in the application system, where the parameter to be verified is a parameter in a specified method code block of the application system; obtaining the regular expression corresponding to the parameter to be verified from a regular expression database, where the regular expression is generated according to the method described above; performing parameter legality verification based on the intercepted parameter value and the obtained regular expression, where, in response to the intercepted parameter value matching the obtained regular expression, it is determined that the parameter to be verified is a legal parameter, and in response to the intercepted parameter value not matching the obtained regular expression, it is determined that the parameter to be verified is an illegal parameter.
[0015] According to another aspect of the embodiments of the present specification, a device for generating regular expressions for parameters of an application system is provided, including: a parameter value acquisition unit that acquires the parameter values of each parameter in each method code block from the historical application program implementation of the application system; a common information extraction unit that extracts common information from the corresponding parameter values for each parameter in each method code block; and a regular expression generation unit that generates corresponding regular expressions for each parameter in each method code block respectively according to the extracted common information.
[0016] Optionally, in an example of the above aspect, the common information extraction unit may include: a parameter category determination module that, for each parameter in each method code block, respectively performs parameter format parsing on the parameter value of the parameter to determine the parameter category of the parameter, and each parameter category corresponds to an information extraction method; and a common information extraction module that, for each parameter category of each parameter, adopts the information extraction method corresponding to the parameter category to extract the common information corresponding to the parameter category from the parameter values of the parameter having the parameter category.
[0017] Optionally, in an example of the above aspect, each parameter category has a corresponding template style, and the template style includes the composition of template information and the record format of each template information. For each parameter category of each parameter, the common information extraction module performs template extraction on the parameter values of the parameter having the parameter category according to the corresponding template style, and the template information in the extracted template style is used as the common information corresponding to the parameter category. For each template corresponding to each parameter in each method code block, the regular expression generation unit generates a corresponding regular expression according to the template information of the template.
[0018] Optionally, in an example of the above aspect, each parameter category has a corresponding regular expression generation method. For each template corresponding to each parameter in each method code block, the regular expression generation unit generates a corresponding regular expression according to the template information of the template in accordance with the regular expression generation method corresponding to the parameter category of the parameter.
[0019] Optionally, in an example of the above aspect, the parameter category includes a first category in which all parameter contents of the parameter value can be format-parsed, a second category in which all parameter contents of the parameter value cannot be format-parsed, and a third category in which some parameter contents of the parameter value can be format-parsed but some parameter contents cannot be format-parsed. In response to the determined parameter category being the first category, the common information extraction unit extracts common information from the parameter value having the first category in accordance with the information extraction method corresponding to the first category. In response to the determined parameter category being the second category, the common information extraction unit extracts common information from the parameter value having the second category in accordance with the information extraction method corresponding to the second category. In response to the determined parameter category being the third category, the common information extraction unit divides each parameter value having the third category of the parameter into a first parameter part having the first category of the parameter category and a second parameter part having the second category of the parameter category, and extracts common information from each first parameter part in accordance with the information extraction method corresponding to the first category, and extracts common information from each second parameter part in accordance with the information extraction method corresponding to the second category.
[0020] Optionally, in an example of the above aspect, the parameter category includes a first category in which all parameter contents of the parameter value can be parsed by a format, a second category in which all parameter contents of the parameter value cannot be parsed by the format, and a third category in which some parameter contents of the parameter value can be parsed by the format but some parameter contents cannot be parsed by the format. For a template whose corresponding parameter's parameter category is the first category, the regular expression generation unit generates a regular expression based on the template information of the template according to the regular expression generation method corresponding to the first category. For a template whose corresponding parameter's parameter category is the second category, the regular expression generation unit generates a regular expression based on the template information of the template according to the regular expression generation method corresponding to the second category. For a template whose corresponding parameter's parameter category is the third category, the regular expression generation unit generates a first regular expression based on the template information extracted according to the information extraction method corresponding to the first category in the template information of the template according to the regular expression generation method corresponding to the first category, generates a second regular expression based on the template information extracted according to the information extraction method corresponding to the second category in the template information of the template according to the regular expression generation method corresponding to the second category, and combines the obtained first regular expression and the second regular expression in pairs to obtain the regular expression corresponding to the template.
[0021] Optionally, in an example of the above aspect, the format parsing includes json format parsing. For a template whose corresponding parameter's parameter category is the second category, the regular expression generation unit uses a double-pointer access method to obtain a character value and a numeric value from the template information of the template, and generates a regular expression based on the obtained character value and numeric value according to the regular expression generation method corresponding to the second category.
[0022] Optionally, in an example of the above aspect, the apparatus may further include: a storage unit that stores the generated regular expression in a regular expression database in a manner associated with both the method code block and the parameter.
[0023] According to another aspect of the embodiments of the present specification, there is provided an apparatus for verifying the legality of parameters of an application system, including: a parameter value interception unit that intercepts the parameter value of a parameter to be verified in the application system, where the parameter to be verified is a parameter in a specified method code block in the application system; a regular expression acquisition unit that acquires the regular expression corresponding to the parameter to be verified from a regular expression database, where the regular expression is generated according to the method described above; a legality verification unit that performs parameter legality verification according to the intercepted parameter value and the acquired regular expression. Among them, in response to the intercepted parameter value matching the acquired regular expression, the legality verification unit determines that the parameter to be verified is a legal parameter, and in response to the intercepted parameter value not matching the acquired regular expression, the legality verification unit determines that the parameter to be verified is an illegal parameter.
[0024] According to another aspect of the embodiments of the present specification, there is provided a system for verifying the legality of parameters of an application system, including: the apparatus for generating a regular expression for a parameter of an application system as described above; a regular expression database that stores the generated regular expression in association with both a method code block and a parameter; and the apparatus for verifying the legality of parameters of an application system as described above.
[0025] According to another aspect of the embodiments of the present specification, there is provided an apparatus for generating a regular expression for a parameter of an application system, including: at least one processor, a memory coupled to the at least one processor, and a computer program stored in the memory, where the at least one processor executes the computer program to implement the method for generating a regular expression for a parameter of an application system as described above.
[0026] According to another aspect of the embodiments of the present specification, there is provided an apparatus for verifying the legality of parameters of an application system, including: at least one processor, a memory coupled to the at least one processor, and a computer program stored in the memory, where the at least one processor executes the computer program to implement the method for performing parameter legality verification on an application system as described above.
[0027] According to another aspect of the embodiments of the present specification, there is provided a computer-readable storage medium that stores executable instructions, and when the instructions are executed, a processor is caused to execute the method for generating a regular expression for a parameter of an application system as described above or execute the method for performing parameter legality verification on an application system as described above.
[0028] According to another aspect of the embodiments of the present specification, there is provided a computer program product including a computer program, which is executed by a processor to implement the method for generating a regular expression for parameters of an application system or the method for performing parameter legitimacy verification on an application system as described above. Description of the Drawings
[0029] By referring to the following drawings, a further understanding of the essence and advantages of the content of the present specification can be achieved. In the drawings, similar components or features may have the same reference numerals.
[0030] Figure 1 Fig. shows an exemplary block diagram of a parameter legitimacy verification system according to an embodiment of the present specification.
[0031] Figure 2 Fig. shows an exemplary flowchart of a regular expression generation process according to an embodiment of the present specification.
[0032] Figure 3 Fig. shows an exemplary schematic diagram of a method in the application program code implementation of an application system.
[0033] Figures 4A - 4F Fig. shows an exemplary schematic diagram of a parameter value according to an embodiment of the present specification.
[0034] Figure 5 Fig. shows an exemplary flowchart of a common information extraction process according to an embodiment of the present specification.
[0035] Figure 6 Fig. shows another exemplary flowchart of a common information extraction process according to an embodiment of the present specification.
[0036] Figure 7 Fig. shows an exemplary schematic diagram of a template style according to an embodiment of the present specification.
[0037] Figure 8 Fig. shows an exemplary schematic diagram of a regular expression generation process according to an embodiment of the present specification.
[0038] Figure 9 Fig. shows an exemplary flowchart of a parameter legitimacy verification method according to an embodiment of the present specification.
[0039] Figure 10 Fig. shows an exemplary block diagram of a regular expression generation device according to an embodiment of the present specification.
[0040] Figure 11 Fig. shows an exemplary block diagram of a common information extraction unit according to an embodiment of the present specification.
[0041] Figure 12Shows an example block diagram of a parameter legality verification device according to an embodiment of the present specification.
[0042] Figure 13 Shows an example schematic diagram of a regular expression generation device implemented based on a computer system according to an embodiment of the present specification.
[0043] Figure 14 Shows an example schematic diagram of a parameter legality verification device implemented based on a computer system according to an embodiment of the present specification. Detailed implementation manners
[0044] Now, the subject matter described herein will be discussed with reference to example embodiments. It should be understood that discussing these embodiments is only to enable those skilled in the art to better understand and thus implement the subject matter described herein, and is not a limitation on the protection scope, applicability, or examples set forth in the claims. The functions and arrangements of the elements discussed can be changed without departing from the protection scope of the content of this specification. Each example can omit, substitute, or add various processes or components as needed. For example, the described method can be executed in a different order than the described order, and each step can be added, omitted, or combined. Additionally, the features described relative to some examples can also be combined in other examples.
[0045] As used herein, the term "including" and its variants represent open terms, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" and "an embodiment" mean "at least one embodiment". The term "another embodiment" means "at least one other embodiment". The terms "first", "second", etc. can refer to different or the same objects. Other definitions, whether explicit or implicit, may be included below. Unless clearly specified in the context, the definition of a term is consistent throughout the specification.
[0046] In existing regular expression generation methods, the regular expressions used are directly generated based on the original data of the historical parameter configuration data of the parameters, and a regular expression is generated for each parameter configuration data. When the application system is applied to a business scenario, the number of parameters used is large, and the corresponding parameter content is diverse. In this case, if a regular expression is generated for each parameter configuration data of each parameter, the number of generated regular expressions will be very large, which is not conducive to later verification. Moreover, since the original data of the parameter configuration data is relatively long, the generated regular expressions will also be relatively long, resulting in an increase in the matching complexity when performing parameter legality verification.
[0047] In view of the above, embodiments of the present specification provide a regular expression generation scheme for parameters of an application system. Using this regular expression generation scheme, for each parameter in each method of the application system, common information can be extracted from the historical configuration data of the parameter, and a regular expression for the parameter can be generated based on the common information, rather than generating a regular expression for each piece of parameter configuration data of each parameter, thereby reducing the number of regular expressions corresponding to each parameter and shortening the length of the generated regular expressions, thus reducing the matching complexity during parameter legality verification.
[0048] Next, a parameter legality verification system, a regular expression generation method, and a parameter legality verification method and apparatus according to embodiments of the present specification will be described in detail with reference to the accompanying drawings.
[0049] Figure 1 FIG. shows an exemplary schematic diagram of a parameter legality verification system 100 according to an embodiment of the present specification. As Figure 1 shown, the parameter legality verification system 100 includes a regular expression generation device 110, a regular expression database 120, a parameter legality verification device 130, and a network 140.
[0050] The regular expression generation device 110 is configured to generate a set of regular expressions for the application system based on the parameter values of each parameter in each method implemented by the historical application program of the application system. In the generated set of regular expressions, one or more regular expressions can be generated for each parameter in each method. The generated set of regular expressions is stored in the regular expression database 120 in association with the application system. For example, each parameter in each method of the application system is assigned a unique parameter id, and the assigned parameter id can be, for example, application system id.interface id.methodid.parameter id. The regular expression corresponding to the parameter is stored in the regular expression database 120 in association with the parameter id of the parameter.
[0051] In some embodiments, the regular expression generation device 110 can be implemented as any type of electronic computing device. For example, the regular expression generation device 110 can be a desktop computer, a laptop computer, a tablet computer, a smart phone, etc.
[0052] In some embodiments, the regular expression database 120 can be deployed at a physical device different from the regular expression generation device 110. In some embodiments, the regular expression database 120 can also be integrated into the regular expression generation device 110.
[0053] The regular expression database 120 and the parameter legitimacy verification device 130 can be communicatively interconnected via the network 140. The network 140 can be any type of network capable of interconnecting network entities. The network 140 can be a single network or a combination of various networks. In terms of coverage, the network 140 can be a local area network (LAN), a wide area network (WAN), etc. In terms of the bearer medium, the network 140 can be a wired network, a wireless network, etc. In terms of data exchange technology, the network 140 can be a circuit-switched network, a packet-switched network, etc. It should be understood that Figure 1 all the network entities shown in
[0054] are exemplary, and according to specific application requirements, any other network entities may be involved in the parameter legitimacy verification system 100.
[0055] Figure 2 An example flowchart of the regular expression generation process 200 according to an embodiment of the present specification is shown.
[0056] As Figure 2 shown, at 210, the parameter values of the respective parameters in the respective method code blocks (methods) are obtained from the historical application implementations of the application system. In the present specification, the historical application implementations of the application system may refer to the application code implementations of the application system in various application scenarios or business scenarios. In the application code implementation of the application system, the application code is organized into different methods, and each method is used to implement a specific function or sub-function of the application system. When the application program runs, each method can implement the corresponding function or sub-function via the corresponding interface call. Each method can have one or more parameters, and in different historical application implementations, different parameter values can be assigned to the one or more parameters, thereby adapting to different application scenarios or business scenarios.
[0057] Figure 3 An example schematic diagram of a method in the application code implementation of the application system is shown. In Figure 3In the example, the name of the method is methodDemo, and the parameters it has are parameter a and parameter b, and parameters a and b are strings. The function executed by methodDemo is "System.out.println("Demo")", that is, to print "Demo". A unique parameter id can be assigned to each parameter in this method. In some embodiments, the parameter id can be uniquely characterized by using the application system name, method name, and parameter name. For example, the parameter id for parameter a can be assigned as: application system name.methodDemo.a. In some embodiments, when this method is called via a specific interface, the parameter id can be uniquely characterized by using the application system name, interface name, method name, and parameter name. For example, the parameter id for parameter a can be assigned as: application system name.interface name.methodDemo.a.
[0058] Each parameter of each method can be assigned a parameter value with various parameter formats and input via the corresponding interface when called. The parameter format of the parameter value can also be referred to as the presentation form of the parameter value. Figures 4A - 4F The figure shows a schematic diagram of an example of a parameter value according to an embodiment of this specification. In Figures 4A - 4F it, each row represents a parameter value of this parameter.
[0059] Figure 4A Each parameter value shown is composed of two key-value pairs. For example, it is composed of "a": "100" and "b": "200". Figure 4B Each parameter value shown is composed of 4 list elements, where the first three elements are strings, and the fourth element is composed of two key-value pairs. Figure 4C Each parameter value shown is composed of 3 parts with the same composition pattern, and the 3 parts are separated by commas. Figure 4D Each parameter value shown is assigned as N or Y. Figure 4E Each parameter value shown is composed of "character", "@", and "numerical value". Figure 4F Each parameter value shown has the same starting part "public".
[0060] After obtaining the parameter values of each parameter in each method, at 220, for each parameter in each method, common information is extracted from the corresponding parameter values respectively. In this specification, the common information may include, for example, a common pattern that can be abstracted based on the parameter values, the specific values or value types of each pattern element in the common pattern, the common part content of the parameter values, etc. Here, the term "pattern" may refer to the parameter composition style. For example, a common pattern (pattern) can be abstracted by tokenizing each parameter value, and the specific values or value types of each pattern element in the common pattern are obtained. In this specification, each specific value may be referred to as a unique value.
[0061] In some embodiments, when extracting common information, classification can be performed according to the parameter format of the parameter. Each parameter category corresponds to an information extraction method. Subsequently, for each parameter category of each parameter, the common information is extracted from all parameter values of the parameter having that parameter category according to the information extraction method corresponding to the parameter category.
[0062] Figure 5 An example flowchart of the common information extraction process 500 according to an embodiment of this specification is shown.
[0063] As Figure 5 shown, at 510, for each parameter in each method, the parameter format of the parameter value of the parameter is parsed respectively to determine the parameter category of the parameter. It should be noted that for each parameter, the above parameter category determination process needs to be performed for all parameter values of the parameter.
[0064] In some embodiments, examples of parameter categories may include but are not limited to: Struct category, Unstruct category, and Mixed category. The Struct type refers to the parameter category where all parameter contents of the parameter value can be format-parsed. In some embodiments, examples of format parsing may include json format parsing, that is, json format parsing can be performed on the parameter content of the parameter value. For example, the json.loads function in python can be used to perform conversion and parsing on the parameter content of the parameter value. The Unstruct category refers to the parameter category where all parameter contents of the parameter value cannot be format-parsed. For example, a parameter value that cannot be json-format-interpreted is considered to have the Unstruct category. The Mixed category refers to the parameter category where some parameter contents of the parameter value can be format-parsed and some parameter contents cannot be format-parsed. In this specification, the Struct category, Unstruct category, and Mixed category may also be referred to as the first category, the second category, and the third category respectively.
[0065] In some embodiments, the Struct category can be further subdivided into a dictionary format category and a list format category. The parameter content with a parameter value of dictionary format type can include multiple key-value pairs. The dictionary format category can include, for example, the json_large category. The parameter content of the parameter value of the json_large category has a json dictionary format. For example, Figure 4A the parameter value shown. The parameter content with a parameter value of list format category can include multiple elements listed in a list form. The list format category can include, for example, the json_middle category. The parameter content of the parameter value of the json_middle category has a json list format. For example, Figure 4B the parameter value shown.
[0066] In some embodiments, the Unstruct category can be further subdivided into the Self_similar category, the Enu category, the Pattern category, and the Common_Start category. The Self_similar category means that the parameter content of each parameter value of the parameter can be abstracted into multiple parts with the same pattern. For example, Figure 4C the parameter value shown has the Self_similar category. The parameter content of each parameter value of this parameter includes three components separated by commas, namely, today123, today234, today1234. Each component can be abstracted into the same pattern, that is, "character + numerical value". The Enu category means a parameter category in which the parameter content of the parameter value is all strings and the number of different unique values of the corresponding strings is lower than a predetermined threshold. For example, Figure 4D the parameter value shown is of the Enu category. In this parameter value, the unique values of the string are "N" and "Y", that is, two unique values. The Pattern category means a parameter category in which the parameter content of each parameter value of the parameter can be abstracted into a pattern. In the Pattern category, the parameter content of each parameter value cannot be divided into components that can be abstracted into the same pattern. For example, Figure 4E the parameter value shown is of the Pattern category. Each parameter value can be abstracted into the pattern of c@d, but the parameter content of each parameter value cannot be divided into components that can be abstracted into the same pattern. The Common_Start category means a parameter category in which the parameter content of the parameter value cannot be abstracted into a pattern but has the same starting part. For example, Figure 4F the parameter value shown in is of the Common_start category.
[0067] In some embodiments, each parameter may have one parameter category. In some embodiments, each parameter may have multiple parameter categories. For example, assume there are 100 parameter values for parameter A, among which the parameter category of 50 parameter values may be the Enu category, and the remaining 50 parameter values may be of the Pattern type. Then parameter A may have two parameter categories, namely, the Enu category and the Pattern category.
[0068] After determining the parameter categories of each parameter as above, at 520, for each parameter category of each parameter, the common information is extracted from the parameter values of the parameter with this parameter category by using the information extraction method corresponding to this parameter category. In the case where a parameter has multiple parameter categories, for each parameter category, the common information can be extracted from all the parameter values of the parameter with this parameter category according to the corresponding information extraction method. Thus, for each parameter category, the corresponding common information is extracted respectively, so that the parameter can have multiple pieces of common information. In the case where a parameter has one parameter category, the common information can be extracted from all the parameter values of the parameter according to the corresponding information extraction method.
[0069] Figure 6 Another example flowchart of the common information extraction process 600 according to an embodiment of the present specification is shown. In Figure 6 In the embodiment shown, the parameter categories include the Struct category, the Unstruct category, and the Mixed category, that is, Figure 6 the first category, the second category, and the third category shown in
[0070] As Figure 6 shown, at 610, for each parameter in each method, the parameter format of the parameter value of the parameter is parsed respectively to determine the parameter category of the parameter.
[0071] In response to the determined parameter category being the Struct category, at 620, the common information is extracted from the parameter value of the parameter according to the information extraction method (the first information extraction method) corresponding to the Struct category.
[0072] For example, if the parameter category is a dictionary format category, such as json_large, for each parameter, a pattern can be extracted from the keys of each key-value pair of all parameter values of the parameter. If there are the same patterns, the patterns are merged. In addition, for each pattern, the values that the keys corresponding to the pattern have are also extracted. If the number of unique values in the values of the keys corresponding to the pattern is lower than a predetermined threshold, the keys corresponding to the pattern are considered to be of the enumeration type, and all unique values of the corresponding keys are extracted. If the number of unique values in the values of the keys corresponding to the pattern is not lower than the predetermined threshold, the keys corresponding to the pattern are considered to be of the unrestricted type, and the value types of the corresponding keys are extracted, such as list type, dictionary type, numeric type, etc. In addition, the value types of the values in the key-value pairs corresponding to each pattern are also extracted. If there are multiple different value types in the value types of the keys or values in the extracted key-value pairs, the value type that can be downward compatible is selected as the extracted value type. Here, value type A being downward compatible with value type B means that the definition range of value type A can include the definition range of value type B. For example, if the extracted value types include character type and numeric type, the character type is selected as the extracted value type. In addition, the number (length) "dict_len" of the key-value pairs is extracted.
[0073] For example, for Figure 4A the parameter values shown in, the parameter category of this parameter is the json_large category, and all the keys in all parameter values can be abstracted into the same pattern, that is, {"c"}, where c represents a string. In addition, among all parameter values, the values corresponding to the key are 2 unique values, and the number is lower than the predetermined threshold (assuming the predetermined threshold is 5), so all the values "a" and "b" of the key are extracted. In addition, the value type of the value in the key-value pair is numeric type, and the number of key-value pairs dict_len is "2". Thus, for Figure 4A the parameter example in, the common information extracted includes the number of key-value pairs dict_len, that is, "2", the pattern corresponding to the key, that is, "c", the values of the keys corresponding to each pattern, that is, "a" and "b", and the value type of the value in the key-value pair, that is, "number".
[0074] If the parameter category is json_middle, for each element in each parameter, when extracting common information, determine whether the element is of the ordinary type or json_large. If it is json_large, extract the common information in the corresponding manner as described above for json_large. For ordinary elements, if the number of elements is lower than a predetermined threshold, the ordinary elements are considered enumeration elements, and thus the value values of all ordinary elements are extracted. If the number of elements is not lower than the predetermined threshold, the ordinary elements are determined to be non-enumeration type. In this case, the ordinary elements need to be tokenized to abstract the corresponding pattern and extract the pattern. For each pattern element in the extracted pattern, if the unique value corresponding to the pattern element is lower than the predetermined threshold, all the unique values corresponding to the pattern element are extracted. If the unique value corresponding to the pattern element is not lower than the predetermined threshold, the value type of the value corresponding to the pattern element is extracted. In addition, the number of elements included in the parameter value also needs to be extracted.
[0075] For example, for the parameter value shown in Figure 4B , the first three elements are strings, which are of the ordinary type, and the fourth element is of the json_large category consisting of two key-value pairs. Thus, the fourth element extracts the common information in the corresponding manner as described above for json_large. For the first three elements, since it is not lower than the predetermined threshold (assuming the predetermined threshold is 3), pattern extraction is required, and thus the common pattern, that is, {"cd"}, is extracted, where c represents a string and d represents a numerical value. In addition, the unique values corresponding to c are "today" and "yestoday", and the number thereof is lower than the predetermined threshold (assuming the predetermined threshold is 5), so all the values, that is, "today" and "yestoday", are extracted. The unique values corresponding to d are "123", "234", and "1234", and the number thereof is lower than the predetermined threshold 5, so all the unique values, that is, "123", "234", and "1234", are extracted. In addition, the number of elements, that is, 4, is also extracted. Thus, it can be seen that for the Figure 4B parameter example, for the json_large type element, the extracted common information may include the number of key-value pairs dict_len, that is, "2", the pattern corresponding to the key, that is, "c", the values of the keys corresponding to each pattern, that is, "a" and "b", and the value type of the value in the key-value pair, that is, "number". For the ordinary element, the extracted common information may include the pattern, the values of "c" and "d" in the pattern, and the number of elements in the parameter value.
[0076] In response to determining that the parameter category is the Unstruct category, at 630, according to the information extraction method (the second information extraction method) corresponding to the Unstruct category, common information is extracted from the parameter value of the parameter.
[0077] For example, if the parameter category is Self_similar, each element in the parameter value is tokenized, thereby abstracting a pattern, and the pattern is extracted. For each pattern element in the extracted pattern, if the unique value corresponding to the pattern element is lower than a predetermined threshold, all unique values corresponding to the pattern element are extracted. If the unique value corresponding to the pattern element is not lower than the predetermined threshold, the value type of the value corresponding to the pattern element is extracted. Additionally, optionally, the number of elements in the parameter value also needs to be extracted.
[0078] For example, in Figure 4C the example, each parameter value is "today123, today234, today1234", and its parameter category is Self_similar. For Figure 4C the example in, the parameter value is divided into three components, namely, "today123", "today234", and "today1234", and then each component is tokenized, thereby abstracting a pattern, namely, "cd", where c represents the character type and d represents the numerical type, and the pattern is extracted. For the pattern element "c" in the extracted pattern, the corresponding unique value is "today", and its quantity is lower than the predetermined threshold (assuming the predetermined threshold is 5), so all values, namely, "today", are extracted. For the pattern element "d" in the extracted pattern, the corresponding unique values are "123", "234", and "1234", and their quantity is lower than the predetermined threshold, so all unique values, namely, "123", "234", and "1234", are extracted. Additionally, optionally, the number of elements "3" in the parameter value also needs to be extracted.
[0079] If the parameter category is Enu, all possible parameter values of the parameter are extracted. For example, Figure 4D in the parameter shown in, the parameter category is Enu, so all parameter values, namely, "N / Y", are extracted. If the parameter category is Pattern, the parameter content of each parameter value is tokenized, thereby abstracting a pattern, and then the pattern and all possible values of each pattern element in the pattern are extracted. For example, Figure 4EThe parameter category of the parameters shown is the Pattern category. Tokenize the parameter content for each parameter value, thereby abstracting a pattern, that is, "c@d", where the value of c is "public", and the values of d are "123", "345", and "234".
[0080] If the parameter category is Common_start, for each parameter, extract the common starting part of all or most of the parameter values. For example, Figure 4F The parameter category of the parameters shown is Common_start, and the extracted common information includes the common starting part "public".
[0081] In response to determining that the parameter category is the Mixed category, at 640, divide the parameter value of the parameter into a first parameter part with a parameter category of Struct and a second parameter part with a parameter category of Unstruct. Subsequently, at 650, extract the common information (first common information) from the first parameter part according to the first information extraction method corresponding to the Struct category, and extract the common information (second common information) from the second parameter part according to the second information extraction method corresponding to the Unstruct category. The first common information and the second common information are used as the final common information.
[0082] In some embodiments, each parameter category may have a corresponding template style, for example, corresponding to one or more template styles. In this specification, the template style may include the composition of template information and the record format of each piece of template information.
[0083] Figure 7 Shows an example schematic diagram of a template style according to an embodiment of this specification. In Figure 7 the example, each row represents a template style.
[0084] In Figure 7 the first row of the template style is the template style corresponding to the json_large category. In this template style, the extracted template information includes the number of key-value pairs "dict_len", the pattern "key_pattern" corresponding to the key, and all possible values "key_value" of "key_pattern". For example, for Figure 4AAn example of the parameters shown, the number of key-value pairs is 2. The pattern corresponding to the key is "c", and all possible values of "c" are "a" and "b". The value type corresponding to the value in the key-value pair is "number". Thus, the resulting template is {'dict_len':{2},'key_pattern':[{'c':'number'}],'key_value':[[a,b]]}.
[0085] The second-line template style is the template style corresponding to the json_middle category. For Figure 4B the example of the parameters shown, the first three elements are of the ordinary type, corresponding to the latter half of the second-line template style, and the fourth element is in the json_large format, corresponding to the first half of the second-line template style, and the template information is extracted and recorded in the manner corresponding to the json_large category. Thus, the resulting template is {'element':[{'pattern':'cd','value':[[today,yestoday]:[123,234,1234]]}],'json_large':{'dict_len':{2},'key_pattern':[{'c':'number'}],'key_value':[[a,b]]},count:{4}}.
[0086] The third-line template style is the template style corresponding to the Enu category. In this template style, the extracted template information includes all possible values, and all the extracted possible values are recorded in the template in the form of list elements. For Figure 4D the example of the parameters shown, the resulting template is {'value':[N,Y]}.
[0087] The fourth-line template style is the template style corresponding to the Self_similar category. In this template style, the extracted template information includes the pattern (i.e., d), all possible values of the pattern elements in the pattern, and the number of elements included. For Figure 4C the example of the parameters shown, the resulting template is {'pattern':'cd','value':[[today],[123,234,1234]],count:{3}}, where the value of c is "today", the values of d are "123", "234", and "1234", and the number of elements is "3".
[0088] The template style of the fifth line corresponds to the Pattern category. In this template style, the extracted template information includes pattern (i.e., c@d), all possible values of c, and all possible values of d. For Figure 4D the parameter example shown, the resulting template is {'pattern': 'c@d', 'value': [[public], [123, 345, 234]]}, where the value of c is "today", and the values of d are "123", "234", and "1234".
[0089] The template style of the sixth line corresponds to the Common_start category. In this template style, the extracted template information includes the common start part. The extracted common start part is recorded as the only element of the template in the template. For Figure 4F the parameter example shown, the resulting template is {'common_start': 'public'}.
[0090] The template style can be generated in advance or generated in real time by analyzing the parameter values. In the case of having a template style, when extracting common information, for each parameter in each method, the template information required by the corresponding template style can be extracted from the parameter value of the parameter respectively as the common information of the parameter.
[0091] Returning to Figure 2 , after extracting the common information as above, at 230, for each parameter in each method code block, a corresponding regular expression is generated respectively according to the extracted common information. According to this regular expression generation method, the generated regular expression can reflect all the extracted common information. In some embodiments, a parameter can have multiple parameter categories. In this case, for each parameter category, a regular expression is generated respectively according to the corresponding extracted common information.
[0092] In some embodiments, for example, corresponding matching conditions can be generated for each template information, and the obtained matching conditions are concatenated using logical operators to generate a regular expression.
[0093] Figure 8 shows an example schematic diagram of the regular expression generation process according to an embodiment of the present specification. In Figure 8 the embodiment shown, the parameter categories include the Struct category, the Unstruct category, and the Mixed category, and each parameter category corresponds to one or more templates.
[0094] As Figure 8 shown, at 810, for each template, the parameter category corresponding to the template is determined.
[0095] In response to the parameter category corresponding to the template being the Struct category, at 820, a regular expression is generated based on the template information of the template in accordance with the regular expression generation method corresponding to the Struct category. For example, matching conditions are generated for each template information, and the obtained matching conditions are concatenated using logical operators, thereby generating a regular expression.
[0096] In response to the parameter category corresponding to the template being the Unstruct category, at 830, a regular expression is generated based on the template information of the template in accordance with the regular expression generation method corresponding to the Unstruct category. Specifically, a double-pointer access method is used to obtain character-type values and numeric-type values from the template information of the template. Then, a regular expression is generated based on the obtained character-type values and numeric-type values. For example, assume the template is {pattern: "c@d", value: [[public], [123, 345, 234]]}. Initially, the first pointer in the double pointer points to 'c' in 'c@d', and the second pointer points to the first element in the corresponding list of value, that is, [public], and then the template information in [public] is obtained. Then, the two pointers move to the right simultaneously, and the template information is obtained simultaneously to generate the corresponding regular expression. For example, the first pointer points to '@', and the second pointer stops moving. Subsequently, the first pointer points to 'd', and the second pointer points to '[123, 345, 234]', thereby obtaining the template information in [123, 345, 234].
[0097] In response to the parameter category of the parameter corresponding to the template being the Mixed category, at 840, a first regular expression is generated based on the template information (i.e., the first common information) extracted according to the information extraction method corresponding to the Struct category in the template information of the template in accordance with the regular expression generation method corresponding to the Struct category, and a second regular expression is generated based on the template information (the second common information) extracted according to the information extraction method corresponding to the Unstruct category in the template information of the template in accordance with the regular expression generation method corresponding to the Unstruct category. Then, at 850, the obtained first regular expression and second regular expression are combined pairwise, thereby obtaining the regular expression corresponding to the template.
[0098] It should be noted that in Figure 8 the example of, for each template, a regular expression is generated. The following takes the Figures 4A - 4F parameter example shown as an example to describe the extracted common information, the extracted template, and the generated regular expression.
[0099] For example, for Figure 4AIn the parameter example shown, among the extracted common information, the number of key-value pairs is 2. The pattern corresponding to the key is "c", all possible values of "c" are "a" and "b", and the value type corresponding to the value in the key-value pair is "number". Thus, the obtained template is {'dict_len':{2},'key_pattern':[{'c':'number'}],'key_value':[[a,b]]}, and then the regular expression "\{((a|b):[\d]+,?){2}}” is obtained.
[0100] For Figure 4B In the parameter example shown, for elements of the json_large type, the extracted common information may include the number of key-value pairs dict_len, that is, "2", the pattern corresponding to the key, that is, "c", the values of the keys corresponding to each pattern, that is, "a" and "b", and the value type of the value in the key-value pair, that is, "number". For ordinary elements, the extracted common information may include the pattern, that is, "cd", the values of "c" in the pattern, that is, "today" and "yestoday", the values of "d", that is, "123", "234" and "1234", and the number of elements in the parameter value, that is, "4". Thus, the template {'element':[{'pattern':'cd','value':[[today,yestoday]:[123,234,1234]]}],'json_large':{'dict_len':{2},'key_pattern':[{'c':'number'}],'key_value':[[a,b]]},count:{4}} is generated. Then, based on the template information in the above template, the regular expression "\[\{((((a|b):[\d]+,?){2}\},?)|((today|yestoday)([\d]{3,4},?){4}\]" is obtained.
[0101] For Figure 4C In the parameter example shown, in the extracted template information, the pattern is "cd", the value of c is "today", the values of d are "123", "234" and "1234", and the number of elements is "3". Thus, the obtained template is {'pattern':'cd','value':[[today],[123,234,1234]],count:{3}}, and then the regular expression ((today)[\d]+,?){3} is obtained.
[0102] ForFigure 4D For the parameter examples shown in Figure 4D , the common information extracted includes "N" and "Y", from which the corresponding template {'value':[N,Y]} is generated, and then the regular expression (N)|(Y) is generated.
[0103] For Figure 4E For the parameter examples shown in Figure 4E , in the extracted template information, the pattern is "c@d", the value of c is "today", the values of d are "123", "234" and "1234", and the number of elements is "3". Thus, the obtained template is {'pattern':'c@d','value':[[public],[123,345,234]} and the regular expression (public)\@[\d]+,?){3} is obtained.
[0104] For Figure 4F For the parameter examples shown in Figure 4F , the extracted template information includes "public". Thus, the obtained template is {'common_start':'public'} and the regular expression ^(public)[\w\W] * 。
[0105] Optionally, after generating the regular expressions for each parameter in each method of the application system as above, at 240, the generated regular expressions are stored in the regular expression database in a manner associated with both the method and the parameter. For example, for each parameter in each method, a unique parameter id can be assigned to it. The parameter id is used to uniquely identify each parameter in each method of the application system. For example, the parameter id can be represented as application system name.method name.parameter name, or application system name.interface name.method name.parameter name.
[0106] Using the above regular expression generation scheme, by extracting common information from the historical configuration data of the parameters and generating the regular expression for the parameter based on the common information, rather than generating one regular expression for each parameter configuration data of each parameter, the number of regular expressions corresponding to each parameter can be reduced, and at the same time, the length of the generated regular expression can be shortened, thereby reducing the matching complexity during parameter legality verification.
[0107] Using the above regular expression generation scheme, by parsing the parameter format of the parameter value to determine the parameter category and extracting the common information from the parameter value according to the information extraction method corresponding to the parameter category, the efficiency and accuracy of common information extraction can be improved.
[0108] Using the above regular expression generation scheme, by performing parameter format parsing on parameter values to determine parameter categories, and extracting common information from parameter values according to the template styles corresponding to the parameter categories, the efficiency and accuracy of common information extraction can be further improved.
[0109] Using the above regular expression generation scheme, by performing parameter format parsing on parameter values to determine parameter categories, and generating regular expressions according to the template information in the template in accordance with the regular expression generation method corresponding to the parameter category, the generation efficiency of regular expressions can be further improved.
[0110] After generating and storing the regular expressions as described above, parameter legality verification can be performed based on the generated regular expressions.
[0111] Figure 9 An example flowchart of a parameter legality verification method 900 according to an embodiment of the present specification is shown.
[0112] As Figure 9 shown, at 910, intercept the parameter value of the parameter to be verified in the application system, where the parameter to be verified is a parameter in a specified method in the application system. For example, the parameter value of the parameter to be verified in the application system can be intercepted using the message middleware SofaMQ. The above interception operation can be executed in response to a parameter debugging operation of the application system or an operation for parameter change or parameter reconfiguration of the application system. Alternatively, the above interception operation can be executed in response to a parameter legality verification request. The parameter id of the parameter to be verified is included in the parameter legality verification request.
[0113] At 920, obtain the regular expression corresponding to the parameter to be verified from the regular expression database. For example, the corresponding regular expression can be obtained from the regular expression database using the parameter id of the parameter to be verified, and the obtained regular expression can include one or more regular expressions.
[0114] Then, perform parameter legality verification according to the intercepted parameter value and the obtained regular expression. Specifically, at 930, determine whether the intercepted parameter value matches the obtained regular expression. In response to the intercepted parameter value matching the obtained regular expression, at 940, determine that the parameter to be verified is a legal parameter. In response to the intercepted parameter value not matching the obtained regular expression, at 950, determine that the parameter to be verified is an illegal parameter. Here, "matching" can also be referred to as "satisfying", that is, the element values of each element in the intercepted parameter value satisfy the corresponding judgment conditions in the regular expression.
[0115] Figure 10 An example block diagram of a regular expression generation device 1000 according to an embodiment of the present specification is shown. As Figure 10As shown, the regular expression generation device 1000 includes a parameter value acquisition unit 1010, a commonality information extraction unit 1020, and a regular expression generation unit 1030.
[0116] The parameter value acquisition unit 1010 is configured to obtain the parameter values of each parameter in each method code block from the historical application implementations of the application system. The operation of the parameter value acquisition unit 1010 can be referred to the operation described in 210 above with reference to Figure 2 hereof.
[0117] The commonality information extraction unit 1020 is configured to extract the commonality information from the corresponding parameter values respectively for each parameter in each method code block. The operation of the commonality information extraction unit 1020 can be referred to the operation described in 220 above with reference to Figure 2 hereof.
[0118] The regular expression generation unit 1030 is configured to generate the corresponding regular expressions respectively for each parameter in each method code block according to the extracted commonality information, and the generated regular expressions can reflect all the extracted commonality information. The operation of the regular expression generation unit 1030 can be referred to the operation described in 230 above with reference to Figure 2 hereof.
[0119] In addition, optionally, the regular expression generation device 1000 may include a storage unit 1040. The storage unit 1040 is configured to store the generated regular expressions in the regular expression database in a manner associated with both the method code block and the parameter.
[0120] Figure 11 Shows an example block diagram of the commonality information extraction unit 1100 according to an embodiment of the present specification. As Figure 11 shown, the commonality information extraction unit 1100 includes a parameter category determination module 1110 and a commonality information extraction module 1120.
[0121] The parameter category determination module 1110 is configured to perform parameter format parsing on the parameter values of each parameter in each method code block respectively to determine the parameter category of the parameter.
[0122] The commonality information extraction module 1120 is configured to adopt the information extraction method corresponding to the parameter category for each parameter category of each parameter, and extract the commonality information corresponding to the parameter category from the parameter values of the parameter having the parameter category.
[0123] In some embodiments, each parameter category has a corresponding template style, which includes the composition of template information and the record format of each piece of template information. For each parameter category of each parameter in each method code block, the common information extraction module 1120 extracts the parameter value with this parameter category according to the corresponding template style, and the template information in the extracted template style is used as the common information corresponding to this parameter category. Accordingly, for each template corresponding to each parameter in each method code block, the regular expression generation unit 1030 generates a corresponding regular expression according to the template information of this template.
[0124] In some embodiments, each parameter category has a corresponding regular expression generation method. Accordingly, for each template corresponding to each parameter in each method code block, the regular expression generation unit 1030 generates a corresponding regular expression according to the template information of this template in accordance with the regular expression generation method corresponding to the parameter category of this parameter.
[0125] In some embodiments, the parameter categories include the Struct category in which all parameter contents of the parameter value are format-parsed, the Unstruct category in which all parameter contents of the parameter value cannot be format-parsed, and the Mixed category in which some parameter contents of the parameter value can be format-parsed but some parameter contents are not format-parsed.
[0126] In response to the determined parameter category being the Struct category, the common information extraction unit 1020 extracts the common information from all parameter values with the Struct category of this parameter according to the information extraction method corresponding to the Struct category. In response to the determined parameter category being the Unstruct category, the common information extraction unit 1020 extracts the common information from all parameter values with the Unstruct category of this parameter according to the information extraction method corresponding to the Unstruct category. In response to the determined parameter category being the Mixed category, the common information extraction unit 1020 divides the parameter value with the Mixed category of this parameter into a first parameter part with the parameter category of the Struct category and a second parameter part with the parameter category of the Unstruct category, and extracts the common information from the first parameter part according to the information extraction method corresponding to the Struct category, and extracts the common information from the second parameter part according to the information extraction method corresponding to the Unstruct category.
[0127] In some embodiments, when there is a template corresponding to a parameter category, for a template whose parameter category corresponding to the parameter is of the Struct type, the regular expression generation unit 1030 generates a regular expression based on the template information of the template according to the regular expression generation method corresponding to the Struct type. For a template whose parameter category corresponding to the parameter is of the Unstruct type, the regular expression generation unit 1030 generates a regular expression based on the template information of the template according to the regular expression generation method corresponding to the Unstruct type. For a template whose parameter category corresponding to the parameter is of the Mixed type, the regular expression generation unit 1030 generates a first regular expression based on the template information extracted according to the information extraction method corresponding to the Struct type in the template information of the template according to the regular expression generation method corresponding to the Struct type, and generates a second regular expression based on the template information extracted according to the information extraction method corresponding to the Unstruct type in the template information of the template according to the regular expression generation method corresponding to the Unstruct type. Then, the regular expression generation unit 1030 combines the obtained first regular expression and the second regular expression in pairs to obtain the regular expression corresponding to the template.
[0128] In some embodiments, the format parsing includes json format parsing. Correspondingly, for a template whose parameter category corresponding to the parameter is of the Unstruct type, the regular expression generation unit 1030 uses a double-pointer access method to obtain character type values and numeric type values from the template information of the template, and generates a regular expression based on the obtained character type values and numeric type values according to the regular expression generation method corresponding to the Unstruct type.
[0129] Figure 12 FIG. shows an exemplary block diagram of a parameter legality verification device 1200 according to an embodiment of the present specification. As Figure 12 shown, the parameter legality verification device 1200 includes a parameter value interception unit 1210, a regular expression acquisition unit 1220, and a parameter legality verification unit 1230.
[0130] The parameter value interception unit 1210 is configured to intercept the parameter value of a parameter to be verified in an application system, and the parameter to be verified is a parameter in a specified method code block in the application system. The operation of the parameter value interception unit 1210 may refer to the operation described above with reference to Figure 9 910.
[0131] The regular expression acquisition unit 1220 is configured to obtain the regular expression corresponding to the parameter to be verified from a regular expression database. The operation of the regular expression acquisition unit 1220 may refer to the operation described above with reference to Figure 9 920.
[0132] The legality verification unit 1230 is configured to perform parameter legality verification based on the intercepted parameter value and the obtained regular expression. In response to the intercepted parameter value matching the obtained regular expression, the legality verification unit 1230 determines that the parameter to be verified is a legal parameter, and in response to the intercepted parameter value not matching the obtained regular expression, the legality verification unit 1230 determines that the parameter to be verified is an illegal parameter.
[0133] As described above with reference to Figures 1 to 12 , a regular expression generation method, a regular expression generation device, a parameter legality verification method, and a parameter legality verification device according to the embodiments of the present specification have been described. The above regular expression generation device and parameter legality verification device can be implemented in hardware, or can be implemented in software or a combination of hardware and software.
[0134] Figure 13 FIG. shows a schematic diagram of a regular expression generation device 1300 implemented based on a computer system according to an embodiment of the present specification. As Figure 13 shown, the regular expression generation device 1300 may include at least one processor 1310, a memory (e.g., a non-volatile memory) 1320, a memory 1330, and a communication interface 1340, and at least one processor 1310, the memory 1320, the memory 1330, and the communication interface 1340 are connected together via a bus 1360. At least one processor 1310 executes at least one computer-readable instruction stored or encoded in the memory (i.e., the above elements implemented in software form).
[0135] In one embodiment, computer-executable instructions are stored in the memory, which when executed cause at least one processor 1310 to: obtain the parameter values of the respective parameters in each method code block from the historical application implementations of the application system; extract the common information from the respective parameter values for each parameter in each method code block; and generate the corresponding regular expression for each parameter in each method code block according to the extracted common information.
[0136] It should be understood that the computer-executable instructions stored in the memory, when executed, cause at least one processor 1310 to perform the various operations and functions described above in the respective embodiments of the present specification in conjunction with Figures 1 - 12 the description.
[0137] Figure 14 FIG. shows a schematic diagram of a parameter legality verification device 1400 implemented based on a computer system according to an embodiment of the present specification. As Figure 14As shown, the parameter legality verification device 1400 may include at least one processor 1410, a memory (e.g., a non-volatile memory) 1420, an internal memory 1430, and a communication interface 1440, and the at least one processor 1410, the memory 1420, the internal memory 1430, and the communication interface 1440 are connected together via a bus 1460. The at least one processor 1410 executes at least one computer-readable instruction stored or encoded in the memory (i.e., the above elements implemented in software form).
[0138] In one embodiment, computer-executable instructions are stored in the memory, which when executed cause the at least one processor 1410 to: intercept the parameter value of the parameter to be verified in the application system, where the parameter to be verified is a parameter in a specified method code block in the application system; obtain the regular expression corresponding to the parameter to be verified from a regular expression database, where the regular expression is generated according to the method described above; perform parameter legality verification based on the intercepted parameter value and the obtained regular expression. Among them, in response to the intercepted parameter value matching the obtained regular expression, it is determined that the parameter to be verified is a legal parameter, and in response to the intercepted parameter value not matching the obtained regular expression, it is determined that the parameter to be verified is an illegal parameter.
[0139] It should be understood that the computer-executable instructions stored in the memory, when executed, cause the at least one processor 1410 to perform the various operations and functions described above in the respective embodiments of this specification in combination with Figures 1 - 12 the descriptions.
[0140] According to one embodiment, a program product such as a machine-readable medium (e.g., a non-transitory machine-readable medium) is provided. The machine-readable medium may have instructions (i.e., the above elements implemented in software form), which when executed by the machine, cause the machine to perform the various operations and functions described above in the respective embodiments of this specification in combination with Figures 1 - 12 the descriptions. Specifically, a system or device equipped with a readable storage medium may be provided, on which software program code for implementing the functions of any one of the above embodiments is stored, and cause the computer or processor of the system or device to read and execute the instructions stored in the readable storage medium.
[0141] In this case, the program code read from the readable medium itself can implement the functions of any one of the above embodiments, so the machine-readable code and the readable storage medium storing the machine-readable code constitute a part of the present invention.
[0142] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROM. Optionally, program code can be downloaded from a server computer or the cloud via a communication network.
[0143] According to one embodiment, there is provided a computer program product, which includes a computer program that, when executed by a processor, causes the processor to perform the various operations and functions described above in connection with the various embodiments of this specification. Figures 1 - 12 described various operations and functions.
[0144] Those skilled in the art should understand that various modifications and variations can be made to the above-disclosed embodiments without departing from the essence of the invention. Therefore, the protection scope of the present invention should be defined by the appended claims.
[0145] It should be noted that not all steps and units in the above-mentioned various processes and system structure diagrams are necessary, and some steps or units can be ignored according to actual needs. The execution order of each step is not fixed and can be determined as needed. The device structures described in the above various embodiments can be physical structures or logical structures. That is, some units may be implemented by the same physical entity, or some units may be implemented separately by multiple physical entities, or some components in multiple independent devices may be jointly implemented.
[0146] In the above various embodiments, the hardware units or modules can be implemented mechanically or electrically. For example, a hardware unit, module, or processor can include permanent dedicated circuits or logic (such as a dedicated processor, FPGA, or ASIC) to perform corresponding operations. The hardware unit or processor can also include programmable logic or circuits (such as a general-purpose processor or other programmable processors), which can be temporarily set by software to perform corresponding operations. The specific implementation method (mechanical method, or dedicated permanent circuit, or temporarily set circuit) can be determined based on cost and time considerations.
[0147] The specific embodiments described above in conjunction with the accompanying drawings describe exemplary embodiments, but do not represent all embodiments that can be implemented or fall within the scope of the claims. The term "exemplary" used throughout this specification means "serving as an example, instance, or illustration" and does not mean "preferred" or "advantageous" over other embodiments. For the purpose of providing an understanding of the described technology, the specific embodiments include specific details. However, the technology can be practiced without these specific details. In some instances, well-known structures and devices are shown in block diagram form in order to avoid obscuring the concepts of the described embodiments.
[0148] The foregoing description of the disclosure has been provided to enable any ordinary skill in the art to make or use the disclosure. Various modifications to the disclosure will be readily apparent to those of ordinary skill in the art, and the general principles defined herein may be applied to other variations without departing from the scope of the disclosure. Thus, the disclosure is not limited to the examples and designs described herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for generating regular expressions for parameters of an application system, comprising: Obtaining the parameter values of each parameter in each method code block from the historical application implementations of the application system; For each parameter in each method code block, respectively extracting the common information from the corresponding parameter values; And For each parameter in each method code block, respectively generating the corresponding regular expression according to the extracted common information.
2. The method according to claim 1, wherein, For each parameter in each method code block, respectively extracting the common information from the corresponding parameter values includes: For each parameter in each method code block, respectively performing parameter format parsing on the parameter value of the parameter to determine the parameter category of the parameter, and each parameter category corresponds to an information extraction method; and For each parameter category of each parameter, adopting the information extraction method corresponding to the parameter category, and extracting the common information corresponding to the parameter category from the parameter values of the parameter having the parameter category.
3. The method according to claim 2, wherein, Each parameter category has a corresponding template style, and the template style includes the composition of template information and the record format of each template information. For each parameter category of each parameter, adopting the information extraction method corresponding to the parameter category, and extracting the common information corresponding to the parameter category from the parameter values of the parameter having the parameter category includes: For each parameter category of each parameter, respectively performing template extraction on the parameter values of the parameter having the parameter category according to the corresponding template style, and the template information in the extracted template style is used as the common information corresponding to the parameter category. For each parameter in each method code block, respectively generating the corresponding regular expression according to the extracted common information includes: For each template corresponding to each parameter in each method code block, generating the corresponding regular expression according to the template information of the template.
4. The method according to claim 3, wherein, Each parameter category has a corresponding regular expression generation method. For each template corresponding to each parameter in each method code block, generating the corresponding regular expression according to the template information of the template includes: For each template corresponding to each parameter in each method code block, generating the corresponding regular expression according to the template information of the template in accordance with the regular expression generation method corresponding to the parameter category of the parameter.
5. The method according to claim 2, wherein, The parameter categories include a first category in which all parameter contents of the parameter value can be format-parsed, a second category in which all parameter contents of the parameter value cannot be format-parsed, and a third category in which some parameter contents of the parameter value can be format-parsed but some parameter contents cannot be format-parsed. For each parameter category of each parameter, adopting the information extraction method corresponding to the parameter category, and extracting the common information corresponding to the parameter category from the parameter values of the parameter having the parameter category includes: In response to the parameter category being the first category, extracting the common information from the parameter values of the parameter having the first category in accordance with the information extraction method corresponding to the first category. In response to the parameter category being the second category, extracting the common information from the parameter values of the parameter having the second category in accordance with the information extraction method corresponding to the second category. In response to determining that the parameter category is the third category, each parameter value having the third category of the parameter is divided into a first parameter part having the first category of the parameter and a second parameter part having the second category of the parameter, and common information is extracted from each first parameter part according to the information extraction method corresponding to the first category, and common information is extracted from each second parameter part according to the information extraction method corresponding to the second category.
6. The method according to claim 4, wherein, The parameter category includes a first category in which all parameter contents of the parameter value can be parsed in format, a second category in which all parameter contents of the parameter value cannot be parsed in format, and a third category in which some parameter contents of the parameter value can be parsed in format but some parameter contents cannot be parsed in format. For each template corresponding to each parameter in each method code block, generating a corresponding regular expression according to the regular expression generation method corresponding to the parameter category of the parameter based on the template information of the template includes: For a template whose parameter category corresponding to the parameter is the first category, generating a regular expression based on the template information of the template according to the regular expression generation method corresponding to the first category. For a template whose parameter category corresponding to the parameter is the second category, generating a regular expression based on the template information of the template according to the regular expression generation method corresponding to the second category. For a template whose parameter category corresponding to the parameter is the third category, generating a first regular expression based on the template information extracted according to the information extraction method corresponding to the first category in the template information of the template according to the regular expression generation method corresponding to the first category, generating a second regular expression based on the template information extracted according to the information extraction method corresponding to the second category in the template information of the template according to the regular expression generation method corresponding to the second category, and combining the obtained first regular expression and second regular expression in pairs to obtain the regular expression corresponding to the template.
7. The method according to claim 6, wherein The format parsing includes json format parsing. For a template whose parameter category corresponding to the parameter is the second category, generating a regular expression based on the template information of the template according to the regular expression generation method corresponding to the second category includes: For a template whose parameter category corresponding to the parameter is the second category, adopting a double-pointer access method to obtain a character value and a numeric value from the template information of the template, and Generating a regular expression based on the obtained character value and numeric value according to the regular expression generation method corresponding to the second category.
8. The method according to any one of claims 1 to 7, further comprising: Storing the generated regular expression in a regular expression database in a manner associated with both the method code block and the parameter.
9. A method for verifying the parameter legality of an application system, comprising: Intercepting the parameter value of the parameter to be verified in the application system, where the parameter to be verified is a parameter in a specified method code block of the application system; Obtain the regular expression corresponding to the parameter to be verified from the regular expression database, where the regular expression is generated according to the method described in claim 8; Perform parameter legality verification based on the intercepted parameter value and the obtained regular expression, wherein, in response to the intercepted parameter value matching the obtained regular expression, determine that the parameter to be verified is a legal parameter, and in response to the intercepted parameter value not matching the obtained regular expression, determine that the parameter to be verified is an illegal parameter.
10. An apparatus for generating regular expressions for parameters of an application system, comprising: A parameter value acquisition unit that acquires the parameter values of each parameter in each method code block from the historical application program implementation of the application system; A common information extraction unit that extracts common information from the corresponding parameter values for each parameter in each method code block; And A regular expression generation unit that generates corresponding regular expressions for each parameter in each method code block according to the extracted common information.
11. The device according to claim 10, wherein, The common information extraction unit includes: A parameter category determination module that, for each parameter in each method code block, respectively performs parameter format parsing on the parameter value of the parameter to determine the parameter category of the parameter, and each parameter category corresponds to an information extraction method; and A common information extraction module that, for each parameter category of each parameter, adopts the information extraction method corresponding to the parameter category to extract the common information corresponding to the parameter category from the parameter values of the parameter having the parameter category.
12. The device according to claim 11, wherein, Each parameter category has a corresponding template style, and the template style includes the composition of template information and the record format of each template information, For each parameter category of each parameter, the common information extraction module respectively performs template extraction on the parameter values of the parameter having the parameter category according to the corresponding template style, and the template information in the extracted template style is used as the common information corresponding to the parameter category, For each template corresponding to each parameter in each method code block, the regular expression generation unit generates a corresponding regular expression according to the template information of the template.
13. The device according to claim 12, wherein, Each parameter category has a corresponding regular expression generation method, For each template corresponding to each parameter in each method code block, the regular expression generation unit generates a corresponding regular expression according to the template information of the template according to the regular expression generation method corresponding to the parameter category of the parameter.
14. The device according to claim 11, wherein, The parameter category includes a first category in which all parameter contents of the parameter value can be format-parsed, a second category in which all parameter contents of the parameter value cannot be format-parsed, and a third category in which some parameter contents of the parameter value can be format-parsed but some parameter contents cannot be format-parsed, In response to the determined parameter category being the first category, the common information extraction unit extracts common information from the parameter values of the parameter having the first category according to the information extraction method corresponding to the first category, In response to determining that the parameter category is the second category, the common information extraction unit extracts common information from the parameter values with the second category of this parameter according to the information extraction method corresponding to the second category. In response to determining that the parameter category is the third category, the common information extraction unit divides each parameter value with the third category of this parameter into a first parameter part with the first category of parameter category and a second parameter part with the second category of parameter category, and extracts common information from each first parameter part according to the information extraction method corresponding to the first category, and extracts common information from each second parameter part according to the information extraction method corresponding to the second category.
15. The device according to claim 13, wherein, The parameter category includes a first category in which all parameter contents of the parameter value can be format-parsed, a second category in which all parameter contents of the parameter value cannot be format-parsed, and a third category in which some parameter contents of the parameter value can be format-parsed but some parameter contents cannot be format-parsed. For a template whose corresponding parameter category is the first category, the regular expression generation unit generates a regular expression based on the template information of this template according to the regular expression generation method corresponding to the first category. For a template whose corresponding parameter category is the second category, the regular expression generation unit generates a regular expression based on the template information of this template according to the regular expression generation method corresponding to the second category. For a template whose corresponding parameter category is the third category, the regular expression generation unit generates a first regular expression based on the template information extracted according to the information extraction method corresponding to the first category in the template information of this template according to the regular expression generation method corresponding to the first category, generates a second regular expression based on the template information extracted according to the information extraction method corresponding to the second category in the template information of this template according to the regular expression generation method corresponding to the second category, and combines the obtained first regular expression and second regular expression in pairs to obtain the regular expression corresponding to this template.
16. The device according to claim 15, wherein, The format parsing includes json format parsing. For a template whose corresponding parameter category is the second category, the regular expression generation unit uses a double-pointer access method to obtain character-type values and numeric-type values from the template information of this template, and generates a regular expression based on the obtained character-type values and numeric-type values according to the regular expression generation method corresponding to the second category.
17. The apparatus according to any one of claims 10 to 16, further comprising: A storage unit that stores the generated regular expression in a regular expression database in a manner associated with both the method code block and the parameter.
18. An apparatus for verifying the parameter legality of an application system, comprising: A parameter value interception unit that intercepts the parameter value of a parameter to be verified in the application system, where the parameter to be verified is a parameter in a specified method code block in the application system. A regular expression acquisition unit that acquires the regular expression corresponding to the parameter to be verified from a regular expression database, where the regular expression is generated according to the method described in claim 8; A legality verification unit that verifies the parameter legality according to the intercepted parameter value and the acquired regular expression, wherein, in response to the intercepted parameter value matching the acquired regular expression, the legality verification unit determines that the parameter to be verified is a legal parameter, and in response to the intercepted parameter value not matching the acquired regular expression, the legality verification unit determines that the parameter to be verified is an illegal parameter.
19. A system for verifying the legality of parameters in an application system, comprising: The device for generating regular expressions for the parameters of the application system according to any one of claims 10 to 17; A regular expression database that stores the generated regular expressions in association with both the method code block and the parameters; and The device for verifying the legality of parameters in the application system according to claim 18.
20. A device for generating regular expressions for the parameters of an application system, comprising: At least one processor, A memory coupled to the at least one processor, and A computer program stored in the memory, where the at least one processor executes the computer program to implement the method according to any one of claims 1 to 8.
21. A device for verifying the legality of parameters in an application system, comprising: At least one processor, A memory coupled to the at least one processor, and A computer program stored in the memory, where the at least one processor executes the computer program to implement the method according to claim 9.
22. A computer-readable storage medium that stores executable instructions, where the instructions, when executed, cause a processor to execute the method according to any one of claims 1 to 8 or execute the method according to claim 9.
23. A computer program product, comprising a computer program, where the computer program is executed by a processor to implement the method according to any one of claims 1 to 8 or execute the method according to claim 9.
Citation Information
Patent Citations
Regular expression generation method and device, computer device and storage medium
CN109766483A
Parameter verification method and device, computer equipment and storage medium
CN114003432A