
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@zapier/secret-scrubber
Advanced tools
Confidently remove secrets and sensitive values from unstructured objects.
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.
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'
// }
// }
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:
+
JSON.stringify
, so secrets with control charactersYou 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:
authorization
or password
)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:
matcher('', value)
)This project uses SemVer as its versioning scheme.
To release a new version publicly on the npm
registry, do the following:
version
in package.json
and updates the CHANGELOG.md
with the new version number.package.json
on the main
branch.Created using generator-xavdid during the Summer '21 Zapier hackathon.
FAQs
Confidently remove secrets and sensitive values from unstructured objects.
The npm package @zapier/secret-scrubber receives a total of 41,670 weekly downloads. As such, @zapier/secret-scrubber popularity was classified as popular.
We found that @zapier/secret-scrubber demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 308 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.