support/scripts/cve.py: remove print from cve.py library
The `support/script/cve.py` file is used as a library. Depending on how you use this library you might not want to write content to stdout when calling its function. This patch move the 'updating' log to the 'pkg-stats' script and write the alert when LooseVersion doesn't have a version to stderr. Signed-off-by: Thomas Perale <thomas.perale@mind.be> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
committed by
Peter Korsgaard
parent
12500fb060
commit
4b318dea17
@@ -69,7 +69,6 @@ class CVE:
|
||||
|
||||
@staticmethod
|
||||
def download_nvd(nvd_git_dir):
|
||||
print(f"Updating from {NVD_BASE_URL}")
|
||||
if os.path.exists(nvd_git_dir):
|
||||
subprocess.check_call(
|
||||
["git", "pull"],
|
||||
@@ -192,7 +191,7 @@ class CVE:
|
||||
|
||||
pkg_version = distutils.version.LooseVersion(version)
|
||||
if not hasattr(pkg_version, "version"):
|
||||
print("Cannot parse package '%s' version '%s'" % (name, version))
|
||||
print("Cannot parse package '%s' version '%s'" % (name, version), file=sys.stderr)
|
||||
pkg_version = None
|
||||
|
||||
# if we don't have a cpeid, build one based on name and version
|
||||
|
||||
@@ -675,6 +675,7 @@ def check_package_cves(nvd_path, packages):
|
||||
else:
|
||||
cpe_product_pkgs[pkg.name].append(pkg)
|
||||
|
||||
print(f"Updating NVD database in '{nvd_path}'")
|
||||
for cve in cvecheck.CVE.read_nvd_dir(nvd_path):
|
||||
check_package_cve_affects(cve, cpe_product_pkgs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user