Socket
Socket
Sign inDemoInstall

fast-redact

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-redact - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

19

lib/restorer.js

@@ -52,2 +52,17 @@ 'use strict'

/**
* Creates the body of the restore function
*
* Restoration of the redacted object happens
* backwards, in reverse order of redactions,
* so that repeated redactions on the same object
* property can be eventually rolled back to the
* original value.
*
* This way dynamic redactions are restored first,
* starting from the last one working backwards and
* followed by the static ones.
*
* @returns {string} the body of the restore function
*/
function restoreTmpl (resetters, paths, hasWildcards) {

@@ -57,3 +72,3 @@ const dynamicReset = hasWildcards === true ? `

const len = keys.length
for (var i = ${paths.length}; i < len; i++) {
for (var i = len - 1; i >= ${paths.length}; i--) {
const k = keys[i]

@@ -69,6 +84,6 @@ const o = secret[k]

const secret = this.secret
${dynamicReset}
${resetters}
${dynamicReset}
return o
`
}

2

package.json
{
"name": "fast-redact",
"version": "3.0.0",
"version": "3.0.1",
"description": "very fast object redaction",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -990,2 +990,34 @@ 'use strict'

test('correctly restores keys matching a static path and a wildcard', ({ end, is }) => {
const redact = fastRedact({
paths: ['a', '*.b', 'x.b'],
serialize: false
})
const o = { x: { a: 'a', b: 'b' } }
redact(o)
is(o.x.a, 'a')
is(o.x.b, '[REDACTED]')
redact.restore(o)
is(o.x.a, 'a')
is(o.x.b, 'b')
end()
})
test('correctly restores keys matching multiple wildcards', ({ end, is }) => {
const redact = fastRedact({
paths: ['a', '*.b', 'x.*', 'y.*.z'],
serialize: false
})
const o = { x: { a: 'a', b: 'b' }, y: { f: { z: 'z' } } }
redact(o)
is(o.x.a, '[REDACTED]')
is(o.x.b, '[REDACTED]')
is(o.y.f.z, '[REDACTED]')
redact.restore(o)
is(o.x.a, 'a')
is(o.x.b, 'b')
is(o.y.f.z, 'z')
end()
})
test('handles multiple paths with leading brackets', ({ end, is }) => {

@@ -992,0 +1024,0 @@ const redact = fastRedact({ paths: ['["x-y"]', '["y-x"]'] })

Sorry, the diff of this file is not supported yet

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