cvss_color
This dynamic automation parses the CVSS score of a CVE and presents it in the layout in color according to its score.
python · Common Scripts
Details
| ID | cvss_color |
|---|---|
| Language | python |
| From Version | 6.5.0 |
| Docker Image | demisto/python3:3.12.13.11879924 |
| Tags | dynamic-indicator-section |
README
CVECVSSColor
This dynamic automation parses the CVSS score of a CVE and presents it in the layout in color according to its score.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | dynamic-indicator-section |
| Cortex XSOAR Version | 6.8.0 |
Inputs
There are no inputs for this script.
Outputs
There are no outputs for this script.
import math from CommonServerPython import * def get_color(cvss: int | float) -> str: """ Gets a CVSS score as an integer\float and sends back the correct hex code for a color as a string. Args: cvss (int\float): A CVE CVSS score. Returns: str: The color of the score in hex format """ colors = { "Green1": "#50C878", "Green2": "#6CB65B", "Green3": "#89C35B", "Green4": "#A3C157", "Amber1": "#FFB347", "Amber2": "#FFA07A", "Amber3": "#FF7F50", "Red1": "#FF6347", "Red2": "#FF4500", "Red3": "#FF4040", } cvss = int(math.ceil(cvss)) if not 0 < cvss <= 10: color = "#000000" elif cvss <= 4: color = colors[f"Green{cvss}"] elif cvss <= 7: color = colors[f"Amber{cvss - 4}"] else: color = colors[f"Red{cvss - 7}"] return color def main(): indicator = demisto.callingContext.get("args", {}).get("indicator", {}) cvss = indicator.get("CustomFields", {}).get("cvssscore", "") theme = demisto.callingContext.get("context", "light").get("User", "light").get("theme", "light") cvss = 0 if not cvss else float(cvss) if cvss == 0: if theme not in ("light", ""): return_results(CommandResults(readable_output="# <-:->{{color:#FFFFFF}}(**N/A**)")) else: return_results(CommandResults(readable_output="# <-:->{{color:#000000}}(**N/A**)")) else: color = get_color(cvss) return_results(CommandResults(readable_output=f"# <-:->{{{{color:{color}}}}}(**{cvss}**)")) if __name__ in ("__builtin__", "builtins", "__main__"): main()