@@ -62,24 +62,29 @@ def agent_without_analyzer(mock_llm):
6262 ("agent_with_llm_analyzer" , "MEDIUM" , SecurityRisk .MEDIUM , False ),
6363 ("agent_with_llm_analyzer" , "HIGH" , SecurityRisk .HIGH , False ),
6464 ("agent_with_llm_analyzer" , "UNKNOWN" , SecurityRisk .UNKNOWN , False ),
65- # Case 2: analyzer is not set, security risk is passed, extracted properly
65+ # Case 2: Non-LLM analyzer set, security risk is passed, extracted properly
6666 ("agent_with_non_llm_analyzer" , "LOW" , SecurityRisk .LOW , False ),
6767 ("agent_with_non_llm_analyzer" , "MEDIUM" , SecurityRisk .MEDIUM , False ),
6868 ("agent_with_non_llm_analyzer" , "HIGH" , SecurityRisk .HIGH , False ),
6969 ("agent_with_non_llm_analyzer" , "UNKNOWN" , SecurityRisk .UNKNOWN , False ),
70- ("agent_without_analyzer" , "LOW" , SecurityRisk .LOW , False ),
71- ("agent_without_analyzer" , "MEDIUM" , SecurityRisk .MEDIUM , False ),
72- ("agent_without_analyzer" , "HIGH" , SecurityRisk .HIGH , False ),
70+ # Case 3: No analyzer set, security risk is passed, should be ignored
71+ # (return UNKNOWN)
72+ ("agent_without_analyzer" , "LOW" , SecurityRisk .UNKNOWN , False ),
73+ ("agent_without_analyzer" , "MEDIUM" , SecurityRisk .UNKNOWN , False ),
74+ ("agent_without_analyzer" , "HIGH" , SecurityRisk .UNKNOWN , False ),
7375 ("agent_without_analyzer" , "UNKNOWN" , SecurityRisk .UNKNOWN , False ),
74- # Case 3 : LLM analyzer set, security risk not passed, ValueError raised
76+ # Case 4 : LLM analyzer set, security risk not passed, ValueError raised
7577 ("agent_with_llm_analyzer" , None , None , True ),
76- # Case 4 : analyzer is not set, security risk is not passed, UNKNOWN returned
78+ # Case 5 : analyzer is not set, security risk is not passed, UNKNOWN returned
7779 ("agent_with_non_llm_analyzer" , None , SecurityRisk .UNKNOWN , False ),
7880 ("agent_without_analyzer" , None , SecurityRisk .UNKNOWN , False ),
79- # Case 5: invalid security risk value passed, ValueError raised
81+ # Case 6: invalid security risk value passed
82+ # - With LLM analyzer: ValueError raised for validation
83+ # - With non-LLM analyzer: ValueError raised for invalid enum
84+ # - Without analyzer: ignored, returns UNKNOWN (no validation attempted)
8085 ("agent_with_llm_analyzer" , "INVALID" , None , True ),
8186 ("agent_with_non_llm_analyzer" , "INVALID" , None , True ),
82- ("agent_without_analyzer" , "INVALID" , None , True ),
87+ ("agent_without_analyzer" , "INVALID" , SecurityRisk . UNKNOWN , False ),
8388 ],
8489)
8590def test_extract_security_risk (
@@ -122,14 +127,14 @@ def test_extract_security_risk_arguments_mutation():
122127 )
123128 )
124129
125- # Test with security_risk present
130+ # Test with security_risk present but no analyzer (should be ignored)
126131 arguments = {"param1" : "value1" , "security_risk" : "LOW" , "param2" : "value2" }
127132 original_args = arguments .copy ()
128133
129134 result = agent ._extract_security_risk (arguments , "test_tool" , False , None )
130135
131- # Verify result
132- assert result == SecurityRisk .LOW
136+ # Verify result is UNKNOWN when no analyzer is set (security_risk is ignored)
137+ assert result == SecurityRisk .UNKNOWN
133138
134139 # Verify security_risk was popped
135140 assert "security_risk" not in arguments
0 commit comments