diff --git a/framework/python/src/common/testreport.py b/framework/python/src/common/testreport.py index 6d0b6e78e..fd9bd3d25 100644 --- a/framework/python/src/common/testreport.py +++ b/framework/python/src/common/testreport.py @@ -308,8 +308,8 @@ def generate_module_reports(self, json_data): #Add styling to the markdown content = content.replace('', '
') - content = content.replace('

', '

') - content = content.replace('

', '

') + content = content.replace('

', '

') + content = content.replace('

', '

') content = self.generate_module_pages(json_data=json_data, module_reports=content) @@ -804,10 +804,24 @@ def generate_css(self): padding: 8px; } - .markdown-header{ + .markdown-header-h1{ margin-left:20px; margin-top:20px; margin-bottom:20px; + margin-right:0px; + + font-size: 2em; + font-weight: bold; + } + + .markdown-header-h2{ + margin-left:20px; + margin-top:20px; + margin-bottom:20px; + margin-right:0px; + + font-size: 1.5em; + font-weight: bold; } .module-page-content{ diff --git a/modules/test/dns/python/src/dns_module.py b/modules/test/dns/python/src/dns_module.py index eefc0c872..2272c6859 100644 --- a/modules/test/dns/python/src/dns_module.py +++ b/modules/test/dns/python/src/dns_module.py @@ -63,18 +63,6 @@ def generate_module_report(self): total_responses = sum(1 for row in dns_table_data if row['Type'] == 'Response') - #total_requests = len(dns_table_data) - - # Find the maximum length of 'Destination' values - max_data_length = max(len(row['Data']) for row in dns_table_data) if len(dns_table_data)>0 else 8 - - table_content = '' - for row in dns_table_data: - table_content += f'''| {row['Source']: ^12} | {row['Destination']: ^13} | {row['Type']: ^9} | {row['Data']: ^{max_data_length}} |\r''' - - # Dynamically adjust the header width based on the longest 'Destination' content - header = f'''| {'Source': ^12} | {'Destination': ^{13}} | {'Type': ^9} | {'Data': ^{max_data_length}} |''' - header_line = f'''|{'-' * 14}|{'-' * 15}|{'-' * 11}|{'-' * (max_data_length + 2)}|''' summary = '## Summary' summary += f'''\n- Requests to local DNS server: {local_requests}''' @@ -82,11 +70,33 @@ def generate_module_report(self): summary += f'''\n- Total DNS requests: {total_requests}''' summary += f'''\n- Total DNS responses: {total_responses}''' - markdown_template = f'''# DNS Module - \r{header}\r{header_line}\r{table_content}\r{summary} - ''' + if (total_requests + total_responses) > 0: + + # Find the maximum length of 'Destination' values + max_data_length = max(len(row['Data']) for row in dns_table_data) if len(dns_table_data)>0 else 8 - LOGGER.debug("Markdown Report:\n" + markdown_template) + table_content = '' + for row in dns_table_data: + table_content += (f'''| {row['Source']: ^12} ''' + f'''| {row['Destination']: ^13} ''' + f'''| {row['Type']: ^9} ''' + f'''| {row['Data']: ^{max_data_length}} |\n''') + + header = (f'''| {'Source': ^12} ''' + f'''| {'Destination': ^{13}} ''' + f'''| {'Type': ^{9}} ''' + f'''| {'Data': ^{max_data_length}} |''') + header_line = (f'''|{'-' * 14}|{'-' * 15}|{'-' * 11}|''' + f'''{'-' * (max_data_length + 2)}''') + + markdown_template = (f'''# DNS Module\n''' + f'''\n{header}\n{header_line}\n{table_content}\n{summary}''') + + else: + markdown_template = (f'''# DNS Module\n''' + f'''\n- No DNS traffic detected\n''' + f'''\n{summary}''') + LOGGER.debug('Markdown Report:\n' + markdown_template) # Use os.path.join to create the complete file path report_path = os.path.join(self._results_dir, MODULE_REPORT_FILE_NAME) diff --git a/modules/test/nmap/python/src/nmap_module.py b/modules/test/nmap/python/src/nmap_module.py index 93477b7ee..2bd0d3a5b 100644 --- a/modules/test/nmap/python/src/nmap_module.py +++ b/modules/test/nmap/python/src/nmap_module.py @@ -57,7 +57,6 @@ def generate_module_report(self): # Use os.path.join to create the complete file path nmap_scan_results_file = os.path.join(self._nmap_scan_results_path, NMAP_SCAN_RESULTS_SCAN_FILE) - LOGGER.info('Scan Results File:\n' + str(nmap_scan_results_file)) # Read the nmap scan results with open(nmap_scan_results_file, 'r', encoding='utf-8') as file: diff --git a/testing/unit/dns/dns.pcap b/testing/unit/dns/captures/dns.pcap similarity index 100% rename from testing/unit/dns/dns.pcap rename to testing/unit/dns/captures/dns.pcap diff --git a/testing/unit/dns/monitor.pcap b/testing/unit/dns/captures/monitor.pcap similarity index 100% rename from testing/unit/dns/monitor.pcap rename to testing/unit/dns/captures/monitor.pcap diff --git a/testing/unit/dns/startup.pcap b/testing/unit/dns/captures/startup.pcap similarity index 100% rename from testing/unit/dns/startup.pcap rename to testing/unit/dns/captures/startup.pcap diff --git a/testing/unit/dns/dns_module_test.py b/testing/unit/dns/dns_module_test.py index 13911a7f3..ad9c89e02 100644 --- a/testing/unit/dns/dns_module_test.py +++ b/testing/unit/dns/dns_module_test.py @@ -19,18 +19,20 @@ MODULE = 'dns' -# Define the file paths +# Define the directories TEST_FILES_DIR = 'testing/unit/' + MODULE -OUTPUT_DIR = TEST_FILES_DIR + '/output/' -# TEMP_DIR = TEST_FILES_DIR + '/temp/' -LOCAL_REPORT = TEST_FILES_DIR + '/dns_report_local.md' -LOCAL_REPORT_NO_DNS = TEST_FILES_DIR + '/dns_report_local_no_dns.md' +OUTPUT_DIR = os.path.join(TEST_FILES_DIR,'output/') +REPORTS_DIR = os.path.join(TEST_FILES_DIR,'reports/') +CAPTURES_DIR = os.path.join(TEST_FILES_DIR,'captures/') + +LOCAL_REPORT = os.path.join(REPORTS_DIR,'dns_report_local.md') +LOCAL_REPORT_NO_DNS = os.path.join(REPORTS_DIR,'dns_report_local_no_dns.md') CONF_FILE = 'modules/test/' + MODULE + '/conf/module_config.json' -# Define the capture files to be used for the test -DNS_SERVER_CAPTURE_FILE = TEST_FILES_DIR + '/dns.pcap' -STARTUP_CAPTURE_FILE = TEST_FILES_DIR + '/startup.pcap' -MONITOR_CAPTURE_FILE = TEST_FILES_DIR + '/monitor.pcap' +# Define the capture files to be used for the test +DNS_SERVER_CAPTURE_FILE = os.path.join(CAPTURES_DIR,'dns.pcap') +STARTUP_CAPTURE_FILE = os.path.join(CAPTURES_DIR,'startup.pcap') +MONITOR_CAPTURE_FILE = os.path.join(CAPTURES_DIR,'monitor.pcap') class TLSModuleTest(unittest.TestCase): """Contains and runs all the unit tests concerning DNS behaviors""" diff --git a/testing/unit/dns/dns_report_local.md b/testing/unit/dns/dns_report_local.md deleted file mode 100644 index c0f076a54..000000000 --- a/testing/unit/dns/dns_report_local.md +++ /dev/null @@ -1 +0,0 @@ -# DNS Module | Source | Destination | Type | Data | |--------------|---------------|-----------|---------------------| | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 8.8.8.8 | Query | mqtt.googleapis.com | | 10.10.10.4 | 8.8.8.8 | Query | mqtt.googleapis.com | | 8.8.8.8 | 10.10.10.4 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 8.8.8.8 | 10.10.10.4 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.4 | 8.8.8.8 | Query | pool.ntp.org | | 10.10.10.4 | 8.8.8.8 | Query | pool.ntp.org | | 8.8.8.8 | 10.10.10.4 | Response | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 8.8.8.8 | 10.10.10.4 | Response | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.4 | 8.8.8.8 | Query | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 8.8.8.8 | 10.10.10.4 | Response | pool.ntp.org | | 10.10.10.4 | 8.8.8.8 | Response | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 8.8.8.8 | Query | mqtt.googleapis.com | | 8.8.8.8 | 10.10.10.4 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | ## Summary - Requests to local DNS server: 71 - Requests to external DNS servers: 6 - Total DNS requests: 77 - Total DNS responses: 91 \ No newline at end of file diff --git a/testing/unit/dns/dns_report_local_no_dns.md b/testing/unit/dns/dns_report_local_no_dns.md deleted file mode 100644 index 6e07516ab..000000000 --- a/testing/unit/dns/dns_report_local_no_dns.md +++ /dev/null @@ -1,11 +0,0 @@ -# DNS Module - -| Source | Destination | Type | Data | -|--------------|---------------|-----------|----------| - -## Summary -- Requests to local DNS server: 0 -- Requests to external DNS servers: 0 -- Total DNS requests: 0 -- Total DNS responses: 0 - \ No newline at end of file diff --git a/testing/unit/dns/reports/dns_report_local.md b/testing/unit/dns/reports/dns_report_local.md new file mode 100644 index 000000000..423745d73 --- /dev/null +++ b/testing/unit/dns/reports/dns_report_local.md @@ -0,0 +1 @@ +# DNS Module | Source | Destination | Type | Data | |--------------|---------------|-----------|--------------------- | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 8.8.8.8 | Query | mqtt.googleapis.com | | 10.10.10.4 | 8.8.8.8 | Query | mqtt.googleapis.com | | 8.8.8.8 | 10.10.10.4 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 8.8.8.8 | 10.10.10.4 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.4 | 8.8.8.8 | Query | pool.ntp.org | | 10.10.10.4 | 8.8.8.8 | Query | pool.ntp.org | | 8.8.8.8 | 10.10.10.4 | Response | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 8.8.8.8 | 10.10.10.4 | Response | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.4 | 8.8.8.8 | Query | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 8.8.8.8 | 10.10.10.4 | Response | pool.ntp.org | | 10.10.10.4 | 8.8.8.8 | Response | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 8.8.8.8 | Query | mqtt.googleapis.com | | 8.8.8.8 | 10.10.10.4 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.4 | 10.10.10.14 | Response | pool.ntp.org | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.14 | 10.10.10.4 | Query | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | | 10.10.10.4 | 10.10.10.14 | Response | mqtt.googleapis.com | ## Summary - Requests to local DNS server: 71 - Requests to external DNS servers: 6 - Total DNS requests: 77 - Total DNS responses: 91 \ No newline at end of file diff --git a/testing/unit/dns/reports/dns_report_local_no_dns.md b/testing/unit/dns/reports/dns_report_local_no_dns.md new file mode 100644 index 000000000..b07302289 --- /dev/null +++ b/testing/unit/dns/reports/dns_report_local_no_dns.md @@ -0,0 +1,9 @@ +# DNS Module + +- No DNS traffic detected + +## Summary +- Requests to local DNS server: 0 +- Requests to external DNS servers: 0 +- Total DNS requests: 0 +- Total DNS responses: 0 \ No newline at end of file diff --git a/testing/unit/nmap/nmap_module_test.py b/testing/unit/nmap/nmap_module_test.py index 0a08ff2d5..8fa42738f 100644 --- a/testing/unit/nmap/nmap_module_test.py +++ b/testing/unit/nmap/nmap_module_test.py @@ -21,8 +21,11 @@ # Define the file paths TEST_FILES_DIR = 'testing/unit/' + MODULE -OUTPUT_DIR = TEST_FILES_DIR + '/output/' -LOCAL_REPORT = TEST_FILES_DIR + '/nmap_report_local.md' +OUTPUT_DIR = os.path.join(TEST_FILES_DIR,'output/') +REPORTS_DIR = os.path.join(TEST_FILES_DIR,'reports/') +RESULTS_DIR = os.path.join(TEST_FILES_DIR,'results/') + +LOCAL_REPORT = os.path.join(REPORTS_DIR,'nmap_report_local.md') CONF_FILE = 'modules/test/' + MODULE + '/conf/module_config.json' @@ -37,7 +40,7 @@ def setUpClass(cls): # Test the module report generation def nmap_module_ports_open_report_test(self): # Move test scan into expected folder - src_scan_results_path = os.path.join(TEST_FILES_DIR,'ports_open_scan_result.json') + src_scan_results_path = os.path.join(RESULTS_DIR,'ports_open_scan_result.json') dst_scan_results_path = os.path.join(OUTPUT_DIR,'nmap_scan_results.json') shutil.copy(src_scan_results_path, dst_scan_results_path) @@ -55,7 +58,8 @@ def nmap_module_ports_open_report_test(self): report_out = file.read() # Read the local good report - local_report = TEST_FILES_DIR + '/ports_open_report.md' + + local_report = os.path.join(REPORTS_DIR,'ports_open_report.md') with open(local_report, 'r', encoding='utf-8') as file: report_local = file.read() @@ -63,7 +67,7 @@ def nmap_module_ports_open_report_test(self): # Test the module report generation with all ports closed def nmap_module_report_all_closed_test(self): - src_scan_results_path = os.path.join(TEST_FILES_DIR,'all_closed_scan_result.json') + src_scan_results_path = os.path.join(RESULTS_DIR,'all_closed_scan_result.json') dst_scan_results_path = os.path.join(OUTPUT_DIR,'nmap_scan_results.json') shutil.copy(src_scan_results_path, dst_scan_results_path) @@ -81,7 +85,7 @@ def nmap_module_report_all_closed_test(self): report_out = file.read() # Read the local good report - local_report = TEST_FILES_DIR + '/all_closed_report.md' + local_report = os.path.join(REPORTS_DIR,'all_closed_report.md') with open(local_report, 'r', encoding='utf-8') as file: report_local = file.read() diff --git a/testing/unit/nmap/nmap_report_local.md b/testing/unit/nmap/nmap_report_local.md deleted file mode 100644 index 1e69bc720..000000000 --- a/testing/unit/nmap/nmap_report_local.md +++ /dev/null @@ -1,8 +0,0 @@ -# NMAP Module - -- No ports detected open - -## Summary -- TCP Ports Open: 0 -- UDP Ports Open: 0 -- Total Ports Open: 0 \ No newline at end of file diff --git a/testing/unit/nmap/all_closed_report.md b/testing/unit/nmap/reports/all_closed_report.md similarity index 100% rename from testing/unit/nmap/all_closed_report.md rename to testing/unit/nmap/reports/all_closed_report.md diff --git a/testing/unit/nmap/reports/nmap_report_local.md b/testing/unit/nmap/reports/nmap_report_local.md new file mode 100644 index 000000000..df7c216f1 --- /dev/null +++ b/testing/unit/nmap/reports/nmap_report_local.md @@ -0,0 +1,12 @@ +# NMAP Module + +| Port | Type | State | Service | Version | +|------------|------------|------------|------|------------------| +| 22 | tcp | open | ssh | 8.8 protocol 2.0 | +| 443 | tcp | open | http | | +| 502 | tcp | open | mbap | | + +## Summary +- TCP Ports Open: 3 +- UDP Ports Open: 0 +- Total Ports Open: 3 \ No newline at end of file diff --git a/testing/unit/nmap/ports_open_report.md b/testing/unit/nmap/reports/ports_open_report.md similarity index 97% rename from testing/unit/nmap/ports_open_report.md rename to testing/unit/nmap/reports/ports_open_report.md index bace55c5a..df7c216f1 100644 --- a/testing/unit/nmap/ports_open_report.md +++ b/testing/unit/nmap/reports/ports_open_report.md @@ -1,12 +1,12 @@ -# NMAP Module - -| Port | Type | State | Service | Version | -|------------|------------|------------|------|------------------| -| 22 | tcp | open | ssh | 8.8 protocol 2.0 | -| 443 | tcp | open | http | | -| 502 | tcp | open | mbap | | - -## Summary -- TCP Ports Open: 3 -- UDP Ports Open: 0 +# NMAP Module + +| Port | Type | State | Service | Version | +|------------|------------|------------|------|------------------| +| 22 | tcp | open | ssh | 8.8 protocol 2.0 | +| 443 | tcp | open | http | | +| 502 | tcp | open | mbap | | + +## Summary +- TCP Ports Open: 3 +- UDP Ports Open: 0 - Total Ports Open: 3 \ No newline at end of file diff --git a/testing/unit/nmap/all_closed_scan_result.json b/testing/unit/nmap/results/all_closed_scan_result.json similarity index 100% rename from testing/unit/nmap/all_closed_scan_result.json rename to testing/unit/nmap/results/all_closed_scan_result.json diff --git a/testing/unit/nmap/ports_open_scan_result.json b/testing/unit/nmap/results/ports_open_scan_result.json similarity index 100% rename from testing/unit/nmap/ports_open_scan_result.json rename to testing/unit/nmap/results/ports_open_scan_result.json diff --git a/testing/unit/ntp/ntp_module_test.py b/testing/unit/ntp/ntp_module_test.py index 7d2bc32c6..40eab9515 100644 --- a/testing/unit/ntp/ntp_module_test.py +++ b/testing/unit/ntp/ntp_module_test.py @@ -21,18 +21,18 @@ # Define the file paths TEST_FILES_DIR = 'testing/unit/' + MODULE -OUTPUT_DIR = f'{TEST_FILES_DIR}/output/' -REPORTS_DIR = '/reports' -CAPTURES_DIR = '/captures' +OUTPUT_DIR = os.path.join(TEST_FILES_DIR,'output/') +REPORTS_DIR = os.path.join(TEST_FILES_DIR,'reports/') +CAPTURES_DIR = os.path.join(TEST_FILES_DIR,'captures/') -LOCAL_REPORT = f'{TEST_FILES_DIR}/{REPORTS_DIR}/ntp_report_local.md' -LOCAL_REPORT_NO_NTP = (f'{TEST_FILES_DIR}/{REPORTS_DIR}/' - f'ntp_report_local_no_ntp.md') +LOCAL_REPORT = os.path.join(REPORTS_DIR,'ntp_report_local.md') +LOCAL_REPORT_NO_NTP = os.path.join(REPORTS_DIR,'ntp_report_local_no_ntp.md') CONF_FILE = 'modules/test/' + MODULE + '/conf/module_config.json' + # Define the capture files to be used for the test -NTP_SERVER_CAPTURE_FILE = f'{TEST_FILES_DIR}/{CAPTURES_DIR}/ntp.pcap' -STARTUP_CAPTURE_FILE = f'{TEST_FILES_DIR}/{CAPTURES_DIR}/startup.pcap' -MONITOR_CAPTURE_FILE = f'{TEST_FILES_DIR}/{CAPTURES_DIR}/monitor.pcap' +NTP_SERVER_CAPTURE_FILE = os.path.join(CAPTURES_DIR,'ntp.pcap') +STARTUP_CAPTURE_FILE = os.path.join(CAPTURES_DIR,'startup.pcap') +MONITOR_CAPTURE_FILE = os.path.join(CAPTURES_DIR,'monitor.pcap') class NTPModuleTest(unittest.TestCase): diff --git a/testing/unit/report/report_test.py b/testing/unit/report/report_test.py index 287e90bed..4a46b81f7 100644 --- a/testing/unit/report/report_test.py +++ b/testing/unit/report/report_test.py @@ -20,10 +20,9 @@ MODULE = 'report' # Define the file paths -TEST_FILES_DIR = 'testing/unit/' + MODULE -OUTPUT_DIR = TEST_FILES_DIR + '/output/' UNIT_TEST_DIR = 'testing/unit/' - +TEST_FILES_DIR = os.path.join('testing/unit',MODULE) +OUTPUT_DIR = os.path.join(TEST_FILES_DIR,'output/') class ReportTest(unittest.TestCase): """Contains and runs all the unit tests concerning DNS behaviors""" @@ -47,6 +46,7 @@ def report_test(self): reports_md = [] reports_md.append(self.get_module_md_report('dns')) reports_md.append(self.get_module_md_report('nmap')) + reports_md.append(self.get_module_md_report('ntp')) report.add_module_reports(reports_md) # Generate the report @@ -56,8 +56,9 @@ def report_test(self): def get_module_md_report(self, module): # Combine the path components using os.path.join - report_file = os.path.join(UNIT_TEST_DIR, module, - module + '_report_local.md') + report_file = os.path.join(UNIT_TEST_DIR, + os.path.join(module, + os.path.join('reports',module+'_report_local.md'))) with open(report_file, 'r', encoding='utf-8') as file: report = file.read() diff --git a/testing/unit/run_tests.sh b/testing/unit/run_tests.sh index c42923a2d..fe186c8db 100644 --- a/testing/unit/run_tests.sh +++ b/testing/unit/run_tests.sh @@ -47,11 +47,10 @@ python3 -u $PWD/testing/unit/dns/dns_module_test.py # Run the NMAP Module Unit Tests python3 -u $PWD/testing/unit/nmap/nmap_module_test.py -# Run the Report Unit Tests -python3 -u $PWD/testing/unit/report/report_test.py - -# Run the NMAP Module Unit Tests +# Run the NTP Module Unit Tests python3 -u $PWD/testing/unit/ntp/ntp_module_test.py +# # Run the Report Unit Tests +python3 -u $PWD/testing/unit/report/report_test.py popd >/dev/null 2>&1 \ No newline at end of file