Skip to content

Commit 74a8ebf

Browse files
fix: escape double quote (#741)
* fix: escape double quote * test: addtional tests
1 parent e8f3f59 commit 74a8ebf

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pytest_splunk_addon/standard_lib/utilities/xml_event_parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
(
5252
"httpd",
5353
{
54-
"regex": r"((?:\d+(?:(?:\.|:)(?:\d+|[a-fA-F]+)?){3,8}))(?:\s(?:-|\w+))*\s\[(\d{1,2}\/\w+\/\d{4}(?:[:]\d{2}){3}(?:\.\d{1,6})?(?:\s[+-]\d{2}[:]?\d{2})?(?:Z)?)]\s(.*)$",
54+
"regex": r"((?:\d+(?:(?:\.|:)[0-9a-fA-F]{0,4}){3,8}))(?:\s(?:-|\w+))*\s\[(\d{1,2}\/\w+\/\d{4}(?:[:]\d{2}){3}(?:\.\d{1,6})?(?:\s[+-]\d{2}[:]?\d{2})?(?:Z)?)]\s(.*)$",
5555
"match_element": 3,
5656
},
5757
),
@@ -100,6 +100,7 @@ def escape_char_event(event):
100100
"WHERE",
101101
"LIKE",
102102
"NOT",
103+
'"',
103104
]
104105
event = event.replace("\\", "\\\\")
105106
bounded_asterisk = re.search(r"\".*?\*+.*?\"", event)

tests/unit/tests_standard_lib/test_utilities/test_xml_event_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
("WHERE", "SESSION \\WHERE CREATED"),
4545
("LIKE", "SESSION \\LIKE CREATED"),
4646
("NOT", "SESSION \\NOT CREATED"),
47+
('"', 'SESSION \\" CREATED'),
4748
],
4849
)
4950
def test_escape_char_event(escape_char, expected_output):
@@ -71,6 +72,10 @@ def test_escape_char_event(escape_char, expected_output):
7172
'10.0.1.1 - - [04/Jan/2021:18:37:21 +0530] "GET /tomcat.svg HTTP/1.1" 200 67795',
7273
'"GET /tomcat.svg HTTP/1.1" 200 67795',
7374
),
75+
(
76+
'2001:0db8:85a3:0000:0000:8a2e:0370:7334 - - [04/Jan/2021:18:37:21 +0530] "GET /tomcat.svg HTTP/1.1" 200 67795',
77+
'"GET /tomcat.svg HTTP/1.1" 200 67795',
78+
),
7479
("- cisco dummy", None),
7580
],
7681
ids=[
@@ -80,6 +85,7 @@ def test_escape_char_event(escape_char, expected_output):
8085
"CEF-checkpoint-foramt",
8186
"CEF-format",
8287
"httpd-format",
88+
"httpd-ipv6-format",
8389
"wrong-format",
8490
],
8591
)

0 commit comments

Comments
 (0)