diff --git a/prowler/lib/outputs/sarif/sarif.py b/prowler/lib/outputs/sarif/sarif.py index c1e2acce66..b974b2ac7b 100644 --- a/prowler/lib/outputs/sarif/sarif.py +++ b/prowler/lib/outputs/sarif/sarif.py @@ -41,15 +41,17 @@ class SARIF(Output): severity = finding.metadata.Severity.lower() if check_id not in rules: - rules[check_id] = { + rule = { "id": check_id, "name": check_id, "shortDescription": {"text": finding.metadata.CheckTitle}, - "fullDescription": {"text": finding.metadata.Description}, - "helpUri": finding.metadata.RelatedUrl or "", + "fullDescription": { + "text": finding.metadata.Description or check_id + }, "help": { "text": finding.metadata.Remediation.Recommendation.Text - or finding.metadata.Description, + or finding.metadata.Description + or check_id, }, "defaultConfiguration": { "level": SEVERITY_TO_SARIF_LEVEL.get(severity, "note"), @@ -65,13 +67,18 @@ class SARIF(Output): ), }, } + if finding.metadata.RelatedUrl: + rule["helpUri"] = finding.metadata.RelatedUrl + rules[check_id] = rule rule_index = list(rules.keys()).index(check_id) result = { "ruleId": check_id, "ruleIndex": rule_index, "level": SEVERITY_TO_SARIF_LEVEL.get(severity, "note"), - "message": {"text": finding.status_extended}, + "message": { + "text": finding.status_extended or finding.metadata.CheckTitle + }, } location = self._build_location(finding) diff --git a/tests/lib/outputs/sarif/sarif_test.py b/tests/lib/outputs/sarif/sarif_test.py index 32f5551f4a..fdcef057de 100644 --- a/tests/lib/outputs/sarif/sarif_test.py +++ b/tests/lib/outputs/sarif/sarif_test.py @@ -221,7 +221,6 @@ class TestSARIF: assert "id" in rule assert "shortDescription" in rule assert "fullDescription" in rule - assert "helpUri" in rule assert "help" in rule assert "defaultConfiguration" in rule assert "properties" in rule