node_modules: update
This commit is contained in:
parent
4a21c51f2f
commit
b91baffed3
107 changed files with 3886 additions and 2943 deletions
111
node_modules/fast-redact/benchmark/index.js
generated
vendored
111
node_modules/fast-redact/benchmark/index.js
generated
vendored
|
@ -1,21 +1,34 @@
|
|||
'use strict'
|
||||
const bench = require('fastbench')
|
||||
const noir = require('pino-noir')(['a.b.c'])
|
||||
const fastRedact = require('..')
|
||||
const redactNoSerialize = fastRedact({ paths: ['a.b.c'], serialize: false })
|
||||
const redactWildNoSerialize = fastRedact({ paths: ['a.b.*'], serialize: false })
|
||||
const redactIntermediateWildNoSerialize = fastRedact({ paths: ['a.*.c'], serialize: false })
|
||||
const redact = fastRedact({ paths: ['a.b.c'] })
|
||||
const noirWild = require('pino-noir')(['a.b.*'])
|
||||
const redactWild = fastRedact({ paths: ['a.b.*'] })
|
||||
const redactIntermediateWild = fastRedact({ paths: ['a.*.c'] })
|
||||
const redactIntermediateWildMatchWildOutcome = fastRedact({ paths: ['a.*.c', 'a.*.b', 'a.*.a'] })
|
||||
const redactStaticMatchWildOutcome = fastRedact({ paths: ['a.b.c', 'a.d.a', 'a.d.b', 'a.d.c'] })
|
||||
const noirCensorFunction = require('pino-noir')(['a.b.*'], (v) => v + '.')
|
||||
const redactCensorFunction = fastRedact({ paths: ['a.b.*'], censor: (v) => v + '.', serialize: false })
|
||||
|
||||
const obj = {
|
||||
a: {
|
||||
const censorFn = (v) => v + '.'
|
||||
const censorFnWithPath = (v, p) => v + '.' + p
|
||||
|
||||
const noir = require('pino-noir')(['aa.b.c'])
|
||||
const redactNoSerialize = fastRedact({ paths: ['ab.b.c'], serialize: false })
|
||||
const redactNoSerializeRestore = fastRedact({ paths: ['ac.b.c'], serialize: false })
|
||||
const noirWild = require('pino-noir')(['ad.b.*'])
|
||||
const redactWildNoSerialize = fastRedact({ paths: ['ae.b.*'], serialize: false })
|
||||
const redactWildNoSerializeRestore = fastRedact({ paths: ['af.b.*'], serialize: false })
|
||||
const redactIntermediateWildNoSerialize = fastRedact({ paths: ['ag.*.c'], serialize: false })
|
||||
const redactIntermediateWildNoSerializeRestore = fastRedact({ paths: ['ah.*.c'], serialize: false })
|
||||
const noirJSONSerialize = require('pino-noir')(['aj.b.c']) // `ai` used in pure JSON test.
|
||||
const redact = fastRedact({ paths: ['ak.b.c'] })
|
||||
const noirWildJSONSerialize = require('pino-noir')(['al.b.c'])
|
||||
const redactWild = fastRedact({ paths: ['am.b.*'] })
|
||||
const redactIntermediateWild = fastRedact({ paths: ['an.*.c'] })
|
||||
const redactIntermediateWildMatchWildOutcome = fastRedact({ paths: ['ao.*.c', 'ao.*.b', 'ao.*.a'] })
|
||||
const redactStaticMatchWildOutcome = fastRedact({ paths: ['ap.b.c', 'ap.d.a', 'ap.d.b', 'ap.d.c'] })
|
||||
const noirCensorFunction = require('pino-noir')(['aq.b.*'], censorFn)
|
||||
const redactCensorFunction = fastRedact({ paths: ['ar.b.*'], censor: censorFn, serialize: false })
|
||||
const redactIntermediateWildCensorFunction = fastRedact({ paths: ['as.*.c'], censor: censorFn, serialize: false })
|
||||
const redactCensorFunctionWithPath = fastRedact({ paths: ['at.d.b'], censor: censorFn, serialize: false })
|
||||
const redactWildCensorFunctionWithPath = fastRedact({ paths: ['au.d.*'], censor: censorFnWithPath, serialize: false })
|
||||
const redactIntermediateWildCensorFunctionWithPath = fastRedact({ paths: ['av.*.c'], censorFnWithPath, serialize: false })
|
||||
|
||||
const getObj = (outerKey) => ({
|
||||
[outerKey]: {
|
||||
b: {
|
||||
c: 's'
|
||||
},
|
||||
|
@ -25,123 +38,169 @@ const obj = {
|
|||
c: 's'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const max = 500
|
||||
|
||||
var run = bench([
|
||||
function benchNoirV2 (cb) {
|
||||
const obj = getObj('aa')
|
||||
for (var i = 0; i < max; i++) {
|
||||
noir.a(obj.a)
|
||||
noir.aa(obj.aa)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedact (cb) {
|
||||
const obj = getObj('ab')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactNoSerialize(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactRestore (cb) {
|
||||
const obj = getObj('ac')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactNoSerialize(obj)
|
||||
redactNoSerialize.restore(obj)
|
||||
redactNoSerializeRestore(obj)
|
||||
redactNoSerializeRestore.restore(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchNoirV2Wild (cb) {
|
||||
const obj = getObj('ad')
|
||||
for (var i = 0; i < max; i++) {
|
||||
noirWild.a(obj.a)
|
||||
noirWild.ad(obj.ad)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactWild (cb) {
|
||||
const obj = getObj('ae')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactWildNoSerialize(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactWildRestore (cb) {
|
||||
const obj = getObj('af')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactWildNoSerialize(obj)
|
||||
redactWildNoSerialize.restore(obj)
|
||||
redactWildNoSerializeRestore(obj)
|
||||
redactWildNoSerializeRestore.restore(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactIntermediateWild (cb) {
|
||||
const obj = getObj('ag')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactIntermediateWildNoSerialize(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactIntermediateWildRestore (cb) {
|
||||
const obj = getObj('ah')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactIntermediateWildNoSerialize(obj)
|
||||
redactIntermediateWildNoSerialize.restore(obj)
|
||||
redactIntermediateWildNoSerializeRestore(obj)
|
||||
redactIntermediateWildNoSerializeRestore.restore(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchJSONStringify (cb) {
|
||||
const obj = getObj('ai')
|
||||
for (var i = 0; i < max; i++) {
|
||||
JSON.stringify(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchNoirV2Serialize (cb) {
|
||||
const obj = getObj('aj')
|
||||
for (var i = 0; i < max; i++) {
|
||||
noir.a(obj.a)
|
||||
noirJSONSerialize.aj(obj.aj)
|
||||
JSON.stringify(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactSerialize (cb) {
|
||||
const obj = getObj('ak')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redact(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchNoirV2WildSerialize (cb) {
|
||||
const obj = getObj('al')
|
||||
for (var i = 0; i < max; i++) {
|
||||
noirWild.a(obj.a)
|
||||
noirWildJSONSerialize.al(obj.al)
|
||||
JSON.stringify(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactWildSerialize (cb) {
|
||||
const obj = getObj('am')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactWild(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactIntermediateWildSerialize (cb) {
|
||||
const obj = getObj('an')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactIntermediateWild(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactIntermediateWildMatchWildOutcomeSerialize (cb) {
|
||||
const obj = getObj('ao')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactIntermediateWildMatchWildOutcome(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactStaticMatchWildOutcomeSerialize (cb) {
|
||||
const obj = getObj('ap')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactStaticMatchWildOutcome(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchNoirV2CensorFunction (cb) {
|
||||
const obj = getObj('aq')
|
||||
for (var i = 0; i < max; i++) {
|
||||
noirCensorFunction.a(obj.a)
|
||||
noirCensorFunction.aq(obj.aq)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactCensorFunction (cb) {
|
||||
const obj = getObj('ar')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactCensorFunction(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactCensorFunctionIntermediateWild (cb) {
|
||||
const obj = getObj('as')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactIntermediateWildCensorFunction(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactCensorFunctionWithPath (cb) {
|
||||
const obj = getObj('at')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactCensorFunctionWithPath(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactWildCensorFunctionWithPath (cb) {
|
||||
const obj = getObj('au')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactWildCensorFunctionWithPath(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchFastRedactIntermediateWildCensorFunctionWithPath (cb) {
|
||||
const obj = getObj('av')
|
||||
for (var i = 0; i < max; i++) {
|
||||
redactIntermediateWildCensorFunctionWithPath(obj)
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 500)
|
||||
|
||||
|
|
3
node_modules/fast-redact/index.js
generated
vendored
3
node_modules/fast-redact/index.js
generated
vendored
|
@ -32,6 +32,7 @@ function fastRedact (opts = {}) {
|
|||
: 'censor' in opts ? opts.censor : DEFAULT_CENSOR
|
||||
|
||||
const isCensorFct = typeof censor === 'function'
|
||||
const censorFctTakesPath = isCensorFct && censor.length > 1
|
||||
|
||||
if (paths.length === 0) return serialize || noop
|
||||
|
||||
|
@ -42,7 +43,7 @@ function fastRedact (opts = {}) {
|
|||
const compileRestore = restorer({ secret, wcLen })
|
||||
const strict = 'strict' in opts ? opts.strict : true
|
||||
|
||||
return redactor({ secret, wcLen, serialize, strict, isCensorFct }, state({
|
||||
return redactor({ secret, wcLen, serialize, strict, isCensorFct, censorFctTakesPath }, state({
|
||||
secret,
|
||||
censor,
|
||||
compileRestore,
|
||||
|
|
55
node_modules/fast-redact/lib/modifiers.js
generated
vendored
55
node_modules/fast-redact/lib/modifiers.js
generated
vendored
|
@ -16,16 +16,27 @@ function groupRestore ({ keys, values, target }) {
|
|||
}
|
||||
}
|
||||
|
||||
function groupRedact (o, path, censor, isCensorFct) {
|
||||
function groupRedact (o, path, censor, isCensorFct, censorFctTakesPath) {
|
||||
const target = get(o, path)
|
||||
if (target == null) return { keys: null, values: null, target: null, flat: true }
|
||||
const keys = Object.keys(target)
|
||||
const length = keys.length
|
||||
const values = new Array(length)
|
||||
for (var i = 0; i < length; i++) {
|
||||
const k = keys[i]
|
||||
values[i] = target[k]
|
||||
target[k] = isCensorFct ? censor(target[k]) : censor
|
||||
const keysLength = keys.length
|
||||
const pathLength = path.length
|
||||
const pathWithKey = censorFctTakesPath ? [...path] : undefined
|
||||
const values = new Array(keysLength)
|
||||
|
||||
for (var i = 0; i < keysLength; i++) {
|
||||
const key = keys[i]
|
||||
values[i] = target[key]
|
||||
|
||||
if (censorFctTakesPath) {
|
||||
pathWithKey[pathLength] = key
|
||||
target[key] = censor(target[key], pathWithKey)
|
||||
} else if (isCensorFct) {
|
||||
target[key] = censor(target[key])
|
||||
} else {
|
||||
target[key] = censor
|
||||
}
|
||||
}
|
||||
return { keys, values, target, flat: true }
|
||||
}
|
||||
|
@ -38,14 +49,15 @@ function nestedRestore (arr) {
|
|||
}
|
||||
}
|
||||
|
||||
function nestedRedact (store, o, path, ns, censor, isCensorFct) {
|
||||
function nestedRedact (store, o, path, ns, censor, isCensorFct, censorFctTakesPath) {
|
||||
const target = get(o, path)
|
||||
if (target == null) return
|
||||
const keys = Object.keys(target)
|
||||
const length = keys.length
|
||||
for (var i = 0; i < length; i++) {
|
||||
const keysLength = keys.length
|
||||
for (var i = 0; i < keysLength; i++) {
|
||||
const key = keys[i]
|
||||
const { value, parent, exists } = specialSet(target, key, ns, censor, isCensorFct)
|
||||
const { value, parent, exists } =
|
||||
specialSet(target, key, path, ns, censor, isCensorFct, censorFctTakesPath)
|
||||
|
||||
if (exists === true && parent !== null) {
|
||||
store.push({ key: ns[ns.length - 1], target: parent, value })
|
||||
|
@ -58,10 +70,11 @@ function has (obj, prop) {
|
|||
return Object.prototype.hasOwnProperty.call(obj, prop)
|
||||
}
|
||||
|
||||
function specialSet (o, k, p, v, f) {
|
||||
function specialSet (o, k, path, afterPath, censor, isCensorFct, censorFctTakesPath) {
|
||||
const afterPathLen = afterPath.length
|
||||
const lastPathIndex = afterPathLen - 1
|
||||
const originalKey = k
|
||||
var i = -1
|
||||
var l = p.length
|
||||
var li = l - 1
|
||||
var n
|
||||
var nv
|
||||
var ov
|
||||
|
@ -69,22 +82,26 @@ function specialSet (o, k, p, v, f) {
|
|||
var exists = true
|
||||
ov = n = o[k]
|
||||
if (typeof n !== 'object') return { value: null, parent: null, exists }
|
||||
while (n != null && ++i < l) {
|
||||
k = p[i]
|
||||
while (n != null && ++i < afterPathLen) {
|
||||
k = afterPath[i]
|
||||
oov = ov
|
||||
if (!(k in n)) {
|
||||
exists = false
|
||||
break
|
||||
}
|
||||
ov = n[k]
|
||||
nv = f ? v(ov) : v
|
||||
nv = (i !== li) ? ov : nv
|
||||
n[k] = (has(n, k) && nv === ov) || (nv === undefined && v !== undefined) ? n[k] : nv
|
||||
nv = (i !== lastPathIndex)
|
||||
? ov
|
||||
: (isCensorFct
|
||||
? (censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov))
|
||||
: censor)
|
||||
n[k] = (has(n, k) && nv === ov) || (nv === undefined && censor !== undefined) ? n[k] : nv
|
||||
n = n[k]
|
||||
if (typeof n !== 'object') break
|
||||
}
|
||||
return { value: ov, parent: oov, exists }
|
||||
}
|
||||
|
||||
function get (o, p) {
|
||||
var i = -1
|
||||
var l = p.length
|
||||
|
|
23
node_modules/fast-redact/lib/redactor.js
generated
vendored
23
node_modules/fast-redact/lib/redactor.js
generated
vendored
|
@ -4,16 +4,16 @@ const rx = require('./rx')
|
|||
|
||||
module.exports = redactor
|
||||
|
||||
function redactor ({ secret, serialize, wcLen, strict, isCensorFct }, state) {
|
||||
function redactor ({ secret, serialize, wcLen, strict, isCensorFct, censorFctTakesPath }, state) {
|
||||
/* eslint-disable-next-line */
|
||||
const redact = Function('o', `
|
||||
if (typeof o !== 'object' || o == null) {
|
||||
${strictImpl(strict, serialize)}
|
||||
}
|
||||
const { censor, secret } = this
|
||||
${redactTmpl(secret, isCensorFct)}
|
||||
${redactTmpl(secret, isCensorFct, censorFctTakesPath)}
|
||||
this.compileRestore()
|
||||
${dynamicRedactTmpl(wcLen > 0, isCensorFct)}
|
||||
${dynamicRedactTmpl(wcLen > 0, isCensorFct, censorFctTakesPath)}
|
||||
${resultTmpl(serialize)}
|
||||
`).bind(state)
|
||||
|
||||
|
@ -24,9 +24,9 @@ function redactor ({ secret, serialize, wcLen, strict, isCensorFct }, state) {
|
|||
return redact
|
||||
}
|
||||
|
||||
function redactTmpl (secret, isCensorFct) {
|
||||
function redactTmpl (secret, isCensorFct, censorFctTakesPath) {
|
||||
return Object.keys(secret).map((path) => {
|
||||
const { escPath, leadingBracket } = secret[path]
|
||||
const { escPath, leadingBracket, path: arrPath } = secret[path]
|
||||
const skip = leadingBracket ? 1 : 0
|
||||
const delim = leadingBracket ? '' : '.'
|
||||
const hops = []
|
||||
|
@ -49,6 +49,11 @@ function redactTmpl (secret, isCensorFct) {
|
|||
`).join('\n')}
|
||||
}
|
||||
`
|
||||
|
||||
const censorArgs = censorFctTakesPath
|
||||
? `val, ${JSON.stringify(arrPath)}`
|
||||
: `val`
|
||||
|
||||
return `
|
||||
if (${existence}) {
|
||||
const val = o${delim}${path}
|
||||
|
@ -56,7 +61,7 @@ function redactTmpl (secret, isCensorFct) {
|
|||
secret[${escPath}].precensored = true
|
||||
} else {
|
||||
secret[${escPath}].val = val
|
||||
o${delim}${path} = ${isCensorFct ? 'censor(val)' : 'censor'}
|
||||
o${delim}${path} = ${isCensorFct ? `censor(${censorArgs})` : 'censor'}
|
||||
${circularDetection}
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +69,7 @@ function redactTmpl (secret, isCensorFct) {
|
|||
}).join('\n')
|
||||
}
|
||||
|
||||
function dynamicRedactTmpl (hasWildcards, isCensorFct) {
|
||||
function dynamicRedactTmpl (hasWildcards, isCensorFct, censorFctTakesPath) {
|
||||
return hasWildcards === true ? `
|
||||
{
|
||||
const { wildcards, wcLen, groupRedact, nestedRedact } = this
|
||||
|
@ -72,8 +77,8 @@ function dynamicRedactTmpl (hasWildcards, isCensorFct) {
|
|||
const { before, beforeStr, after, nested } = wildcards[i]
|
||||
if (nested === true) {
|
||||
secret[beforeStr] = secret[beforeStr] || []
|
||||
nestedRedact(secret[beforeStr], o, before, after, censor, ${isCensorFct})
|
||||
} else secret[beforeStr] = groupRedact(o, before, censor, ${isCensorFct})
|
||||
nestedRedact(secret[beforeStr], o, before, after, censor, ${isCensorFct}, ${censorFctTakesPath})
|
||||
} else secret[beforeStr] = groupRedact(o, before, censor, ${isCensorFct}, ${censorFctTakesPath})
|
||||
}
|
||||
}
|
||||
` : ''
|
||||
|
|
13
node_modules/fast-redact/lib/rx.js
generated
vendored
13
node_modules/fast-redact/lib/rx.js
generated
vendored
|
@ -1,3 +1,16 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = /[^.[\]]+|\[((?:.)*?)\]/g
|
||||
|
||||
/*
|
||||
Regular expression explanation:
|
||||
|
||||
Alt 1: /[^.[\]]+/ - Match one or more characters that are *not* a dot (.)
|
||||
opening square bracket ([) or closing square bracket (])
|
||||
|
||||
Alt 2: /\[((?:.)*?)\]/ - If the char IS dot or square bracket, then create a capture
|
||||
group (which will be capture group $1) that matches anything
|
||||
within square brackets. Expansion is lazy so it will
|
||||
stop matching as soon as the first closing bracket is met `]`
|
||||
(rather than continuing to match until the final closing bracket).
|
||||
*/
|
||||
|
|
4
node_modules/fast-redact/lib/state.js
generated
vendored
4
node_modules/fast-redact/lib/state.js
generated
vendored
|
@ -6,7 +6,6 @@ function state (o) {
|
|||
const {
|
||||
secret,
|
||||
censor,
|
||||
isCensorFct,
|
||||
compileRestore,
|
||||
serialize,
|
||||
groupRedact,
|
||||
|
@ -14,8 +13,7 @@ function state (o) {
|
|||
wildcards,
|
||||
wcLen
|
||||
} = o
|
||||
const builder = [{ secret, censor, isCensorFct, compileRestore }]
|
||||
builder.push({ secret })
|
||||
const builder = [{ secret, censor, compileRestore }]
|
||||
if (serialize !== false) builder.push({ serialize })
|
||||
if (wcLen > 0) builder.push({ groupRedact, nestedRedact, wildcards, wcLen })
|
||||
return Object.assign(...builder)
|
||||
|
|
2
node_modules/fast-redact/lib/validator.js
generated
vendored
2
node_modules/fast-redact/lib/validator.js
generated
vendored
|
@ -6,7 +6,7 @@ module.exports = validator
|
|||
|
||||
function validator (opts = {}) {
|
||||
const {
|
||||
ERR_PATHS_MUST_BE_STRINGS = () => 'fast-redact - Paths must be strings',
|
||||
ERR_PATHS_MUST_BE_STRINGS = () => 'fast-redact - Paths must be (non-empty) strings',
|
||||
ERR_INVALID_PATH = (s) => `fast-redact – Invalid path (${s})`
|
||||
} = opts
|
||||
|
||||
|
|
10
node_modules/fast-redact/package.json
generated
vendored
10
node_modules/fast-redact/package.json
generated
vendored
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"_from": "fast-redact@^2.0.0",
|
||||
"_id": "fast-redact@2.0.0",
|
||||
"_id": "fast-redact@2.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-zxpkULI9W9MNTK2sJ3BpPQrTEXFNESd2X6O1tXMFpK/XM0G5c5Rll2EVYZH2TqI3xRGK/VaJ+eEOt7pnENJpeA==",
|
||||
"_integrity": "sha512-0LkHpTLyadJavq9sRzzyqIoMZemWli77K2/MGOkafrR64B9ItrvZ9aT+jluvNDsv0YEHjSNhlMBtbokuoqii4A==",
|
||||
"_location": "/fast-redact",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
|
@ -18,8 +18,8 @@
|
|||
"_requiredBy": [
|
||||
"/pino"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-2.0.0.tgz",
|
||||
"_shasum": "17bb8f5e1f56ecf4a38c8455985e5eab4c478431",
|
||||
"_resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-2.1.0.tgz",
|
||||
"_shasum": "dfe3c1ca69367fb226f110aa4ec10ec85462ffdf",
|
||||
"_spec": "fast-redact@^2.0.0",
|
||||
"_where": "/home/dawidd6/github/dawidd6/action-debian-package/node_modules/pino",
|
||||
"author": {
|
||||
|
@ -74,5 +74,5 @@
|
|||
"posttest": "standard index.js 'lib/*.js' 'example/*.js' benchmark/index.js test/index.js | snazzy",
|
||||
"test": "tap test"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
"version": "2.1.0"
|
||||
}
|
||||
|
|
2
node_modules/fast-redact/readme.md
generated
vendored
2
node_modules/fast-redact/readme.md
generated
vendored
|
@ -115,7 +115,7 @@ Please note that asynchronous functions are not supported.
|
|||
|
||||
#### `serialize` – `Function | Boolean` – `(JSON.stringify)`
|
||||
|
||||
The `serialize` option may be a function of a boolean. If a function is supplied, this
|
||||
The `serialize` option may either be a function or a boolean. If a function is supplied, this
|
||||
will be used to `serialize` the redacted object. It's important to understand that for
|
||||
performance reasons `fast-redact` *mutates* the original object, then serializes, then
|
||||
restores the original values. So the object passed to the serializer is the exact same
|
||||
|
|
79
node_modules/fast-redact/test/index.js
generated
vendored
79
node_modules/fast-redact/test/index.js
generated
vendored
|
@ -5,6 +5,7 @@ const fastRedact = require('..')
|
|||
|
||||
const censor = '[REDACTED]'
|
||||
const censorFct = value => !value ? value : 'xxx' + value.substr(-2)
|
||||
const censorWithPath = (v, p) => p.join('.') + ' ' + censorFct(v)
|
||||
|
||||
test('returns no-op when passed no paths [serialize: false]', ({ end, doesNotThrow }) => {
|
||||
const redact = fastRedact({ paths: [], serialize: false })
|
||||
|
@ -88,23 +89,27 @@ test('returns original value when passed non-object using [strict: false, serial
|
|||
end()
|
||||
})
|
||||
|
||||
test('throws if a path is not a string', ({ end, is, throws }) => {
|
||||
test('throws if a path is not a string', ({ end, throws }) => {
|
||||
const invalidTypeMsg = 'fast-redact - Paths must be (non-empty) strings'
|
||||
throws((e) => {
|
||||
fastRedact({ paths: [1] })
|
||||
}, Error('fast-redact - Paths must be strings'))
|
||||
}, Error(invalidTypeMsg))
|
||||
throws((e) => {
|
||||
fastRedact({ paths: [null] })
|
||||
}, Error('fast-redact - Paths must be strings'))
|
||||
}, Error(invalidTypeMsg))
|
||||
throws((e) => {
|
||||
fastRedact({ paths: [undefined] })
|
||||
}, Error('fast-redact - Paths must be strings'))
|
||||
}, Error(invalidTypeMsg))
|
||||
throws((e) => {
|
||||
fastRedact({ paths: [{}] })
|
||||
}, Error('fast-redact - Paths must be strings'))
|
||||
}, Error(invalidTypeMsg))
|
||||
throws((e) => {
|
||||
fastRedact({ paths: [[null]] })
|
||||
}, Error(invalidTypeMsg))
|
||||
end()
|
||||
})
|
||||
|
||||
test('throws when passed illegal paths', ({ end, is, throws }) => {
|
||||
test('throws when passed illegal paths', ({ end, throws }) => {
|
||||
const err = (s) => Error(`fast-redact – Invalid path (${s})`)
|
||||
throws((e) => {
|
||||
fastRedact({ paths: ['@'] })
|
||||
|
@ -193,6 +198,12 @@ test('throws when passed illegal paths', ({ end, is, throws }) => {
|
|||
throws((e) => {
|
||||
fastRedact({ paths: ['a\r'] })
|
||||
}, err('a\r'))
|
||||
throws((e) => {
|
||||
fastRedact({ paths: [''] })
|
||||
}, err(''))
|
||||
throws((e) => {
|
||||
fastRedact({ paths: ['[""""]'] })
|
||||
}, err('[""""]'))
|
||||
end()
|
||||
})
|
||||
|
||||
|
@ -217,6 +228,42 @@ test('throws if serialize is false and remove is true', ({ end, throws }) => {
|
|||
end()
|
||||
})
|
||||
|
||||
test('supports path segments that aren\'t identifiers if bracketed', ({ end, strictSame }) => {
|
||||
const redactSerializeFalse = fastRedact({
|
||||
paths: ['a[""]', 'a["x-y"]', 'a[\'"y"\']', "a['\\'x\\'']"],
|
||||
serialize: false,
|
||||
censor: 'X'
|
||||
})
|
||||
|
||||
const res = redactSerializeFalse({ a: { '': 'Hi!', 'x-y': 'Hi!', '"y"': 'Hi!', "'x'": 'Hi!' } })
|
||||
strictSame(res, { a: { '': 'X', 'x-y': 'X', '"y"': 'X', "'x'": 'X' } })
|
||||
end()
|
||||
})
|
||||
|
||||
test('supports consecutive bracketed path segments', ({ end, strictSame }) => {
|
||||
const redactSerializeFalse = fastRedact({
|
||||
paths: ['a[""]["y"]'],
|
||||
serialize: false,
|
||||
censor: 'X'
|
||||
})
|
||||
|
||||
const res = redactSerializeFalse({ a: { '': { 'y': 'Hi!' } } })
|
||||
strictSame(res, { a: { '': { 'y': 'X' } } })
|
||||
end()
|
||||
})
|
||||
|
||||
test('supports leading bracketed widcard', ({ end, strictSame }) => {
|
||||
const redactSerializeFalse = fastRedact({
|
||||
paths: ['[*]["y"]'],
|
||||
serialize: false,
|
||||
censor: 'X'
|
||||
})
|
||||
|
||||
const res = redactSerializeFalse({ 'x': { 'y': 'Hi!' } })
|
||||
strictSame(res, { 'x': { 'y': 'X' } })
|
||||
end()
|
||||
})
|
||||
|
||||
test('masks according to supplied censor', ({ end, is }) => {
|
||||
const censor = 'test'
|
||||
const redact = fastRedact({ paths: ['a'], censor, serialize: false })
|
||||
|
@ -262,6 +309,26 @@ test('masks according to supplied censor function with nested wildcards', ({ end
|
|||
end()
|
||||
})
|
||||
|
||||
test('masks according to supplied censor-with-path function', ({ end, is }) => {
|
||||
const redact = fastRedact({ paths: ['a'], censor: censorWithPath, serialize: false })
|
||||
is(redact({ a: '0123456' }).a, 'a xxx56')
|
||||
end()
|
||||
})
|
||||
|
||||
test('masks according to supplied censor-with-path function with wildcards', ({ end, is }) => {
|
||||
const redact = fastRedact({ paths: '*', censor: censorWithPath, serialize: false })
|
||||
is(redact({ a: '0123456' }).a, 'a xxx56')
|
||||
end()
|
||||
})
|
||||
|
||||
test('masks according to supplied censor-with-path function with nested wildcards', ({ end, is }) => {
|
||||
const redact = fastRedact({ paths: ['*.b'], censor: censorWithPath, serialize: false })
|
||||
is(redact({ a: { b: '0123456' } }).a.b, 'a.b xxx56')
|
||||
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.b, 'c.b xxx56')
|
||||
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.d, 'pristine')
|
||||
end()
|
||||
})
|
||||
|
||||
test('redact.restore function places original values back in place with censor function', ({ end, is }) => {
|
||||
const redact = fastRedact({ paths: ['a'], censor: censorFct, serialize: false })
|
||||
const o = { a: 'qwerty' }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue