1+ import json
2+
13from .base import ModuleTestBase
24
35
@@ -12,3 +14,55 @@ def check(self, module_test, events):
1214 and event .data ["protocol" ] == "HTTP"
1315 for event in events
1416 ), "HTTP protocol not detected"
17+
18+
19+ class TestFingerprintxURLs (ModuleTestBase ):
20+ """Mocks fingerprintx output to verify URL_UNVERIFIED construction across IPv4/IPv6 and default/non-default ports."""
21+
22+ module_name = "fingerprintx"
23+ targets = [
24+ "127.0.0.1:80" ,
25+ "127.0.0.1:8443" ,
26+ "[::1]:443" ,
27+ "[::1]:8080" ,
28+ ]
29+ config_overrides = {"modules" : {"fingerprintx" : {"skip_common_web" : False }}}
30+
31+ # (host, port, protocol) -> what fingerprintx pretends to find
32+ fake_results = [
33+ ("127.0.0.1" , 80 , "HTTP" ),
34+ ("127.0.0.1" , 8443 , "HTTPS" ),
35+ ("::1" , 443 , "HTTPS" ),
36+ ("::1" , 8080 , "HTTP" ),
37+ ]
38+
39+ async def setup_after_prep (self , module_test ):
40+ results = self .fake_results
41+
42+ async def fake_run_process_live (self , command , ** kwargs ):
43+ for host , port , protocol in results :
44+ yield json .dumps ({"ip" : host , "host" : host , "port" : port , "protocol" : protocol })
45+
46+ module_test .monkeypatch .setattr (module_test .module .__class__ , "run_process_live" , fake_run_process_live )
47+
48+ def check (self , module_test , events ):
49+ urls = {e .data ["url" ] for e in events if e .type == "URL_UNVERIFIED" }
50+ expected = {
51+ "http://127.0.0.1/" ,
52+ "https://127.0.0.1:8443/" ,
53+ "https://[::1]/" ,
54+ "http://[::1]:8080/" ,
55+ }
56+ assert expected .issubset (urls ), f"missing URLs; got { urls } "
57+
58+ protocol_events = [e for e in events if e .type == "PROTOCOL" ]
59+ assert any (
60+ e .host == module_test .scan .helpers .make_ip_type ("::1" ) and e .port == 443 and e .data ["protocol" ] == "HTTPS"
61+ for e in protocol_events
62+ ), "IPv6 PROTOCOL event missing — parent lookup likely broken"
63+ assert any (
64+ e .host == module_test .scan .helpers .make_ip_type ("127.0.0.1" )
65+ and e .port == 8443
66+ and e .data ["protocol" ] == "HTTPS"
67+ for e in protocol_events
68+ ), "IPv4 PROTOCOL event missing"
0 commit comments