File tree 2 files changed +23
-1
lines changed
test/test_step_2/module_tests
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,15 @@ class wafw00f(BaseModule):
26
26
in_scope_only = True
27
27
per_hostport_only = True
28
28
29
+ async def filter_event (self , event ):
30
+ http_status = getattr (event , "http_status" , 0 )
31
+ if not http_status or str (http_status ).startswith ("3" ):
32
+ return False , f"Invalid HTTP status code: { http_status } "
33
+ return True , ""
34
+
29
35
async def handle_event (self , event ):
30
36
url = f"{ event .parsed .scheme } ://{ event .parsed .netloc } /"
31
- WW = await self .scan .run_in_executor (wafw00f_main .WAFW00F , url )
37
+ WW = await self .scan .run_in_executor (wafw00f_main .WAFW00F , url , followredirect = False )
32
38
waf_detections = await self .scan .run_in_executor (WW .identwaf )
33
39
if waf_detections :
34
40
for waf in waf_detections :
Original file line number Diff line number Diff line change @@ -12,3 +12,19 @@ async def setup_after_prep(self, module_test):
12
12
13
13
def check (self , module_test , events ):
14
14
assert any (e .type == "WAF" and "LiteSpeed" in e .data ["WAF" ] for e in events )
15
+
16
+
17
+ class TestWafw00f_noredirect (ModuleTestBase ):
18
+ targets = ["http://127.0.0.1:8888" ]
19
+ modules_overrides = ["httpx" , "wafw00f" ]
20
+
21
+ async def setup_after_prep (self , module_test ):
22
+ expect_args = {"method" : "GET" , "uri" : "/" }
23
+ respond_args = {"status" : 301 , "headers" : {"Location" : "/redirect" }}
24
+ module_test .set_expect_requests (expect_args = expect_args , respond_args = respond_args )
25
+ expect_args = {"method" : "GET" , "uri" : "/redirect" }
26
+ respond_args = {"response_data" : "Proudly powered by litespeed web server" }
27
+ module_test .set_expect_requests (expect_args = expect_args , respond_args = respond_args )
28
+
29
+ def check (self , module_test , events ):
30
+ assert not any (e .type == "WAF" for e in events )
You can’t perform that action at this time.
0 commit comments