@@ -526,6 +526,7 @@ def test_report_output_format_sarif_includes_finding_properties(self) -> None:
526526 }
527527 result = report (state )
528528 result_row = result ["sarif_report" ]["runs" ][0 ]["results" ][0 ]
529+ assert result_row ["properties" ]["severity" ] == "HIGH"
529530 assert result_row ["properties" ]["category" ] == "environment"
530531 assert result_row ["properties" ]["pattern" ] == r"os\.environ"
531532 assert result_row ["properties" ]["confidence" ] == 0.85
@@ -611,6 +612,7 @@ def test_report_baseline_suppresses_finding_and_lowers_score() -> None:
611612 suppressed_result = sarif_results [0 ]
612613 assert suppressed_result ["suppressions" ][0 ]["kind" ] == "external"
613614 assert suppressed_result ["suppressions" ][0 ]["justification" ] == "false positive"
615+ assert suppressed_result ["properties" ]["severity" ] == "CRITICAL"
614616 assert suppressed_result ["properties" ]["category" ] == "critical_path"
615617 assert suppressed_result ["properties" ]["pattern" ] == r"exec\("
616618 assert suppressed_result ["properties" ]["confidence" ] == 1.0
@@ -743,3 +745,24 @@ def test_report_doc_findings_no_multiplier() -> None:
743745 # Without the multiplier: 2 HIGH = 50, not 65
744746 assert result ["risk_score" ] == 50
745747 assert result ["risk_severity" ] == "MEDIUM"
748+
749+
750+ def test_report_sarif_preserves_high_vs_critical_severity () -> None :
751+ """HIGH and CRITICAL both map to SARIF error, but properties keep the exact severity."""
752+ state : SkillspectorState = {
753+ "filtered_findings" : [
754+ _finding ("R1" , "HIGH" , message = "high finding" , file = "high.py" ),
755+ _finding ("R2" , "CRITICAL" , message = "critical finding" , file = "critical.py" ),
756+ ],
757+ "component_metadata" : [],
758+ "has_executable_scripts" : False ,
759+ "manifest" : {},
760+ "skill_path" : None ,
761+ "output_format" : "sarif" ,
762+ }
763+ results = report (state )["sarif_report" ]["runs" ][0 ]["results" ]
764+ by_rule = {item ["ruleId" ]: item for item in results }
765+ assert by_rule ["R1" ]["level" ] == "error"
766+ assert by_rule ["R2" ]["level" ] == "error"
767+ assert by_rule ["R1" ]["properties" ]["severity" ] == "HIGH"
768+ assert by_rule ["R2" ]["properties" ]["severity" ] == "CRITICAL"
0 commit comments