Skip to content

Commit 876cb80

Browse files
authored
fix: support date format with year for cisco asa (#604)
* fix: support date format cisco asa
1 parent 91f4ab7 commit 876cb80

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

pytest_splunk_addon/standard_lib/requirement_tests/test_generator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ def strip_syslog_header(self, raw_event):
103103
if regex_rfc5424:
104104
stripped_header = regex_rfc5424.group(3)
105105
return stripped_header
106+
# regex = r"([A-Z][a-z][a-z]\s{1,2}\d{1,2}\s\d{2}[:]\d{2}[:]\d{2})\s+([\w][\w\d\.@-]*)\s\w*:?(.*)$",
107+
# (?:\s\d{4})? Added to support cisco asa date format
106108
regex_rfc3164 = re.search(
107-
r"([A-Z][a-z][a-z]\s{1,2}\d{1,2}\s\d{2}[:]\d{2}[:]\d{2})\s+([\w][\w\d\.@-]*)\s\w*:?(.*)$",
109+
r"([A-Z][a-z][a-z]\s{1,2}\d{1,2}(?:\s\d{4})?\s\d{2}[:]\d{2}[:]\d{2})\s+([\w][\w\d\.@-]*)\s\w*:?(.*)$",
108110
raw_event,
109111
)
110112
if regex_rfc3164:

tests/unit/tests_standard_lib/test_requirement_tests/test_test_generator.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,33 @@ def test_extract_params():
191191
),
192192
],
193193
),
194+
(
195+
["requirement_cisco_asa.log"],
196+
[True],
197+
["syslog"],
198+
{
199+
"event": [
200+
"Oct 06 2021 14:44:59 10.10.10.10 : %ASA-4-405001: Received ARP response collision from 1.1.1.1/0050.56b7.52b6 on interface outside with existing ARP entry 1.1.0.1/0011.56b7.7853"
201+
]
202+
},
203+
[["model_1:dataset_1"]],
204+
["event_name_1"],
205+
[{"field1": "value1", "field2": "value2"}, {"field3": "value3"}],
206+
[
207+
(
208+
# test for cisco event ingestion and escaped event with removed header
209+
{
210+
"model_list": [("model_1", "dataset_1", "")],
211+
"escaped_event": " %ASA-4-405001: Received ARP response collision from 1.1.1.1/0050.56b7.52b6 on interface outside with existing ARP entry 1.1.0.1/0011.56b7.7853",
212+
"exceptions_dict": {"field3": "value3"},
213+
"Key_value_dict": {"field1": "value1", "field2": "value2"},
214+
"modinput_params": None,
215+
"transport_type": "syslog",
216+
},
217+
"model_1:dataset_1::fake_path/requirement_cisco_asa.log::event_no::1::event_name::event_name_1",
218+
),
219+
],
220+
),
194221
],
195222
)
196223
def test_generate_cim_req_params(

0 commit comments

Comments
 (0)