Uncompress vulnerability databases at runtime
Proposal
In order to save space in the Docker image, gemmnasium-maven contains various versions of Java in a compressed state, and inflates them before running a scan.
The purpose of this issue is to implement the same approach in container-scanning in order to decrease the size of the Docker image. For example, this proof of concept Uncompress vulnerability databases at runtime (gitlab-org/security-products/analyzers/container-scanning!2868 - merged) was able to decrease the size of the container-scanning image from 1,160MB to 502MB, a savings of 57%.
Implementation Plan
Use Uncompress vulnerability databases at runtime (gitlab-org/security-products/analyzers/container-scanning!2868 - merged) as a starting point.
-
Update script/setup.sh: -
Do not uncompress trivydata files:Remove the lines that uncompresses
db.tar.gztotrivy/ce/dbandtrivy/ee/db, and instead, pull thetrivy_db_version_ceandtrivy_db_version_eeORAS images directly to the/tmp/trivy-ceand/tmp/trivy-eedirectories, repectively. -
Compress grypedata files:In the
setup_grype_filesfunction, right after we calldownload_grype_db, we should add another functioncompress_grype_dbwhich compresses the files in~/.cache/grype/db/
-
-
Create a .bashrcfile which inflates thetrivyandgrypedatabase files compressed in step1.above.This
.bashrcshould be executed and inflate the vulnerability databases when running the GitLab container scanning image from:- the commandline
- a CI job
-
Update the description of this issue to show how much space was saved for both grypeandtrivycontainer scanning images.Compression and benchmarking details are in the MR description.
/cc @sam.white @gonzoyumo