From c6066166895b77e9956dff93af53357b5304be9b Mon Sep 17 00:00:00 2001 From: Aliaksandr Nikitsin Date: Wed, 14 May 2025 20:08:39 +0200 Subject: [PATCH 1/3] Slpit Outbound Connection table to pages --- modules/test/tls/python/src/tls_module.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/test/tls/python/src/tls_module.py b/modules/test/tls/python/src/tls_module.py index bb5ff6695..4892829d1 100644 --- a/modules/test/tls/python/src/tls_module.py +++ b/modules/test/tls/python/src/tls_module.py @@ -36,6 +36,7 @@ GATEWAY_CAPTURE_FILE = '/runtime/network/gateway.pcap' LOGGER = None REPORT_TEMPLATE_FILE = 'report_template.jinja2' +OUTBOUND_CONNS_PER_PAGE = 18 class TLSModule(TestModule): @@ -193,12 +194,21 @@ def generate_module_report(self): device_mac=self._device_mac, capture_files=pcap_files) if outbound_conns: - out_page = template.render( - base_template=self._base_template_file, - ountbound_headers=outbound_headers, - outbound_conns=outbound_conns - ) - report_jinja += out_page + # Splitting Outbound Coonestions table to pages + pages = len(outbound_conns) // OUTBOUND_CONNS_PER_PAGE + if pages * OUTBOUND_CONNS_PER_PAGE < len(outbound_conns): + pages += 1 + for page in range(pages): + start = page * OUTBOUND_CONNS_PER_PAGE + end = min(page * OUTBOUND_CONNS_PER_PAGE + OUTBOUND_CONNS_PER_PAGE, + len(outbound_conns)) + outbound_conns_chunk = outbound_conns[start:end] + out_page = template.render( + base_template=self._base_template_file, + ountbound_headers=outbound_headers, + outbound_conns=outbound_conns_chunk + ) + report_jinja += out_page LOGGER.debug('Module report:\n' + report_jinja) From fabcff9275be9c224552151d78ef7b387f526547 Mon Sep 17 00:00:00 2001 From: Aliaksandr Nikitsin Date: Wed, 14 May 2025 20:08:50 +0200 Subject: [PATCH 2/3] unit tests --- .../unit/tls/reports/tls_report_local.html | 149 ++++++++++++++++++ testing/unit/tls/tls_module_test.py | 7 +- 2 files changed, 155 insertions(+), 1 deletion(-) diff --git a/testing/unit/tls/reports/tls_report_local.html b/testing/unit/tls/reports/tls_report_local.html index 3100aaf69..a1cc9f2d5 100644 --- a/testing/unit/tls/reports/tls_report_local.html +++ b/testing/unit/tls/reports/tls_report_local.html @@ -465,6 +465,155 @@

Outbound Connections

52.94.225.110 443 + + 224.0.0.251 + 5353 + + + 209.244.0.3 + Unknown + + + 3.227.250.136 + 443 + + + 3.227.203.88 + 443 + + + 34.226.101.252 + 8883 + + + 3.227.250.208 + 443 + + + 52.94.225.110 + 443 + + + 224.0.0.251 + 5353 + + + 209.244.0.3 + Unknown + + + 3.227.250.136 + 443 + + + 3.227.203.88 + 443 + + + + + + + +
+ +
+
+
+ {# Badge #} +

+ + {{ name }} +

+ {{ title }} +
+ + {{ device['manufacturer'] }} + {{ device['model']}} + + Testrun +
+
+

Outbound Connections

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Destination IPPort
34.226.101.2528883
3.227.250.208443
52.94.225.110443
224.0.0.2515353
209.244.0.3Unknown
3.227.250.136443
3.227.203.88443
34.226.101.2528883
3.227.250.208443
52.94.225.110443
224.0.0.2515353
209.244.0.3Unknown
3.227.250.136443
3.227.203.88443
34.226.101.2528883
3.227.250.208443
52.94.225.110443
diff --git a/testing/unit/tls/tls_module_test.py b/testing/unit/tls/tls_module_test.py index 205280329..5d456591a 100644 --- a/testing/unit/tls/tls_module_test.py +++ b/testing/unit/tls/tls_module_test.py @@ -16,6 +16,7 @@ from tls_util import TLSUtil import os import unittest +import unittest.mock from common import logger from scapy.all import sniff, wrpcap import threading @@ -367,10 +368,14 @@ def tls_module_report_multi_page_test(self): startup_capture_file=startup_pcap_file, monitor_capture_file=monitor_pcap_file, tls_capture_file=tls_pcap_file) + conns_orig = TLS_UTIL.get_all_outbound_connections( + device_mac='68:5e:1c:cb:6e:cb', capture_files=[monitor_pcap_file]) * 5 + conns_mock = unittest.mock.MagicMock() + conns_mock.get_all_outbound_connections.return_value = conns_orig + tls._tls_util = conns_mock # pylint: disable=W0212 report_out_path = tls.generate_module_report() with open(report_out_path, 'r', encoding='utf-8') as file: report_out = file.read() - # Read the local good report with open(LOCAL_REPORT, 'r', encoding='utf-8') as file: report_local = file.read() From b08fbf585f971afa665f9c158907a9ff55e5cb1c Mon Sep 17 00:00:00 2001 From: Aliaksandr Nikitsin Date: Wed, 14 May 2025 20:22:37 +0200 Subject: [PATCH 3/3] pylint --- modules/test/tls/python/src/tls_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/test/tls/python/src/tls_module.py b/modules/test/tls/python/src/tls_module.py index 4892829d1..041ea7e62 100644 --- a/modules/test/tls/python/src/tls_module.py +++ b/modules/test/tls/python/src/tls_module.py @@ -194,7 +194,7 @@ def generate_module_report(self): device_mac=self._device_mac, capture_files=pcap_files) if outbound_conns: - # Splitting Outbound Coonestions table to pages + # Splitting Outbound Coonestions table to pages pages = len(outbound_conns) // OUTBOUND_CONNS_PER_PAGE if pages * OUTBOUND_CONNS_PER_PAGE < len(outbound_conns): pages += 1