newrelic / newrelic-browser-agent

New Relic Browser Agent
Apache License 2.0
76 stars 40 forks source link

Enhance obfuscation rule to get dynamic replacement value. #1110

Open sandipkokitkar opened 2 months ago

sandipkokitkar commented 2 months ago

Summary

The current obfuscation rule configuration allows for static string replacement. While this method is useful, it poses challenges for problem investigation due to the static nature of the obfuscated value. For instance, consider a rule to obfuscate account numbers. { regex: //regex for account number, replacement: 'account_number' }

This rule will replace each account number with the same placeholder "account_number," making it impossible to differentiate between account numbers, especially since a user can have multiple accounts.

Desired Behavior

Replacement value should be dynamic, based on the value being obfuscated.

Possible Solution

Allow a function to be used as a replacement instead of a string only, in obfuscation rule. The obfuscateString in obfuscate.js will check if the replacement is a function, and if so, it will call the function with the input string. The value returned from the function will then be used as the replacement.

The replacement function can perform various operations, such as hashing the value or masking the initial characters only, depending on the specific requirements.

Additional context

workato-integration[bot] commented 2 months ago

https://new-relic.atlassian.net/browse/NR-290869

metal-messiah commented 2 weeks ago

FYI, This has now been elevated to our PM as a feature request