@@ -200,3 +200,36 @@ def test_ssrf_vulnerability_scan_bypassed_ip(get_context):
200200
201201 # Verify that hostnames.add was not called due to bypassed IP
202202 assert get_cache ().hostnames .as_array () == []
203+
204+
205+ def test_ssrf_vulnerability_scan_protection_gets_forced_off (get_context ):
206+ get_context .set_as_current_context ()
207+ get_cache ().config .bypassed_ips = IPMatcher (["198.51.100.23" ])
208+
209+ dns_results = MagicMock ()
210+ hostname = "example.com"
211+ port = 80
212+ assert get_context .protection_forced_off is None
213+ run_vulnerability_scan (kind = "ssrf" , op = "test" , args = (dns_results , hostname , port ))
214+ assert get_context .protection_forced_off is False
215+
216+
217+ def test_sql_injection_with_protection_forced_off (caplog , get_context , monkeypatch ):
218+ get_context .set_as_current_context ()
219+ monkeypatch .setenv ("AIKIDO_BLOCK" , "1" )
220+ with patch ("aikido_zen.background_process.comms.get_comms" ) as mock_get_comms :
221+ # Create a mock comms object
222+ mock_comms = MagicMock ()
223+ mock_get_comms .return_value = mock_comms # Set the return value of get_comms
224+ with pytest .raises (AikidoSQLInjection ):
225+ run_vulnerability_scan (
226+ kind = "sql_injection" ,
227+ op = "test_op" ,
228+ args = ("INSERT * INTO VALUES ('doggoss2', TRUE);" , "mysql" ),
229+ )
230+ get_context .set_force_protection_off (True )
231+ run_vulnerability_scan (
232+ kind = "sql_injection" ,
233+ op = "test_op" ,
234+ args = ("INSERT * INTO VALUES ('doggoss2', TRUE);" , "mysql" ),
235+ )
0 commit comments