Skip to content

Commit 767ff57

Browse files
committed
extract colors
1 parent c9ac875 commit 767ff57

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

cimd/commands/extract/trivy_scans.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
from cimd.classes.metadata import Item
1010
from cimd.classes.shields_link import ShieldsLink
1111

12+
COLORS = {
13+
"CRITICAL": "red",
14+
"HIGH": "orange",
15+
"MEDIUM": "yellow",
16+
"LOW": "green",
17+
"UNKNOWN": "lightgray",
18+
}
19+
1220

1321
class Vulnerability(BaseModel):
1422
"""Single vulnerability item"""
@@ -44,14 +52,7 @@ def count_json_file(json_file: str) -> dict[str, int]:
4452
def image_for_severity_count(severity: str, count: int) -> str:
4553
"""Create a shields.io image for a severity count"""
4654
severity = severity.upper()
47-
colors = {
48-
"CRITICAL": "red",
49-
"HIGH": "orange",
50-
"MEDIUM": "yellow",
51-
"LOW": "green",
52-
"UNKNOWN": "lightgray",
53-
}
54-
color = colors.get(severity, "blue")
55+
color = COLORS.get(severity, "blue")
5556
return ShieldsLink(label=severity, message=str(count), color=color, logo="trivy").to_string()
5657

5758

0 commit comments

Comments
 (0)