Skip to content

Commit 20e68a2

Browse files
committed
conf: parser: iptables: fixes so more test cases match
Also more whitespace and comments for legibility. Signed-off-by: Hank Leininger <hlein@korelogic.com>
1 parent 99ae7b7 commit 20e68a2

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

conf/parsers_extra.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ parsers:
7575
format: regex
7676
regex: |
7777
(?x)
78+
79+
# Log prefix - depends on the rule-building tools
7880
\[ (?<rule_chain>\w*) - (?<rule_name>\w*) - (?<accept_or_drop>\w*) \]
81+
7982
IN=(?<in_interface>[\w.]+)?\s
8083
OUT=(?<out_interface>[\w.]+)?\s
8184
@@ -101,19 +104,27 @@ parsers:
101104
TTL=(?<pkt_ttl>\d+)\s
102105
ID=(?<pkt_id>\d+)\s?
103106
(?<pkt_frg>[A-Z\s].?)\s?
107+
108+
# TCP and UDP have some next fields in common
104109
PROTO=(?<protocol>[\w\d]+)\s
105110
(
106-
SPT=(?<source_port>.*)\s
107-
DPT=(?<dest_port>.*)\s
108-
( LEN=(?<proto_pkt_len>\w+)? )?
111+
SPT=(?<source_port>\d+)\s
112+
DPT=(?<dest_port>\d+)\s
113+
( LEN=(?<proto_pkt_len>\w+)? \s )?
109114
(
115+
(?:
116+
SEQ=(?<tcp_seq>\d+)\s
117+
ACK=(?<tcp_ack>\d+)\s
118+
)?
110119
WINDOW=(?<proto_window_size>\d+)\s
111120
RES=(?<pkt_res>\w+)?\s
112121
(?<pkt_type>\w+)\s
113-
( (?<pkt_flag>\w+)? )\s?
114-
URGP=(?<pkg_urgency>\d)
115-
)?\s
122+
( (?<pkt_flag>\w+)? \s )*
123+
URGP=(?<pkg_urgency>\d)\s
124+
)?
116125
)?
126+
127+
# ICMP is the next most likely protocol
117128
(
118129
TYPE=(?<pkt_icmp_type>\d+)\s
119130
CODE=(?<pkt_icmp_code>\d+)\s

0 commit comments

Comments
 (0)