From c3811781c92292c33ef5ef5e9d345c65e0aa28a4 Mon Sep 17 00:00:00 2001 From: "Mahir Chavda (C)" Date: Mon, 15 Jun 2020 11:49:16 +0530 Subject: [PATCH 1/2] Extract Source from the ProductName & Update document --- docs/sources/McAfee/index.md | 5 +- .../conf.d/log_paths/lp-mcafee_epo.conf.tmpl | 10 +++ tests/test_mcafee_epo.py | 68 +++++++++++++++++-- 3 files changed, 77 insertions(+), 6 deletions(-) diff --git a/docs/sources/McAfee/index.md b/docs/sources/McAfee/index.md index 250d6e5..c9ec15e 100644 --- a/docs/sources/McAfee/index.md +++ b/docs/sources/McAfee/index.md @@ -19,8 +19,9 @@ | source | notes | |----------------|---------------------------------------------------------------------------------------------------------| -| Future | source field will be updated in the future to identify record types | - +| policy_auditor_vulnerability_assessment | Policy Auditor Vulnerability Assessment events | +| mcafee_agent | McAfee Agent events | +| mcafee_endpoint_security | McAfee Endpoint Security events | ### Index Configuration | key | index | notes | diff --git a/package/etc/conf.d/log_paths/lp-mcafee_epo.conf.tmpl b/package/etc/conf.d/log_paths/lp-mcafee_epo.conf.tmpl index 36419fb..b56d8ed 100644 --- a/package/etc/conf.d/log_paths/lp-mcafee_epo.conf.tmpl +++ b/package/etc/conf.d/log_paths/lp-mcafee_epo.conf.tmpl @@ -21,6 +21,16 @@ log { }; }; + if { + filter { + message('ProductName="([^"]+)"' flags(store-matches)); + }; + rewrite { + set("$(lowercase $1)" value(".mcafee.product")); + subst('\s', '_', value(".mcafee.product") flags("global")); + r_set_splunk_dest_default(sourcetype("mcafee:epo:syslog"), index("epav"), source("${.mcafee.product}")) + }; + }; rewrite { set("mcafee_epo", value("fields.sc4s_vendor_product")); diff --git a/tests/test_mcafee_epo.py b/tests/test_mcafee_epo.py index 8d8df32..e9e17e6 100644 --- a/tests/test_mcafee_epo.py +++ b/tests/test_mcafee_epo.py @@ -12,16 +12,76 @@ import pytest env = Environment() -testdata = [ + +mcafee_endpoint_security_testdata = [ r'{{ mark }} {{ iso }}Z {{ host }} EPOEvents - EventFwd [agentInfo@3401 tenantId="1" bpsId="1" tenantGUID="{00000000-0000-0000-0000-000000000000}" tenantNodePath="1\2"] ?DESKTOP-000010011aacc-eeee-0000-0000-00001122331110.222.22.131Windows 10 Server%CTX_DOMAIN_USER%-330000011223311ENDP_GS_1060McAfee Endpoint Security10.6.1.1607DESKTOP-0000111200{{ iso }}_ops.update1none6', r'{{ mark }} {{ iso }}Z {{ host }} EPOEvents - EventFwd [agentInfo@3401 tenantId="1" bpsId="1" tenantGUID="{00000000-0000-0000-0000-000000000000}" tenantNodePath="1\2"] ?DESKTOP-000010011aacc-eeee-0000-0000-00001122331110.222.22.83Windows 10 Server%CTX_DOMAIN_USER%-330000011223311ENDP_GS_1070McAfee Endpoint Security10.7.0.1285DESKTOP-0000111180{{ iso }}_ops.update.end1none6', r'{{ mark }} {{ iso }}Z {{ host }} EPOEvents - EventFwd [agentInfo@3401 tenantId="1" bpsId="1" tenantGUID="{00000000-0000-0000-0000-000000000000}" tenantNodePath="1\2"] ?DESKTOP-000010011aacc-eeee-0000-0000-00001122331110.222.22.45Windows 10 WorkstationSYSTEM-330000011223311ENDP_WP_1060McAfee Endpoint Security10.6.1DESKTOP-00001URL navigation186003{{ iso }}wp.detect.url186002Web Control ViolationIDS_THREAT_TYPE_URL{{ iso }}ZblockedTrue213.211.198.58http://2222.aaaaa.org/download/eicarcom2.zipDESKTOP-00001\adminC:\Program Files\McAfee\Endpoint Security\Web Control\McChHost.exeDESKTOP-00001\adminIDS_BLADE_NAME_WPTrue03e33bcdd99853ea8c83407c3ab4599cC:\Program Files\Google\Chrome\Application\chrome.exea1902e39f3a1610751b707a6742082c3TrueGoogle LLC0FalseIDS_SECUIRTY_RATING_SA_REDIDS_SAE_CONTENT_MS1IDS_WC_NLD_URL_RATING|SourceURL=http://2222.aaaaa.org/download/eicarcom2.zip|SourceProcessName=C:\Program Files\McAfee\Endpoint Security\Web Control\McChHost.exe|SourceUserName=DESKTOP-00001\admin|ThreatActionTaken=blocked|AnalyzerName=McAfee Endpoint Security|SourceURLRatingCode=IDS_SECUIRTY_RATING_SA_RED186002222.aaaaa.orghttp://2222.aaaaa.org/download/eicarcom2.zip10413143444413000000100000000000000000011000000', r'{{ mark }} {{ iso }}Z {{ host }} EPOEvents - EventFwd [agentInfo@3401 tenantId="1" bpsId="1" tenantGUID="{00000000-0000-0000-0000-000000000000}" tenantNodePath="1\2"] ?DESKTOP-000010011aacc-eeee-0000-0000-00001122331110.222.22.131Windows 10 ServerSYSTEM-330000011223311ENDP_AM_1060McAfee Endpoint Security10.6.1DESKTOP-000016010.8670On-Access Scan3811.012783{{ iso }}av.detect12782EICAR test filetest{{ iso }}ZIDS_ALERT_ACT_TAK_DELTrueDESKTOP-00001C:\Users\admin123.WIN-QFN79SPC5U4.000\Desktop\Tops.exeDESKTOP-00001DESKTOP-00001\admin123C:\Users\admin123.WIN-QFN79SPC5U4.000\Desktop\TEST_SAMPLES_MVS\Standard Test Set\eicarIDS_BLADE_NAME_SPB2019-08-25T02:22:00ZFalseTrueeicarC:\Users\admin123.WIN-QFN79SPC5U4.000\Desktop\TEST_SAMPLES_MVS\Standard Test Sete7e5fa40569514ec442bbdf755d89c2f702000-10-24T05:13:46Z2019-08-26T05:32:39Z2019-08-26T05:32:39ZFalseIDS_OAS_TASK_NAMEIDS_ALERT_THACT_ATT_CLEFalseIDS_ALERT_THACT_ATT_DELTrue410IDS_NATURAL_LANG_OAS_DETECTION_DEL|TargetName=eicar|TargetPath=C:\Users\admin123.WIN-QFN79SPC5U4.000\Desktop\TEST_SAMPLES_MVS\Standard Test Set|ThreatName=EICAR test file|SourceProcessName=C:\Users\admin123.WIN-QFN79SPC5U4.000\Desktop\Tops.exe|ThreatType=test|TargetUserName=DESKTOP-00001\admin123IDS_OAS_DEFAULT_THREAT_MESSAGE3811.0', +] +mcafee_agent_testdata = [ r'{{ mark }} {{ iso }}Z {{ host }} EPOEvents - EventFwd [agentInfo@4444 tenantId="1" bpsId="1" tenantGUID="{00000000-0000-0000-0000-000000000000}" tenantNodePath="1\2"] {0011aacc-eeee-0000-0000-000011223311}THEMBP1000011223311172.16.23.1231.1.1.103Windows 1024024224{{ iso }}POLICYAU6000040959Policy EnforcementN/AEPOAGENT3000N/AN/AN/A', +] +policy_auditor_vulnerability_assessment_testdata = [ r'{{ mark }} {{ iso }}Z {{ host }} EPOEvents - EventFwd [agentInfo@4444 tenantId="1" bpsId="1" tenantGUID="{00000000-0000-0000-0000-000000000000}" tenantNodePath="1\2"] {0011aacc-eeee-0000-0000-000011223311}THEMBP1000011223311172.16.23.1231.1.1.103Linux0GARY189050{{ iso }}Policy Auditor Vulnerability Assessment1.1.0Security020eJx1jjELgzAUhPf+ipCpBYWoS+smOHYQHEuR1xjKK+YZzEupiP+9j+7d7o7vuNs0gXe61l2jmhgd qxYYVG+BCOmprkjpo45N1/UnnemUcBS4NKIZvYsMPvyC0uSmyouLKqramLo8C7G4mCYeeA2ysGkI YUILjDMN8+PlLEsTyS7OO2KY9J6JfYuel3UY5ce/1u2+74cvff89lg==', ] -@pytest.mark.parametrize("event", testdata) -def test_mcafee_epo_structured(record_property, setup_wordlist, get_host_key, setup_splunk, setup_sc4s,event): + +@pytest.mark.parametrize("event", mcafee_endpoint_security_testdata) +def test_mcafee_epo_structured_mcafee_endpoint_security(record_property, setup_wordlist, get_host_key, setup_splunk, setup_sc4s,event): + host = get_host_key + + dt = datetime.datetime.now(datetime.timezone.utc) + iso, bsd, time, date, tzoffset, tzname, epoch = time_operations(dt) + + # Tune time functions + iso = dt.isoformat()[0:23] + epoch = epoch[:-3] + + mt = env.from_string(event + "\n") + message = mt.render(mark="<29>1", iso=iso, host=host) + + sendsingle(message, setup_sc4s[0], setup_sc4s[1][514]) + + st = env.from_string('search _time={{ epoch }} index=epav host="{{ host }}" sourcetype="mcafee:epo:syslog" source="mcafee_endpoint_security"') + search = st.render(epoch=epoch, host=host) + + resultCount, eventCount = splunk_single(setup_splunk, search) + + record_property("host", host) + record_property("resultCount", resultCount) + record_property("message", message) + + assert resultCount == 1 + +@pytest.mark.parametrize("event", mcafee_agent_testdata) +def test_mcafee_epo_structured_mcafee_agent(record_property, setup_wordlist, get_host_key, setup_splunk, setup_sc4s,event): + host = get_host_key + + dt = datetime.datetime.now(datetime.timezone.utc) + iso, bsd, time, date, tzoffset, tzname, epoch = time_operations(dt) + + # Tune time functions + iso = dt.isoformat()[0:23] + epoch = epoch[:-3] + + mt = env.from_string(event + "\n") + message = mt.render(mark="<29>1", iso=iso, host=host) + + sendsingle(message, setup_sc4s[0], setup_sc4s[1][514]) + + st = env.from_string('search _time={{ epoch }} index=epav host="{{ host }}" sourcetype="mcafee:epo:syslog" source="mcafee_agent"') + search = st.render(epoch=epoch, host=host) + + resultCount, eventCount = splunk_single(setup_splunk, search) + + record_property("host", host) + record_property("resultCount", resultCount) + record_property("message", message) + + assert resultCount == 1 + +@pytest.mark.parametrize("event", policy_auditor_vulnerability_assessment_testdata) +def test_mcafee_epo_structured_policy_auditor_vulnerability_assessment(record_property, setup_wordlist, get_host_key, setup_splunk, setup_sc4s,event): host = get_host_key dt = datetime.datetime.now(datetime.timezone.utc) @@ -36,7 +96,7 @@ def test_mcafee_epo_structured(record_property, setup_wordlist, get_host_key, se sendsingle(message, setup_sc4s[0], setup_sc4s[1][514]) - st = env.from_string("search _time={{ epoch }} index=epav host=\"{{ host }}\" sourcetype=\"mcafee:epo:syslog\"") + st = env.from_string('search _time={{ epoch }} index=epav host="{{ host }}" sourcetype="mcafee:epo:syslog" source="policy_auditor_vulnerability_assessment"') search = st.render(epoch=epoch, host=host) resultCount, eventCount = splunk_single(setup_splunk, search) From d00266675fa4212d7112ff054c776e6db6bda3f0 Mon Sep 17 00:00:00 2001 From: Ryan Faircloth <35384120+rfaircloth-splunk@users.noreply.github.com> Date: Mon, 15 Jun 2020 09:01:00 -0400 Subject: [PATCH 2/2] Update for syntax changes in develop Remove use of the index macro and ensure the source is set if not provided --- .../etc/conf.d/log_paths/lp-mcafee_epo.conf.tmpl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/package/etc/conf.d/log_paths/lp-mcafee_epo.conf.tmpl b/package/etc/conf.d/log_paths/lp-mcafee_epo.conf.tmpl index b56d8ed..74b590d 100644 --- a/package/etc/conf.d/log_paths/lp-mcafee_epo.conf.tmpl +++ b/package/etc/conf.d/log_paths/lp-mcafee_epo.conf.tmpl @@ -28,16 +28,17 @@ log { rewrite { set("$(lowercase $1)" value(".mcafee.product")); subst('\s', '_', value(".mcafee.product") flags("global")); - r_set_splunk_dest_default(sourcetype("mcafee:epo:syslog"), index("epav"), source("${.mcafee.product}")) - }; + r_set_splunk_dest_default(sourcetype("mcafee:epo:syslog"), source("${.mcafee.product}")) + }; + } else { + # If the product is not provided by EPO we will just use a constant for the value + rewrite { + set("mcafee_epo", value("fields.sc4s_vendor_product")); + r_set_splunk_dest_default(sourcetype("mcafee:epo:syslog"), source("epo")) + }; }; - rewrite { - set("mcafee_epo", value("fields.sc4s_vendor_product")); - r_set_splunk_dest_default(sourcetype("mcafee:epo:syslog"), index("epav")) - }; parser {p_add_context_splunk(key("mcafee_epo")); }; - parser (compliance_meta_by_source); rewrite { set("$(template ${.splunk.sc4s_template} $(template t_msg_only))" value("MSG")); };