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

fix(output): normalize severity values to prevent HTML report failure #4786

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JigyasuRajput
Copy link
Contributor

@JigyasuRajput JigyasuRajput commented Feb 8, 2025

Description

Fixes #4392 where the HTML report generator fails due to unexpected severity values like "HIGH-EXPLOIT". The error occurs because the severity key is not recognized in SEVERITY_TYPES_COLOR, leading to a KeyError.

Solution

  • Introduced a normalize_severity() function to standardize severity values before processing.
  • The function converts severities to uppercase and ensures that values with prefixes (e.g., "HIGH-EXPLOIT") are mapped to their base severities ("HIGH").
  • Updated occurrences where severity values are used:
    • Normalized severity before incrementing cve_severity counters.
    • Applied normalization while analyzing cve_data["cves"].

Previously, this failed due to an unknown severity. With this fix, it now processes correctly.

Testing

  • Unit Tests: Added a test case for normalize_severity() with various input formats (e.g., "HIGH-EXPLOIT", "critical-risk", "something-else").
  • Integration Test: Verified that an HTML report with non-standard severity values is generated correctly without errors.
  • Manually tested with severities like "HIGH-EXPLOIT", "CRITICAL-RISK", and "LOW-VULNERABILITY".
  • Verified that the HTML report is generated successfully without errors.

Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is looking good. Could you also add a test that will trigger this?

@JigyasuRajput
Copy link
Contributor Author

Thanks, this is looking good. Could you also add a test that will trigger this?

Done! I've Added test cases to cover severity normalization. Let me know if any changes are needed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: HTML report generator fails due to unknown severity
2 participants