
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
@amaabca/sensitive-param-filter
Advanced tools
A package for filtering sensitive data (parameters, keys) from a variety of JS objects
sensitive-param-filter
is a zero-dependency package designed to filter sensitive values from JavaScript objects.
This package can be used to scrub logs, filer data before outputting to a UI, etc.
The defaults provided with sensitive-param-filter should work well for most applications.
Install sensitive-param-filter to your project via either npm:
npm install @amaabca/sensitive-param-filter
or yarn:
yarn add @amaabca/sensitive-param-filter
const { SensitiveParamFilter } = require('@amaabca/sensitive-param-filter')
const paramFilter = new SensitiveParamFilter()
const rawObject = {
Authorization: 'Bearer somedatatoken',
body: {
info: '{ "amount": 28.64, "credit_card": "4242424242424242", "cvv": "123" }'
},
method: 'POST',
url: 'https://pay.example.com?user=bob.bobbington&password=asecurepassword1234'
}
const filteredObject = paramFilter.filter(rawObject)
// filteredObject = {
// Authorization: 'FILTERED',
// body: {
// info: '{ "amount": 28.64, "credit_card": "FILTERED", "cvv": "FILTERED" }'
// },
// method: 'POST',
// url: 'https://pay.example.com?user=bob.bobbington&password=FILTERED'
// }
sensitive-param-filter examines keys to determine which values to filter.
Key matching is done in a case-insensitive, partial-macthing manner (that is, if the param AUTH
is provided, Authorization
, AUTHENTICATION
, etc. will be filtered).
const { SPFDefaultParams, SensitiveParamFilter } = require('@amaabca/sensitive-param-filter')
const filter = new SensitiveParamFilter({
filterUnknown: false,
params: SPFDefaultParams.concat(['data', 'email']),
replacement: '***',
whitelist: ['authentic', 'encryption_standard']
})
filterUnknown:
Indicates whether "unexpected" objects (such as functions) should be filtered or returned as-is.
Defaults to true
params:
An array of string params to filter.
These entries will be combined into a regex that is used by sensitive-param-filter.
Setting this option overwrites the default array (SPFDefaultParams
).
replacement:
The object to replace filtered values with.
Defaults to 'FILTERED'
.
whitelist:
An array of strings to exclude from filtering.
For example, if pass_through
is including in the whitelist, the key pass_through
will not be filtered.
Note that entries must match keys exactly to prevent filtering - that is, whitelisting secrets
still causes secrets_store
to be filtered.
See defaults. Note that all of these values can be overridden via the options.
The default keys that are filtered are:
sensitive-param-filter
uses the MIT license.
See the license.
We welcome contributions. See contributing.
FAQs
A package for filtering sensitive data (parameters, keys) from a variety of JS objects
We found that @amaabca/sensitive-param-filter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.