A simple tool to remove all sensitive data from structures, so they can be used safely. Go from my credit card number is 4024-0071-4571-8614
to my credit card number is NOT_VISIBLE
and much more!
Using npm:
$ npm install blur-sensitive-data
Using yarn:
$ yarn add blur-sensitive-data
const ob = require('blur-sensitive-data');
const obf = new ob.Obfuscator().blur("Credit Card Number 4024-0071-4571-8614");
//output: Credit Card Number NOT_VISIBLE_SECURITY_REASON
STRUCTURES | DESCRIPTION |
---|---|
object |
Obfuscation happens on any value at which the key is considered sensitive. +2k keys are parsed by default and you can add more values to obfuscate, the default fields are based on cabinjs sensitive list. |
string |
The obfuscation happens in the patterns that are considered sensitive, the match is done by regex. By default we offer some patterns to obfuscate whether the sentence is formatted or not: Brazilian CPF , Brazilian CNPJ , Brazilian RG , Phone Number , Object Id , UUID and Credit Card Number , other values can be added. |
The library supports objects whether they are simple or deep, keyword scanning is done on the entire object, there is also a layer to remove circular dependency if it is present.
import Obfuscator from 'blur-sensitive-data';
const dirtyObjectData = {
Api_key: 'test string api_key',
test: 'test string teste',
some: {
password: 'test string password',
test: {
password: 'test string nested password',
obfuscator: 'test string obfuscator'
}
}
}
const configObject = {
additionalObjectKeys: ['obfuscator']
}
const obf = new Obfuscator(configObject);
const clearData = obf.blur(dirtyObjectData);
//Output:
//{
// password: 'NOT_VISIBLE_SECURITY_REASON',
// Api_key: 'NOT_VISIBLE_SECURITY_REASON',
// test: 'test string teste',
// some: {
// password: 'NOT_VISIBLE_SECURITY_REASON',
// test: {
// password: 'NOT_VISIBLE_SECURITY_REASON',
// obfuscator: 'NOT_VISIBLE_SECURITY_REASON'
// }
//}
//}
PARAM | TYPE | MANDATORY | DESCRIPTION |
---|---|---|---|
replacerText | string |
❌ | Text to make sensitive parameter substitution. |
additionalObjectKeys | string[] |
❌ | Additional keys to obfuscate. |
The library supports type string, in this case the obfuscation is done by matching the searched pattern, whether it is presented only in the sentence or multiple times, and can be in several differents formats and/or intertwined with other texts.
import Obfuscator from 'blur-sensitive-data';
const dirtyStringData = 'this is a string with Credit Card Number 4024-0071-4571-8614, CPF 222.222.222-22 with obfuscator';
const configObject = {
replacerText: 'NOT_VISIBLE',
stringPatterns: [Obfuscator.EStringLookUpFields.CPF, Obfuscator.EStringLookUpFields.CREDIT_CARD],
additionalStringPatterns: [/obfuscator/]
}
const obf = new Obfuscator(configObject);
const clearData = obf.blur(dirtyStringData);
//output: this is a string with Credit Card Number NOT_VISIBLE, CPF NOT_VISIBLE with NOT_VISIBLE
PARAM | TYPE | MANDATORY | DESCRIPTION |
---|---|---|---|
replacerText | string |
❌ | Text to make sensitive parameter substitution. |
stringPatterns | EStringLookUpFields[] |
❌ | Sensitive default settings for substitution. If omitted, obfuscation will be done by default sensitive types. |
additionalStringPatterns | RegExp[] |
❌ | Alternative patterns for obfuscating. |