A mirror image updating method, device, equipment and medium

By identifying and replacing inconsistent files between the basic system image and the target image, and only repairing the inconsistent files, the problem of heavy image repair workload and non-persistent repair in the container environment is solved, and an efficient and durable image repair process is realized.

CN113672349BActive Publication Date: 2024-10-01NSFOCUS INFORMATION TECHNOLOGY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110958811.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-20
Publication Date
2024-10-01
Estimated Expiration
2041-08-20

AI Technical Summary

Technical Problem

In a container environment, the vulnerability repair process of the basic system image requires re-creating the image and restarting the container, resulting in a heavy workload and short-lasting repair results. Especially when distributing multiple images on devices that have sold products, it increases the work pressure of the device and is easy to The repair content is lost due to changes in the external environment.

Method used

By determining the inconsistent files between the basic system image and the target image, obtain the file path and replacement file, only repair the inconsistent files, avoid restarting the container, use multiple images to share a basic system image structure, reduce the workload and ensure repair Persistence.

Benefits of technology

This reduces the workload of the image repair process, avoids the loss of repair content due to external environmental influences, improves the durability and efficiency of repair, and reduces the work pressure on the equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113672349B_ABST
    Figure CN113672349B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention provide a method, apparatus, device and medium for updating an image. In the embodiments of the present invention, the images to be updated share a basic system image, and the inconsistent first target file is determined according to the basic system image and the target basic system image obtained after repair, and the file path corresponding to the first target file recorded in the basic system image of the image to be updated in the device to be repaired is obtained. Based on the file path and the second target file in the target basic system image that replaces the first target file, the repair of the image in the device to be repaired can be completed. The process does not require restarting the container, and only the inconsistent files are repaired, thereby reducing the workload.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of containers and virtualization, and in particular to an image updating method, device, equipment and medium. Background Art

[0002] Many images in the environment are built based on the same base system image. If a vulnerability occurs in the base system image, after repairing it, the usual practice is to rebuild the images that depend on the base system image based on the repaired base system image, and re-run the containers involved based on all the rebuilt images.

[0003] This process requires recreating the image and restarting the container, which is very costly. The solution to fix the vulnerability of the basic system image may be as simple as replacing a file in the basic system image. If the environment is a product that has already been sold, it will involve distributing multiple rebuilt images to hundreds of devices, increasing the workload of each device.

[0004] When fixing vulnerabilities in the base system image, you do not need to rebuild the image, but replace the files in the running container, because the images used by all containers are generated based on the base system image that needs to be fixed, so all containers need to replace the files. The workload of this repair process is also very large, and the modifications to the container are not persistent. Even if the file replacement of the container is successful, in some cases, Docker restarts, such as power failure of the host machine, Docker upgrades, etc., will also cause the container to lose related changes. Therefore, once this happens, the container will be restored to the state where the vulnerability has not been fixed. Summary of the invention

[0005] In view of this, embodiments of the present invention provide an image update method, apparatus, device and medium to reduce the workload of image repair and avoid loss of container-related changes under the influence of external environment.

[0006] In a first aspect, an embodiment of the present invention provides a method for updating an image, the method comprising:

[0007] Repair vulnerabilities in the base system image, obtain a target base system image, determine a first target file that is inconsistent between the base system image and the target base system image, and a second target file in the target base system image that replaces the first target file;

[0008] Obtaining a file path corresponding to the first target file recorded in a base system image of the image to be updated in the device to be repaired, wherein the images to be updated in the device to be repaired share a common base system image;

[0009] The file path and the second target file are sent so that the device to be repaired repairs each image to be updated according to the file path and the second target file.

[0010] Further, the determining of the first target file that is inconsistent between the base system image and the target base system image includes:

[0011] Obtain a first compressed package corresponding to the base system image and a second compressed package corresponding to the target base system image;

[0012] Compare the files contained in the bottom layer of the first compressed package and the second compressed package to identify inconsistent first target files.

[0013] Further, the step of obtaining the file path corresponding to the first target file recorded in the base system image of the image to be updated in the device to be repaired includes:

[0014] Determine the bottom-level verification code identification information of the image to be updated according to the information of the preset file record in the storage path of the image to be updated;

[0015] Constructing the bottom-level path information according to the verification code identification information;

[0016] The index identification information included in the bottom-level path information is searched, and the file path corresponding to the first target file is constructed according to the index identification information.

[0017] Further, the determining the bottom-level verification code identification information of the image to be updated according to the information of the preset file record in the storage path of the image to be updated includes:

[0018] Obtaining identification information of the image to be updated recorded in a first preset file in the storage path of the image to be updated;

[0019] According to the identification information, obtaining a path of a metadata configuration file recorded in a second preset file in a storage path of the image to be updated;

[0020] According to the path of the metadata configuration file, the bottom-level verification code identification information recorded in the metadata configuration file is searched.

[0021] In a second aspect, an embodiment of the present invention further provides a mirror image update device, the device comprising:

[0022] A first acquisition module is used to acquire a target basic system image, determine a first target file that is inconsistent between the basic system image and the target basic system image, and a second target file in the target basic system image that replaces the first target file;

[0023] A second acquisition module is used to acquire a file path corresponding to the first target file recorded in a base system image of the image to be updated in the device to be repaired, wherein the images to be updated in the device to be repaired share a common base system image;

[0024] The repair module is used to send the file path and the second target file, so that the device to be repaired repairs each image to be updated according to the file path and the second target file.

[0025] Furthermore, the first acquisition module is specifically used to obtain a first compressed package corresponding to the basic system image and a second compressed package corresponding to the target basic system image; compare the files contained in the bottom layer of the first compressed package and the second compressed package, and identify inconsistent first target files.

[0026] Furthermore, the second acquisition module is specifically used to determine the bottom-level verification code identification information of the image to be updated based on the information of the preset file record in the storage path of the image to be updated; construct the bottom-level path information based on the verification code identification information; search for the index identification information contained in the bottom-level path information, and construct the file path corresponding to the first target file based on the index identification information.

[0027] Furthermore, the second acquisition module is specifically used to obtain the path of the metadata configuration file recorded in the second preset file in the storage path of the image to be updated according to the identification information; and according to the path of the metadata configuration file, search for the bottom-level verification code identification information recorded in the metadata configuration file.

[0028] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising at least a processor and a memory, the processor being configured to execute the image update steps described in any one of the above claims when executing a computer program stored in the memory.

[0029] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the image updating steps described in any one of the above claims are performed.

[0030] In the embodiment of the present invention, the image to be updated shares a common base system image, and the inconsistent first target file is determined according to the base system image and the target base system image obtained after the repair, and the file path corresponding to the first target file recorded in the base system image of the image to be updated in the device to be repaired is obtained. Based on the file path and the second target file in the target base system image that replaces the first target file, the repair of the image in the device to be repaired can be completed. This process does not require restarting the container, and only the inconsistent files are repaired, thereby reducing the workload. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0032] Figure 1 A schematic diagram of an image update process provided by an embodiment of the present invention;

[0033] Figure 2 A schematic diagram of the contents recorded in a compressed image package provided by an embodiment of the present invention;

[0034] Figure 3 A schematic diagram of the content of the bottom-level path information provided by an embodiment of the present invention;

[0035] Figure 4 A schematic diagram of the contents of a bottom-level file path provided by an embodiment of the present invention;

[0036] Figure 5 A schematic diagram of the correspondence between an image and its identification information provided by an embodiment of the present invention;

[0037] Figure 6 A schematic diagram of metadata content provided by an embodiment of the present invention;

[0038] Figure 7 A schematic diagram of a program for replacing files of a basic system image provided by an embodiment of the present invention;

[0039] Figure 8 A schematic diagram of a docker image and container layer structure provided in an embodiment of the present invention;

[0040] Fig. 9 An overall flow chart of an image update provided by an embodiment of the present invention;

[0041] Fig.10A schematic diagram of a process of replacing a common layer file provided by an embodiment of the present invention;

[0042] Fig.11 A schematic diagram of the structure of an image updating device provided by an embodiment of the present invention;

[0043] Fig.12 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0045] In order to reduce the workload of image repair and avoid losing container-related changes due to the influence of the external environment, an embodiment of the present invention provides an image update method.

[0046] Embodiment 1:

[0047] Figure 1 A schematic diagram of an image update process provided by an embodiment of the present invention, the process includes the following steps:

[0048] S101: Repair vulnerabilities in a basic system image to obtain a target basic system image, determine a first target file that is inconsistent between the basic system image and the target basic system image, and a second target file in the target basic system image that replaces the first target file.

[0049] The image updating method provided by the embodiment of the present invention is applied to an electronic device, which may be a terminal, a server, etc. The image updating method provided by the embodiment of the present invention is based on a docker environment.

[0050] When a vulnerability appears in the basic system image, in order to ensure the normal operation of the image, the basic system image needs to be repaired. The specific process of repairing the vulnerability of the basic system image belongs to the existing technology and will not be repeated in the embodiments of the present invention.

[0051] The repaired basic system image obtained after repairing the basic system image is the target basic system image. In order to achieve the repair of the image, in an embodiment of the present invention, after obtaining the target basic system image, the underlying files in the target basic system image and the basic system image are compared to determine the inconsistent files in the underlying layers between the basic system image and the target basic system image, and the inconsistent files are used as the first target file, which is the file that needs to be replaced, and the file in the target basic image that replaces the first target file is used as the second target file, which is the file that needs to be replaced. For example, when repairing a vulnerability in the basic system image, file A is replaced with file B. Then, after obtaining the target basic system image, the first target file that is inconsistent between the basic system image and the target basic system image is file A, and the second target file in the target basic system image that replaces the first target file is file B.

[0052] S102: Obtain a file path corresponding to the first target file recorded in a base system image of an image to be updated in a device to be repaired, wherein each of the images to be updated in the device to be repaired shares a common base system image.

[0053] Since the image itself is stored in layers, if multiple images share a base system image, then the bottom layer of the base system image should be reused by multiple images, and the bottom layer is reused by multiple images as a common layer. Therefore, in the embodiment of the present invention, the structure of multiple images sharing a base system image is adopted to perform image repair.

[0054] In the embodiment of the present invention, since multiple images share a basic system image, and the basic system image is the bottom layer which is the common layer of multiple images, after the first target file is determined, the file path corresponding to the first target file can be searched based on the layer path of the common layer used by the image, so as to replace the first target file under the file path.

[0055] S103: Send the file path and the second target file, so that the device to be repaired repairs each image to be updated according to the file path and the second target file.

[0056] In order to enable the device to be repaired to repair the image, after obtaining the file paths corresponding to the second target file and the first target file, the file path and the second target file are sent to the device to be repaired, so that the device to be repaired can repair each image to be updated according to the file path and the second target file.

[0057] The acquired second target file is sent to the device to be repaired. The device to be repaired searches for the storage location of the first target file according to the second target file and the file path, thereby replacing the first target file with the second target file, thereby completing the repair of each image to be updated.

[0058] In the embodiment of the present invention, the image to be updated shares a common base system image, and the inconsistent first target file is determined according to the base system image and the target base system image obtained after the repair, and the file path corresponding to the first target file recorded in the base system image of the image to be updated in the device to be repaired is obtained. Based on the file path and the second target file in the target base system image that replaces the first target file, the repair of the image in the device to be repaired can be completed. This process does not require restarting the container, and only the inconsistent files are repaired, thereby reducing the workload.

[0059] Embodiment 2:

[0060] In order to accurately determine the first target file, based on the above embodiment, in an embodiment of the present invention, the step of determining the first target file that is inconsistent between the base system image and the target base system image includes:

[0061] Obtain a first compressed package corresponding to the base system image and a second compressed package corresponding to the target base system image;

[0062] Compare the files contained in the bottom layer of the first compressed package and the second compressed package to identify inconsistent first target files.

[0063] Specifically, the target basic system image after the vulnerability is repaired is generally saved as a compressed package. For example, the docker save imagename-o image.tar command can be used to save the target basic system image as a tar package. The corresponding basic system image will also be saved as a compressed package. In order to distinguish the compressed packages of the basic system image and the target basic system image, the compressed package corresponding to the basic system image is called the first compressed package, and the compressed package corresponding to the target basic system image is called the second compressed package.

[0064] The compressed package records the layer file of the image, and the layer file records each file contained in the corresponding layer. After obtaining the compressed packages of the base system image and the target base system image, the layer file corresponding to the bottom layer is obtained from each compressed package, and the bottom layer files of the two compressed packages are compared to obtain the first target file that needs to be replaced.

[0065] Figure 2 A schematic diagram of the contents recorded in a mirror image compression package provided by an embodiment of the present invention, according to Figure 2 As shown, layer.tar is the bottom-most layer files in the compressed package of the target basic system image. By comparing the bottom-most layer files of the first compressed package with the second compressed package, the first target file to be replaced can be obtained.

[0066] After determining the first target file that is inconsistent between the base system image and the target base system image, in order to facilitate image repair of the device to be repaired, in an embodiment of the present invention, the first target file can also be compressed into a compressed package. When sending, the compressed package can be uploaded to the device to be repaired for the next replacement action.

[0067] Embodiment 3:

[0068] In order to obtain an accurate file path of the first target file, based on the above embodiments, in an embodiment of the present invention, the step of obtaining the file path corresponding to the first target file recorded in the basic system image of the image to be updated in the device to be repaired includes:

[0069] Determine the bottom-level verification code identification information of the image to be updated according to the information of the preset file record in the storage path of the image to be updated;

[0070] Constructing the bottom-level path information according to the verification code identification information;

[0071] The index identification information included in the bottom-level path information is searched, and the file path corresponding to the first target file is constructed according to the index identification information.

[0072] Since the storage path of the Docker file is fixed, and each file contained in the storage path is also fixed, and the content recorded in each file is also fixed, therefore, a preset file can be pre-configured according to the information recorded in each file, and the bottom-level verification code identification information (diff_id) of the image to be updated can be determined according to the information recorded in the preset file.

[0073] Since the path format of the middle layer in the docker file is fixed, specifically, the path format of the layer is / var / lib / docker / image / aufs / layerdb / sha256 / {chainid}, where chainid is the verification code identification information corresponding to each layer to be input. Therefore, after obtaining the verification code identification information of the bottom layer, the path information of the bottom layer can be constructed based on the path format of the middle layer in the docker file and the verification code identification information of the bottom layer.

[0074] If the path format of the Docker middle layer is / var / lib / docker / image / aufs / layerdb / sha256 / {chainid}, the bottom chainid is equal to diff_id. Therefore, when the bottom diff_id obtained is 174f5685490326fc0a1c0f5570b8663732189b327007e47ff13d2ca59673db02, based on the above method, the bottom path information can be constructed as: / var / lib / docker / image / aufs / layerdb / sha256 / 174f5685490326fc0a1c0f5570b8663732189b327007e47ff13d2ca59673db02.

[0075] Similarly, the format of the file path corresponding to the file of the real layer is also fixed. Specifically, the format of the file path corresponding to the file of the real layer is / var / lib / docker / aufs / diff / {cache-id}, where the cache-id is the index identification information of each layer to be input. Specifically, after determining the path information of the lowest level, the path of the lowest level contains files of various names, and the content of the cache-id file under the path of the lowest level is determined, and the content of the cache-id file is determined as the index identification information of the lowest level. Based on the index identification information of the lowest level and the format of the file path corresponding to the file of the real layer, the file path corresponding to the lowest level file is constructed, specifically, the file path corresponding to the first target file is constructed.

[0076] Figure 3 A schematic diagram of the content of the bottom layer path information provided by an embodiment of the present invention is now directed to Figure 3 Provide explanation.

[0077] The file recorded under the path information includes information such as cache-id, diff, size, etc. The index identification information is determined based on the content contained in the cache-id file.

[0078] Because the file path information of the layer file has a fixed relationship with the cache-id, the specific file path information of the layer file can be expressed as follows: / var / lib / docker / aufs / diff / {cache-id}, so when the cache-id value is obtained, it is:

[0079] 1fedc742b7efd5fc14f87e5b56c1b0aed19fdde399e9d280b382d14333cf4208, the file path corresponding to the bottom-level file can be constructed based on the cache-id. Specifically, the file path is: / var / lib / docker / aufs / diff / 1fedc742b7efd5fc14f87e5b56c1b0aed19fdde399e9d280b382d14333cf4208.

[0080] Figure 4 A schematic diagram of the contents under the bottom-level file path provided by an embodiment of the present invention.

[0081] according to Figure 4 As shown, we can see that the directory structure here is already the system directory structure. Therefore, we can replace the file based on the compressed package of the second target file and the file path. Since all images and containers use this basic system image, the replacement action will affect all images and containers that use this basic system image, so that the vulnerabilities of all images and containers that use this basic system image can be repaired without building the image.

[0082] Embodiment 4:

[0083] In order to obtain the accurate file path of the first target file, based on the above embodiments, in an embodiment of the present invention, the information of the preset file record in the storage path of the image to be updated is used to determine the bottom-level verification code identification information of the image to be updated, including:

[0084] Obtaining identification information of the image to be updated recorded in a first preset file in the storage path of the image to be updated;

[0085] According to the identification information, obtaining a path of a metadata configuration file recorded in a second preset file in a storage path of the image to be updated;

[0086] According to the path of the metadata configuration file, the bottom-level verification code identification information recorded in the metadata configuration file is searched.

[0087] The storage path of Docker files is fixed. By default, the files are stored in the / var / lib / docker path. The files in this path include: repositories.json, imagedb, and layerdb. The repositories.json records the correspondence between each image and its corresponding identification information (sha256). Therefore, repositories.json can be determined as the first preset file. Based on the information recorded in the first preset file, the identification information of the image to be updated is determined.

[0088] Specifically, the Docker file is stored in the / var / lib / docker path by default, and the storage path of its first preset file is / var / lib / docker / image / aufs / repositories.json. The first preset file is searched based on the storage path. According to the correspondence between the image and the image's identification information (sha256 value) recorded in the first preset file, and based on the object relationship between the image and the image's identification information, the sha256 value of each image to be repaired can be found.

[0089] Figure 5 A schematic diagram of the correspondence between an image and its identification information provided by an embodiment of the present invention. According to the diagram, the sha256 corresponding to the image 10.67.2.143:8080 / bsp / kafka is: db625ad3cad09b41b8f760d35028cf09bfeb90b112d3154798ce07caef41a145.

[0090] The path of the metadata configuration file is recorded in the imagedb file of the Docker file. Since the path format corresponding to the metadata of the image is fixed, after the path corresponding to the metadata of the image is determined, the diff_ids under the root file system (rootfs) node based on the path corresponding to the metadata of the image records the diff_ids of each layer used by the image, so that the diff_id of the bottom layer of the image to be updated can be determined based on this information. Specifically, diff_ids is an array, and the first element in the array is the diff_id of the bottom layer of the image to be updated. In an embodiment of the present invention, in order to determine the bottom layer path information, the path where the metadata corresponding to the metadata of the image is located is determined based on the format of the metadata corresponding to the metadata of the image and the bottom layer verification code identification information (diff_id) of the image to be updated. The format of the metadata corresponding to the metadata of the image is fixed. Specifically, the format of the metadata corresponding to the metadata of the image is: / var / lib / docker / image / aufs / imagedb / content / sha256 / {imageid}, wherein the imageid is the verification code identification information of each layer to be input. If the verification code identification information of the bottom layer of the image to be updated is db625ad3cad09b41b8f760d35028cf09bfeb90b112d3154798ce07caef41a145, then the path of the metadata of the image to be updated is / var / lib / docker / image / aufs / imagedb / content / sha256 / db625ad3cad09b41b8f760d35028cf09bfeb90b112d3154798ce07caef41a145.

[0091] Figure 6 A schematic diagram of metadata content provided by an embodiment of the present invention is now directed to Figure 6 To explain:

[0092] The diff_ids under the root file system (rootfs) node of the path corresponding to the metadata of the image is an array, which records the diff_id of each layer used by the image in the set order. Among them, the first element in the array is the diff_id of the bottom layer, and the last element is the diff_id of the top layer.

[0093] Figure 7 A schematic diagram of a program for replacing files of a basic system image provided by an embodiment of the present invention is now directed to Figure 7 Provide explanation.

[0094] If the kafka image and the zookeeper image are included, before the image is updated, that is, before the image to be updated is updated based on the path of the first target file and the second target file, the version of the system kernel is Linux release 7.9.2009. After the image to be updated is updated based on the path of the first target file and the second target file, the specific replacement procedure is:

[0095] pythonreplace_base_img.py10.67.2.143:8080 / bsp / kafka / root / layer.tar, where layer.tar is the replacement file. The system kernel version of the container corresponding to the kafka image is Linux release 8.3.2011, and the system kernel version of the container corresponding to the zookeeper image is also Linux release8.3.2011. That is to say, after replacing the bottom layer of the kafka image with the centos8.3 image, since the kafka image and zookeeper image to be updated both use centos7 as the basic system image, when the bottom layer file of kafka is replaced, you can see that the versions of the basic system images of the zookeeper container and the kafka container are all changed to centos8. Therefore, since all images and containers use this basic system image, the replacement action will affect all images and containers that use the basic system image, thereby realizing that the public layer vulnerabilities of images and containers can be repaired without building images.

[0096] Figure 8 A schematic diagram of a docker image and container layer structure provided in an embodiment of the present invention is now directed to Figure 8 Provide explanation.

[0097] An image is a unified view of a bunch of read-only layers. A container is also a unified view of a bunch of layers. The difference between a container and an image is that the top layer of the container is a read-write layer.

[0098] Fig. 9 The overall flow chart of an image update provided by an embodiment of the present invention is now directed to Fig. 9 Provide explanation.

[0099] First, based on the repositories.json in docker, get the sha256 value corresponding to the image to be updated, then determine the metadata path of the image based on the sha256 value, enter the metadata path, get the layer information array, that is, diff_ids, and get the bottom diff_id based on the layer information array, where the bottom diff_id is not the first element in the layer information array. Based on the bottom diff_id, determine the path corresponding to the bottom layer, and get the cache_id corresponding to the bottom file path. Based on the cache_id, determine the path where the real file is located, that is, the file path corresponding to the first target file. Based on the file path corresponding to the first target file, replace the relevant files. That is, based on the file path corresponding to the first target file and the second target file, replace the first target file corresponding to the file path corresponding to the first target file with the second target file, thereby updating the image.

[0100] Fig.10 A schematic diagram of a process of replacing a common layer file provided by an embodiment of the present invention is now directed to Fig.10 Provide explanation.

[0101] First, fix the vulnerability of the base system image, obtain the target base system image, obtain all the bottom files in the target base image, and determine all the bottom files in the base system image. Based on all the bottom files in the target image and all the bottom files in the base system image, obtain the compressed package of the file to be replaced, that is, after determining the inconsistent first target file in the base system image and the target base image, compress the first target file in a compressed package, and then upload the compressed package of the file to be replaced, that is, upload the compressed package of the first target file. Search and confirm the bottom public path of the image, and replace the file in the public layer, that is, determine the file path of the first target file, and replace the first target file in the image with the second target file based on the file path and the second target file after the first target file in the target base system image is replaced.

[0102] Embodiment 5:

[0103] Fig.11 A schematic diagram of the structure of an image updating device provided by an embodiment of the present invention, the image updating device comprises:

[0104] A first acquisition module 1101 is used to acquire a target basic system image, determine a first target file that is inconsistent between the basic system image and the target basic system image, and a second target file in the target basic system image that replaces the first target file;

[0105] The second acquisition module 1102 is used to acquire a file path corresponding to the first target file recorded in a base system image of the image to be updated in the device to be repaired, wherein the images to be updated in the device to be repaired share a common base system image;

[0106] The repair module 1103 is used to send the file path and the second target file, so that the device to be repaired repairs each image to be updated according to the file path and the second target file.

[0107] In a possible implementation, the first acquisition module 1101 is specifically used to acquire a first compressed package corresponding to the basic system image and a second compressed package corresponding to the target basic system image; compare the files contained in the bottom layer of the first compressed package and the second compressed package, and identify inconsistent first target files.

[0108] In a possible implementation, the second acquisition module 1102 is specifically used to determine the bottom-level verification code identification information of the image to be updated according to the information of the preset file record in the storage path of the image to be updated; construct the bottom-level path information according to the verification code identification information; search for the index identification information contained in the bottom-level path information, and construct the file path corresponding to the first target file according to the index identification information.

[0109] In a possible implementation, the second acquisition module 1102 is specifically used to obtain, according to the identification information, the path of the metadata configuration file recorded in the second preset file in the storage path of the image to be updated; and according to the path of the metadata configuration file, search for the bottom-level verification code identification information recorded in the metadata configuration file.

[0110] Embodiment 6:

[0111] Fig.12 FIG. 1 is a schematic diagram of the structure of an electronic device provided by the present invention. Based on the above embodiments, the present invention further provides an electronic device, such as Fig.12 As shown, it includes: a processor 1201 , a communication interface 1202 , a memory 1203 and a communication bus 1204 , wherein the processor 1201 , the communication interface 1202 , and the memory 1203 communicate with each other via the communication bus 1204 .

[0112] The memory 1203 stores a computer program. When the program is executed by the processor 1201, the processor 1201 performs the following steps:

[0113] Repair vulnerabilities in the base system image, obtain a target base system image, determine a first target file that is inconsistent between the base system image and the target base system image, and a second target file in the target base system image that replaces the first target file;

[0114] Obtaining a file path corresponding to the first target file recorded in a base system image of an image to be updated in a device to be repaired, wherein the images to be updated in the device to be repaired share a common base system image;

[0115] The file path and the second target file are sent so that the device to be repaired repairs each image to be updated according to the file path and the second target file.

[0116] In a possible implementation manner, determining the first target file that is inconsistent between the base system image and the target base system image includes:

[0117] Obtain a first compressed package corresponding to the base system image and a second compressed package corresponding to the target base system image;

[0118] Compare the files contained in the bottom layer of the first compressed package and the second compressed package to identify inconsistent first target files.

[0119] In a possible implementation manner, obtaining the file path corresponding to the first target file recorded in the base system image of the image to be updated in the device to be repaired includes:

[0120] Determine the bottom-level verification code identification information of the image to be updated according to the information of the preset file record in the storage path of the image to be updated;

[0121] Constructing the bottom-level path information according to the verification code identification information;

[0122] The index identification information included in the bottom-level path information is searched, and the file path corresponding to the first target file is constructed according to the index identification information.

[0123] In a possible implementation manner, determining the bottom-level verification code identification information of the image to be updated according to information of a preset file record in a storage path of the image to be updated includes:

[0124] Obtaining identification information of the image to be updated recorded in a first preset file in the storage path of the image to be updated;

[0125] According to the identification information, obtaining a path of a metadata configuration file recorded in a second preset file in a storage path of the image to be updated;

[0126] According to the path of the metadata configuration file, the bottom-level verification code identification information recorded in the metadata configuration file is searched.

[0127] The communication bus mentioned in the above server can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0128] The communication interface is used for communication between the above electronic device and other devices.

[0129] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0130] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.

[0131] Embodiment 7:

[0132] On the basis of the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program executable by an electronic device, and when the program is run on the electronic device, the electronic device implements the following steps when executing:

[0133] The memory stores a computer program, and when the program is executed by the processor, the processor performs the following steps:

[0134] Repair vulnerabilities in the base system image, obtain a target base system image, determine a first target file that is inconsistent between the base system image and the target base system image, and a second target file in the target base system image that replaces the first target file;

[0135] Obtaining a file path corresponding to the first target file recorded in a base system image of an image to be updated in a device to be repaired, wherein the images to be updated in the device to be repaired share a common base system image;

[0136] The file path and the second target file are sent so that the device to be repaired repairs each image to be updated according to the file path and the second target file.

[0137] In a possible implementation manner, determining the first target file that is inconsistent between the base system image and the target base system image includes:

[0138] Obtain a first compressed package corresponding to the base system image and a second compressed package corresponding to the target base system image;

[0139] Compare the files contained in the bottom layer of the first compressed package and the second compressed package to identify inconsistent first target files.

[0140] In a possible implementation manner, obtaining the file path corresponding to the first target file recorded in the base system image of the image to be updated in the device to be repaired includes:

[0141] Determine the bottom-level verification code identification information of the image to be updated according to the information of the preset file record in the storage path of the image to be updated;

[0142] Constructing the bottom-level path information according to the verification code identification information;

[0143] The index identification information included in the bottom-level path information is searched, and the file path corresponding to the first target file is constructed according to the index identification information.

[0144] In a possible implementation manner, determining the bottom-level verification code identification information of the image to be updated according to information of a preset file record in a storage path of the image to be updated includes:

[0145] Obtaining identification information of the image to be updated recorded in a first preset file in the storage path of the image to be updated;

[0146] According to the identification information, obtaining a path of a metadata configuration file recorded in a second preset file in a storage path of the image to be updated;

[0147] According to the path of the metadata configuration file, the bottom-level verification code identification information recorded in the metadata configuration file is searched.

[0148] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0149] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0150] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0151] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0152] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A mirror image update method, characterized in that: The method comprises: Repair vulnerabilities in a base system image, obtain a target base system image, determine a first target file that is inconsistent between the base system image and the target base system image, and a second target file in the target base system image that replaces the first target file; wherein the base system image is a common layer of multiple images as the bottom layer; Obtaining a file path corresponding to the first target file recorded in a base system image of an image to be updated in a device to be repaired, wherein the images to be updated in the device to be repaired share a common base system image; Sending the file path and the second target file, so that the device to be repaired repairs each image to be updated according to the file path and the second target file; The step of obtaining the file path corresponding to the first target file recorded in the basic system image of the image to be updated in the device to be repaired comprises: Obtaining identification information of the image to be updated recorded in a first preset file in the storage path of the image to be updated; According to the identification information, obtaining a path of a metadata configuration file recorded in a second preset file in a storage path of the image to be updated; According to the path of the metadata configuration file, searching for the bottom-level verification code identification information recorded in the metadata configuration file; Constructing the bottom-level path information according to the verification code identification information; The index identification information included in the bottom-level path information is searched, and the file path corresponding to the first target file is constructed according to the index identification information.

2. The method according to claim 1, characterized in that The determining of the first target file that is inconsistent between the base system image and the target base system image comprises: Obtain a first compressed package corresponding to the base system image and a second compressed package corresponding to the target base system image; Compare the files contained in the bottom layer of the first compressed package and the second compressed package to identify inconsistent first target files.

3. A mirror image update device, characterized in that: The device comprises: A first acquisition module is used to acquire a target basic system image, determine a first target file that is inconsistent between the basic system image and the target basic system image, and a second target file in the target basic system image that replaces the first target file; wherein the basic system image is a common layer of multiple images as the bottom layer; A second acquisition module is used to acquire a file path corresponding to the first target file recorded in a base system image of the image to be updated in the device to be repaired, wherein the images to be updated in the device to be repaired share a common base system image; A repair module, used for sending the file path and the second target file, so that the device to be repaired repairs each image to be updated according to the file path and the second target file; The second acquisition module is specifically used to obtain the identification information of the image to be updated recorded in the first preset file in the storage path of the image to be updated; according to the identification information, obtain the path of the metadata configuration file recorded in the second preset file in the storage path of the image to be updated; according to the path of the metadata configuration file, search for the bottom-level verification code identification information recorded in the metadata configuration file; according to the verification code identification information, construct the bottom-level path information; search for the index identification information contained in the bottom-level path information, and construct the file path corresponding to the first target file according to the index identification information.

4. The device according to claim 3, characterized in that The first acquisition module is specifically used to obtain a first compressed package corresponding to the basic system image and a second compressed package corresponding to the target basic system image; compare the files contained in the bottom layer of the first compressed package and the second compressed package, and identify inconsistent first target files.

5. An electronic device, comprising at least a processor and a memory, characterized in that: The processor is used to execute the image update steps described in any one of claims 1-2 when executing the computer program stored in the memory.

6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the image updating steps described in any one of claims 1 to 2 are performed.