1.2.0 • Published 3 months ago

blur-sensitive-data v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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!

Maintainability Test Coverage

Installing

Using npm:

$ npm install blur-sensitive-data

Using yarn:

$ yarn add blur-sensitive-data

How to use

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
STRUCTURESDESCRIPTION
objectObfuscation 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.
stringThe 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.

Objects

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'
//    }
//}
//}

Possible parameters for customizing objects obfuscator

PARAMTYPEMANDATORYDESCRIPTION
replacerTextstring:x:Text to make sensitive parameter substitution.
additionalObjectKeysstring[]:x:Additional keys to obfuscate.

String

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

Possible parameters for customizing the strings obfuscator

PARAMTYPEMANDATORYDESCRIPTION
replacerTextstring:x:Text to make sensitive parameter substitution.
stringPatternsEStringLookUpFields[]:x:Sensitive default settings for substitution. If omitted, obfuscation will be done by default sensitive types.
additionalStringPatternsRegExp[]:x:Alternative patterns for obfuscating.
1.2.0

3 months ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago