Skip to content

Commit

Permalink
chore: fixes most mypy errors in file output_engine/util.py (intel#2785)
Browse files Browse the repository at this point in the history
* chore: fixes most mypy errors in file output_engine/util.py
* fix: intel#2766

updated if statement to check if cve.cve_number is valid key for dic
  • Loading branch information
angelina-p09 authored Mar 16, 2023
1 parent 8749b8b commit 25ebe75
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cve_bin_tool/output_engine/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def get_cve_summary(
for cve_data in all_cve_data.values():
for s in summary.keys():
summary[s] += sum(
cve.severity == s
isinstance(cve, CVE)
and cve.severity == s
and cve.remarks not in [Remarks.Ignored, Remarks.Mitigated]
for cve in cve_data["cves"]
)
Expand Down Expand Up @@ -137,6 +138,8 @@ def format_output(
formatted_output = []
for product_info, cve_data in all_cve_data.items():
for cve in cve_data["cves"]:
if isinstance(cve, str):
continue
details = {
"vendor": product_info.vendor,
"product": product_info.product,
Expand All @@ -154,9 +157,12 @@ def format_output(
if detailed:
details["description"] = cve.description
if affected_versions != 0:
try:
if (
all_cve_version_info is not None
and cve.cve_number in all_cve_version_info
):
version_info = all_cve_version_info[cve.cve_number]
except KeyError: # TODO: handle 'UNKNOWN' and some cves more cleanly
else: # TODO: handle 'UNKNOWN' and some cves more cleanly
version_info = VersionInfo("", "", "", "")
details["affected_versions"] = format_version_range(version_info)
formatted_output.append(details)
Expand Down

0 comments on commit 25ebe75

Please sign in to comment.