From e484d63fc104beed2def68987e26def84efbd865 Mon Sep 17 00:00:00 2001 From: MariusBaldovin Date: Fri, 28 Feb 2025 13:30:43 +0000 Subject: [PATCH] handle the dns.pcap missing --- modules/test/dns/python/src/dns_module.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/test/dns/python/src/dns_module.py b/modules/test/dns/python/src/dns_module.py index 49a657e30..a06ab5aa6 100644 --- a/modules/test/dns/python/src/dns_module.py +++ b/modules/test/dns/python/src/dns_module.py @@ -14,6 +14,7 @@ """DNS test module""" import subprocess from scapy.all import rdpcap, DNS, IP, Ether, DNSRR +from scapy.error import Scapy_Exception from test_module import TestModule import os from collections import Counter @@ -156,9 +157,15 @@ def generate_module_report(self): def extract_dns_data(self): dns_data = [] - # Read the pcap file - packets = rdpcap(self.dns_server_capture_file) + rdpcap( - self.startup_capture_file) + rdpcap(self.monitor_capture_file) + # Read the startup and monitor pcap files + packets = (rdpcap(self.startup_capture_file) + + rdpcap(self.monitor_capture_file)) + + # Read the dns.pcap file + try: + packets += rdpcap(self.dns_server_capture_file) + except (FileNotFoundError, Scapy_Exception): + LOGGER.error('dns.pcap not found or empty, ignoring') # Iterate through DNS packets for packet in packets: