Commit acab321d authored by Clement Bois's avatar Clement Bois
Browse files

chore: improve findings format

parent ce27817e
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ INSECURE_SSL_CTX.verify_mode = ssl.CERT_NONE

MIME_APPLICATION_JSON = "application/json"

SEVERITY_COLOR = [AnsiColors.HRED, AnsiColors.RED, AnsiColors.YELLOW, AnsiColors.GREEN, AnsiColors.RESET, AnsiColors.PURPLE]

class DtPermission(str, Enum):
    """Dependency Track permissions.
@@ -552,11 +553,12 @@ class Scanner:
        for o in findings:
            vuln = o.get("vulnerability", {})
            component = o.get("component", {})
            color = SEVERITY_COLOR[vuln.get("severityRank", 5)]
            cwes = (cwe["name"] for cwe in vuln.get("cwes", []))
            print(
                f'[{vuln.get("severity", "?")}] {" ".join(cwes)} - {component.get("group","")}:{component.get("name")}:{component.get("version","")}'
                f'  - {vuln["vulnId"]} {color}{vuln.get("severity", "?").capitalize()}{AnsiColors.RESET}: {component.get("group","")}:{component.get("name")}:{component.get("version","")} - {" ".join(cwes)}'
            )
            print(vuln.get("description", "").strip())
            print(re.sub('\n+', '\n', vuln.get("description", "").strip()))
            print()
        print(
            f"- scan {AnsiColors.HGREEN}succeeded{AnsiColors.RESET}: {len(findings)} vulnerabilities found{AnsiColors.RESET}"