Microservice configuration detection method, device, electronic device and readable storage medium
By inserting stubs at the target locations of microservices to collect configuration detection information, and combining data flow analysis to determine the usage scope of configuration items, the problem of false positives and negatives in microservice configuration detection is solved, and the accuracy and comprehensiveness of detection are improved.
Patent Information
- Application Number
- CN202210957687.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-10
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2042-08-10
AI Technical Summary
Existing microservice configuration detection solutions cannot comprehensively and accurately detect the configuration items of microservices, and are prone to false negatives and false positives. Moreover, the usage scope of custom configuration items is difficult to standardize, resulting in inaccurate matching results.
Perform instrumentation at the target location of the microservice, collect configuration detection information at the configuration initialization location and key service locations, determine the usage scope of the configuration items through data flow analysis, and perform configuration detection based on the configuration items and usage scope to avoid false positives and leaks. Report.
Through instrumentation, the actual configuration information of microservices during startup and operation is collected, and configuration items from different sources such as configuration files, configuration management centers, and startup parameters are fully and comprehensively detected to improve the accuracy and comprehensiveness of configuration detection and avoid misunderstandings. Reports and false negatives.
Smart Images

Figure CN115292128B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure belongs to the field of network security technology, and specifically relates to a microservice configuration detection method, device, electronic device and readable storage medium. Background Art
[0002] Configuration files are used to configure parameters or perform initial settings for different systems, programs, and applications to support the operation of systems, programs, and applications. Therefore, it is crucial to test configuration files to ensure the security of system, program, and application configurations and the normal operation of services. Currently, the configuration file to be tested is usually obtained directly according to the file path or detection command, and then the configuration file is parsed to obtain all the configuration items in the configuration file, and then the configuration items are matched based on the preset blacklist or scanning rules, and the detection results of the configuration items are determined based on the matching results, thereby realizing configuration detection.
[0003] Microservice is a service architecture that can divide a single application into multiple loosely coupled and independently deployable services. Each service runs in an independent process, and different services communicate with each other using lightweight communication mechanisms to coordinate and cooperate. Microservices may use default configurations or manage configurations through configuration management center components, so that their related configurations are not recorded in the configuration files. In the current detection scheme, it is impossible to fully and comprehensively implement the configuration detection of microservices, and there may be problems of missed reports; and there are large differences between the configuration files of microservices and the configuration items of actual applications. For example, when a microservice is started, startup parameters can be added to cover the configuration items of the configuration file, which may lead to inadequate inspection of configuration items similar to startup parameters, resulting in problems of missed reports and false reports; in addition, there are custom configuration items in the configuration files of microservices, and the scope of use of custom configuration items is difficult to standardize, which makes the matching results inaccurate, and there may be problems of missed reports and false reports. Summary of the invention
[0004] The purpose of the embodiments of the present disclosure is to provide a microservice configuration detection method, device, electronic device and readable storage medium, which can solve the problems of underreporting and false alarms in the current configuration detection scheme for microservices and improve the comprehensiveness and accuracy of microservice configuration detection.
[0005] In order to solve the above technical problems, the present disclosure is implemented as follows:
[0006] In a first aspect, the present disclosure provides a microservice configuration detection method, which may include: inserting a pile at a target location of a microservice, the target location includes a configuration initialization location and a service key location, the configuration initialization location records the configuration items initialized by the microservice during the startup process, and the service key location records the usage method of the microservice to interact with external services for data; during the startup process of the microservice, collecting configuration detection information at the target location based on the pile; and performing configuration detection on the microservice according to the configuration detection information.
[0007] Optionally, the configuration detection information includes configuration items collected from the configuration initialization location and the usage method call chain collected from the service key location. The microservice is configured to be detected based on the configuration detection information, including: performing data flow analysis on the configuration items based on the usage method call chain to determine the usage scope of the configuration items; and performing configuration detection on the microservice based on the configuration items and the usage scope.
[0008] Optionally, data flow analysis is performed on the configuration item according to the usage method call chain to determine the usage scope of the configuration item, including: determining the configuration value acquisition method of the usage method call chain through data flow analysis; matching the configuration value acquisition method of the usage method call chain with the configuration item to determine the usage scope corresponding to the configuration item.
[0009] Optionally, the configuration value acquisition method of the usage method call chain is matched with the configuration item to determine the usage scope corresponding to the configuration item, including: matching the configuration value acquisition method of the usage method call chain with the configuration item to determine the configuration value acquisition method that matches the configuration item; determining the usage method corresponding to the configuration item based on the matched configuration value acquisition method; and determining the usage scope corresponding to the configuration item based on an external service that interacts with the usage method for data.
[0010] Optionally, the configuration value acquisition method of the usage method call chain is matched with the configuration item to determine the usage scope corresponding to the configuration item, including: matching the configuration value acquisition method of the usage method call chain with the configuration item, and when the configuration item does not match the configuration value acquisition method of each usage method call chain, determining that the usage scope of the configuration item is internal service.
[0011] Optionally, configuration detection is performed on the microservice according to the configuration items and the usage scope, including: obtaining configuration detection rules corresponding to the usage scope; and detecting the configuration items corresponding to each usage scope based on the configuration detection rules.
[0012] Optionally, inserting a stub at a target location of a microservice includes: determining a target variable and a configuration assignment method and a configuration value acquisition method corresponding to the target variable according to annotations in the microservice; determining a configuration initialization location according to the locations of the configuration assignment method and the configuration value acquisition method; determining a usage method for interacting with an external service in the microservice; determining a service key location according to the location of the usage method for interacting with an external service; and inserting a stub at the configuration initialization location and the service key location.
[0013] In the second aspect, the present disclosure also provides a microservice configuration detection device, which may include: an insertion module, which is used to insert a pile at the target location of the microservice, the target location includes a configuration initialization location and a service key location, the configuration initialization location records the configuration items initialized by the microservice during the startup process, and the service key location records the usage method of the microservice to interact with external services for data; a collection module, which is used to collect configuration detection information at the target location based on the insertion pile during the startup process of the microservice; and a detection module, which is used to perform configuration detection on the microservice according to the configuration detection information.
[0014] Optionally, the configuration detection information includes configuration items collected from the configuration initialization location and the usage method call chain collected from the service key location. The detection module includes: a data analysis submodule, which performs data flow analysis on the configuration items according to the usage method call chain to determine the usage scope of the configuration items; and a configuration detection submodule, which is used to perform configuration detection on the microservice according to the configuration items and the usage scope.
[0015] Optionally, the data analysis submodule includes a configuration value acquisition method analysis unit, which determines the configuration value acquisition method using the method call chain through data flow analysis; and a configuration item matching unit, which is used to match the configuration value acquisition method using the method call chain with the configuration item to determine the usage scope corresponding to the configuration item.
[0016] Optionally, the configuration item matching unit is specifically used to match the configuration value acquisition method of the usage method call chain with the configuration item, determine the configuration value acquisition method that matches the configuration item; determine the usage method corresponding to the configuration item based on the matched configuration value acquisition method; and determine the usage scope corresponding to the configuration item based on the external service that interacts with the usage method for data.
[0017] Optionally, the configuration item matching unit is further used to match the configuration value acquisition method of the usage method call chain with the configuration item, and when the configuration item does not match the configuration value acquisition method of each usage method call chain, determine that the usage scope of the configuration item is internal service.
[0018] Optionally, the detection module includes: a detection rule acquisition submodule, used to acquire configuration detection rules corresponding to the usage scope; and a configuration item detection submodule, used to detect the configuration items corresponding to each usage scope based on the configuration detection rules.
[0019] Optionally, the insertion module includes: a target variable determination submodule, which is used to determine the target variable and the configuration assignment method and configuration value acquisition method corresponding to the target variable according to the annotation in the microservice; a configuration initialization position determination submodule, which is used to determine the configuration initialization position according to the position of the configuration assignment method and the configuration value acquisition method; an external service interaction method determination submodule, which is used to determine the usage method for interacting with the external service in the microservice; a service key position determination submodule, which is used to determine the service key position according to the position of the usage method for interacting with the external service; and an insertion submodule, which is used to insert piles at the configuration initialization position and the service key position.
[0020] In a third aspect, the present disclosure provides an electronic device, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the microservice configuration detection method of the first aspect.
[0021] In a fourth aspect, the present disclosure provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the microservice configuration detection method of the first aspect are implemented.
[0022] In a fifth aspect, the present disclosure provides a chip, comprising a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run a program or instruction to implement the steps of the microservice configuration detection method of the first aspect.
[0023] In a sixth aspect, the present disclosure provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the steps of implementing the microservice configuration detection method of the first aspect.
[0024] In the microservice configuration detection method provided in the present disclosure, a pile is inserted at the target location of the microservice, and configuration detection information is collected at the target location based on the pile during the startup process of the microservice, so as to perform configuration detection on the microservice according to the configuration detection information, wherein the target location includes a configuration initialization location and a service key location, the configuration initialization location records the configuration items initialized by the microservice during the startup process, and the service key location records the usage method of the microservice and the external service for data interaction. The above scheme collects the configuration detection information of the configuration initialization location and the service key location by inserting a pile at the target location of the microservice, so as to collect the configuration detection information of the configuration initialization location and the service key location, so as to collect the configuration detection information actually applied by the microservice during the startup and operation process, so as to fully and comprehensively collect the configuration items from different sources such as the configuration file, the configuration management center, and the startup parameters, so as to avoid the problems of false positives and false negatives in the configuration detection; and by collecting the usage method of the microservice and the external service data interaction at the service key location, the role of the relevant configuration items in the operation of the microservice can be determined, so as to improve the accuracy of the configuration item detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 One of the step flow charts of the microservice configuration detection method provided in the embodiment of the present disclosure;
[0026] Figure 2 The second step flow chart of the microservice configuration detection method provided in the embodiment of the present disclosure;
[0027] Figure 3 A configuration example diagram of a database configuration class provided in an embodiment of the present disclosure;
[0028] Figure 4 A flowchart of the steps for determining the usage scope of a configuration item provided in an embodiment of the present disclosure;
[0029] Figure 5 A flowchart of the steps for performing configuration detection on microservices provided in an embodiment of the present disclosure;
[0030] Figure 6 A schematic diagram of the structure of a microservice configuration detection device provided in an embodiment of the present disclosure;
[0031] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure;
[0032] Figure 8 A hardware schematic diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0034] The terms "first", "second", etc. in the specification and claims of the present disclosure are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable when appropriate, so that the embodiments of the present disclosure can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0035] The microservice configuration detection provided by the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0036] Figure 1 This is one of the step flow charts of the microservice configuration detection method provided in the embodiment of the present disclosure. Figure 1 As shown, the method may include the following steps 101 to 103.
[0037] Step 101, insert a stub at the target location of the microservice, the target location includes a configuration initialization location and a service key location, the configuration initialization location records the configuration items initialized during the startup process of the microservice, and the service key location records the usage method of data interaction between the microservice and the external service.
[0038] Among them, the instrumentation can be to insert a probe at a target location in the code of the microservice on the basis of ensuring the logical integrity of the microservice, so as to add the collection logic of configuration information detection in the microservice, and the information collected by the instrumentation can be methods, configuration values, etc. The instrumentation can be implemented by inserting or overwriting the code for collecting configuration detection information at a target location in the code of the microservice, such as by compiling the instrumentation by modifying the bytecode.
[0039] In the disclosed embodiment, the target location may include a configuration initialization location and a service key location in the microservice, wherein configuration initialization may refer to initialization of configuration items according to configuration values from different sources during the startup process of the microservice, and the configuration initialization location may be a location recording the initialization of configuration items during the startup process of the microservice, and the configuration initialization location includes configuration items from different sources for configuring the microservice, such as configuration files, startup parameters, and a configuration management center, etc.; the method is an encapsulated code block that revolves around the implementation of a specific function, and the service key location records the usage method of the microservice to interact with an external service, and the interaction may include making a request to an external service, or responding to a request from an external service.
[0040] Step 102: During the startup of the microservice, configuration detection information is collected at the target location based on the instrumentation.
[0041] Among them, during the startup process of the microservice, the initialization configuration can be performed according to the configuration values from different sources, and different usage methods can be called to interact with external services. At this time, configuration detection information can be collected at the target location of the microservice based on the plug-in. The configuration detection information refers to information related to configuration item detection, which may include configuration values, data interactions related to configuration items, etc. The configuration item detection information includes the configuration items actually applied in the microservice. Moreover, when the source of the configuration item, the configuration value, etc. change, the initialization settings, usage method calls, etc. will be further configured to change, thereby changing the collected configuration detection information, and also improving the initiative of configuration detection.
[0042] Step 103: Perform configuration detection on the microservice according to the configuration detection information.
[0043] Among them, after collecting the configuration detection information, the configuration detection information can be used to perform configuration detection on the microservice. Through the configuration detection information, the setting status and function of the configuration items during the startup and operation of the microservice can be fully determined. On this basis, the rule conditions that the configuration items should meet can be determined according to the requirements of the microservice operation status, configuration security and other directions, and the configuration detection information can be further analyzed and matched based on the rule conditions to determine whether the configuration items during the startup and operation of the microservice meet the application requirements, so as to achieve comprehensive and accurate configuration detection of the microservice.
[0044] In the microservice configuration detection method provided in the present disclosure, a pile is inserted at the target location of the microservice, and configuration detection information is collected at the target location based on the pile during the startup process of the microservice, so as to perform configuration detection on the microservice according to the configuration detection information, wherein the target location includes a configuration initialization location and a service key location, the configuration initialization location records the configuration items initialized by the microservice during the startup process, and the service key location records the usage method of the microservice and the external service for data interaction. The above scheme collects the configuration detection information of the configuration initialization location and the service key location by inserting a pile at the target location of the microservice, so as to collect the configuration detection information of the configuration initialization location and the service key location, so as to collect the configuration detection information actually applied by the microservice during the startup and operation process, so as to fully and comprehensively collect the configuration items from different sources such as the configuration file, the configuration management center, and the startup parameters, so as to avoid the problems of false positives and false negatives in the configuration detection, and by collecting the usage method of the microservice and the external service data interaction at the service key location, the role of the relevant configuration items in the operation of the microservice can be determined, and the accuracy of the configuration item detection can be improved.
[0045] Figure 2 This is a second flow chart of the steps of the microservice configuration detection method provided in the embodiment of the present disclosure. Figure 2 As shown, the method may include the following steps 201 to 216.
[0046] Step 201: Determine the target variable, and the configuration assignment method and configuration value acquisition method corresponding to the target variable in the microservice according to the annotation.
[0047] Step 202: Determine the configuration initialization location according to the locations of the configuration assignment method and the configuration value acquisition method, and the configuration initialization location records the configuration items initialized during the startup process of the microservice.
[0048] Among them, annotations are marks for the code in microservices, which can be declared before packages, classes, fields, methods, local variables, method parameters, etc., to explain and annotate the aforementioned elements. Therefore, the annotations in microservices can be used to determine the target variables that are initialized and set according to the configuration items from different sources when the microservice is started. Then, the configuration assignment method and configuration value acquisition method can be determined based on the target variable. The configuration assignment method is used to assign the target variable based on the configuration value, and the configuration value acquisition method is used to obtain the configuration value.
[0049] In the embodiment of the present disclosure, the configuration initialization location of the microservice can be determined according to the location of the configuration assignment method and the configuration value acquisition method. During the microservice startup process, the method at this location assigns the target variable according to the configuration items from different sources.
[0050] For example, in the microservice, determine the target variables declared by the annotations @ConfigurationProperties and @Value("${}"), and the target variables with the above annotations will generate the get method (configuration value acquisition method) and the set method (configuration assignment method) in the class (bytecode) file. Therefore, after determining the target variable, you can further determine the configuration assignment method and configuration value acquisition method corresponding to the target variable, and use the location of the configuration assignment method and configuration value acquisition method in the microservice as the configuration initialization location.
[0051] Step 203: Determine the method of using the microservice to interact with the external service.
[0052] Step 204: Determine the service key location according to the location of the usage method for interacting with the external service. The service key location records the usage method for data interaction between the microservice and the external service.
[0053] Among them, during the process of starting and running the microservice, the method called to interact with the external service can be determined as the usage method, and the external service can be other microservices, applications, etc. other than the microservice, such as a database, and the interaction between the microservice and the external service can be a request, response, and connection, etc. On this basis, the usage method can include a code block that implements the above interaction process, such as a connect method for a database.
[0054] In the embodiments of the present disclosure, the key position of the service in the microservice can be determined according to the position of the usage method for interacting with the external service. During the startup and operation of the microservice, the usage method at this position implements interactive behaviors such as request, response or connection with the external service.
[0055] Step 205: insert stubs at the configuration initialization location and the service key location.
[0056] In the embodiment of the present disclosure, step 205 may correspond to the relevant description of the aforementioned step 101, and will not be described again here to avoid repetition.
[0057] For example, taking Java as an example, before the microservice starts loading, the bytecode at the configuration initialization location and the service key location in the class file can be modified through the Java agent to add logic for collecting configuration detection information at the configuration initialization location and the service key location, thereby implementing the plugging of the configuration initialization location and the service key location.
[0058] Step 206: During the startup of the microservice, configuration detection information is collected at the target location based on the instrumentation.
[0059] In the embodiment of the present disclosure, step 206 may correspond to the relevant description of the aforementioned step 102, and will not be described again here to avoid repetition.
[0060] In a method embodiment of the present disclosure, the configuration detection information includes configuration items collected from a configuration initialization location and a usage method call chain collected from a service key location.
[0061] Among them, during the startup and operation of the microservice, the configuration assignment method of the target variable will be called to initialize the value of the target variable. At this time, based on the plug-in at the configuration initialization location, the configuration items related to the target variable can be collected. The configuration items may include the variable name, configuration name, configuration value, the class name where the variable is located, the get method name, and the set method name, etc.
[0062] Figure 3 The configuration example diagram of the database configuration class provided in the embodiment of the present disclosure is as follows: Figure 3 As shown, the configuration items collected from the configuration initialization location are as follows:
[0063] Configuration name: spring.datasource.username
[0064] Configuration value: the actual variable value used
[0065] Variable name: username
[0066] Class name: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties
[0067] get method: String getUsername()
[0068] set method: void setUsername(String username)
[0069] Also, during the startup and operation of a microservice, it is usually necessary to interact with external services, such as MySQL (relational database management system), Redis (Remote Dictionary Server) and other databases, and relevant configuration items will be applied during the interaction. In the disclosed embodiment, by inserting the usage method applied to the relevant configuration items at the key position of the service, the microservice can collect the call chain of the usage method being called during the interaction with the external service, including the configuration value acquisition method, the method passed, and the method of using the configuration item, etc. The call chain includes the get method of the configuration item, which can trace the source of the configuration item during the call process.
[0070] Step 207: Perform data flow analysis on the configuration item according to the usage method call chain to determine the usage scope of the configuration item.
[0071] Among them, the scope of use can be the interactive objects related to the configuration item. For example, the scope of use of the configuration item in the method application for interacting with MySQL can be MySQL, and the scope of use of the configuration item in the method application for interacting with Redis can be Redis. By using the method call chain to perform data flow analysis on the configuration items actually applied by the microservice, the scope of use of each configuration item can be determined to avoid missed reports and false reports.
[0072] In a method embodiment of the present disclosure, a flowchart of the steps of determining the usage scope of the configuration item in step 207 is also provided, such as Figure 4 As shown, the following steps 401 to 402 may be included.
[0073] Step 401: Determine the configuration value acquisition method using the method call chain through data flow analysis;
[0074] Step 402: Match the configuration value acquisition method of the usage method call chain with the configuration item to determine the usage scope corresponding to the configuration item.
[0075] Among them, the configuration value acquisition method can also be the get method of the configuration variable, the configuration variable introduction point, etc. By analyzing the data volume of the usage method call chain, the source related to the configuration item can be traced back. Since the variable value of each configuration item is obtained through the get method, the configuration value acquisition method of the usage method call chain can be determined, and the configuration value acquisition method can include the class name, method name, and parameter type, etc. At this time, since the configuration item is collected and acquired at the configuration initialization position, the initialization position is determined according to the location of the configuration value acquisition method and the configuration assignment method, the configuration value acquisition method of the usage method call chain can be matched with the configuration item to determine the corresponding usage scope of the configuration item.
[0076] In a method embodiment of the present disclosure, step 402 may include the following steps S11 to S13.
[0077] Step S11: Match the configuration value acquisition method using the method call chain with the configuration item to determine the configuration value acquisition method that matches the configuration item.
[0078] Step S12: Determine the usage method corresponding to the configuration item according to the matched configuration value acquisition method.
[0079] Step S13: Determine the usage scope corresponding to the configuration item according to the external service that interacts with the usage method.
[0080] Among them, after matching the class name, method name and other information of the configuration item acquisition method with the configuration item information and determining the configuration value acquisition method that matches the configuration item, since the configuration value acquisition method is obtained by analyzing the usage method call chain data, the usage method corresponding to the configuration item on the call chain can be further determined. If the usage method interacts with the external service during the startup and operation of the microservice, the usage scope of the configuration item can be determined based on the interaction object of the usage method.
[0081] In a method embodiment of the present disclosure, step 402 may further include the following step S14.
[0082] Step S14: Match the configuration value acquisition method of the usage method call chain with the configuration item. If the configuration item does not match the configuration value acquisition method of each usage method call chain, determine that the usage scope of the configuration item is internal service.
[0083] Among them, when the configuration value acquisition method and the configuration item do not match, it means that the configuration item is not used in the method of interaction between microservices and external services. It can be considered that the configuration item is customized by the developer during the development process and used within the microservice. It does not interact with external services, and the scope of use of the configuration item is internal services. By distinguishing the configuration items of internal services and external services, it can effectively avoid the problem of misreporting or missing of customized configurations in matching the configuration items in the configuration file with the black and white lists in the existing configuration detection, thereby improving the accuracy of configuration detection.
[0084] In the disclosed embodiment, the configuration items can also be classified according to the scope of use, such as the configuration items can be classified into external services, internal services, etc., or further classified into MySQL classification and Redis classification according to different interactive objects. Configuration items of different classifications can also be merged into different collections, such as putting configuration items into MySQL collection, Redis collection, and internal service collection according to the scope of use, so as to analyze, manage and subsequently process the configuration items.
[0085] Step 208: Perform configuration detection on the microservice according to the configuration items and usage scope.
[0086] Among them, since the requirements for operation and security may be different in different usage scopes, the configuration detection of microservices to adapt to different requirements can be performed according to the configuration items and usage scopes. The specific detection process can refer to the relevant description of the aforementioned step 103. To avoid repetition, it will not be repeated here.
[0087] In a method embodiment of the present disclosure, a flowchart of the steps of performing configuration detection on the microservice in step 208 is also provided, such as Figure 5 As shown, the following steps 501 to 502 may be included.
[0088] Step 501: Obtain configuration detection rules corresponding to the usage scope.
[0089] Step 502: Detect the configuration items corresponding to each usage scope based on the configuration detection rule.
[0090] Among them, the corresponding configuration detection rules can be set according to the operation and security requirements of configuration items with different usage scopes during the startup and operation of the microservice. For example, for the login service, the configuration detection rules may include the default user name, password composition complexity, whether remote control is enabled, etc. On this basis, in the configuration detection process, the corresponding configuration detection rules can be obtained according to the usage scope of the configuration item, and then the detection result corresponding to the configuration item can be obtained according to the configuration detection rules.
[0091] In a method embodiment of the present disclosure, a configuration detection engine can be used to implement the process from step 207 to step 208. By writing the data volume analysis logic of the call chain used in the configuration detection engine, the configuration item usage scope classification logic, and the configuration item detection logic based on the applicable scope, etc., the collected configuration items and the usage method call chain can be automatically analyzed and detected based on the configuration detection engine. For example, the usage method can be pre-associated with the corresponding interactive external service through the configuration detection engine. After matching the configuration item corresponding to the usage method, the configuration detection engine can determine the usage scope corresponding to the configuration item based on the association relationship, thereby realizing the classification of the configuration item.
[0092] It should be noted that the data obtained in this disclosure, including microservices, configuration items, usage method call chains and other data, are accessed, collected, stored and used for subsequent analysis and processing with the consent and authorization of the user or the relevant data owner after the user or the relevant data owner is clearly informed of the data collection content, data purpose, processing method and other information, and the user or the relevant data owner can be provided with ways to access, correct and delete the data, as well as methods to revoke consent and authorization.
[0093] In the microservice configuration detection method provided by the present invention, a stub is inserted at a target location of a microservice, and configuration detection information is collected at the target location based on the stub during the startup of the microservice, so as to perform configuration detection on the microservice according to the configuration detection information, wherein the target location includes a configuration initialization location and a service key location, the configuration initialization location records the configuration items initialized by the microservice during the startup process, and the service key location records the usage method of data interaction between the microservice and an external service. The above scheme collects configuration detection information of the configuration initialization position and the key position of the service by inserting piles at the target position of the microservice, so as to collect the configuration detection information of different sources actually applied by the microservice during startup and operation, so as to fully and comprehensively collect configuration items from different sources such as configuration files, configuration management centers, and startup parameters, expand the detection scope of configuration items, and avoid the problems of false positives and false negatives in configuration detection; by collecting the usage method of microservice and external service data interaction at the key position of the service, the role of related configuration items in the operation of the microservice can be determined to determine the specific usage scope of the configuration items, and the configuration items can be targeted according to the security configuration requirements of different usage scopes. Based on the usage scope, internal services and external services are distinguished, and the false positive problem caused by matching configuration items by using black and white list matching is avoided, thereby improving the accuracy of configuration item detection; and because when the source and configuration value of the configuration item change, the initialization settings and usage method calls will be further configured, thereby changing the collected configuration detection information, and improving the initiative of configuration detection.
[0094] Figure 6 This is one of the structural diagrams of the microservice configuration detection device 600 provided in the embodiment of the present disclosure, such as Figure 6 As shown in , a microservice configuration detection device 600 may include an insertion module 601, which is used to insert a pile at a target location of a microservice, the target location includes a configuration initialization location and a service key location, the configuration initialization location records the configuration items initialized by the microservice during the startup process, and the service key location records the usage method of the microservice to interact with external services for data; a collection module 602, which is used to collect configuration detection information at the target location based on the insertion pile during the startup process of the microservice; and a detection module 603, which is used to perform configuration detection on the microservice according to the configuration detection information.
[0095] In an apparatus embodiment of the present disclosure, the configuration detection information includes configuration items collected from the configuration initialization location and the usage method call chain collected from the service key location. The detection module 603 includes: a data analysis submodule, which performs data flow analysis on the configuration items according to the usage method call chain to determine the usage scope of the configuration items; and a configuration detection submodule, which is used to perform configuration detection on the microservice according to the configuration items and the usage scope.
[0096] In an embodiment of a device disclosed herein, a data analysis submodule includes a configuration value acquisition method analysis unit, which determines the configuration value acquisition method using the method call chain through data flow analysis; and a configuration item matching unit, which is used to match the configuration value acquisition method using the method call chain with the configuration item to determine the usage scope corresponding to the configuration item.
[0097] In an embodiment of a device disclosed herein, a configuration item matching unit is specifically used to match a configuration value acquisition method of a usage method call chain with a configuration item, and determine a configuration value acquisition method that matches the configuration item; determine a usage method corresponding to the configuration item based on the matched configuration value acquisition method; and determine a usage scope corresponding to the configuration item based on an external service that interacts with the usage method for data.
[0098] In an apparatus embodiment of the present disclosure, the configuration item matching unit is also used to match the configuration value acquisition method of the usage method call chain with the configuration item. When the configuration item does not match the configuration value acquisition method of each usage method call chain, the usage scope of the configuration item is determined to be an internal service.
[0099] In an apparatus embodiment of the present disclosure, the detection module 603 includes: a detection rule acquisition submodule for acquiring a configuration detection rule corresponding to a usage scope; and a configuration item detection submodule for detecting a configuration item corresponding to each usage scope based on the configuration detection rule.
[0100] In an apparatus embodiment of the present disclosure, the insertion module 601 includes: a target variable determination submodule, which is used to determine the target variable and the configuration assignment method and configuration value acquisition method corresponding to the target variable in the microservice according to the annotation; a configuration initialization position determination submodule, which is used to determine the configuration initialization position according to the position of the configuration assignment method and the configuration value acquisition method; an external service interaction method determination submodule, which is used to determine the usage method for interacting with the external service in the microservice; a service key position determination submodule, which is used to determine the service key position according to the position of the usage method for interacting with the external service; and an insertion submodule, which is used to insert piles at the configuration initialization position and the service key position.
[0101] In the microservice configuration detection device provided by the present invention, a plug-in is performed at a target location of a microservice, and configuration detection information is collected at the target location based on the plug-in during the startup of the microservice, so as to perform configuration detection on the microservice according to the configuration detection information, wherein the target location includes a configuration initialization location and a service key location, the configuration initialization location records the configuration items initialized by the microservice during the startup process, and the service key location records the usage method of the microservice for data interaction with an external service. The above scheme collects configuration detection information of the configuration initialization position and the key position of the service by inserting piles at the target position of the microservice, so as to collect the configuration detection information of different sources actually applied by the microservice during startup and operation, so as to fully and comprehensively collect configuration items from different sources such as configuration files, configuration management centers, and startup parameters, expand the detection scope of configuration items, and avoid the problems of false positives and false negatives in configuration detection; by collecting the usage method of microservice and external service data interaction at the key position of the service, the role of related configuration items in the operation of the microservice can be determined to determine the specific usage scope of the configuration items, and the configuration items can be targeted according to the security configuration requirements of different usage scopes. Based on the usage scope, internal services and external services are distinguished, and the false positive problem caused by matching configuration items by using black and white list matching is avoided, thereby improving the accuracy of configuration item detection; and because when the source and configuration value of the configuration item change, the initialization settings and usage method calls will be further configured, thereby changing the collected configuration detection information, and improving the initiative of configuration detection.
[0102] The microservice configuration detection device provided by the embodiment of the present disclosure can achieve Figures 1 to 5 To avoid repetition, the various processes implemented in the method embodiment will not be described again here.
[0103] Figure 7 A schematic diagram of the structure of an electronic device 700 provided in an embodiment of the present disclosure is shown in FIG. Figure 7 As shown, the electronic device 700 may include a processor 701, a memory 702, and a program or instruction stored in the memory 702 and executable on the processor 701. When the program or instruction is executed by the processor 701, each process of the above-mentioned microservice configuration detection embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0104] It should be noted that Figure 7 The electronic device 700 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0105] Figure 8 A hardware schematic diagram of an electronic device 800 provided in an embodiment of the present disclosure is shown in FIG. Figure 8As shown, the electronic device 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to the program stored in ROM (Read Only Memory) 802 or the program loaded from the storage part 808 to RAM (Random Access Memory) 803. In RAM 803, various programs and data required for system operation are also stored. CPU 801, ROM 802 and RAM 803 are connected to each other through bus 804. I / O (Input / Output) interface 805 is also connected to bus 804.
[0106] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a CRT (Cathode Ray Tube), an LCD (Liquid Crystal Display), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed so that a computer program read therefrom is installed into the storage section 808 as needed.
[0107] In particular, according to an embodiment of the present disclosure, the process described below with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 809, and / or installed from a removable medium 811. When the computer program is executed by a central processing unit (CPU801), various functions defined in the system of the present application are executed.
[0108] The embodiments of the present disclosure also provide a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned microservice configuration detection embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0109] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as ROM, RAM, magnetic disk or optical disk.
[0110] The disclosed embodiment further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned microservice configuration detection embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0111] It should be understood that the chip mentioned in the embodiments of the present disclosure may also be referred to as a system-level chip, a system chip, a chip system, or a system-on-chip chip, etc.
[0112] The embodiments of the present disclosure provide a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps of the microservice configuration detection as described above, and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0113] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises one..." does not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the method and device in the embodiments of the present disclosure is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0114] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present disclosure, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, an electronic device, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present disclosure.
[0115] The embodiments of the present disclosure are described above in conjunction with the accompanying drawings, but the present disclosure is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present disclosure, ordinary technicians in this field can also make many forms without departing from the scope of protection of the purpose of the present disclosure and the claims, all of which are within the protection of the present disclosure.
Claims
1. A microservice configuration detection method, It is characterized in that The method comprises: Insert a stub at a target location of a microservice, wherein the target location includes a configuration initialization location and a service key location, wherein the configuration initialization location records the configuration items initialized during the startup of the microservice, and the service key location records the usage method of data interaction between the microservice and an external service; During the startup of the microservice, collecting configuration detection information at the target location based on the plugging; Performing configuration detection on the microservice according to the configuration detection information; The inserting of the microservice at the target location includes: Determine the target variable in the microservice according to the annotation, as well as the configuration assignment method and configuration value acquisition method corresponding to the target variable; Determining the configuration initialization position according to the positions of the configuration assignment method and the configuration value acquisition method; Determining, in the microservice, a method for interacting with an external service; Determine the key location of the service according to the location of the usage method for interacting with the external service; Insert stubs at the configuration initialization location and the service key location.
2. The method according to claim 1, It is characterized in that The configuration detection information includes configuration items collected from the configuration initialization position and a usage method call chain collected from the key position of the service. The configuration detection of the microservice according to the configuration detection information includes: Performing data flow analysis on the configuration item according to the usage method call chain to determine the usage scope of the configuration item; A configuration check is performed on the microservice according to the configuration item and the usage scope.
3. The method according to claim 2, It is characterized in that The performing data flow analysis on the configuration item according to the usage method call chain to determine the usage scope of the configuration item includes: Determine the configuration value acquisition method of the usage method call chain through data flow analysis; The configuration value acquisition method of the usage method call chain is matched with the configuration item to determine the usage scope corresponding to the configuration item.
4. The method according to claim 3, It is characterized in that The method for obtaining the configuration value of the usage method call chain is matched with the configuration item to determine the usage scope corresponding to the configuration item, including: Matching the configuration value acquisition method of the usage method call chain with the configuration item, and determining the configuration value acquisition method that matches the configuration item; Determining the usage method matched by the configuration item according to the matched configuration value acquisition method; The usage scope corresponding to the configuration item is determined according to the external service that interacts with the usage method.
5. The method according to claim 3, It is characterized in that The method for obtaining the configuration value of the usage method call chain is matched with the configuration item to determine the usage scope corresponding to the configuration item, including: The configuration value acquisition method of the usage method call chain is matched with the configuration item, and when the configuration item does not match the configuration value acquisition method of each usage method call chain, it is determined that the usage scope of the configuration item is an internal service.
6. The method according to claim 2, It is characterized in that The performing configuration detection on the microservice according to the configuration item and the usage scope includes: Obtaining configuration detection rules corresponding to the usage scope; The configuration item corresponding to each usage scope is detected based on the configuration detection rule.
7. A microservice configuration detection device, It is characterized in that The device comprises: An instrumentation module is used to perform instrumentation at a target location of a microservice, wherein the target location includes a configuration initialization location and a service key location, wherein the configuration initialization location records configuration items initialized during the startup of the microservice, and the service key location records the usage method of data interaction between the microservice and an external service; A collection module, used for collecting configuration detection information at the target location based on the plugging during the startup of the microservice; A detection module, used to perform configuration detection on the microservice according to the configuration detection information; The plugging module includes: The target variable determination submodule is used to determine the target variable according to the annotation in the microservice, as well as the configuration assignment method and configuration value acquisition method corresponding to the target variable; A configuration initialization position determination submodule is used to determine the configuration initialization position according to the positions of the configuration assignment method and the configuration value acquisition method; The external service interaction method determination submodule is used to determine the method of interaction with external services in the microservice; The service key position determination submodule is used to determine the service key position according to the location of the usage method for interacting with external services; the stub insertion submodule is used to insert stubs at the configuration initialization location and the service key position.
8. An electronic device, It is characterized in that The invention comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the microservice configuration detection method as claimed in any one of claims 1 to 6.
9. A readable storage medium, It is characterized in that The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the microservice configuration detection method according to any one of claims 1 to 6 is implemented.
