-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlevel.py
54 lines (44 loc) · 910 Bytes
/
level.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""Levels for confidence and severity.
UNKNOWN = 0
LOW = 1
MED = 2
HIGH = 3
"""
from __future__ import annotations
from enum import IntEnum
class Level(IntEnum):
"""Levels for confidence and severity."""
UNKNOWN = 0
LOW = 1
MED = 2
HIGH = 3
CRIT = 4
def __repr__(self) -> str:
"""__repr__ method.
Returns:
str: string representation of a level
"""
return self.__str__()
def __str__(self) -> str:
"""__str__ method (tostring).
Returns:
str: string representation of a level
"""
reprMap = {
Level.UNKNOWN: "Unknown",
Level.LOW: "Low",
Level.MED: "Medium",
Level.HIGH: "High",
Level.CRIT: "Critical",
}
return reprMap[self]
def toSarif(self) -> str:
"""Convert to sarif representation."""
reprMap = {
Level.UNKNOWN: "note",
Level.LOW: "note",
Level.MED: "warning",
Level.HIGH: "error",
Level.CRIT: "error",
}
return reprMap[self]