Skip to content

Commit 3ee8fa0

Browse files
authored
fix: fix CISE_Alarm messages parsing (#2609)
1 parent e32e519 commit 3ee8fa0

File tree

5 files changed

+154
-11
lines changed

5 files changed

+154
-11
lines changed

package/etc/conf.d/conflib/post-filter/app-postfilter-cisco_ise.conf

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ block parser app-postfilter-cisco_ise() {
5757
application app-postfilter-cisco_ise[sc4s-finalfilter] {
5858
filter {
5959
program('CISE_' type(string) flags(prefix))
60-
and "${.values.num}" != 1;
60+
and "${.values.num}" != 1
61+
and not program('CISE_Alarm');
6162
};
6263
parser { app-postfilter-cisco_ise(); };
6364
};

package/etc/conf.d/conflib/syslog/app-syslog-cisco_ise.conf

+25-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@ parser ise_event_time {
1818
block parser app-syslog-cisco_ise() {
1919

2020
channel {
21+
22+
if {
23+
parser {
24+
regexp-parser(
25+
template("${MESSAGE}")
26+
patterns("^(?<real_day>\\d{2}) (?<real_hour>\\d{2}:\\d{2}:\\d{2}) (?<real_host>[^ ]+) (?<real_program>[^ ]+) (?<rest_of_message>.*)")
27+
prefix(".parsed.")
28+
);
29+
30+
date-parser-nofilter(
31+
format('%b %d %H:%M:%S')
32+
template("${PROGRAM} ${.parsed.real_day} ${.parsed.real_hour}")
33+
);
34+
};
35+
rewrite {
36+
set("${.parsed.real_host}" value("HOST"));
37+
set("${.parsed.real_program}" value("PROGRAM"));
38+
set("${.parsed.rest_of_message}" value("MESSAGE"));
39+
};
40+
};
41+
2142
parser {
2243
csv-parser(
2344
columns(serial, num, seq, message)
@@ -44,13 +65,13 @@ block parser app-syslog-cisco_ise() {
4465
product('ise')
4566
);
4667
};
47-
48-
49-
};
68+
};
5069
};
70+
5171
application app-syslog-cisco_ise[sc4s-syslog-pgm] {
5272
filter {
53-
program('CISE_' type(string) flags(prefix));
73+
program('CISE_' type(string) flags(prefix))
74+
or message('CISE_' type(string) flags(substring));
5475
};
5576
parser { app-syslog-cisco_ise(); };
5677
};

package/lite/etc/addons/cisco/app-postfilter-cisco_ise.conf

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ block parser app-postfilter-cisco_ise() {
5757
application app-postfilter-cisco_ise[sc4s-finalfilter] {
5858
filter {
5959
program('CISE_' type(string) flags(prefix))
60-
and "${.values.num}" != 1;
60+
and "${.values.num}" != 1
61+
and not program('CISE_Alarm');
6162
};
6263
parser { app-postfilter-cisco_ise(); };
6364
};

package/lite/etc/addons/cisco/app-syslog-cisco_ise.conf

+25-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@ parser ise_event_time {
1818
block parser app-syslog-cisco_ise() {
1919

2020
channel {
21+
22+
if {
23+
parser {
24+
regexp-parser(
25+
template("${MESSAGE}")
26+
patterns("^(?<real_day>\\d{2}) (?<real_hour>\\d{2}:\\d{2}:\\d{2}) (?<real_host>[^ ]+) (?<real_program>[^ ]+) (?<rest_of_message>.*)")
27+
prefix(".parsed.")
28+
);
29+
30+
date-parser-nofilter(
31+
format('%b %d %H:%M:%S')
32+
template("${PROGRAM} ${.parsed.real_day} ${.parsed.real_hour}")
33+
);
34+
};
35+
rewrite {
36+
set("${.parsed.real_host}" value("HOST"));
37+
set("${.parsed.real_program}" value("PROGRAM"));
38+
set("${.parsed.rest_of_message}" value("MESSAGE"));
39+
};
40+
};
41+
2142
parser {
2243
csv-parser(
2344
columns(serial, num, seq, message)
@@ -44,13 +65,13 @@ block parser app-syslog-cisco_ise() {
4465
product('ise')
4566
);
4667
};
47-
48-
49-
};
68+
};
5069
};
70+
5171
application app-syslog-cisco_ise[sc4s-syslog-pgm] {
5272
filter {
53-
program('CISE_' type(string) flags(prefix));
73+
program('CISE_' type(string) flags(prefix))
74+
or message('CISE_' type(string) flags(substring));
5475
};
5576
parser { app-syslog-cisco_ise(); };
5677
};

tests/test_cisco_ise.py

+100-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def test_cisco_ise_cise_alarm_single(
207207
sendsingle(message, setup_sc4s[0], setup_sc4s[1][514])
208208

209209
st = env.from_string(
210-
'search index=netauth host="{{ host }}" sourcetype="cisco:ise:syslog" "Server=10.0.0.5"'
210+
'search index=netauth host="{{ host }}" sourcetype="cisco:ise:syslog" "CISE_Alarm WARN: RADIUS Authentication Request dropped : Server=10.0.0.5;"'
211211
)
212212
search = st.render(epoch=epoch, host=host)
213213

@@ -218,3 +218,102 @@ def test_cisco_ise_cise_alarm_single(
218218
record_property("message", message)
219219

220220
assert result_count == 1
221+
222+
@pytest.mark.addons("cisco")
223+
def test_cisco_ise_double_timestamp_and_hostname(
224+
record_property, setup_splunk, setup_sc4s
225+
):
226+
host = f"{shortuuid.ShortUUID().random(length=5).lower()}-{shortuuid.ShortUUID().random(length=5).lower()}"
227+
228+
dt = datetime.datetime.now()
229+
_, bsd, time, date, tzoffset, _, epoch = time_operations(dt)
230+
231+
# Tune time functions for Cisco ISE
232+
time = time[:-3]
233+
tzoffset = tzoffset[0:3] + ":" + tzoffset[3:]
234+
epoch = epoch[:-3]
235+
236+
mt = env.from_string(
237+
"{{ mark }}{{ bsd }} wrong_host {{ bsd }} {{ host }} CISE_System_Statistics 0000001313 1 4 2020-01-01 10:00:00.000000 +00:00 0000015291 70501 NOTICE System-Stats: ISE Counters, ConfigVersionId=1, OperationCounters=Counter=1_LocalEndPointReads:1]\n"
238+
)
239+
message = mt.render(
240+
mark="<165>", bsd=bsd, host=host, date=date, time=time, tzoffset=tzoffset
241+
)
242+
sendsingle(message, setup_sc4s[0], setup_sc4s[1][514])
243+
244+
st = env.from_string(
245+
'search index=netauth host="{{ host }}" sourcetype="cisco:ise:syslog" "CISE_System_Statistics: 0000001313 1 4 2020-01-01 10:00:00.000000"'
246+
)
247+
search = st.render(epoch=epoch, host=host)
248+
249+
result_count, _ = splunk_single(setup_splunk, search)
250+
251+
record_property("host", host)
252+
record_property("resultCount", result_count)
253+
record_property("message", message)
254+
255+
assert result_count == 1
256+
257+
@pytest.mark.addons("cisco")
258+
def test_cisco_ise_double_timestamp_and_hostname_sequence_eq_0(
259+
record_property, setup_splunk, setup_sc4s
260+
):
261+
host = f"{shortuuid.ShortUUID().random(length=5).lower()}-{shortuuid.ShortUUID().random(length=5).lower()}"
262+
263+
dt = datetime.datetime.now()
264+
_, bsd, time, date, tzoffset, _, epoch = time_operations(dt)
265+
266+
# Tune time functions for Cisco ISE
267+
time = time[:-3]
268+
tzoffset = tzoffset[0:3] + ":" + tzoffset[3:]
269+
epoch = epoch[:-3]
270+
271+
mt = env.from_string(
272+
"{{ mark }}{{ bsd }} wrong_host {{ bsd }} {{ host }} CISE_System_Statistics 0000001313 4 0 {{ date }} {{ time }} {{ tzoffset }} 0000015291 70501 NOTICE System-Stats: part one,\n"
273+
)
274+
275+
message = mt.render(
276+
mark="<165>", bsd=bsd, host=host, date=date, time=time, tzoffset=tzoffset
277+
)
278+
sendsingle(message, setup_sc4s[0], setup_sc4s[1][514])
279+
280+
# Generate new datetime for subsequent messages; not used in log path parser so actually could be anything
281+
dt = datetime.datetime.now() + datetime.timedelta(seconds=1)
282+
bsd = dt.strftime("%b %d %H:%M:%S")
283+
284+
mt = env.from_string(
285+
"{{ mark }}{{ bsd }} wrong_host {{ bsd }} {{ host }} CISE_System_Statistics 0000001313 4 1 part two,\n"
286+
)
287+
message = mt.render(
288+
mark="<111>", bsd=bsd, host=host, date=date, time=time, tzoffset=tzoffset
289+
)
290+
sendsingle(message, setup_sc4s[0], setup_sc4s[1][514])
291+
292+
mt = env.from_string(
293+
"{{ mark }}{{ bsd }} wrong_host {{ bsd }} {{ host }} CISE_System_Statistics 0000001313 4 2 part three,\n"
294+
)
295+
message = mt.render(
296+
mark="<111>", bsd=bsd, host=host, date=date, time=time, tzoffset=tzoffset
297+
)
298+
sendsingle(message, setup_sc4s[0], setup_sc4s[1][514])
299+
300+
mt = env.from_string(
301+
"{{ mark }}{{ bsd }} wrong_host {{ bsd }} {{ host }} CISE_System_Statistics 0000001313 4 3 part four,\n"
302+
)
303+
message = mt.render(
304+
mark="<111>", bsd=bsd, host=host, date=date, time=time, tzoffset=tzoffset
305+
)
306+
sendsingle(message, setup_sc4s[0], setup_sc4s[1][514])
307+
308+
st = env.from_string(
309+
'search _time={{ epoch }} index=netauth host="{{ host }}" sourcetype="cisco:ise:syslog" one two three four'
310+
)
311+
search = st.render(epoch=epoch, host=host)
312+
313+
result_count, _ = splunk_single(setup_splunk, search)
314+
315+
record_property("host", host)
316+
record_property("resultCount", result_count)
317+
record_property("message", message)
318+
319+
assert result_count == 1

0 commit comments

Comments
 (0)