Skip to content

Commit b11bfc4

Browse files
committed
Handle Options Templates gracefully
1 parent a3cfd60 commit b11bfc4

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

netflowwriter.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + '/pynetflow')
2828
from pynetflow.netflow import parse_packet
2929
from pynetflow.netflow.utils import UnknownExportVersion
30-
from pynetflow.netflow.v9 import V9TemplateNotRecognized
30+
from pynetflow.netflow.v9 import V9TemplateNotRecognized, V9OptionsTemplatesNotSupported
3131

3232

3333
IS_DEBUG = os.environ.get('DEBUG', 'false') in ['true', 'yes', '1']
@@ -154,8 +154,13 @@ def process_named_pipe(named_pipe_filename):
154154
continue
155155
except V9TemplateNotRecognized as ex:
156156
log.warning(f"Failed to decode a v9 ExportPacket, template not recognized (if this happens at the start, it's ok)")
157-
log.debug(f"Problematic packet data: {data_b64}")
158-
log.debug(f"Known templates until now: {templates}")
157+
if client_ip in last_record_seqs:
158+
last_record_seqs[client_ip] += 1
159+
continue
160+
except V9OptionsTemplatesNotSupported as ex:
161+
log.debug(f"Skipping Options Data Record (Options Template parsing not supported)")
162+
if client_ip in last_record_seqs:
163+
last_record_seqs[client_ip] += 1
159164
continue
160165

161166
except Exception as ex:

pynetflow

0 commit comments

Comments
 (0)