Splunk Search

How to mask credit card data in splunk using SEDCMD in props.conf on a HF...

prakash007
Builder

I'm using this regex to mask cc data in props.cof on a Heavy Forwarder....need help in validating....

log format

  all numbers starts with account=" some of them ends with " and some are not..

    xxxxxxxxxxxxxxxxxxx/xxxxx
    xxxxxxxxxxxxxxxx xx/xx xxx
    xxxxxxxxxxxxxxxx: xx xxxxx
    "xxxxxxxxxxxxxxxx   "
    xxxxxxxxxxxxxxxxx
    "xxxx-xxxx-xxxx-xxxx"
    "0-xxxxxxxxxxxxxxx"

I see the entire event has been dropped, i don't see any event with account=xxxx-xxxx-xxxx-xxxx

 [my_sourcetype]
SEDCMD-accmasking= s/account=\"?[\w\d\-\s\/\:\S]+\"?/xxxx-xxxx-xxxx-xxxx/g

I tried using the capturing groups (), still it didn't work...

 [my_sourcetype]
 SEDCMD-accmasking= s/account=(\"?[\w\d\-\s\/\:\S]+\"?)/xxxx-xxxx-xxxx-xxxx/g
0 Karma

ryanoconnor
Builder

Can you try the following?

[my_sourcetype]
SEDCMD-accmasking = s/account=(\d{4}-){3}(\d{4})/cc=xxxx-xxxx-xxxx-\2/g

If that doesn't work are you able to submit a scrubbed sample event?

Also for future use: http://docs.splunk.com/Documentation/Splunk/6.0/Data/Anonymizedatausingconfigurationfiles

0 Karma

somesoni2
Revered Legend

Give this a try

[my_sourcetype]
 SEDCMD-accmasking= s/(account=\")[^\"]+)(\")/\1xxxx-xxxx-xxxx-xxxx\3/g

Update

Try this (runanywhere sample, everything except last rex line is to generate dummy data, replace that with your search)

| gentimes start=-1 | eval t="account=\"1111111111111111111/11111 some other text#account=\"1111111111111111 11/11 111 some other text#account=\"1111111111111111: 11 11111#account=\"1111111111111111   \" some other text#account=\"11111111111111111 some other text#account=\"1111-1111-1111-1111\" some other text#account=\"0-111111111111111\" some other text" | table t | makemv t delim="#" | mvexpand t  | rename t as _raw | eval orig=_raw
| rex mode=sed "s/(account=\")([\d-:\s\/]+)(\"*)(\s*\w)/\1xxxx-xxxx-xxxx-xxxx\" \4/g" 
0 Karma

gf13579
Communicator

that minus/hyphen character may need escaping in someoni2's rex:

| gentimes start=-1 
| eval t="account=\"1111111111111111111/11111 some other text#account=\"1111111111111111 11/11 111 some other text#account=\"1111111111111111: 11 11111#account=\"1111111111111111   \" some other text#account=\"11111111111111111 some other text#account=\"1111-1111-1111-1111\" some other text#account=\"0-111111111111111\" some other text" 
| table t 
| makemv t delim="#" 
| mvexpand t 
| rename t as _raw 
| eval orig=_raw
| rex mode=sed "s/(account=\")([\d\-:\s\/]+)(\"*)(\s*\w)/\1xxxx-xxxx-xxxx-xxxx\"/g"
0 Karma

prakash007
Builder

Have added the logformat in my question if you can give me one regex based on that. Thanks..!!

0 Karma

ryanoconnor
Builder

@mcnamara I just tested with all of your formats and I think the following should work

[my_sourcetype]
SEDCMD-accmasking = s/account=(\d{4}-){3}(\d{4})/cc=xxxx-xxxx-xxxx-\2/g
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...