diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2020-09-26 11:19:21 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2020-09-26 11:19:21 +0200 |
commit | 8c61f883621169f5c9451758eed4b3a4ee9ee3a2 (patch) | |
tree | b5d3c5b25c9210cb8afcd5df09f1dff140020f81 /examples | |
parent | b6b62ac883b32dbe2d31a0b13c32a7752182f0d2 (diff) |
Added event validation functions and fixed Python scripts.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/py-flow-info/flow-info.py | 10 | ||||
-rwxr-xr-x | examples/py-flow-undetected-to-pcap/flow-undetected-to-pcap.py | 2 | ||||
-rwxr-xr-x | examples/py-risky-flow-to-pcap/risky-flow-to-pcap.py | 2 |
3 files changed, 8 insertions, 6 deletions
diff --git a/examples/py-flow-info/flow-info.py b/examples/py-flow-info/flow-info.py index 638c76581..61f25429d 100755 --- a/examples/py-flow-info/flow-info.py +++ b/examples/py-flow-info/flow-info.py @@ -11,10 +11,12 @@ from nDPIsrvd import nDPIsrvdSocket, TermColor def parse_json_str(json_str): j = nDPIsrvd.JsonParseBytes(json_str[0]) - - event_str = validateEventName(j) - if event_str is None: - raise RuntimeError('unknown flow event name: {}'.format(event)) + event_str = nDPIsrvd.validateFlowEventName(j) + if event_str is 'Unknown': + if nDPIsrvd.validatePacketEventName(j) is 'Unknown': + raise RuntimeError('Missing flow_event_name in the JSON string.') + else: + return ndpi_proto_categ = '' ndpi_frisk = '' diff --git a/examples/py-flow-undetected-to-pcap/flow-undetected-to-pcap.py b/examples/py-flow-undetected-to-pcap/flow-undetected-to-pcap.py index 8a4c2fe93..26eac3ff5 100755 --- a/examples/py-flow-undetected-to-pcap/flow-undetected-to-pcap.py +++ b/examples/py-flow-undetected-to-pcap/flow-undetected-to-pcap.py @@ -30,7 +30,7 @@ def parse_json_str(json_str): return elif event == 'end' or event == 'idle': del FLOWS[flow_id] - elif event == 'detected': + elif event == 'detected' or event == 'detection-update': FLOWS[flow_id].detected() elif event == 'guessed' or event == 'not-detected': if event == 'guessed': diff --git a/examples/py-risky-flow-to-pcap/risky-flow-to-pcap.py b/examples/py-risky-flow-to-pcap/risky-flow-to-pcap.py index 65b543ca6..5636b25d5 100755 --- a/examples/py-risky-flow-to-pcap/risky-flow-to-pcap.py +++ b/examples/py-risky-flow-to-pcap/risky-flow-to-pcap.py @@ -30,7 +30,7 @@ def parse_json_str(json_str): return elif event == 'end' or event == 'idle': del FLOWS[flow_id] - elif event == 'detected' or event == 'guessed' or event == 'not-detected': + elif event == 'detected' or event == 'detection-update' or event == 'guessed' or event == 'not-detected': if 'ndpi' in j and 'flow_risk' in j['ndpi']: print('Risky flow with id {}, PCAP dump returned: {}'.format(flow_id, FLOWS[flow_id].fin('risky'))) |