npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redact-phi

v1.0.1

Published

Assists in the redaction of PHI in structured or semi-structured data, supporting excel (XSLX), CSV or JSON.

Downloads

4

Readme

Build Status tracker

redact-PHI

A command-line utility to remove, redact and fabricate PHI, PII or protected data (CSV, JSON, XLSX).

Online Demo

Browser-based version

Local Installation

Install globally using npm i -g redact-phi

Usage

Removing PII from CSV

redact [options] <infile> [outfile]

Options:
  -V, --version            output the version number
  --delimiter <delimiter>  sets delimiter type (default: ",")
  --override <override>    Provide the location of your redaction specification
  -h, --help               display help for command

Redaction Example

redact-PHI includes an example (./example/) :

  • example.csv - CSV source file (data to be redacted)
  • example.json - JSON redaction strategy (defines how columns will be redacted with: faker, a custom redactor or a constant)
  • example.js - JavaScript custom redactors (this file is optional)

The .csv, .json and .js files must all be named the same (e.g. data.csv, data.json, data.js)


example/example.csv :

id,email,ssn,first name,last name,full address,order date,order amount
783,[email protected],706-25-4558,Caroline,Goodwin,82703 Yasmeen Corner Apt. 379,"10/9/2020, 4:48:52 AM",252.94
784,[email protected],282-57-6226,Izabella,Bosco,2930 Alisa Heights Apt. 572,"3/27/2021, 11:51:26 PM",689.40
784,[email protected],282-57-6226,Izabella,Bosco,2930 Alisa Heights Apt. 572,"6/17/2021, 9:44:54 PM",446.29
786,[email protected],677-86-2303,Celine,Dicki,68305 Labadie Shoal Suite 608,"4/23/2021, 6:49:34 PM",889.37
...

example/example.json :

{
  "columns": [
    {
      "redactWith": "random.number",
      "columnNum": "",
      "columnKey": "order id",
      "tracked": false
    },
    {
      "redactWith": "customGenerateId",
      "columnNum": 0,
      "columnKey": "",
      "tracked": true
    },
...

The columns array contains objects with properties that describe how each column should be redacted:

  • columnNum - (integer) Identifies the column to be redacted with an integer index (zero-based). (columnNum or columnKey must be set)

  • columnKey - (string) Identifies the column to be redacted using the file's header. (columnNum or columnKey must be set)

  • redactWith - (string) The strategy used to redact a value, there are four options:

    • faker function - Available functions : name.firstName or internet.email
    • faker template - Faker methods in a mustache template : {{address.streetAddress(true)}} or {{address.city}}, {{address.state}} {{address.zip}}
    • custom JavaScript - For more complicated redacted values you can call a JavaScript function defined in your .js file (see example.js)
    • constant value - If you wish to replace every value in this column with a constant, e.g. John Doe
  • tracked - Tracking preserves the relationships within your data while de-identifying. With tracking enabled, the redaction engine tracks a column's original value and reuses the redacted value if the original is re-encountered. To see this in-action, run redact /example/example.csv and note how columns with tracking enabled (id,ssn,email) are redacted with the same value in example_redacted.csv.


example/example.js :

module.exports = {
    customGenerateId: () => {
        return ++currentId;
    },
...

Custom redactors provide more control over your data. A custom redactor is referenced from your .json file using the redactWith property. For example: redactWith: "customGenerateId"

De-identification Examples

These JSON examples will remove the following PII:

  • First Name: "redactWith": "name.firstName"
  • Last Name: "redactWith": "name.lastName"
  • Full Name: "redactWith": "name.findName"
  • Social Security number: "redactWith": "{{datatype.number({\"min\":100,\"max\":999})}}-{{datatype.number({\"min\":10,\"max\":99})}}-{{datatype.number({\"min\":1000,\"max\":9999})}}"
  • Email Address: "redactWith": "internet.email"
  • Phone / Fax number: "redactWith": "phone.phoneNumber"
  • Street Address: "redactWith": "address.streetAddress"
  • City: "redactWith": "address.city"
  • Zip Code: "redactWith": "address.zipCode"
  • City, State, Zip: "redactWith": "{{address.city()}}, {{address.stateAbbr()}} {{address.zipCode()}}"
  • Full Address: "redactWith": "{{address.streetAddress(true)}}"
  • IP: "redactWith": "internet.ip"
  • IP v6: "redactWith": "internet.ipv6"

Full De-identification example.json:

{
  "columns": [
    {
      "redactWith": "name.firstName",
      "columnNum": "",
      "columnKey": "first name",
      "tracked": false
    },
    {
      "redactWith": "name.lastName",
      "columnNum": "",
      "columnKey": "last name",
      "tracked": false
    },
    {
      "redactWith": "name.findName",
      "columnNum": "",
      "columnKey": "full name",
      "tracked": false
    },
    {
      "redactWith": "{{datatype.number({\"min\":100,\"max\":999})}}-{{datatype.number({\"min\":10,\"max\":99})}}-{{datatype.number({\"min\":1000,\"max\":9999})}}",
      "columnNum": "",
      "columnKey": "social security number",
      "tracked": false
    },
    {
      "redactWith": "internet.email",
      "columnNum": "",
      "columnKey": "email",
      "tracked": false
    },
    {
      "redactWith": "phone.phoneNumber",
      "columnNum": "",
      "columnKey": "phone",
      "tracked": false
    },
    {
      "redactWith": "address.city",
      "columnNum": "",
      "columnKey": "city",
      "tracked": false
    },
    {
      "redactWith": "address.zipCode",
      "columnNum": "",
      "columnKey": "zip",
      "tracked": false
    },
    {
      "redactWith": "address.streetAddress",
      "columnNum": "",
      "columnKey": "street address",
      "tracked": false
    },
    {
      "redactWith": "{{address.city()}}, {{address.stateAbbr()}} {{address.zipCode()}}",
      "columnNum": "",
      "columnKey": "city state zip",
      "tracked": false
    },
    {
      "redactWith": "{{address.streetAddress(true)}}",
      "columnNum": "",
      "columnKey": "full address",
      "tracked": false
    },
    {
      "redactWith": "internet.ip",
      "columnNum": "",
      "columnKey": "ip",
      "tracked": false
    },
    {
      "redactWith": "internet.ipv6",
      "columnNum": "",
      "columnKey": "ipv6",
      "tracked": false
    }
  ]
}

Redaction Strategy JSON Schema

JSON Schema for creating a spec