Getting Data In

Help with data masking

vrmandadi
Builder

Below is the sample mocked up data .I want to mask the the ones's highlighted .The sample data is part of an event which is more than 300 lines

"status": 1,
"parentGoalId": 5133,
"account": {
"goalId": 0,
"accountType": "regular",
"accountOpenDate": "0001-01-01T00:00:00",
"isAccountOpeningInProgress": true,
"owner": {
"firstName": "abc",
"middleName": "xyz",
"lastName": "eee",
"dateOfBirth": "1/1/2000 12:00:00 AM",
"ssn": "099999999
",
"citizenship": "alien",
"isMailingAddressAsPhysical": false,
"isTextMessageNotificationEnabled": false,

0 Karma
1 Solution

mayurr98
Super Champion

You could probably use below link to anonymize data at index time.
https://docs.splunk.com/Documentation/SplunkCloud/7.2.6/Data/Anonymizedata#Define_the_sed_script_in_...

and try s/(\"firstName\":\s+\")\w+/\1xxx/g for every field. Use the same for every field just change the name in round brackets and it should work.

Before this I would recommend you to try this in search time using rex on your prod data to see if it actually what you want.

This is sample run anywhere search

| makeresults | eval data="\"owner\": {
\"firstName\": \"abc\",
\"middleName\": \"xyz\",
\"lastName\": \"eee\",
\"dateOfBirth\": \"1/1/2000 12:00:00 AM\",
\"ssn\": \"099999999\",
\"citizenship\": \"alien\"," | rex field=data mode=sed "s/(\"firstName\":\s+\")\w+/\1xxx/g" | rex field=data mode=sed "s/(\"middleName\":\s+\")\w+/\1xxx/g"

You should use rex command given above on your prod data and see if it is actually working.

Let me know if this helps!

View solution in original post

mayurr98
Super Champion

You could probably use below link to anonymize data at index time.
https://docs.splunk.com/Documentation/SplunkCloud/7.2.6/Data/Anonymizedata#Define_the_sed_script_in_...

and try s/(\"firstName\":\s+\")\w+/\1xxx/g for every field. Use the same for every field just change the name in round brackets and it should work.

Before this I would recommend you to try this in search time using rex on your prod data to see if it actually what you want.

This is sample run anywhere search

| makeresults | eval data="\"owner\": {
\"firstName\": \"abc\",
\"middleName\": \"xyz\",
\"lastName\": \"eee\",
\"dateOfBirth\": \"1/1/2000 12:00:00 AM\",
\"ssn\": \"099999999\",
\"citizenship\": \"alien\"," | rex field=data mode=sed "s/(\"firstName\":\s+\")\w+/\1xxx/g" | rex field=data mode=sed "s/(\"middleName\":\s+\")\w+/\1xxx/g"

You should use rex command given above on your prod data and see if it is actually working.

Let me know if this helps!

vrmandadi
Builder

Hello Mayurr,

Thank you for your response I tries using the rex for date of birth s/(\"dateOfBirth\":\s+\")\w+/\1xxx/g .This only masked the part before the first / like xxx/1/2000 12:00:00 AM

0 Karma

mayurr98
Super Champion

Try this for date of birth:

| rex field=data mode=sed "s/(\"dateOfBirth\":\s+\")[^\"]+/\1xxx/g"

Pls accept if it works for you to close this question.

0 Karma

vrmandadi
Builder

Thank You it worked

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...