A method and device for generating a detection toolkit

By generating detection toolkits, we solve the problem of low image and container detection efficiency, provide standardized and reusable detection functions, improve detection efficiency and security, and ensure the stable operation of images and containers.

CN118245386BActive Publication Date: 2024-08-23BEIJING CHAITIN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410673992.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2024-08-23
Estimated Expiration
2044-05-28

AI Technical Summary

Technical Problem

The existing technology lacks an effective detection toolkit, resulting in low detection efficiency of images and containers, making it difficult to detect potential problems and risks, and affecting security.

Method used

By obtaining the operating instructions and behaviors of images and containers, defining and encapsulating detection interfaces and functions, creating access interfaces, generating detection toolkits, providing standardized and reusable detection functions, simplifying the detection process and improving security.

Benefits of technology

It improves the detection efficiency and security of images and containers, can detect potential problems and risks in a timely manner, and ensures the stable operation of images and containers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118245386B
    Figure CN118245386B
Patent Text Reader

Abstract

The embodiment of the present application provides a detection toolkit generation method and device, obtains a first interface defining an image operation instruction, a second interface defining an image operation behavior, a third interface defining a container operation instruction, and a fourth interface defining a container operation behavior; encapsulates the first interface and the first detection function to obtain a first data structure, encapsulates the second interface and the second detection function to obtain a second data structure, encapsulates the third interface and the third detection function corresponding to the third interface to obtain a third data structure, encapsulates the fourth interface and the fourth detection function corresponding to the fourth interface to obtain a fourth data structure; creates an access interface for the fifth data structure; stores the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in a file, packages the file, and generates a detection toolkit for images and containers. The embodiment of the present application is conducive to improving the detection efficiency of images and containers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application belong to the field of Internet technology, and in particular, relate to a method and device for generating a detection toolkit. Background Art

[0002] With the rapid development of science and technology, images and containers have become indispensable tools in modern software development, testing and deployment. Images and containers greatly simplify the deployment and management process of applications by providing a lightweight, portable and efficient operating environment.

[0003] However, the lack of a detection toolkit for images and containers is not conducive to improving the detection efficiency of images and containers. Therefore, how to generate a detection toolkit for images and containers is an urgent problem to be solved. Summary of the invention

[0004] The embodiments of the present application provide a detection toolkit generation method and device to solve the above-mentioned technical problem of how to generate detection toolkits for images and containers.

[0005] In a first aspect, an embodiment of the present application provides a detection toolkit generation method, which is applied to an electronic device, and the detection toolkit generation method includes:

[0006] Obtain image operation instructions and image operation behaviors of the image, and obtain container operation instructions and container operation behaviors of the container;

[0007] Acquire a first interface defining the image operation instruction, a second interface defining the image operation behavior, a third interface defining the container operation instruction, and a fourth interface defining the container operation behavior;

[0008] Encapsulate the first interface and a first detection function corresponding to the first interface to obtain a first data structure, encapsulate the second interface and a second detection function corresponding to the second interface to obtain a second data structure, encapsulate the third interface and a third detection function corresponding to the third interface to obtain a third data structure, and encapsulate the fourth interface and a fourth detection function corresponding to the fourth interface to obtain a fourth data structure;

[0009] Encapsulate the calling functions corresponding to the first data structure, the second data structure, the third data structure, and the fourth data structure, respectively, to obtain a fifth data structure, and create an access interface for the fifth data structure;

[0010] The access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function are stored in a file, and the file is packaged to generate a detection toolkit for the image and the container.

[0011] The beneficial effects of the embodiments of the present application lie in two aspects. On the one hand, the access interface, the first detection function, the second detection function, the third detection function and the fourth detection function are stored in a file, and the file is packaged to generate a detection toolkit for the image and the container. The detection toolkit provides a standardized access interface and reusable first detection function, second detection function, third detection function and fourth detection function, which can simplify the detection process of the image and the container and is beneficial to improving the detection efficiency of the image and the container. On the other hand, the detection toolkit for the image and the container is highly targeted to the image and the container, and can detect potential problems or risks of the image and the container, thereby helping to improve the security of the image and the container.

[0012] In a possible implementation manner of the first aspect, the obtaining of an image operation instruction and an image operation behavior of an image, and the obtaining of a container operation instruction and a container operation behavior of a container include:

[0013] Obtain first configuration information and second configuration information of the cloud native platform;

[0014] The image operation instruction and the image operation behavior of the image are obtained in the first configuration information, and the container operation instruction and the container operation behavior of the container are obtained in the second configuration information.

[0015] In an embodiment of the present application, the image operation instructions and image operation behaviors of the image are obtained in the first configuration information, and the container operation instructions and container operation behaviors of the container are obtained in the second configuration information, which can ensure that the image operation instructions, image operation behaviors, container operation instructions and container operation behaviors all comply with the specifications of the cloud native platform.

[0016] In a possible implementation manner of the first aspect, encapsulating the calling functions corresponding to the first data structure, the second data structure, the third data structure, and the fourth data structure to obtain a fifth data structure, and creating an access interface for the fifth data structure includes:

[0017] Encapsulate the calling functions corresponding to the first data structure, the second data structure, the third data structure and the fourth data structure respectively to obtain a fifth data structure;

[0018] An interaction statement corresponding to the fifth data structure is obtained, and the access interface of the fifth data structure is created based on the interaction statement.

[0019] In the embodiment of the present application, access to the first data structure, the second data structure, the third data structure and the fourth data structure can be achieved through the access interface of the fifth data structure, thereby greatly simplifying the operation process and improving work efficiency.

[0020] In a possible implementation manner of the first aspect, storing the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in one file, packaging the file, and generating a detection toolkit for the image and the container includes:

[0021] Using a preset test case to test the access interface and obtain the test result of the access interface;

[0022] When the test result is a preset result, the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function are stored in a file, and the file is packaged to generate a detection toolkit for the image and the container.

[0023] In the embodiment of the present application, when the test result is a preset result, it indicates that the effect of the access interface meets expectations, which is helpful to ensure the reliability of the access interface.

[0024] In a possible implementation manner of the first aspect, using a preset test case to test the access interface and obtaining a test result of the access interface includes:

[0025] Display a list of test cases, and obtain a specified operation in the list of test cases;

[0026] According to the specified operation, the test case specified by the user is obtained in the test case list, the access interface is tested using the test case specified by the user, and the test result of the access interface is obtained.

[0027] In an embodiment of the present application, the test case specified by the user is used to test the access interface and obtain the test result of the access interface, which can save test time, improve test efficiency, and meet the user's customized needs.

[0028] In a possible implementation manner of the first aspect, after storing the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in a file, packaging the file, and generating a detection toolkit for the image and the container, the detection toolkit generation method includes:

[0029] Constructing a detection rule based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in the detection toolkit;

[0030] The current information of the image or the container is obtained, the current information is input into the detection rule, and the detection result output by the detection rule based on the current information is obtained.

[0031] In an embodiment of the present application, the current information is input into the detection rule, and the detection result output by the detection rule based on the current information is obtained. The detection rule can realize automatic detection, save detection time, and is conducive to improving the efficiency and accuracy of detection.

[0032] In a possible implementation manner of the first aspect, the constructing a detection rule based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in the detection toolkit includes:

[0033] Obtain a first detection object of the image, where the first detection object is a sensitive file of the image, and construct the detection rule corresponding to the first detection object based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function;

[0034] Alternatively, a second detection object of the container is obtained, where the second detection object is a sensitive file of the container, and the detection rule corresponding to the second detection object is constructed based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function;

[0035] Alternatively, a first detection scope of the image is obtained, where the first detection scope includes one of a single image, a group of images, and an image cluster, or a combination thereof, and the detection rule corresponding to the first detection scope is constructed based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function;

[0036] Alternatively, a second detection scope of the container is obtained, where the second detection scope includes a single container, a group of containers, a container cluster, or a combination thereof, and the detection rule corresponding to the second detection scope is constructed based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function.

[0037] In the embodiments of the present application, by constructing detection rules and reusing existing detection rules, the process of repeatedly writing and configuring detection rules can be avoided, thereby saving a lot of time and energy, which makes the detection work more efficient and is conducive to improving the stability and security of images and containers.

[0038] In a possible implementation manner of the first aspect, obtaining current information of the image or the container, inputting the current information into the detection rule, and obtaining a detection result output by the detection rule based on the current information includes:

[0039] Read the preset detection time and determine whether the current time is the detection time;

[0040] If the current time is the detection time, current information of the image or the container is obtained, the current information is input into the detection rule, and a detection result output by the detection rule based on the current information is obtained.

[0041] In the embodiment of the present application, problems with the current information can be discovered in a timely manner through the detection results, and the stable operation of the image and the container can be guaranteed by repairing the problems.

[0042] In a possible implementation manner of the first aspect, after obtaining the current information of the image or the container, inputting the current information into the detection rule, and obtaining the detection result output by the detection rule based on the current information, the detection toolkit generation method includes:

[0043] Obtain a push instruction for the detection result, execute the push instruction, and push the detection result to a monitoring system corresponding to the image or the container.

[0044] In an embodiment of the present application, the detection result is pushed to the monitoring system corresponding to the image or the container, so that the monitoring system can provide valuable detection results. The detection results can help developers better understand the operating status of the image or the container, thereby formulating more effective detection strategies.

[0045] In a second aspect, an embodiment of the present application provides a detection toolkit generation device, including:

[0046] A first acquisition module is used to acquire image operation instructions and image operation behaviors of an image, and to acquire container operation instructions and container operation behaviors of a container;

[0047] A second acquisition module is used to acquire a first interface defining the image operation instruction, a second interface defining the image operation behavior, a third interface defining the container operation instruction, and a fourth interface defining the container operation behavior;

[0048] A first encapsulation module is used to encapsulate the first interface and a first detection function corresponding to the first interface to obtain a first data structure, encapsulate the second interface and a second detection function corresponding to the second interface to obtain a second data structure, encapsulate the third interface and a third detection function corresponding to the third interface to obtain a third data structure, and encapsulate the fourth interface and a fourth detection function corresponding to the fourth interface to obtain a fourth data structure;

[0049] A second encapsulation module is used to encapsulate the calling functions corresponding to the first data structure, the second data structure, the third data structure and the fourth data structure, obtain a fifth data structure, and create an access interface for the fifth data structure;

[0050] A generation module is used to store the access interface, the first detection function, the second detection function, the third detection function and the fourth detection function in a file, package the file, and generate a detection toolkit for the image and the container.

[0051] The beneficial effects of the embodiments of the present application lie in two aspects. On the one hand, the access interface, the first detection function, the second detection function, the third detection function and the fourth detection function are stored in a file, and the file is packaged to generate a detection toolkit for the image and the container. The detection toolkit provides a standardized access interface and reusable first detection function, second detection function, third detection function and fourth detection function, which can simplify the detection process of the image and the container and is beneficial to improving the detection efficiency of the image and the container. On the other hand, the detection toolkit for the image and the container is highly targeted to the image and the container, and can detect potential problems or risks of the image and the container, thereby helping to improve the security of the image and the container. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. Some specific embodiments of the present application will be described in detail in an illustrative and non-restrictive manner with reference to the drawings. The same reference numerals in the drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the drawings:

[0053] Figure 1 is a flow chart of a method for generating a detection tool kit provided in an embodiment of the present application;

[0054] Figure 2This is a flowchart of detecting an image provided by an embodiment of the present application;

[0055] Figure 3 A flow chart of a detection container provided in an embodiment of the present application;

[0056] Figure 4 A schematic block diagram of a detection tool kit generating device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0057] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present application.

[0058] The detection toolkit generation method provided in the embodiment of the present application can be applied to electronic devices such as servers, mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), etc. The embodiment of the present application does not impose any restrictions on the specific types of electronic devices.

[0059] Figure 1 is a flow chart of a method for generating a detection tool kit provided in an embodiment of the present application, such as Figure 1 As shown, the detection tool kit generation method provided in the embodiment of the present application includes the following steps, which are described in detail as follows:

[0060] S101, obtaining an image operation instruction and an image operation behavior of an image, and obtaining a container operation instruction and a container operation behavior of a container;

[0061] Among them, the image operation instructions, image operation behaviors, container operation instructions and container operation behaviors are set by the user or by system default and are not restricted here.

[0062] The image operation instructions refer to instructions used to manage and operate images.

[0063] For ease of explanation, the mirror operation instructions mainly include the following:

[0064] The image pull command is a command used to pull an image;

[0065] The image search command is a command used to search for a specified image;

[0066] The image list command is a command used to list the locally downloaded images.

[0067] The image view command is a command used to list and view detailed information of an image.

[0068] The mirror operation behavior is the behavior of executing the mirror operation instruction.

[0069] For ease of explanation, the mirroring operations mainly include the following:

[0070] The image pull behavior is the behavior of executing the image pull instruction;

[0071] The mirror search behavior is the behavior of executing the mirror search instruction;

[0072] The image listing behavior is the behavior of executing the image listing instruction.

[0073] The image viewing behavior is the behavior of executing the image viewing instruction. Among them, the container operation instruction refers to the instruction used to manage and operate the container.

[0074] For ease of explanation, the container operation instructions mainly include the following:

[0075] The container run instruction is an instruction used to start a container;

[0076] The container stop instruction is an instruction used to stop a running container;

[0077] The container delete command is a command used to delete a container.

[0078] The container operation behavior refers to the behavior of actually executing the container operation instruction.

[0079] For ease of explanation, container operations mainly include the following:

[0080] The container running behavior is the behavior of executing the container running instructions;

[0081] The container stop behavior is the behavior of executing the container stop instruction;

[0082] The container deletion behavior is the behavior of executing the container deletion instruction. Among them, the image operation instruction and image operation behavior of the image are obtained, and the container operation instruction and container operation behavior of the container are obtained, including:

[0083] Obtain first configuration information and second configuration information of the cloud native platform;

[0084] The image operation instruction and the image operation behavior of the image are obtained in the first configuration information, and the container operation instruction and the container operation behavior of the container are obtained in the second configuration information.

[0085] In an embodiment of the present application, the image operation instructions and image operation behaviors of the image are obtained in the first configuration information, and the container operation instructions and container operation behaviors of the container are obtained in the second configuration information, which can ensure that the image operation instructions, image operation behaviors, container operation instructions and container operation behaviors all comply with the specifications of the cloud native platform.

[0086] S102, acquiring a first interface defining the image operation instruction, a second interface defining the image operation behavior, a third interface defining the container operation instruction, and a fourth interface defining the container operation behavior;

[0087] Among them, an interface file is created, and a first interface defining the mirror operation instruction, a second interface defining the mirror operation behavior, a third interface defining the container operation instruction, and a fourth interface defining the container operation behavior are respectively written in the interface file.

[0088] wherein, obtaining a first permission level of the current account, and determining whether the first permission level is higher than a preset second permission level;

[0089] If the first permission level of the current account is higher than the second permission level, the current account is authorized to create an interface file, and the interface file contains a first interface defining the image operation instructions, a second interface defining the image operation behavior, a third interface defining the container operation instructions, and a fourth interface defining the container operation behavior.

[0090] Among them, only the authorized current account can create an interface file, which can prevent the interface file from being tampered with and help ensure the reliability of the interface file.

[0091] S103, encapsulating the first interface and the first detection function corresponding to the first interface to obtain a first data structure, encapsulating the second interface and the second detection function corresponding to the second interface to obtain a second data structure, encapsulating the third interface and the third detection function corresponding to the third interface to obtain a third data structure, encapsulating the fourth interface and the fourth detection function corresponding to the fourth interface to obtain a fourth data structure;

[0092] Since the first interface, the second interface, the third interface and the fourth interface are set according to the detection requirements of the project, the first interface and the first detection function corresponding to the first interface are encapsulated to obtain a first data structure, the second interface and the second detection function corresponding to the second interface are encapsulated to obtain a second data structure, the third interface and the third detection function corresponding to the third interface are encapsulated to obtain a third data structure, and the fourth interface and the fourth detection function corresponding to the fourth interface are encapsulated to obtain a fourth data structure, which can meet the detection requirements of the project.

[0093] S104, encapsulating the calling functions corresponding to the first data structure, the second data structure, the third data structure, and the fourth data structure, respectively, to obtain a fifth data structure, and creating an access interface for the fifth data structure;

[0094] The encapsulating the calling functions corresponding to the first data structure, the second data structure, the third data structure, and the fourth data structure to obtain a fifth data structure and creating an access interface for the fifth data structure includes:

[0095] Encapsulate the calling functions corresponding to the first data structure, the second data structure, the third data structure and the fourth data structure respectively to obtain a fifth data structure;

[0096] An interaction statement corresponding to the fifth data structure is obtained, and the access interface of the fifth data structure is created based on the interaction statement.

[0097] In the embodiment of the present application, access to the first data structure, the second data structure, the third data structure and the fourth data structure can be achieved through the access interface of the fifth data structure, thereby greatly simplifying the operation process and improving work efficiency.

[0098] S107: Store the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in a file, package the file, and generate a detection toolkit for the image and the container.

[0099] The step of storing the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in one file, packaging the file, and generating a detection toolkit for the image and the container includes:

[0100] Using a preset test case to test the access interface and obtain the test result of the access interface;

[0101] When the test result is a preset result, the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function are stored in a file, the files are packaged, and a detection toolkit for the image and the container is generated. In an embodiment of the present application, when the test result is a preset result, it means that the effect of the access interface meets expectations, which is conducive to ensuring the reliability of the access interface.

[0102] The adopting of a preset test case to test the access interface and obtaining the test result of the access interface includes:

[0103] Display a list of test cases, and obtain a specified operation in the list of test cases;

[0104] According to the specified operation, the test case specified by the user is obtained in the test case list, the access interface is tested using the test case specified by the user, and the test result of the access interface is obtained.

[0105] In an embodiment of the present application, the test case specified by the user is used to test the access interface and obtain the test result of the access interface, which can save test time, improve test efficiency, and meet the user's customized needs.

[0106] Wherein, after storing the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in one file, packaging the file, and generating the detection toolkit of the image and the container, the detection toolkit generation method includes:

[0107] Constructing a detection rule based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in the detection toolkit;

[0108] The current information of the image or the container is obtained, the current information is input into the detection rule, and the detection result output by the detection rule based on the current information is obtained.

[0109] In the embodiment of the present application, problems with the current information can be discovered in a timely manner through the detection results, and the stable operation of the image and the container can be guaranteed by repairing the problems.

[0110] The step of constructing a detection rule based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in the detection toolkit includes:

[0111] Obtain a first detection object of the image, where the first detection object is a sensitive file of the image, and construct the detection rule corresponding to the first detection object based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function;

[0112] The sensitive files of the image include one or a combination of the password file, key, and certificate of the image.

[0113] For the sake of illustration, an example is given below:

[0114] For example, when the sensitive file of the image is the password file of the image, the detection rule corresponding to the first detection object is: detecting whether the file content of the image includes the password file of the image;

[0115] For example, when the sensitive file of the image is the key of the image, the detection rule corresponding to the first detection object is: detecting whether the file content of the image includes the key of the image;

[0116] For example, when the sensitive file of the image is the certificate of the image, the detection rule corresponding to the first detection object is: detecting whether the file content of the image includes the certificate of the image.

[0117] Alternatively, a second detection object of the container is obtained, where the second detection object is a sensitive file of the container, and the detection rule corresponding to the second detection object is constructed based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function;

[0118] The sensitive files of the container include one or a combination of password files, keys, certificates, and log files of the container.

[0119] For the sake of illustration, an example is given below:

[0120] For example, when the sensitive file of the container is a password file of the container, the detection rule corresponding to the first detection object is: detecting whether the file content of the container includes the password file of the container;

[0121] For example, when the sensitive file of the container is the key of the container, the detection rule corresponding to the first detection object is: detecting whether the file content of the container includes the key of the container;

[0122] For example, when the sensitive file of the container is a certificate of the container, the detection rule corresponding to the first detection object is: detecting whether the file content of the container includes the certificate of the container.

[0123] For example, when the sensitive file of the container is a log file of the container, the detection rule corresponding to the first detection object is: detecting whether the file content of the container includes the log file of the container.

[0124] Alternatively, a first detection scope of the image is obtained, where the first detection scope includes one of a single image, a group of images, and an image cluster, or a combination thereof, and the detection rule corresponding to the first detection scope is constructed based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function;

[0125] The first detection range includes a single mirror, a group of mirrors, a mirror cluster, or a combination thereof.

[0126] For the sake of illustration, an example is given below:

[0127] For example, when the first detection scope is a single image, the detection rule corresponding to the first detection scope is: detecting whether the file content of the single image includes the key of the image;

[0128] For example, when the first detection scope is a group of images, the detection rule corresponding to the first detection scope is: detecting whether the file content of a group of images includes the key of the image;

[0129] For example, when the first detection scope is a mirror cluster, the detection rule corresponding to the first detection scope is: detect whether the file content of the mirror cluster includes the certificate of the mirror;

[0130] Alternatively, a second detection scope of the container is obtained, where the second detection scope includes a single container, a group of containers, a container cluster, or a combination thereof, and the detection rule corresponding to the second detection scope is constructed based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function.

[0131] The second detection range includes a single container, a group of containers, a container cluster, or a combination thereof.

[0132] For the sake of illustration, an example is given below:

[0133] For example, when the second detection scope is a single container, the detection rule corresponding to the second detection scope is: detecting whether the file content of the single container includes the key of the container;

[0134] For example, when the second detection scope is a group of containers, the detection rule corresponding to the second detection scope is: detecting whether the file content of a group of containers includes the key of the container;

[0135] For example, when the second detection scope is a container cluster, the detection rule corresponding to the second detection scope is: detecting whether the file content of the container cluster includes the certificate of the container;

[0136] In the embodiments of the present application, by constructing detection rules and reusing existing detection rules, the process of repeatedly writing and configuring detection rules can be avoided, thereby saving a lot of time and energy, which makes the detection work more efficient and is conducive to improving the stability and security of images and containers.

[0137] The obtaining of the current information of the image or the container, inputting the current information into the detection rule, and obtaining the detection result output by the detection rule based on the current information includes:

[0138] Read the preset detection time and determine whether the current time is the detection time;

[0139] If the current time is the detection time, current information of the image or the container is obtained, the current information is input into the detection rule, and a detection result output by the detection rule based on the current information is obtained.

[0140] In the embodiment of the present application, problems with the current information can be discovered in a timely manner through the detection results, and the stable operation of the image and the container can be guaranteed by repairing the problems.

[0141] Wherein, after obtaining the current information of the image or the container, inputting the current information into the detection rule, and obtaining the detection result output by the detection rule based on the current information, the detection toolkit generation method includes:

[0142] Obtain a push instruction for the detection result, execute the push instruction, and push the detection result to a monitoring system corresponding to the image or the container.

[0143] In an embodiment of the present application, the detection result is pushed to the monitoring system corresponding to the image or the container, so that the monitoring system can provide valuable detection results. The detection results can help developers better understand the operating status of the image or the container, thereby formulating more effective detection strategies.

[0144] The beneficial effects of the embodiments of the present application lie in two aspects. On the one hand, the access interface, the first detection function, the second detection function, the third detection function and the fourth detection function are stored in a file, and the file is packaged to generate a detection toolkit for the image and the container. The detection toolkit provides a standardized access interface and reusable first detection function, second detection function, third detection function and fourth detection function, which can simplify the detection process of the image and the container and is beneficial to improving the detection efficiency of the image and the container. On the other hand, the detection toolkit for the image and the container is highly targeted to the image and the container, and can detect potential problems or risks of the image and the container, thereby helping to improve the security of the image and the container.

[0145] Figure 2 This is a flow chart of detecting images provided by an embodiment of the present application, which is described in detail as follows:

[0146] S201, obtaining the file system of the image;

[0147] The image file system includes the data required to build the image.

[0148] S202, traversing the file system of the image to obtain the file content of the image;

[0149] The file content of the image includes one or a combination of the file name of the image, the content of the image, the state of the image, and the permissions of the image.

[0150] S203: Input the file content of the image into the detection rule, and obtain a detection result output by the detection rule based on the file content of the image.

[0151] In an embodiment of the present application, the detection rule is based on the detection results output by the file content of the image, which can verify whether the image meets the expected requirements. When the image meets the expected requirements, the image is used in the cloud native platform. When the image does not meet the expected requirements, the image is not used in the cloud native platform. This ensures that the images used by the cloud native platform are tested and verified, thereby ensuring the stability of the cloud native platform.

[0152] Figure 3 The flowchart of the detection container provided in the embodiment of the present application is described in detail as follows:

[0153] S301, obtaining the file system of the container;

[0154] The container's file system includes the data required to build the container.

[0155] S302, traversing the file system of the container to obtain the file content of the container;

[0156] The file content of the container includes one or a combination of the file name of the container, the content of the container, the state of the container, and the permission of the container.

[0157] S303: Input the file content of the container into the detection rule, and obtain the detection result output by the detection rule based on the file content of the container.

[0158] In an embodiment of the present application, the detection rule is based on the detection result outputted from the file content of the container, and can verify whether the container meets the expected requirements. When the container meets the expected requirements, the container is used in the cloud native platform. When the container does not meet the expected requirements, the container is not used in the cloud native platform. This ensures that the containers used by the cloud native platform are tested and verified, and can ensure the stability of the cloud native platform.

[0159] For the detection kit generation method described in the above embodiment, please refer to Figure 4 , Figure 4 A schematic block diagram of a detection tool kit generation device provided in an embodiment of the present application, Figure 4 The detection tool kit generating device 400 shown in the figure can be applied to the above-mentioned electronic device. Figure 4 The detection toolkit generating device 400 shown in the figure is described in detail. The detection toolkit generating device 400 may include a first acquisition module 401, a second acquisition module 402, a first packaging module 403, a second packaging module 404, a construction module 405, and a packaging module 405.

[0160] The first acquisition module 401 is used to acquire image operation instructions and image operation behaviors of an image, and acquire container operation instructions and container operation behaviors of a container;

[0161] A second acquisition module 402 is used to acquire a first interface defining the image operation instruction, a second interface defining the image operation behavior, a third interface defining the container operation instruction, and a fourth interface defining the container operation behavior;

[0162] The first encapsulation module 403 is used to encapsulate the first interface and the first detection function corresponding to the first interface to obtain a first data structure, encapsulate the second interface and the second detection function corresponding to the second interface to obtain a second data structure, encapsulate the third interface and the third detection function corresponding to the third interface to obtain a third data structure, and encapsulate the fourth interface and the fourth detection function corresponding to the fourth interface to obtain a fourth data structure;

[0163] A second encapsulation module 404 is used to encapsulate the calling functions corresponding to the first data structure, the second data structure, the third data structure and the fourth data structure, obtain a fifth data structure, and create an access interface for the fifth data structure;

[0164] The packaging module 405 is used to store the access interface, the first detection function, the second detection function, the third detection function and the fourth detection function in a file, package the file, and generate a detection toolkit for the image and the container.

[0165] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0166] The beneficial effects of the embodiments of the present application lie in two aspects. On the one hand, the access interface, the first detection function, the second detection function, the third detection function and the fourth detection function are stored in a file, and the file is packaged to generate a detection toolkit for the image and the container. The detection toolkit provides a standardized access interface and reusable first detection function, second detection function, third detection function and fourth detection function, which can simplify the detection process of the image and the container and is beneficial to improving the detection efficiency of the image and the container. On the other hand, the detection toolkit for the image and the container is highly targeted to the image and the container, and can detect potential problems or risks of the image and the container, thereby helping to improve the security of the image and the container.

[0167] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for generating a detection toolkit, It is characterized in that The detection tool kit generation method comprises: Obtain image operation instructions and image operation behaviors of the image, and obtain container operation instructions and container operation behaviors of the container; Acquire a first interface defining the image operation instruction, a second interface defining the image operation behavior, a third interface defining the container operation instruction, and a fourth interface defining the container operation behavior; Encapsulate the first interface and a first detection function corresponding to the first interface to obtain a first data structure, encapsulate the second interface and a second detection function corresponding to the second interface to obtain a second data structure, encapsulate the third interface and a third detection function corresponding to the third interface to obtain a third data structure, and encapsulate the fourth interface and a fourth detection function corresponding to the fourth interface to obtain a fourth data structure; Encapsulate the calling functions corresponding to the first data structure, the second data structure, the third data structure, and the fourth data structure, respectively, to obtain a fifth data structure, and create an access interface for the fifth data structure; The access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function are stored in a file, and the files are packaged to generate a detection toolkit for the image and the container; The encapsulating the calling functions corresponding to the first data structure, the second data structure, the third data structure, and the fourth data structure to obtain a fifth data structure, and creating an access interface for the fifth data structure includes: Encapsulate the calling functions corresponding to the first data structure, the second data structure, the third data structure and the fourth data structure respectively to obtain a fifth data structure; Acquire an interaction statement corresponding to the fifth data structure, and create the access interface of the fifth data structure based on the interaction statement; The step of storing the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in a file, packaging the file, and generating a detection toolkit for the image and the container includes: Using a preset test case to test the access interface and obtain the test result of the access interface; When the test result is a preset result, the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function are stored in a file, and the file is packaged to generate a detection toolkit for the image and the container; The adopting a preset test case to test the access interface and obtaining the test result of the access interface includes: Display a list of test cases, and obtain a specified operation in the list of test cases; According to the specified operation, the test case specified by the user is obtained in the test case list, the access interface is tested using the test case specified by the user, and the test result of the access interface is obtained.

2. The method for generating a detection tool kit according to claim 1, It is characterized in that The obtaining of the image operation instruction and the image operation behavior of the image, and the obtaining of the container operation instruction and the container operation behavior of the container, includes: Obtain first configuration information and second configuration information of the cloud native platform; The image operation instruction and the image operation behavior of the image are obtained in the first configuration information, and the container operation instruction and the container operation behavior of the container are obtained in the second configuration information.

3. The method for generating a detection tool kit according to any one of claims 1 to 2, It is characterized in that After storing the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in a file, packaging the file, and generating a detection toolkit for the image and the container, the detection toolkit generation method includes: Constructing a detection rule based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in the detection toolkit; The current information of the image or the container is obtained, the current information is input into the detection rule, and the detection result output by the detection rule based on the current information is obtained.

4. The method for generating a detection tool kit according to claim 3, It is characterized in that The constructing of detection rules based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function in the detection toolkit includes: Obtain a first detection object of the image, where the first detection object is a sensitive file of the image, and construct the detection rule corresponding to the first detection object based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function; Alternatively, a second detection object of the container is obtained, where the second detection object is a sensitive file of the container, and the detection rule corresponding to the second detection object is constructed based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function; Alternatively, a first detection scope of the image is obtained, where the first detection scope includes one of a single image, a group of images, and an image cluster, or a combination thereof, and the detection rule corresponding to the first detection scope is constructed based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function; Alternatively, a second detection scope of the container is obtained, where the second detection scope includes a single container, a group of containers, a container cluster, or a combination thereof, and the detection rule corresponding to the second detection scope is constructed based on the access interface, the first detection function, the second detection function, the third detection function, and the fourth detection function.

5. The method for generating a detection tool kit according to claim 3, It is characterized in that The obtaining current information of the image or the container, inputting the current information into the detection rule, and obtaining the detection result output by the detection rule based on the current information includes: Read the preset detection time and determine whether the current time is the detection time; If the current time is the detection time, current information of the image or the container is obtained, the current information is input into the detection rule, and a detection result output by the detection rule based on the current information is obtained.

6. The method for generating a detection tool kit according to claim 3, It is characterized in that After obtaining the current information of the image or the container, inputting the current information into the detection rule, and obtaining the detection result output by the detection rule based on the current information, the detection toolkit generation method includes: Obtain a push instruction for the detection result, execute the push instruction, and push the detection result to a monitoring system corresponding to the image or the container.

7. A detection tool kit generation device, It is characterized in that Used to perform the method according to any one of claims 1 to 6, comprising: A first acquisition module is used to acquire image operation instructions and image operation behaviors of an image, and to acquire container operation instructions and container operation behaviors of a container; A second acquisition module is used to acquire a first interface defining the image operation instruction, a second interface defining the image operation behavior, a third interface defining the container operation instruction, and a fourth interface defining the container operation behavior; A first encapsulation module is used to encapsulate the first interface and a first detection function corresponding to the first interface to obtain a first data structure, encapsulate the second interface and a second detection function corresponding to the second interface to obtain a second data structure, encapsulate the third interface and a third detection function corresponding to the third interface to obtain a third data structure, and encapsulate the fourth interface and a fourth detection function corresponding to the fourth interface to obtain a fourth data structure; A second encapsulation module is used to encapsulate the calling functions corresponding to the first data structure, the second data structure, the third data structure and the fourth data structure, obtain a fifth data structure, and create an access interface for the fifth data structure; A generation module is used to store the access interface, the first detection function, the second detection function, the third detection function and the fourth detection function in a file, package the file, and generate a detection toolkit for the image and the container.