diff --git a/cve_bin_tool/util.py b/cve_bin_tool/util.py index 52a7cb70d7..c0fb0ceac3 100644 --- a/cve_bin_tool/util.py +++ b/cve_bin_tool/util.py @@ -85,14 +85,14 @@ 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. """ @@ -100,8 +100,17 @@ def __new__(cls, value: int, *aliases: str) -> Remarks: 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): """