From 5810c7564cc73bf3b043184f1dd176e75e89b71d Mon Sep 17 00:00:00 2001 From: tahifahimi Date: Wed, 7 Feb 2024 12:14:07 -0700 Subject: [PATCH] chore: update inconsistency in files with black v24.1.1 --- cve_bin_tool/checkers/bind.py | 2 +- cve_bin_tool/checkers/binutils.py | 2 +- cve_bin_tool/checkers/cups.py | 2 +- cve_bin_tool/data_sources/gad_source.py | 8 +++++--- cve_bin_tool/data_sources/nvd_source.py | 16 ++++++++++------ cve_bin_tool/data_sources/osv_source.py | 8 +++++--- cve_bin_tool/nvd_api.py | 8 ++++---- cve_bin_tool/output_engine/__init__.py | 18 +++++++++--------- cve_bin_tool/output_engine/html.py | 8 +++++--- 9 files changed, 41 insertions(+), 31 deletions(-) diff --git a/cve_bin_tool/checkers/bind.py b/cve_bin_tool/checkers/bind.py index 18f3523186..f14b8006ad 100644 --- a/cve_bin_tool/checkers/bind.py +++ b/cve_bin_tool/checkers/bind.py @@ -32,7 +32,7 @@ class BindChecker(Checker): VERSION_PATTERNS = [ r"version: BIND ([0-9]+\.[0-9]+\.[0-9]+)", # for .rpm, .tgz, etc. r"(?:lib|/)bind[0-9]*-([0-9]+\.[0-9]+\.[0-9]+)", # for .deb - r"/bind9-([0-9]+\.[0-9]+\.[0-9]+)" # using buildpath if included + r"/bind9-([0-9]+\.[0-9]+\.[0-9]+)", # using buildpath if included # If you trust the filenames to contain the right version number enable the following regular expressions: # r"libisc-([0-9]+\.[0-9]+\.[0-9]+)", # for libisc # r"libisccfg-([0-9]+\.[0-9]+\.[0-9]+)", # for libisccfg diff --git a/cve_bin_tool/checkers/binutils.py b/cve_bin_tool/checkers/binutils.py index cdc597252c..a6a0fee88e 100644 --- a/cve_bin_tool/checkers/binutils.py +++ b/cve_bin_tool/checkers/binutils.py @@ -48,7 +48,7 @@ class BinutilsChecker(Checker): # readelf - Displays information from any ELF format object file. # size - Lists the section sizes of an object or archive file. # strings - Lists printable strings from files. - r"can't set BFD default target to `%s': %s" + r"can't set BFD default target to `%s': %s", # strip - Discards symbols. # windmc - A Windows compatible message compiler.get_ver # windres - A compiler for Windows resource files. diff --git a/cve_bin_tool/checkers/cups.py b/cve_bin_tool/checkers/cups.py index e71ad1e516..d130731058 100644 --- a/cve_bin_tool/checkers/cups.py +++ b/cve_bin_tool/checkers/cups.py @@ -18,7 +18,7 @@ class CupsChecker(Checker): CONTAINS_PATTERNS = [ r"No limit for CUPS-Get-Document defined in policy %s and no suitable template found.", - r"\*%%%%%%%% Created by the CUPS PPD Compiler CUPS v([0-9]+\.[0-9]+\.[0-9]+)" + r"\*%%%%%%%% Created by the CUPS PPD Compiler CUPS v([0-9]+\.[0-9]+\.[0-9]+)", # Alternate optional contains patterns, # see https://github.com/intel/cve-bin-tool/tree/main/cve_bin_tool/checkers#helper-script for more details # r"Unable to edit cupsd.conf files larger than 1MB", diff --git a/cve_bin_tool/data_sources/gad_source.py b/cve_bin_tool/data_sources/gad_source.py index 081f4dca31..191ece779e 100644 --- a/cve_bin_tool/data_sources/gad_source.py +++ b/cve_bin_tool/data_sources/gad_source.py @@ -304,9 +304,11 @@ def format_data(self, all_cve_entries): "score": score if vector[0] is not None else "unknown", "CVSS_version": str(version) if vector[0] is not None else "unknown", "CVSS_vector": vector if vector[0] is not None else "unknown", - "last_modified": cve_item["date"] - if cve_item.get("date", None) - else cve_item["pubdate"], + "last_modified": ( + cve_item["date"] + if cve_item.get("date", None) + else cve_item["pubdate"] + ), } severity_data.append(cve) diff --git a/cve_bin_tool/data_sources/nvd_source.py b/cve_bin_tool/data_sources/nvd_source.py index fa7d5302ea..f3d66037d3 100644 --- a/cve_bin_tool/data_sources/nvd_source.py +++ b/cve_bin_tool/data_sources/nvd_source.py @@ -128,9 +128,11 @@ def format_data(self, all_cve_entries): "score": "unknown", "CVSS_version": "unknown", "CVSS_vector": "unknown", - "last_modified": cve_item["lastModifiedDate"] - if cve_item.get("lastModifiedDate", None) - else cve_item["publishedDate"], + "last_modified": ( + cve_item["lastModifiedDate"] + if cve_item.get("lastModifiedDate", None) + else cve_item["publishedDate"] + ), } if cve["description"].startswith("** REJECT **"): # Skip this CVE if it's marked as 'REJECT' @@ -226,9 +228,11 @@ def format_data_api2(self, all_cve_entries): "score": "unknown", "CVSS_version": "unknown", "CVSS_vector": "unknown", - "last_modified": cve_item["lastModified"] - if cve_item.get("lastModified", None) - else cve_item["published"], + "last_modified": ( + cve_item["lastModified"] + if cve_item.get("lastModified", None) + else cve_item["published"] + ), } if cve["description"].startswith("** REJECT **"): # Skip this CVE if it's marked as 'REJECT' diff --git a/cve_bin_tool/data_sources/osv_source.py b/cve_bin_tool/data_sources/osv_source.py index c8bbfea37e..2d5ea18037 100644 --- a/cve_bin_tool/data_sources/osv_source.py +++ b/cve_bin_tool/data_sources/osv_source.py @@ -285,9 +285,11 @@ def format_data(self, all_cve_entries): "score": score if vector is not None else "unknown", "CVSS_version": version if vector is not None else "unknown", "CVSS_vector": vector if vector is not None else "unknown", - "last_modified": cve_item["modified"] - if cve_item.get("modified", None) - else cve_item["published"], + "last_modified": ( + cve_item["modified"] + if cve_item.get("modified", None) + else cve_item["published"] + ), } severity_data.append(cve) diff --git a/cve_bin_tool/nvd_api.py b/cve_bin_tool/nvd_api.py index 33da2c53f6..7c7c4bf7f0 100644 --- a/cve_bin_tool/nvd_api.py +++ b/cve_bin_tool/nvd_api.py @@ -158,10 +158,10 @@ async def get_nvd_params( if time_of_last_update: # Fetch all the updated CVE entries from the modified date. Subtracting 2-minute offset for updating cve entries if self.api_version == "2.0": - self.params[ - "lastModStartDate" - ] = self.convert_date_to_nvd_date_api2( - time_of_last_update - timedelta(minutes=2) + self.params["lastModStartDate"] = ( + self.convert_date_to_nvd_date_api2( + time_of_last_update - timedelta(minutes=2) + ) ) self.params["lastModEndDate"] = self.convert_date_to_nvd_date_api2( datetime.now() diff --git a/cve_bin_tool/output_engine/__init__.py b/cve_bin_tool/output_engine/__init__.py index f588da58b8..9dccc92c85 100644 --- a/cve_bin_tool/output_engine/__init__.py +++ b/cve_bin_tool/output_engine/__init__.py @@ -481,9 +481,9 @@ def output_pdf( pdfdoc.paragraph( "The table given below gives CVE found with there score on different metrics." ) - cve_by_metrics: defaultdict[ - Remarks, list[dict[str, str]] - ] = defaultdict(list) + cve_by_metrics: defaultdict[Remarks, list[dict[str, str]]] = ( + defaultdict(list) + ) col_headings = [ "CVE Number", "CVSS_version", @@ -920,9 +920,9 @@ def generate_sbom( my_package.set_licenseconcluded(license) my_package.set_supplier("UNKNOWN", "NOASSERTION") # Store package data - sbom_packages[ - (my_package.get_name(), my_package.get_value("version")) - ] = my_package.get_package() + sbom_packages[(my_package.get_name(), my_package.get_value("version"))] = ( + my_package.get_package() + ) sbom_relationship.initialise() sbom_relationship.set_relationship(parent, "DESCRIBES", root_package) sbom_relationships.append(sbom_relationship.get_relationship()) @@ -935,9 +935,9 @@ def generate_sbom( my_package.set_supplier("Organization", product_data.vendor) my_package.set_licensedeclared(license) my_package.set_licenseconcluded(license) - sbom_packages[ - (my_package.get_name(), my_package.get_value("version")) - ] = my_package.get_package() + sbom_packages[(my_package.get_name(), my_package.get_value("version"))] = ( + my_package.get_package() + ) sbom_relationship.initialise() sbom_relationship.set_relationship( root_package, "DEPENDS_ON", product_data.product diff --git a/cve_bin_tool/output_engine/html.py b/cve_bin_tool/output_engine/html.py index 6944c5c9c5..3a7312460c 100644 --- a/cve_bin_tool/output_engine/html.py +++ b/cve_bin_tool/output_engine/html.py @@ -368,9 +368,11 @@ def output_html( vendor=product_info.vendor, name=product_info.product, version=product_info.version, - cve_count=0 - if cve_data["cves"][0][1] == "UNKNOWN" - else len(cve_data["cves"]), + cve_count=( + 0 + if cve_data["cves"][0][1] == "UNKNOWN" + else len(cve_data["cves"]) + ), severity_analysis=analysis_pie.to_html( full_html=False, include_plotlyjs=False ),