mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
Fix bug in split when program running on UDP contains space in name (#447)
* Add condition before split. * Safe detection of 'state' presence. --------- Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
This commit is contained in:
@ -31,10 +31,15 @@ def normalize_interface_headers(header):
|
||||
|
||||
|
||||
def parse_network(headers, entry):
|
||||
LIST_OF_STATES = ["ESTABLISHED", "SYN_SENT", "SYN_RECV", "FIN_WAIT1", "FIN_WAIT2", "TIME_WAIT", "CLOSED", "CLOSE_WAIT", "LAST_ACK", "LISTEN", "CLOSING", "UNKNOWN"]
|
||||
|
||||
# split entry based on presence of value in "State" column
|
||||
contains_state = any(state in entry for state in LIST_OF_STATES)
|
||||
split_modifier = 1 if contains_state else 2
|
||||
entry = entry.split(maxsplit=len(headers) - split_modifier)
|
||||
|
||||
# Count words in header
|
||||
# if len of line is one less than len of header, then insert None in field 5
|
||||
entry = entry.split(maxsplit=len(headers) - 1)
|
||||
|
||||
if len(entry) == len(headers) - 1:
|
||||
entry.insert(5, None)
|
||||
|
||||
|
Reference in New Issue
Block a user