Splunk Search

How to use mvfilter with multiple regexes?

pdoconnell
Path Finder

I am building an alert based on file accesses to certain files. This is what I have so far:

index=wineventlog sourcetype=WinEventLog:Security EventCode=560 OR EventCode=4663 OR EventCode=5145 NOT user=*$
| lookup lookup_wild_folder folder_lookup AS folder_name, server AS host OUTPUT group_lookup user_lookup file_exceptions 
| eval user=if(isnull(Object_Name),null,user)
| eval user=if(match(Object_Name,folder_lookup),null,user)
| eval user=if(match(user_lookup,user),null,user)
| eval user=mvfilter(match(Object_Name,file_exceptions))
| table user host folder_lookup folder_name Object_Name Message group_lookup
| ldapfilter domain=default search="(sAMAccountName=$user$)" attrs="memberOf"
| rex field=memberOf "^CN=(?<group_name>[^,]+)"
| eval user=mvfilter(match(group_name,group_lookup))
| search user!=null
| table user host folder_lookup folder_name Object_Name Message group_lookup group_name

My problems are in the mvfilter lines. What I want is to check if the user is a member of an Active Directory group that is in the list of owners for the files (e.g. is user foo in group bar or baz), and is the file something we care about (e.g. does Object_Name contain one of the various file names from the lookup). The mvfilter command LOOKS similar to what I want, but in reverse (the mv variables are the regexes, of which any match is a reason to exit the search). Do I need to create a junk variable to do this?

0 Karma

woodcock
Esteemed Legend

If you make sure that your lookup values have known delimiters, then you can do it like this. Let's assume you are using a pair of colons ( :: ) to make your list and your input files look something like this (notice the delimiter on both ends of the strings, too):

lookup_wild_folder

folder_lookup,server,group_lookup,user_lookup,file_exceptions
some_folder,some_server,::group_A::group_B::group_C::,some_user,::exceptions_A::exceptions_B::exceptions_C::

Then you can do your search like this (untested but should work):

index=wineventlog sourcetype=WinEventLog:Security EventCode=560 OR EventCode=4663 OR EventCode=5145 NOT user=*$ | lookup lookup_wild_folder folder_lookup AS folder_name, server AS host OUTPUT group_lookup user_lookup file_exceptions | eval user=if(isnull(Object_Name),null,user) | eval user=if(match(Object_Name,folder_lookup),null,user) | eval user=if(match(user_lookup,user),null,user) | eval user=mvfilter(if(mvindex(split($file_exceptions$, "::" . $Object_Name$ . "::"), 0)) != $file_exceptions$)) | table user host folder_lookup folder_name Object_Name Message group_lookup | ldapfilter domain=default search="(sAMAccountName=$user$)" attrs="memberOf" | rex field=memberOf "^CN=(?<group_name>[^,]+)" | eval user=mvfilter(if(mvindex(split($group_lookup$, "::" . $group_name$ . "::"), 0)) != $group_lookup$)) | search user!=null | table user host folder_lookup folder_name Object_Name Message group_lookup group_name
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...