Skip to content

Commit

Permalink
feat: Made Remark enumeration human readable in reports (#3991)
Browse files Browse the repository at this point in the history
This update modifies the HTML report to display human-readable names for the Remarks type. For example, instead of displaying "Remarks.NotAffected" as the Python enumeration representation, the report now shows a more user-friendly name, such as "Not Affected".
  • Loading branch information
cinix committed Apr 1, 2024
1 parent d74b27f commit cdf85b3
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions cve_bin_tool/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,32 @@ class Remarks(OrderedEnum):
Each member of the enumeration represents a specific remark with a unique value.
"""

NewFound = 1, "1", "NewFound", "n", "N"
Unexplored = 2, "2", "Unexplored", "u", "U", ""
Confirmed = 3, "3", "Confirmed", "c", "C"
Mitigated = 4, "4", "Mitigated", "m", "M"
FalsePositive = 5, "5", "FalsePositive", "f", "F"
NotAffected = 6, "6", "NotAffected", "i", "I"

def __new__(cls, value: int, *aliases: str) -> Remarks:
NewFound = 1, "New", "1", "NewFound", "n", "N"
Unexplored = 2, "Unexplored", "2", "Unexplored", "u", "U", ""
Confirmed = 3, "Confirmed", "3", "Confirmed", "c", "C"
Mitigated = 4, "Mitigated", "4", "Mitigated", "m", "M"
FalsePositive = 5, "False Positive", "5", "FalsePositive", "f", "F"
NotAffected = 6, "Not Affected", "6", "NotAffected", "i", "I"

def __new__(cls, value: int, string: str, *aliases: str) -> Remarks:
"""
Return a new instance of the Remarks enumeration.
"""
obj = object.__new__(cls)
obj._value_ = value
for alias in aliases:
cls._value2member_map_[alias] = obj
string_map = getattr(cls, "string_map", {})
string_map[value] = string
cls.string_map = string_map
return obj

def __str__(self):
"""
Returns a human-readable string of the enumeration value
"""
return self.string_map[self.value]


class CVE(NamedTuple):
"""
Expand Down

0 comments on commit cdf85b3

Please sign in to comment.