Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions modules/test/tls/python/src/tls_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down
149 changes: 149 additions & 0 deletions testing/unit/tls/reports/tls_report_local.html
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,155 @@ <h4 class="page-heading">Outbound Connections</h4>
<td>52.94.225.110</td>
<td>443</td>
</tr>
<tr>
<td>224.0.0.251</td>
<td>5353</td>
</tr>
<tr>
<td>209.244.0.3</td>
<td>Unknown</td>
</tr>
<tr>
<td>3.227.250.136</td>
<td>443</td>
</tr>
<tr>
<td>3.227.203.88</td>
<td>443</td>
</tr>
<tr>
<td>34.226.101.252</td>
<td>8883</td>
</tr>
<tr>
<td>3.227.250.208</td>
<td>443</td>
</tr>
<tr>
<td>52.94.225.110</td>
<td>443</td>
</tr>
<tr>
<td>224.0.0.251</td>
<td>5353</td>
</tr>
<tr>
<td>209.244.0.3</td>
<td>Unknown</td>
</tr>
<tr>
<td>3.227.250.136</td>
<td>443</td>
</tr>
<tr>
<td>3.227.203.88</td>
<td>443</td>
</tr>
</tbody>
</table>
</div>

<div class="footer">
<div class="footer-label">Testrun {{ version }}</div>
<div class="footer-label page-index" style="right: 0px"></div>
</div>
</div>
<div style="break-after:page"></div>

<div class="page">
<div class="header">
<div class="header-info">
{# Badge #}
<p class="header-info-badge">
<img src="data:image/png;base64, {{ icon }}" alt="">
<span>{{ name }}</span>
</p>
<span style="font-weight:600">{{ title }}</span>
</div>
<span style="margin-top:0;max-width:700px;font-size:24px;font-weight:600;">
{{ device['manufacturer'] }}
{{ device['model']}}
</span>
<img src="data:image/png;base64, {{ logo }}" alt="Testrun" width="90" style="position: absolute;top: 40%; right: 0px;"></img>
</div>
<div class="module-page-content">
<h4 class="page-heading">Outbound Connections</h4>
<table class="module-data">
<thead>
<tr>
<th>Destination IP</th>
<th>Port</th>
</tr>
</thead>
<tbody>
<tr>
<td>34.226.101.252</td>
<td>8883</td>
</tr>
<tr>
<td>3.227.250.208</td>
<td>443</td>
</tr>
<tr>
<td>52.94.225.110</td>
<td>443</td>
</tr>
<tr>
<td>224.0.0.251</td>
<td>5353</td>
</tr>
<tr>
<td>209.244.0.3</td>
<td>Unknown</td>
</tr>
<tr>
<td>3.227.250.136</td>
<td>443</td>
</tr>
<tr>
<td>3.227.203.88</td>
<td>443</td>
</tr>
<tr>
<td>34.226.101.252</td>
<td>8883</td>
</tr>
<tr>
<td>3.227.250.208</td>
<td>443</td>
</tr>
<tr>
<td>52.94.225.110</td>
<td>443</td>
</tr>
<tr>
<td>224.0.0.251</td>
<td>5353</td>
</tr>
<tr>
<td>209.244.0.3</td>
<td>Unknown</td>
</tr>
<tr>
<td>3.227.250.136</td>
<td>443</td>
</tr>
<tr>
<td>3.227.203.88</td>
<td>443</td>
</tr>
<tr>
<td>34.226.101.252</td>
<td>8883</td>
</tr>
<tr>
<td>3.227.250.208</td>
<td>443</td>
</tr>
<tr>
<td>52.94.225.110</td>
<td>443</td>
</tr>
</tbody>
</table>
</div>
Expand Down
7 changes: 6 additions & 1 deletion testing/unit/tls/tls_module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from common import logger
import os
import unittest
import unittest.mock
from scapy.all import sniff, wrpcap
import threading
import time
Expand Down Expand Up @@ -635,10 +636,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()
Expand Down