
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
@doist/piiranha
Advanced tools
Remove personally identifiable information from text.
This package is published on npm as @doist/piiranha and is maintained as a fork of the original solvvy/redact-pii package.
This library is primarily written for Node.js, but also works in the browser with compatible tooling/runtime (such as Vite, Webpack, Rollup, Parcel, esbuild). A transpiler/build setup such as TypeScript compiler, Babel, or both, can be used to target older browser support. It is written in TypeScript and currently compiles to ES2016. The project is tested in CI on Node.js 18.x and 20.x.
npm install @doist/piiranha
import { SyncRedactor } from 'piiranha';
const redactor = new SyncRedactor();
const redactedText = redactor.redact('Hi David Johnson, Please give me a call at 555-555-5555');
// Hi NAME, Please give me a call at PHONE_NUMBER
console.log(redactedText);
CommonJS equivalent:
const { SyncRedactor } = require('piiranha');
const redactor = new SyncRedactor();
const redactedText = redactor.redact('Hi David Johnson, Please give me a call at 555-555-5555');
// Hi NAME, Please give me a call at PHONE_NUMBER
console.log(redactedText);
import { AsyncRedactor } from 'piiranha';
const redactor = new AsyncRedactor();
redactor.redactAsync('Hi David Johnson, Please give me a call at 555-555-5555').then((redactedText) => {
// Hi NAME, Please give me a call at PHONE_NUMBER
console.log(redactedText);
});
import { SyncRedactor } from 'piiranha';
// use a single replacement value for all built-in patterns found.
const redactor = new SyncRedactor({ globalReplaceWith: 'TOP_SECRET' });
redactor.redact('Dear David Johnson, I live at 42 Wallaby Way');
// Dear TOP_SECRET, I live at TOP_SECRET
// use a custom replacement value for a specific built-in pattern
const redactor = new SyncRedactor({
builtInRedactors: {
names: {
replaceWith: 'ANONYMOUS_PERSON',
},
},
});
redactor.redact('Dear David Johnson');
// Dear ANONYMOUS_PERSON
Note that the order of redaction rules matters, therefore you have to decide whether you want your custom redaction rules to run before or after the built-in ones. Generally it's better to put very specialized patterns or functions before the built-in ones and more broad / general ones after.
import { SyncRedactor } from 'piiranha';
// add a custom regexp pattern
const redactor = new SyncRedactor({
customRedactors: {
before: [
{
regexpPattern: /\b(cat|dog|cow)s?\b/gi,
replaceWith: 'ANIMAL',
},
],
},
});
redactor.redact('I love cats, dogs, and cows');
// I love ANIMAL, ANIMAL, and ANIMAL
// add a synchronous custom redaction function
const redactor = new SyncRedactor({
customRedactors: {
before: [
{
redact(textToRedact) {
return textToRedact.includes('TopSecret')
? 'THIS_FILE_IS_SO_TOP_SECRET_WE_HAD_TO_REDACT_EVERYTHING'
: textToRedact;
},
},
],
},
});
redactor.redact('This document is classified as TopSecret.');
// THIS_FILE_IS_SO_TOP_SECRET_WE_HAD_TO_REDACT_EVERYTHING
import { AsyncRedactor } from './src/index';
// add an asynchronous custom redaction function
const redactor = new AsyncRedactor({
customRedactors: {
before: [
{
redactAsync(textToRedact) {
return myCustomRESTApiServer.redactCustomWords(textToRedact);
},
},
],
},
});
const redactor = new SyncRedactor({
builtInRedactors: {
names: {
enabled: false,
},
emailAddress: {
enabled: false,
},
},
});
To block direct local commits to the main branch, run:
npm run setup-hooks
This configures core.hooksPath to use the committed hooks in .githooks/.
Before a PR can be merged to main:
These checks ensure code quality and prevent regressions.
For non-main branches, commits are allowed only when branch names match:
<owner>/<type>/<description>
Allowed type values:
Examples:
odsamuels/chore/setup-hooksalice/feat/redaction-pipelineAutomation branches are also allowed:
dependabot/*renovate/*You can run the tests via npm run test.
FAQs
Remove personally identifiable information from text.
We found that @doist/piiranha demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 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
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.