![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@npmcli/redact
Advanced tools
@npmcli/redact is a utility for redacting sensitive information from strings. It is particularly useful for logging and debugging purposes where you want to ensure that sensitive data such as passwords, API keys, or personal information is not exposed.
Redact sensitive information
This feature allows you to redact specified sensitive information from a string. In this example, the words 'password' and 'secret' are redacted.
const { create } = require('@npmcli/redact');
const redactor = create(['password', 'secret']);
const redactedString = redactor('My password is password and my secret is secret.');
console.log(redactedString); // Output: My ****** is ****** and my ****** is ******.
Custom redaction patterns
This feature allows you to use custom regular expressions to define what should be redacted. In this example, a pattern for credit card numbers is used.
const { create } = require('@npmcli/redact');
const redactor = create([/\b\d{4}-\d{4}-\d{4}-\d{4}\b/]);
const redactedString = redactor('My credit card number is 1234-5678-1234-5678.');
console.log(redactedString); // Output: My credit card number is ********************.
Redact multiple patterns
This feature allows you to redact multiple patterns at once. In this example, both the word 'password' and a credit card number pattern are redacted.
const { create } = require('@npmcli/redact');
const redactor = create(['password', /\b\d{4}-\d{4}-\d{4}-\d{4}\b/]);
const redactedString = redactor('My password is password and my credit card number is 1234-5678-1234-5678.');
console.log(redactedString); // Output: My ****** is ****** and my credit card number is ********************.
redact-secrets is a package that provides similar functionality for redacting sensitive information from strings. It allows for custom patterns and multiple redactions. Compared to @npmcli/redact, it offers a more flexible API for defining redaction rules.
redact-pii is focused on redacting personally identifiable information (PII) from strings. It comes with built-in patterns for common PII such as email addresses, phone numbers, and social security numbers. While @npmcli/redact is more general-purpose, redact-pii is specialized for PII.
log-sanitizer is a package designed to sanitize logs by redacting sensitive information. It supports custom patterns and multiple redactions similar to @npmcli/redact. However, it is specifically optimized for use in logging scenarios.
Redact sensitive npm information from output.
This will redact npm_
prefixed tokens and UUIDs from values.
It will also replace passwords in stringified URLs.
redact(string)
Redact values from a single value
const { redact } = require('@npmcli/redact')
redact('https://user:pass@registry.npmjs.org/')
// https://user:***@registry.npmjs.org/
redact(`https://registry.npmjs.org/path/npm_${'a'.repeat('36')}`)
// https://registry.npmjs.org/path/npm_***
redactLog(string | string[])
Redact values from a string or array of strings.
This method will also split all strings on \s
and =
and iterate over them.
const { redactLog } = require('@npmcli/redact')
redactLog([
'Something --x=https://user:pass@registry.npmjs.org/ foo bar',
'--url=http://foo:bar@registry.npmjs.org',
])
// [
// 'Something --x=https://user:***@registry.npmjs.org/ foo bar',
// '--url=http://foo:***@registry.npmjs.org/',
// ]
FAQs
Redact sensitive npm information from output
The npm package @npmcli/redact receives a total of 2,083,682 weekly downloads. As such, @npmcli/redact popularity was classified as popular.
We found that @npmcli/redact demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.