scripts/support/cve.py: avoid a complete clone of the CVE git repository

Just a simple clone and pull with --depth 1 should be enough to parse
the CVE data and generate the pkg-stats report.

From a full clone and a depth-1 clone, and the size delta is 2.9GiB
vs. 2.2GiB.

The download size does change: from 983.55MiB down to 270.78MiB.

It's a net time win too: 2m17s vs 1min7s (on a 100Mbps link).

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Michael Trimarchi 2024-09-03 10:57:44 +02:00 committed by Thomas Petazzoni
parent 37801767f6
commit e0ed05cc00

View File

@ -72,7 +72,7 @@ class CVE:
print(f"Updating from {NVD_BASE_URL}")
if os.path.exists(nvd_git_dir):
subprocess.check_call(
["git", "pull"],
["git", "pull", "--depth", "1"],
cwd=nvd_git_dir,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
@ -82,7 +82,7 @@ class CVE:
# happily clones into an empty directory.
os.makedirs(nvd_git_dir)
subprocess.check_call(
["git", "clone", NVD_BASE_URL, nvd_git_dir],
["git", "clone", "--depth", "1", NVD_BASE_URL, nvd_git_dir],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)