MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / analyzer

Function analyzer

tests/test_traffic_analyzer_beacon.py:20–33  ·  view source on GitHub ↗

A TrafficAnalyzer with side-effecting init paths stubbed out. We don't want the constructor probing real network interfaces or running `ip`/tcpdump during unit tests.

()

Source from the content-addressed store, hash-verified

18
19@pytest.fixture
20def analyzer():
21 """A TrafficAnalyzer with side-effecting init paths stubbed out.
22
23 We don't want the constructor probing real network interfaces or running
24 `ip`/tcpdump during unit tests.
25 """
26 with patch.object(TrafficAnalyzer, '_detect_interface', return_value='lo'), \
27 patch.object(TrafficAnalyzer, '_detect_local_ips',
28 return_value={'127.0.0.1', '192.168.1.10'}):
29 a = TrafficAnalyzer(shared_data=None, interface='lo')
30 # Make alert rate-limiting essentially unlimited for tests.
31 a.MAX_ALERTS_PER_MINUTE = 10_000
32 a._alert_dedup_window = 0
33 return a
34
35
36def _seed_periodic_flow(analyzer, src, dst, port, *,

Callers

nothing calls this directly

Calls 1

TrafficAnalyzerClass · 0.90

Tested by

no test coverage detected