Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
deep-redact
Advanced tools
deep-redact
Deep redact is a package that recursively redacts sensitive data from JavaScript primitives based on a list of keys.
npm install deep-redact
import { redact } from "deep-redact";
const data = {
email: "hello@test.com",
password: "123456",
dontReactMe: "123456",
jsonString: '{ "email": "hello@test.com"}',
url: "https://cv.moshie.dev/redactor?this=test&password=12345&email=hello@test.com",
};
const result = redact(data, {
list: ["email", "password"],
strict: true,
redactString: "[REDACTED]",
});
console.log(result);
/**
* {
* email: "[REDACTED]",
* password: "[REDACTED]",
* dontReactMe: "123456",
* jsonString: {
* email: "[REDACTED]"
* },
* url: "https://cv.moshie.dev/redactor?email=[REDACTED]&password=[REDACTED]&this=test"
* }
*/
We also expose a replacer function that can be used with JSON.stringify
and JSON.parse
the redactor does this behind the scenes but you can use it if you want to.
import { replacer } from "deep-redact";
const data = {
email: "hello@test.com",
password: "123456",
dontReactMe: "123456",
};
const replacer = replacer({
list: ["email", "password"],
strict: true,
redactString: "[REDACTED]",
})
try {
const raw = JSON.stringify(data, replacer);
const result = JSON.parse(raw);
console.log(result);
/**
* "{
* "email": "[REDACTED]",
* password: "[REDACTED]",
* dontReactMe: "123456",
* }"
*/
} catch (e) {
console.log(e);
}
redactString
- The string to replace the redacted data with. Default is [REDACTED]
.
list
- An array of keys to redact. Default is []
.
strict
- A boolean to determine if the data should be redacted or not. Default is false
.
1.0.7
FAQs
Deeply redact sensitive data from JS primitives
The npm package deep-redact receives a total of 3 weekly downloads. As such, deep-redact popularity was classified as not popular.
We found that deep-redact demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.