Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CPE summary (without latest stable release) #3277

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions cve_bin_tool/output_engine/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,52 @@ def _output_console_nowrap(
console.print(Panel("CVE SUMMARY", expand=False))
console.print(table)

# Create table instance for CPE Summary
table = Table()
# Add Head Columns to the Table
table.add_column("Vendor")
table.add_column("Product")
table.add_column("Version")
table.add_column("CRITICAL CVEs Count")
table.add_column("HIGH CVEs Count")
table.add_column("MEDIUM CVEs Count")
table.add_column("LOW CVEs Count")
table.add_column("UNKNWON CVEs Count")
table.add_column("TOTAL CVEs Count")
if all_product_data is not None:
for product_data in all_product_data:
color = None
summary = get_cve_summary(
{product_data: all_cve_data[product_data]}, exploits
)

# Display package with the color of the highest CVE
for severity, count in summary.items():
if color is None and count > 0:
color = summary_color[severity.split("-")[0]]

if all_product_data[product_data] != 0:
cells = [
Text.styled(product_data.vendor, color),
Text.styled(product_data.product, color),
Text.styled(product_data.version, color),
]
for severity, count in summary.items():
if count > 0:
color = summary_color[severity.split("-")[0]]
else:
color = "white"
cells += [
Text.styled(str(count), color),
]
cells += [
Text.styled(str(all_product_data[product_data]), color),
]
table.add_row(*cells)
# Print the table to the console
console.print(Panel("CPE SUMMARY", expand=False))
console.print(table)

cve_by_remarks: defaultdict[Remarks, list[dict[str, str]]] = defaultdict(list)
cve_by_paths: defaultdict[Remarks, list[dict[str, str]]] = defaultdict(list)
# group cve_data by its remarks and separately by paths
Expand Down