Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pino-noir

Package Overview
Dependencies
Maintainers
5
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-noir - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

39

index.js

@@ -6,4 +6,8 @@ 'use strict'

function noir (keys, censor) {
if (arguments.length < 2) {
function noir (serializers, keys, censor) {
if (Array.isArray(serializers)) {
censor = arguments.length === 2 ? keys : DEFAULT_CENSOR
keys = serializers
serializers = {}
} else if (arguments.length === 2) {
censor = DEFAULT_CENSOR

@@ -19,11 +23,26 @@ }

var tops = Object.keys(shape)
for (var i = 0; i < tops.length; i++) {
if (shape[tops[i]].some(function (a) { return a.length === 1 })) {
shape[tops[i]] = redact
continue
Object.keys(shape).forEach(function (top) {
if (shape[top].some(function (a) { return a.length === 1 })) {
shape[top] = redact
} else {
shape[top].forEach(function (a) { a.shift() })
shape[top] = factory(shape[top])
}
shape[tops[i]].forEach(function (a) { a.shift() })
shape[tops[i]] = factory(shape[tops[i]])
}
var prev = shape[top]
var serializer = serializers[top]
if (serializer) {
shape[top] = function (obj) {
var intermediate = serializer(obj)
return prev(intermediate)
}
}
})
Object.keys(serializers).forEach(function (top) {
if (!shape[top]) {
shape[top] = serializers[top]
}
})
return shape

@@ -30,0 +49,0 @@

{
"name": "pino-noir",
"version": "1.1.0",
"version": "1.2.0",
"description": "Redact sensitive information from your pino logs. ",

@@ -20,3 +20,3 @@ "main": "index.js",

"fastbench": "^1.0.1",
"pino": "v4.0.0",
"pino": "^4.0.0",
"standard": "^10.0.0",

@@ -23,0 +23,0 @@ "tap": "^10.0.0"

@@ -1,5 +0,5 @@

# pino-noir
# pino-noir
Redact sensitive information from your pino logs.
🍾🍷

@@ -12,10 +12,9 @@

```js
noir(paths = [], censor = '[Redacted]') => {Pino Serializer Object}
noir([serializers = {}], paths = [], censor = '[Redacted]') => {Pino Serializer Object}
```
### `paths`
The `paths` parameter should be an array of strings, describing the nested location of a key in an object.
The `paths` parameter should be an array of strings, describing the nested location of a key in an object.
The path can be represented in dot notation, `a.b.c`, and/or bracket notation
The path can be represented in dot notation, `a.b.c`, and/or bracket notation
`a[b[c]]`, `a.b[c]`, `a[b].c`.

@@ -32,2 +31,9 @@

### `serializers` (optional)
An object containing a previous
[serializers](https://github.com/pinojs/pino/blob/master/docs/API.md#example) object. The output of those
serializers will be redacted. In this way it is possible to chain
standard serializers with pino-noir.
## Example

@@ -119,2 +125,2 @@

MIT
MIT

@@ -128,1 +128,34 @@ 'use strict'

})
test('redacts nested keys with a custom serializers', function (t) {
t.plan(2)
var fixture = {
something: 'else'
}
var serializers = noir({
test: function (obj) {
t.is(fixture, obj)
return {
test1: 'should be redacted',
a: 1
}
}
}, ['test.test1'])
t.is(stringify(serializers.test(fixture)), '{"test1":"[Redacted]","a":1}')
})
test('pass through existing serializers', function (t) {
t.plan(2)
var fixture = {
something: 'else'
}
var serializers = noir({
test: function (obj) {
t.is(fixture, obj)
return {
a: 1
}
}
}, ['to.be.redacted'])
t.is(stringify(serializers.test(fixture)), '{"a":1}')
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc