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

@zapier/secret-scrubber

v1.1.1

Published

Confidently remove secrets and sensitive values from unstructured objects.

Downloads

100,323

Maintainers

diomerdiomereumie.jhong-zapiereumie.jhong-zapiermahsa.khoshab-zapiermahsa.khoshab-zapiermatthew.hockenbury-zapiermatthew.hockenbury-zapierkit.burgess-zapierkit.burgess-zapierjake.talgard-zapierjake.talgard-zapierjonathan.wise-zapierjonathan.wise-zapierisidro.hernandez-zapierisidro.hernandez-zapierdaniel.vagg-zapierdaniel.vagg-zapiermason.geloso-zapiermason.geloso-zapierlisa.orrlisa.orrrafal.wilinski-zapierrafal.wilinski-zapieranna.hadnagy-zapieranna.hadnagy-zapierchris.lee-zapierchris.lee-zapierzackary.higgins-zapierzackary.higgins-zapierrahul.es-zapierrahul.es-zapierjake.lear-zapierjake.lear-zapierservice-account-appsecservice-account-appsecmichael.gill-zapiermichael.gill-zapiersara.gomez-zapiersara.gomez-zapiercameron.phillips-zapiercameron.phillips-zapierjoe.smith-zapierjoe.smith-zapierolajide.ayinla-zapierolajide.ayinla-zapiercharan.mahesan-zapiercharan.mahesan-zapierjames.miltenberger-zapierjames.miltenberger-zapierdan.middleton-zapierdan.middleton-zapierjake.moghtader-zapierjake.moghtader-zapiertreesrule14treesrule14aispurostrangepixelsaispurostrangepixelscarlos.bazana-zapiercarlos.bazana-zapierdiego.rodriguez.vzqdiego.rodriguez.vzqmyless91myless91heather.osborn-zapierheather.osborn-zapiernicholas.civili-zapiernicholas.civili-zapierlukas.toma-zapierlukas.toma-zapierhusaina.wardhawala-zapierhusaina.wardhawala-zapierlisa.zapierlisa.zapierdavid.jardine-zapierdavid.jardine-zapierdavid.graves-zapierdavid.graves-zapierana.krivokapic-zapierana.krivokapic-zapierjacob.blakely-zapierjacob.blakely-zapierryan.detzel-zapierryan.detzel-zapierbrody-zapierbrody-zapierben.rugg-zapierben.rugg-zapiernicole.hardson-hurley-zapiernicole.hardson-hurley-zapierbryce.seagervandyk-zapierbryce.seagervandyk-zapierchristophe.coutzoukis-zapierchristophe.coutzoukis-zapierjessica.winters-zapierjessica.winters-zapiercameron.barnes-zapiercameron.barnes-zapierwojciech.matuszewski-zapierwojciech.matuszewski-zapierankit.gordhandas-zapierankit.gordhandas-zapierchrys.swingler-zapierchrys.swingler-zapierryan.vennell-zapierryan.vennell-zapierbenjamin.kempe-zapierbenjamin.kempe-zapierali.tycast-zapierali.tycast-zapierjelani.jackson-zapierjelani.jackson-zapierjdotceejdotceejeanny.syjeanny.syjames.hong-zapierjames.hong-zapierdennis.kailikia-zapierdennis.kailikia-zapiertom.leung-zapiertom.leung-zapierservice-account-renovateservice-account-renovateerin.williams-zapiererin.williams-zapiernolan.little-zapiernolan.little-zapiernik.danilov-zapiernik.danilov-zapiermichal.wysocki-zapiermichal.wysocki-zapiertomasz.piechota-zapiertomasz.piechota-zapiernate.moore-zapiernate.moore-zapiercorbin.schwartz-zapiercorbin.schwartz-zapierandrew.kordampalos-zapierandrew.kordampalos-zapierjonathan.harrell-zapierjonathan.harrell-zapierjc.coto-zapierjc.coto-zapierandrew.gosnell-zapierandrew.gosnell-zapieramber.diehl-zapieramber.diehl-zapiervivian.lau-zapiervivian.lau-zapierosarhomiyeke.iyere-zapierosarhomiyeke.iyere-zapierkristen.keller-zapierkristen.keller-zapierblzapierblzapiertal.peretz-zapiertal.peretz-zapiershanan.holm-zapiershanan.holm-zapiervj.clasgens-zapiervj.clasgens-zapiermarina.handmarina.handaubry.stewart-zapieraubry.stewart-zapieraleks.ozolins-zapieraleks.ozolins-zapierabraham.duran-zapierabraham.duran-zapierabdullah.umar-zapierabdullah.umar-zapierrohit.tripathi-zapierrohit.tripathi-zapiermike.lambert-zapiermike.lambert-zapierted.schmidt-zapierted.schmidt-zapierlaura.giles-zapierlaura.giles-zapiernitish.upadhyay-zapiernitish.upadhyay-zapiercatherine.murray-zapiercatherine.murray-zapierken.ng-zapierken.ng-zapieromar.delossantos-zapieromar.delossantos-zapierryan.laxson-zapierryan.laxson-zapierpedro.louro-zapierpedro.louro-zapierzac.jones-zapierzac.jones-zapierbrandon.parker-zapierbrandon.parker-zapieralec.hinh-zapieralec.hinh-zapiermaggie.cody-zapiermaggie.cody-zapiermary.rising-zapiermary.rising-zapierharrison.jackson-zapierharrison.jackson-zapieralex.hovancik-zapieralex.hovancik-zapiermatthew.kiernander-zapiermatthew.kiernander-zapierphilip.ng-zapierphilip.ng-zapierdaniel.shepard-zapierdaniel.shepard-zapiersharvari.desai-zapiersharvari.desai-zapierjenna.macdonald-zapierjenna.macdonald-zapierrval-zapierrval-zapierryan.dunnewold-zapierryan.dunnewold-zapierashley.isles-zapierashley.isles-zapierservice-account-catalogservice-account-catalogtazrafiqtazrafiqjayson.kadlecek-zapierjayson.kadlecek-zapierismail.latona-zapierismail.latona-zapierkasey.cowley-zapierkasey.cowley-zapiersarah.hernandez-zapiersarah.hernandez-zapieraaron.kosel-zapieraaron.kosel-zapieriris.huang-zapieriris.huang-zapierzapier-interfaceszapier-interfacesvitor.balocco-zapiervitor.balocco-zapierscott.woodend-zapierscott.woodend-zapieremily.harris-zapieremily.harris-zapiersandy.brydon-zapiersandy.brydon-zapierbrian.wendt-zapierbrian.wendt-zapierron.swanson-zapiertestron.swanson-zapiertestdilan-zapierdilan-zapierkatestamzapkatestamzapjhk2020jhk2020percy_at_zapierpercy_at_zapiertupelo8tupelo8dewayne-zapierdewayne-zapiersarahstorysarahstoryraquel.zapierraquel.zapierdanielheidornzapdanielheidornzapalex.blackalex.blackkatesowleskatesowlesjacquelynmccrayjacquelynmccrayschlickmannschlickmanncody.landrycody.landryhgascoignehgascoigneahsanhassanahsanhassankaushibkaushibnkroeker_zapnkroeker_zaprecamiliorecamilioandyzapierandyzapierariella-zapierariella-zapiervaleriia.shpinervaleriia.shpinerrchinermanrchinermanmiklossimonmiklossimonamickael-zapamickael-zapsethettersethetteryohana-heringeryohana-heringerrebecca.davis.zapierrebecca.davis.zapierben.clapp.zapierben.clapp.zapiermattplachtermattplachtermirrenzapmirrenzaplizzyzaplizzyzapcolemacleancolemacleansdelosrios95sdelosrios95magweavermagweaverjoseph-corona-zapierjoseph-corona-zapiernickaccuardizapiernickaccuardizapierraul.negronraul.negronnormanroanormanroafernando.velascosalazarfernando.velascosalazarmanasseh_zapiermanasseh_zapierdavidwin-zapdavidwin-zapgabebravogabebravoannader-zapierannader-zapieraparkinaparkinabhi-kapoorabhi-kapoorblakekblakekchasehambychasehambyzoeykim-zapierzoeykim-zapierdjeebusdjeebusxavierh-zapierxavierh-zapierkalenwesselkalenwessellev.glicklev.glickgreg-zapiergreg-zapierdavid.zapierdavid.zapierjoel.taddeijoel.taddeirobert.lewisrobert.lewisplorryplorryilari.scheininilari.scheininmsholtymsholtypoterekmpoterekmfgrafafgrafadayne-taittdayne-taittjosuezapjosuezappwhammanpwhammanomar.razaomar.razaadampieadampieerikamontanierikamontanistandielplsstandielplsmdgreenwaldmdgreenwaldloveena.vattenkyloveena.vattenkyjasehackmanjasehackmantims256tims256zapetczapetcchaodonghuchaodonghuemma-haysemma-haysmichaelannmichaelannjdaudierjdaudierjoaopimenteljoaopimentelryanmrubinryanmrubinter0ter0rghazalirghazalirsiemensrsiemenscasshill13casshill13eliangeliangnoahmangernoahmangerkola-erkola-ercodebycalebcodebycalebcalebpetersoncalebpetersonjordyvdjordyvdvictoravasiloaeivictoravasiloaeilukecjohnsonlukecjohnsonzapier-engineeringzapier-engineeringstevemolitorstevemolitorjdealjdealbcookseybcookseybryanhelmigbryanhelmigrobgoldingrobgoldingfokkezbfokkezbsam.plantsam.plantmichaelgilleymichaelgilleymluksomluksomikekucheramikekucherajoannejoannejuanvjuanvibrahem.zayedibrahem.zayedmuyiwa.olurinmuyiwa.olurinjamesacarrjamesacarrmikeknoopmikeknoopjosh.newmanjosh.newmanparsenzparsenzlarrytlarrytrhubbardrhubbardjacobsowlesjacobsowlesjacebrowningjacebrowningstacietaylorcimastacietaylorcimahitchcockwillhitchcockwillrenaekathleenrenaekathleenchelsea.weberchelsea.weberreganstarrzapierreganstarrzapiercyberwitchcyberwitchveebersveebersthomirthomirshalgrimshalgrimseason.huangseason.huangchris.vanderkolk.zapierchris.vanderkolk.zapiernickm0501nickm0501kayceekayceeowarijowarijbrian.corbinbrian.corbindarko.ronic.zapierdarko.ronic.zapierkredlearkredlearnumichuunumichuujustin.zapierjustin.zapierchelschubbchelschubbskylershawskylershawdaniel-frazierdaniel-frazieraaclarker-zapaaclarker-zaptiffanietiffanieerrorificerrorificezerwxezerwxlijennilijennijasonkotenkojasonkotenkowernertcwernertccortega_zpcortega_zptkcrannytkcrannybrandon.myers.zapierbrandon.myers.zapiermatthewwaltersmatthewwalterskat.nestorkat.nestorandya-zapierandya-zapierianscoianscowill.wigginswill.wigginsrondiegerondiegeannaulyanovaannaulyanovabskaurudbskaurudkaitrin.coxkaitrin.coxjeansimonjeansimonrocioarrocioarmilkrammilkrammburnimburnipeterbritnellpeterbritnellguivasconcelos-zapierguivasconcelos-zapiercarolinezapiercarolinezapieremmaielleemmaiellejeanetteujeanetteuismael.mendoncaismael.mendoncabbohenbbohensugatmahantisugatmahantinicole.thomasnicole.thomasagscalaagscalajordanraleighjordanraleighjosh.barberjosh.barberkamalsingh.narukakamalsingh.narukarobertsclrobertsclwavebeemwavebeemlaurenmbeattylaurenmbeattyankush_zapierankush_zapierihor.horakihor.horakmaxwellgbrownmaxwellgbrownhanz.corteshanz.cortesalejandro-lagosalejandro-lagos

Keywords

Readme

secret-scrubber-js

secret-scrubber is a JS package for removing sensitive data (such as passwords or API secrets) from arbitrary objects. It was written by Zapier to programmatically censor user logs without knowing what we were looking for.

Installation + Quick Start

yarn add @zapier/secret-scrubber

There are two main functions:

  • scrub takes an object/array/string and an array of sensitive strings. It returns the input with anything from the sensitive array censored.
  • findSensitiveValues uses our battle-tested heuristics to guess which values should be censored in an object.

Used together, these functions make it easy to pull sensitive data out of a user-supplied object without knowing the exact secrets you're looking for. To get value from this library, it's very important to use the scrub function. Without its transform logic, there's a much greater chance of leaking secrets. See the scrub docs for more info about the transforms.

Here's an example:

import { scrub, findSensitiveValues } from '@zapier/secret-scrubber'

scrub('Hey there! The password is "very-secret-password"', [
  'very-secret-password',
])
// 'Hey there! The password is ":censored:20:7991f05acc:"'

const request = {
  url: 'https://site.com?api_key=this%20is%20my%20key',
  body: {
    text: 'The password is "this is my key"',
  },
  headers: {
    authorization: 'Basic ZGF2aWQ6aHVudGVyMg==',
    accept: 'application/json',
  },
}
findSensitiveValues(request)
// [
//   'this is my key',
//   'Basic ZGF2aWQ6aHVudGVyMg=='
// ]

scrub(request, findSensitiveValues(request))
// {
//   url: 'https://site.com?api_key=:censored:14:5538025964:',
//   body: { text: 'The password is ":censored:14:5538025964:"' },
//   headers: {
//     authorization: ':censored:26:861bf51897:',
//     accept: 'application/json'
//   }
// }

API

The following are the functions exported by this package:

scrub

scrub: (input: object | any[] | string, secretValues: Array<string | number>) =>
  any

Recursively removes any version of each secretValue found in input. It looks for secrets both as plaintext and after a number of transformations. For instance, it you pass 'secret code' as a secret, it properly censors https://example.com?key=secret%20code. It currently performs the following transforms:

  1. as-is (no transform)
  2. percent encoded (via encodeURIComponent)
  3. percent encoded, but strings are replaces with +
  4. via JSON.stringify, so secrets with control characters

You can supply your own list of secret values (if you know them) or use one of the below functions to help extract a list of secrets.

findSensitiveValues

findSensitiveValues: (obj: object) => string[]

A convenience function to find potentially sensitive data in objects. It grabs:

  • any value tied to a typically sensitive key (such as authorization or password)
  • the username, password, and all querystring items with sensitive keys from any URL

recurseExtract

recurseExtract: (obj: object | any[], matcher: (key: string, value: any) => boolean): string[]

The underlying recursive function that powers findSensitiveValues. It takes an object to recurse and a matcher function. It returns stringified versions of any values that were found in the below steps. It's algorithm is as follows:

In the root object, each key/value pair are passed to the matcher function. Then:

  • if the value is an object, the function recurses
  • if the value is an array, we iterate each element:
    • if the element is an object or array, we recurse
    • otherwise, we call the matcher with only the value (matcher('', value))
  • otherwise, we pass the key and value to the matcher. If it's true, we collect the value

Versioning

This project uses SemVer as its versioning scheme.

  • Major versions will change change the public API (changing call signatures of exported functions or removing/renaming them entirely) or change platform support (aka, dropping support for older versions of Node.js)
  • Minor versions will add options, exported functions, or add transforms (see the the list of current transforms)
  • Patch versions will be internal bug fixes that don't affect either of the above cases

Deploying New Versions

To release a new version publicly on the npm registry, do the following:

  • Create a PR that updates the version in package.json and updates the CHANGELOG.md with the new version number.
  • Once that's approved merge it.
  • in CI, once tests pass, there's a "deploy" button. Clicking it will run the job that releases whatever version is in package.json on the main branch.

Created using generator-xavdid during the Summer '21 Zapier hackathon.