Skip to content

Commit

Permalink
Merge pull request #296 from splunk/log_paths/cisco_asa
Browse files Browse the repository at this point in the history
Update ASA log path to account for events with no hostname
  • Loading branch information
Ryan Faircloth authored and GitHub committed Feb 2, 2020
2 parents 9b48d9d + a0dd880 commit 04ef223
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
9 changes: 7 additions & 2 deletions package/etc/conf.d/filters/cisco/asa.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
filter f_cisco_asa {
message('^%ASA-\d+-\d{1,10}: ');
};
message('^%ASA-\d+-\d{1,10}: ') or
match('^%ASA-\d+-\d{1,10}:', value("LEGACY_MSGHDR"));
};

filter f_cisco_asa_nohost {
match('^%ASA-\d+-\d{1,10}:', value("LEGACY_MSGHDR"));
};
6 changes: 5 additions & 1 deletion package/etc/conf.d/log_paths/lp-cisco_asa_legacy.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ log {
};
parser {p_add_context_splunk(key("cisco_asa")); };
parser (compliance_meta_by_source);
rewrite { set("$(template ${.splunk.sc4s_template} $(template t_msg_only))" value("MSG")); };
if (filter (f_cisco_asa_nohost)) {
rewrite { set("$(template ${.splunk.sc4s_template} $(template t_legacy_hdr_msg))" value("MSG")); };
} else {
rewrite { set("$(template ${.splunk.sc4s_template} $(template t_msg_only))" value("MSG")); };
};

{{- if or (conv.ToBool (getenv "SC4S_DEST_SPLUNK_HEC_GLOBAL" "yes")) (conv.ToBool (getenv "SC4S_DEST_CISCO_ASA_HEC" "no")) }}
destination(d_hec);
Expand Down
21 changes: 21 additions & 0 deletions tests/test_cisco_asa.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ def test_cisco_asa_traditional(record_property, setup_wordlist, setup_splunk):

assert resultCount == 1

# <164>Jan 31 2020 17:24:03: %ASA-4-402119: IPSEC: Received an ESP packet (SPI= 0x0C190BF9, sequence number= 0x598243) from 192.0.0.1 (user= 192.0.0.1) to 192.0.0.2 that failed anti-replay checking.
def test_cisco_asa_traditional_nohost(record_property, setup_wordlist, setup_splunk):
host = "{}-{}".format(random.choice(setup_wordlist), random.choice(setup_wordlist))

mt = env.from_string(
"{{ mark }} {% now 'utc', '%b %d %H:%M:%S' %}: %ASA-4-402119: IPSEC: Received an ESP packet (SPI= 0x0C190BF9, sequence number= 0x598243) from {host} (user= 192.0.0.1) to 192.0.0.2 that failed anti-replay checking.\n")
message = mt.render(mark="<111>", host=host)

sendsingle(message)

st = env.from_string("search index=netfw sourcetype=\"cisco:asa\" \"%ASA-4-402119\" \"{host}\" | head 2")
search = st.render(host=host)

resultCount, eventCount = splunk_single(setup_splunk, search)

record_property("host", host)
record_property("resultCount", resultCount)
record_property("message", message)

assert resultCount == 1


# <166>2018-06-27T12:17:46Z asa : %ASA-3-710003: TCP access denied by ACL from 179.236.133.160/8949 to outside:72.142.18.38/23
def test_cisco_asa_rfc5424(record_property, setup_wordlist, setup_splunk):
Expand Down

0 comments on commit 04ef223

Please sign in to comment.