Skip to content

Commit

Permalink
fix: Many changes to reduce false positives and more: (#11)
Browse files Browse the repository at this point in the history
* made DIGITS more restrictive: only 4+ consecutive digits
* match NAME only in saluation and valediction contexts
* company names are not really sensitive to don't redact them
* add SSN pattern
  • Loading branch information
justbbetter authored Nov 29, 2017
1 parent 33d9ce1 commit 769a414
Show file tree
Hide file tree
Showing 7 changed files with 3,726 additions and 4,042 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"env" {
"env": {
"node": true,
"es6": true
},
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ npm install redact-pii

```js
var redactor = require('redact-pii')();
var redacted = redactor.redact('Hey it\'s David Johnson with ACME Corp. Give me a call at 555-555-5555');
// Hey it's NAME with COMPANY. Give me a call at PHONE_NUMBER
var redacted = redactor.redact('Hi David Johnson, Please give me a call at 555-555-5555');
// Hi NAME, Please give me a call at PHONE_NUMBER
```

## API
Expand All @@ -24,19 +24,19 @@ var redacted = redactor.redact('Hey it\'s David Johnson with ACME Corp. Give me
* `options` {Object}
* `replace` {String|Function} If a string, the value will be used as the replacement for all identified patterns. If a function, the function will be called with the name of each pattern to determine the replacement value for the pattern.
* `*` {RegExp|`false`} Any other key in options will be treated as a regular expression to use for replacing matches, `false` if no replacement is desired for a particular pattern. The following patterns are enabled by default.
* company
* credentials
* creditCardNumber
* emailAddress
* ipAddress
* name
* password
* phoneNumber
* salutation
* streetAddress
* username
* valediction
* ssn
* zipcode
* url
* digits

### redactor.redact(text)
* `text` {String} The text which contains PII to redact
Expand All @@ -47,8 +47,8 @@ var redacted = redactor.redact('Hey it\'s David Johnson with ACME Corp. Give me
### Replacement Values
```js
var redactor = require('redact-pii')({replace: 'TOP_SECRET'});
redactor.redact('David Johnson lives at 42 Wallaby Way');
// TOP_SECRET lives at TOP_SECRET
redactor.redact('Dear David Johnson, I live at 42 Wallaby Way');
// Dear TOP_SECRET, I live at TOP_SECRET

var redactor = require('redact-pii')({
replace: function (name, defaultReplacement) {
Expand All @@ -66,8 +66,8 @@ redactor.redact('my CC is 1234567812345678');
### Patterns
```js
var redactor = require('redact-pii')({name: false});
redactor.redact('David Johnson lives at 42 Wallaby Way');
// David Johnson lives at STREET_ADDRESS
redactor.redact('Dear David Johnson, I live at 42 Wallaby Way');
// Dear David Johnson, I live at STREET_ADDRESS


var redactor = require('redact-pii')({animal: /\b(cat|dog|cow)s?\b/gi});
Expand Down
Loading

0 comments on commit 769a414

Please sign in to comment.