@contrast/agent-bundle 5.46.0 → 5.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/node_modules/@contrast/agent/README.md +1 -1
- package/node_modules/@contrast/agent/package.json +12 -12
- package/node_modules/@contrast/agentify/package.json +15 -15
- package/node_modules/@contrast/architecture-components/package.json +5 -5
- package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/common.js +1 -1
- package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/handlers.js +23 -10
- package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/index.js +6 -4
- package/node_modules/@contrast/assess/lib/configuration-analysis/install/apollo-server.js +92 -0
- package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/express-session.js +2 -2
- package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/fastify-cookie.js +2 -2
- package/node_modules/@contrast/assess/lib/configuration-analysis/install/graphql-yoga.js +90 -0
- package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/hapi.js +2 -2
- package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/koa.js +3 -3
- package/node_modules/@contrast/assess/lib/dataflow/propagation/install/string/substring.js +1 -1
- package/node_modules/@contrast/assess/lib/dataflow/sinks/install/fs.js +8 -15
- package/node_modules/@contrast/assess/lib/dataflow/sources/handler.js +9 -2
- package/node_modules/@contrast/assess/lib/dataflow/sources/index.js +2 -0
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/fastify-websocket.js +63 -0
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/http.js +42 -38
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/index.js +1 -1
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-bodyparsers.js +76 -48
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-multer.js +1 -1
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-routers.js +2 -2
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/{koa2.js → koa.js} +3 -3
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/socket.io.js +80 -0
- package/node_modules/@contrast/assess/lib/index.d.ts +4 -3
- package/node_modules/@contrast/assess/lib/index.js +1 -1
- package/node_modules/@contrast/assess/lib/policy.js +2 -2
- package/node_modules/@contrast/assess/package.json +12 -12
- package/node_modules/@contrast/common/lib/constants.d.ts +12 -4
- package/node_modules/@contrast/common/lib/constants.js +16 -7
- package/node_modules/@contrast/common/lib/types.d.ts +5 -1
- package/node_modules/@contrast/common/package.json +1 -1
- package/node_modules/@contrast/config/lib/common.js +1 -0
- package/node_modules/@contrast/config/lib/options.js +7 -1
- package/node_modules/@contrast/config/package.json +3 -3
- package/node_modules/@contrast/core/package.json +5 -5
- package/node_modules/@contrast/deadzones/package.json +5 -5
- package/node_modules/@contrast/dep-hooks/lib/export-handler-registry.js +1 -10
- package/node_modules/@contrast/dep-hooks/lib/export-hook-descriptor.js +1 -1
- package/node_modules/@contrast/dep-hooks/lib/index.d.ts +1 -1
- package/node_modules/@contrast/dep-hooks/lib/index.js +1 -1
- package/node_modules/@contrast/dep-hooks/lib/package-finder.d.ts +3 -2
- package/node_modules/@contrast/dep-hooks/lib/package-finder.js +14 -4
- package/node_modules/@contrast/dep-hooks/package.json +4 -4
- package/node_modules/@contrast/esm-hooks/README.md +2 -2
- package/node_modules/@contrast/esm-hooks/package.json +6 -6
- package/node_modules/@contrast/instrumentation/package.json +5 -5
- package/node_modules/@contrast/library-analysis/lib/install/library-reporting/dep.json +166 -224
- package/node_modules/@contrast/library-analysis/lib/install/library-reporting/index.js +2 -11
- package/node_modules/@contrast/library-analysis/lib/install/library-reporting/utils.js +2 -0
- package/node_modules/@contrast/library-analysis/lib/install/library-usage/index.js +3 -1
- package/node_modules/@contrast/library-analysis/lib/util.js +0 -2
- package/node_modules/@contrast/library-analysis/package.json +4 -4
- package/node_modules/@contrast/logger/package.json +4 -4
- package/node_modules/@contrast/metrics/package.json +6 -6
- package/node_modules/@contrast/patcher/package.json +2 -2
- package/node_modules/@contrast/protect/lib/error-handlers/index.js +1 -1
- package/node_modules/@contrast/protect/lib/error-handlers/install/{koa2.js → koa.js} +4 -4
- package/node_modules/@contrast/protect/lib/index.d.ts +1 -1
- package/node_modules/@contrast/protect/lib/input-analysis/index.js +2 -3
- package/node_modules/@contrast/protect/lib/input-analysis/install/koa-bodyparsers.js +92 -0
- package/node_modules/@contrast/protect/lib/input-analysis/install/{koa2.js → koa.js} +5 -5
- package/node_modules/@contrast/protect/lib/input-tracing/install/fs.js +0 -8
- package/node_modules/@contrast/protect/package.json +11 -11
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/translations.js +6 -10
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/routes-observed.js +4 -0
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/index.d.ts +1 -1
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/index.js +1 -1
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.d.ts +1 -1
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.js +22 -9
- package/node_modules/@contrast/reporter/lib/reporters/file.js +1 -1
- package/node_modules/@contrast/reporter/package.json +6 -6
- package/node_modules/@contrast/rewriter/package.json +5 -5
- package/node_modules/@contrast/route-coverage/lib/index.d.ts +2 -2
- package/node_modules/@contrast/route-coverage/lib/index.js +12 -2
- package/node_modules/@contrast/route-coverage/lib/install/express.js +535 -0
- package/node_modules/@contrast/route-coverage/lib/install/fastify/fastify-express.js +71 -0
- package/node_modules/@contrast/route-coverage/lib/install/fastify/fastify-middie.js +67 -0
- package/node_modules/@contrast/route-coverage/lib/install/{fastify.js → fastify/fastify.js} +32 -22
- package/node_modules/@contrast/route-coverage/lib/install/{express → fastify}/index.js +6 -5
- package/node_modules/@contrast/route-coverage/lib/install/graphql.js +6 -1
- package/node_modules/@contrast/route-coverage/lib/install/koa.js +39 -45
- package/node_modules/@contrast/route-coverage/lib/install/socket.io.js +127 -0
- package/node_modules/@contrast/route-coverage/lib/utils/route-info.js +26 -1
- package/node_modules/@contrast/route-coverage/package.json +8 -8
- package/node_modules/@contrast/scopes/package.json +5 -5
- package/node_modules/@contrast/sec-obs/package.json +9 -9
- package/node_modules/@contrast/sources/lib/index.js +65 -22
- package/node_modules/@contrast/sources/lib/index.test.js +78 -33
- package/node_modules/@contrast/sources/lib/source-info.js +1 -10
- package/node_modules/@contrast/sources/package.json +3 -3
- package/node_modules/@contrast/telemetry/package.json +5 -5
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.d.ts +697 -30
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js +697 -30
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_events.d.ts +6 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_events.js +6 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_events.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.d.ts +877 -49
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.js +877 -49
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.d.ts +13 -4
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js +13 -4
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.d.ts +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.d.ts +697 -30
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.js +697 -30
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_events.d.ts +6 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_events.js +6 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_events.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.d.ts +877 -49
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.js +877 -49
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.d.ts +13 -4
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.js +13 -4
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.d.ts +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.d.ts +697 -30
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.js +729 -61
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_events.d.ts +6 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_events.js +7 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_events.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.d.ts +877 -49
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js +886 -56
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.d.ts +13 -4
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js +13 -4
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.d.ts +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/package.json +3 -5
- package/node_modules/{pino → @pinojs/redact}/.github/dependabot.yml +1 -1
- package/node_modules/@pinojs/redact/.github/workflows/ci.yml +48 -0
- package/node_modules/@pinojs/redact/.github/workflows/publish-release.yml +43 -0
- package/node_modules/{pino/node_modules/sonic-boom → @pinojs/redact}/LICENSE +1 -1
- package/node_modules/@pinojs/redact/README.md +350 -0
- package/node_modules/@pinojs/redact/benchmarks/basic.js +184 -0
- package/node_modules/@pinojs/redact/eslint.config.js +1 -0
- package/node_modules/@pinojs/redact/index.d.ts +52 -0
- package/node_modules/@pinojs/redact/index.js +529 -0
- package/node_modules/@pinojs/redact/index.test-d.ts +22 -0
- package/node_modules/@pinojs/redact/package.json +37 -0
- package/node_modules/@pinojs/redact/scripts/sync-version.mjs +20 -0
- package/node_modules/@pinojs/redact/test/actual-redact-comparison.test.js +211 -0
- package/node_modules/@pinojs/redact/test/index.test.js +824 -0
- package/node_modules/@pinojs/redact/test/integration.test.js +390 -0
- package/node_modules/@pinojs/redact/test/multiple-wildcards.test.js +227 -0
- package/node_modules/@pinojs/redact/test/prototype-pollution.test.js +223 -0
- package/node_modules/@pinojs/redact/test/selective-clone.test.js +115 -0
- package/node_modules/@pinojs/redact/tsconfig.json +19 -0
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/assert.d.ts +37 -2
- package/node_modules/@types/node/buffer.buffer.d.ts +9 -0
- package/node_modules/@types/node/buffer.d.ts +8 -4
- package/node_modules/@types/node/child_process.d.ts +65 -42
- package/node_modules/@types/node/cluster.d.ts +4 -5
- package/node_modules/@types/node/console.d.ts +3 -2
- package/node_modules/@types/node/crypto.d.ts +1079 -338
- package/node_modules/@types/node/dgram.d.ts +9 -8
- package/node_modules/@types/node/diagnostics_channel.d.ts +0 -2
- package/node_modules/@types/node/dns.d.ts +1 -1
- package/node_modules/@types/node/events.d.ts +1 -1
- package/node_modules/@types/node/fs/promises.d.ts +39 -21
- package/node_modules/@types/node/fs.d.ts +104 -87
- package/node_modules/@types/node/globals.d.ts +2 -0
- package/node_modules/@types/node/globals.typedarray.d.ts +19 -0
- package/node_modules/@types/node/http.d.ts +66 -27
- package/node_modules/@types/node/http2.d.ts +178 -52
- package/node_modules/@types/node/https.d.ts +91 -62
- package/node_modules/@types/node/index.d.ts +2 -0
- package/node_modules/@types/node/inspector.d.ts +24 -0
- package/node_modules/@types/node/inspector.generated.d.ts +181 -0
- package/node_modules/@types/node/net.d.ts +12 -11
- package/node_modules/@types/node/os.d.ts +14 -3
- package/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/node/perf_hooks.d.ts +6 -8
- package/node_modules/@types/node/process.d.ts +19 -23
- package/node_modules/@types/node/readline/promises.d.ts +1 -1
- package/node_modules/@types/node/sea.d.ts +9 -0
- package/node_modules/@types/node/sqlite.d.ts +226 -10
- package/node_modules/@types/node/stream/consumers.d.ts +2 -2
- package/node_modules/@types/node/stream/web.d.ts +6 -55
- package/node_modules/@types/node/stream.d.ts +38 -23
- package/node_modules/@types/node/string_decoder.d.ts +2 -2
- package/node_modules/@types/node/test.d.ts +29 -3
- package/node_modules/@types/node/tls.d.ts +90 -66
- package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +10 -2
- package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +16 -0
- package/node_modules/@types/node/ts5.6/index.d.ts +2 -0
- package/node_modules/@types/node/ts5.7/index.d.ts +2 -0
- package/node_modules/@types/node/url.d.ts +34 -10
- package/node_modules/@types/node/util.d.ts +12 -3
- package/node_modules/@types/node/v8.d.ts +38 -5
- package/node_modules/@types/node/vm.d.ts +169 -88
- package/node_modules/@types/node/wasi.d.ts +1 -1
- package/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
- package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
- package/node_modules/@types/node/worker_threads.d.ts +76 -1
- package/node_modules/@types/node/zlib.d.ts +25 -24
- package/node_modules/axios/CHANGELOG.md +410 -346
- package/node_modules/axios/README.md +79 -51
- package/node_modules/axios/dist/axios.js +121 -46
- package/node_modules/axios/dist/axios.js.map +1 -1
- package/node_modules/axios/dist/axios.min.js +2 -2
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +126 -57
- package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
- package/node_modules/axios/dist/esm/axios.js +126 -57
- package/node_modules/axios/dist/esm/axios.js.map +1 -1
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +351 -97
- package/node_modules/axios/dist/node/axios.cjs.map +1 -1
- package/node_modules/axios/index.d.cts +4 -0
- package/node_modules/axios/index.d.ts +4 -0
- package/node_modules/axios/lib/adapters/adapters.js +85 -40
- package/node_modules/axios/lib/adapters/fetch.js +1 -1
- package/node_modules/axios/lib/adapters/http.js +224 -42
- package/node_modules/axios/lib/core/InterceptorManager.js +1 -1
- package/node_modules/axios/lib/core/mergeConfig.js +4 -4
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +6 -0
- package/node_modules/axios/lib/helpers/bind.js +7 -0
- package/node_modules/axios/lib/helpers/cookies.js +24 -13
- package/node_modules/axios/package.json +9 -4
- package/node_modules/detect-libc/lib/filesystem.js +1 -1
- package/node_modules/detect-libc/package.json +3 -1
- package/node_modules/form-data/CHANGELOG.md +60 -2
- package/node_modules/form-data/README.md +4 -4
- package/node_modules/form-data/lib/form_data.js +2 -2
- package/node_modules/form-data/package.json +4 -4
- package/node_modules/ipaddr.js/README.md +1 -0
- package/node_modules/ipaddr.js/ipaddr.min.js +1 -1
- package/node_modules/ipaddr.js/lib/ipaddr.js +11 -0
- package/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +1 -0
- package/node_modules/ipaddr.js/package.json +2 -3
- package/node_modules/nan/.github/workflows/ci.yml +3 -1
- package/node_modules/nan/CHANGELOG.md +4 -1
- package/node_modules/nan/README.md +2 -2
- package/node_modules/nan/nan.h +25 -15
- package/node_modules/nan/nan_maybe_43_inl.h +5 -1
- package/node_modules/nan/package.json +2 -2
- package/node_modules/node-abi/abi_registry.json +19 -2
- package/node_modules/node-abi/package.json +3 -6
- package/node_modules/pino/CONTRIBUTING.md +4 -0
- package/node_modules/pino/LICENSE +1 -1
- package/node_modules/pino/README.md +20 -3
- package/node_modules/pino/benchmarks/basic.bench.js +1 -1
- package/node_modules/pino/benchmarks/child-child.bench.js +1 -1
- package/node_modules/pino/benchmarks/child-creation.bench.js +1 -1
- package/node_modules/pino/benchmarks/child.bench.js +1 -1
- package/node_modules/pino/benchmarks/deep-object.bench.js +1 -1
- package/node_modules/pino/benchmarks/internal/just-pino-heavy.bench.js +1 -1
- package/node_modules/pino/benchmarks/internal/just-pino.bench.js +1 -1
- package/node_modules/pino/benchmarks/internal/redact.bench.js +1 -1
- package/node_modules/pino/benchmarks/long-string.bench.js +1 -1
- package/node_modules/pino/benchmarks/multi-arg.bench.js +1 -1
- package/node_modules/pino/benchmarks/multistream.js +1 -1
- package/node_modules/pino/benchmarks/object.bench.js +1 -1
- package/node_modules/pino/benchmarks/utils/generate-benchmark-doc.js +2 -2
- package/node_modules/pino/benchmarks/utils/runbench.js +3 -3
- package/node_modules/pino/benchmarks/utils/wrap-log-level.js +2 -2
- package/node_modules/pino/browser.js +76 -36
- package/node_modules/pino/build/sync-version.js +18 -3
- package/node_modules/pino/docs/api.md +155 -13
- package/node_modules/pino/docs/browser.md +16 -1
- package/node_modules/pino/docs/bundling.md +5 -3
- package/node_modules/pino/docs/diagnostics.md +16 -0
- package/node_modules/pino/docs/ecosystem.md +15 -12
- package/node_modules/pino/docs/help.md +29 -3
- package/node_modules/pino/docs/lts.md +5 -4
- package/node_modules/pino/docs/transports.md +442 -271
- package/node_modules/pino/docs/web.md +59 -9
- package/node_modules/pino/eslint.config.js +19 -0
- package/node_modules/pino/examples/transport.js +2 -2
- package/node_modules/pino/file.js +1 -1
- package/node_modules/pino/lib/meta.js +1 -1
- package/node_modules/pino/lib/multistream.js +17 -2
- package/node_modules/pino/lib/proto.js +35 -11
- package/node_modules/pino/lib/redaction.js +9 -13
- package/node_modules/pino/lib/time.js +29 -1
- package/node_modules/pino/lib/tools.js +37 -8
- package/node_modules/pino/lib/transport-stream.js +10 -4
- package/node_modules/pino/lib/transport.js +23 -9
- package/node_modules/pino/lib/worker.js +164 -24
- package/node_modules/pino/package.json +28 -27
- package/node_modules/pino/pino.d.ts +244 -203
- package/node_modules/pino/pino.js +7 -3
- package/node_modules/pino/test/basic.test.js +181 -169
- package/node_modules/pino/test/broken-pipe.test.js +18 -16
- package/node_modules/pino/test/browser-child.test.js +26 -0
- package/node_modules/pino/test/browser-is-level-enabled.test.js +101 -0
- package/node_modules/pino/test/browser-serializers.test.js +0 -2
- package/node_modules/pino/test/browser-transmit.test.js +68 -0
- package/node_modules/pino/test/browser.test.js +98 -13
- package/node_modules/pino/test/complex-objects.test.js +8 -6
- package/node_modules/pino/test/crlf.test.js +7 -5
- package/node_modules/pino/test/custom-levels.test.js +80 -66
- package/node_modules/pino/test/diagnostics.test.js +107 -0
- package/node_modules/pino/test/error-key.test.js +37 -0
- package/node_modules/pino/test/error.test.js +48 -43
- package/node_modules/pino/test/escaping.test.js +8 -6
- package/node_modules/pino/test/esm/esm.mjs +5 -3
- package/node_modules/pino/test/esm/index.test.js +14 -27
- package/node_modules/pino/test/esm/named-exports.mjs +9 -8
- package/node_modules/pino/test/exit.test.js +18 -16
- package/node_modules/pino/test/fixtures/broken-pipe/basic.js +1 -1
- package/node_modules/pino/test/fixtures/broken-pipe/destination.js +1 -1
- package/node_modules/pino/test/fixtures/broken-pipe/syncfalse.js +1 -1
- package/node_modules/pino/test/fixtures/console-transport.js +1 -1
- package/node_modules/pino/test/fixtures/crashing-transport.js +13 -0
- package/node_modules/pino/test/fixtures/default-exit.js +1 -1
- package/node_modules/pino/test/fixtures/destination-exit.js +1 -1
- package/node_modules/pino/test/fixtures/noop-transport.js +1 -1
- package/node_modules/pino/test/fixtures/pretty/null-prototype.js +1 -1
- package/node_modules/pino/test/fixtures/stdout-hack-protection.js +1 -1
- package/node_modules/pino/test/fixtures/syncfalse-child.js +1 -1
- package/node_modules/pino/test/fixtures/syncfalse-exit.js +1 -1
- package/node_modules/pino/test/fixtures/syncfalse-flush-exit.js +1 -1
- package/node_modules/pino/test/fixtures/syncfalse.js +1 -1
- package/node_modules/pino/test/fixtures/syntax-error-esm.mjs +2 -0
- package/node_modules/pino/test/fixtures/to-file-transport-with-transform.js +3 -3
- package/node_modules/pino/test/fixtures/to-file-transport.js +2 -2
- package/node_modules/pino/test/fixtures/to-file-transport.mjs +2 -2
- package/node_modules/pino/test/fixtures/transport/index.js +2 -2
- package/node_modules/pino/test/fixtures/transport-main.js +1 -1
- package/node_modules/pino/test/fixtures/transport-transform.js +1 -1
- package/node_modules/pino/test/fixtures/transport-uses-pino-config.js +1 -1
- package/node_modules/pino/test/fixtures/transport-worker-data.js +1 -1
- package/node_modules/pino/test/fixtures/transport-worker.js +2 -2
- package/node_modules/pino/test/fixtures/ts/to-file-transport-with-transform.ts +3 -3
- package/node_modules/pino/test/fixtures/ts/to-file-transport.ts +2 -2
- package/node_modules/pino/test/fixtures/ts/transpile.cjs +1 -1
- package/node_modules/pino/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +1 -1
- package/node_modules/pino/test/fixtures/ts/transport-main.ts +1 -1
- package/node_modules/pino/test/fixtures/ts/transport-worker.ts +1 -1
- package/node_modules/pino/test/formatters.test.js +46 -37
- package/node_modules/pino/test/helper.d.ts +1 -1
- package/node_modules/pino/test/helper.js +37 -10
- package/node_modules/pino/test/hooks.test.js +45 -28
- package/node_modules/pino/test/http.test.js +39 -67
- package/node_modules/pino/test/internals/version.test.js +11 -9
- package/node_modules/pino/test/is-level-enabled.test.js +66 -72
- package/node_modules/pino/test/levels.test.js +245 -141
- package/node_modules/pino/test/metadata.test.js +45 -31
- package/node_modules/pino/test/mixin-merge-strategy.test.js +9 -7
- package/node_modules/pino/test/mixin.test.js +63 -40
- package/node_modules/pino/test/multistream.test.js +174 -118
- package/node_modules/pino/test/redact.test.js +172 -126
- package/node_modules/pino/test/serializers.test.js +61 -57
- package/node_modules/pino/test/stdout-protection.test.js +14 -12
- package/node_modules/pino/test/syncfalse.test.js +29 -34
- package/node_modules/pino/test/timestamp-nano.test.js +37 -0
- package/node_modules/pino/test/timestamp.test.js +37 -34
- package/node_modules/pino/test/transport/big.test.js +11 -12
- package/node_modules/pino/test/transport/bundlers-support.test.js +15 -43
- package/node_modules/pino/test/transport/caller.test.js +9 -8
- package/node_modules/pino/test/transport/core.test.js +175 -145
- package/node_modules/pino/test/transport/core.transpiled.test.ts +17 -19
- package/node_modules/pino/test/transport/crash.test.js +36 -0
- package/node_modules/pino/test/transport/module-link.test.js +21 -19
- package/node_modules/pino/test/transport/pipeline.test.js +109 -8
- package/node_modules/pino/test/transport/repl.test.js +4 -3
- package/node_modules/pino/test/transport/{syncfalse.test.js → sync-false.test.js} +14 -12
- package/node_modules/pino/test/transport/sync-true.test.js +57 -0
- package/node_modules/pino/test/transport/targets.test.js +25 -5
- package/node_modules/pino/test/transport/uses-pino-config.test.js +16 -17
- package/node_modules/pino/test/transport-stream.test.js +40 -0
- package/node_modules/pino/test/types/{pino-import.test-d.ts → pino-import.test-d.cts} +4 -3
- package/node_modules/pino/test/types/pino-multistream.test-d.ts +1 -1
- package/node_modules/pino/test/types/pino-top-export.test-d.ts +1 -0
- package/node_modules/pino/test/types/pino-transport.test-d.ts +1 -1
- package/node_modules/pino/test/types/pino-type-only.test-d.ts +24 -6
- package/node_modules/pino/test/types/pino.test-d.ts +161 -6
- package/node_modules/pino/test/types/pino.ts +31 -19
- package/node_modules/pino/tsconfig.json +1 -1
- package/node_modules/pino-abstract-transport/.github/workflows/ci.yml +2 -4
- package/node_modules/pino-abstract-transport/index.js +1 -1
- package/node_modules/pino-abstract-transport/package.json +2 -3
- package/node_modules/pino-abstract-transport/test/base.test.js +1 -1
- package/node_modules/pino-abstract-transport/test/worker.test.js +7 -14
- package/node_modules/pino-std-serializers/.github/workflows/ci.yml +5 -5
- package/node_modules/pino-std-serializers/Readme.md +1 -0
- package/node_modules/pino-std-serializers/package.json +9 -8
- package/node_modules/pino-std-serializers/test/err-with-cause.test.js +72 -88
- package/node_modules/pino-std-serializers/test/err.test.js +76 -91
- package/node_modules/pino-std-serializers/test/req.test.js +142 -98
- package/node_modules/pino-std-serializers/test/res.test.js +42 -31
- package/node_modules/process-warning/.github/dependabot.yml +1 -1
- package/node_modules/process-warning/.github/workflows/ci.yml +1 -2
- package/node_modules/process-warning/README.md +4 -4
- package/node_modules/process-warning/eslint.config.js +6 -0
- package/node_modules/process-warning/package.json +39 -8
- package/node_modules/process-warning/test/emit-interpolated-string.test.js +11 -6
- package/node_modules/process-warning/test/emit-once-only.test.js +11 -6
- package/node_modules/process-warning/test/emit-reset.test.js +10 -6
- package/node_modules/process-warning/test/emit-set.test.js +10 -5
- package/node_modules/process-warning/test/emit-unlimited.test.js +12 -7
- package/node_modules/process-warning/test/index.test.js +20 -20
- package/node_modules/process-warning/test/issue-88.test.js +8 -3
- package/node_modules/process-warning/test/jest.test.js +17 -15
- package/node_modules/process-warning/test/no-warnings.test.js +9 -9
- package/node_modules/process-warning/test/promise.js +10 -0
- package/node_modules/process-warning/types/index.d.ts +5 -5
- package/node_modules/semver/classes/range.js +1 -0
- package/node_modules/semver/classes/semver.js +19 -5
- package/node_modules/semver/internal/identifiers.js +4 -0
- package/node_modules/semver/package.json +3 -3
- package/node_modules/thread-stream/.github/workflows/ci.yml +4 -8
- package/node_modules/thread-stream/index.d.ts +4 -5
- package/node_modules/thread-stream/lib/worker.js +5 -2
- package/node_modules/thread-stream/package.json +6 -4
- package/node_modules/thread-stream/test/base.test.js +12 -0
- package/node_modules/thread-stream/test/never-drain.test.js +3 -1
- package/node_modules/thread-stream/test/pkg/pkg.test.js +2 -0
- package/node_modules/thread-stream/test/syntax-error.mjs +2 -0
- package/node_modules/thread-stream/tsconfig.json +8 -0
- package/node_modules/undici-types/agent.d.ts +1 -0
- package/node_modules/undici-types/diagnostics-channel.d.ts +0 -1
- package/node_modules/undici-types/errors.d.ts +5 -15
- package/node_modules/undici-types/eventsource.d.ts +6 -1
- package/node_modules/undici-types/index.d.ts +4 -1
- package/node_modules/undici-types/interceptors.d.ts +5 -0
- package/node_modules/undici-types/package.json +1 -1
- package/node_modules/undici-types/snapshot-agent.d.ts +5 -3
- package/node_modules/undici-types/webidl.d.ts +82 -21
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +1 -1
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +1 -1
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +2 -2
- package/node_modules/yaml/browser/dist/errors.js +1 -1
- package/node_modules/yaml/browser/dist/nodes/Alias.js +1 -1
- package/node_modules/yaml/browser/dist/parse/parser.js +2 -2
- package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +1 -1
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +1 -1
- package/node_modules/yaml/dist/compose/compose-collection.js +1 -1
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +1 -1
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +2 -2
- package/node_modules/yaml/dist/errors.js +1 -1
- package/node_modules/yaml/dist/nodes/Alias.js +1 -1
- package/node_modules/yaml/dist/parse/parser.js +2 -2
- package/node_modules/yaml/dist/stringify/stringifyNumber.js +1 -1
- package/node_modules/yaml/dist/stringify/stringifyPair.js +1 -1
- package/node_modules/yaml/package.json +4 -4
- package/package.json +3 -3
- package/node_modules/@contrast/protect/lib/input-analysis/install/koa-body5.js +0 -63
- package/node_modules/@contrast/protect/lib/input-analysis/install/koa-bodyparser4.js +0 -64
- package/node_modules/@contrast/route-coverage/lib/install/express/express4.js +0 -157
- package/node_modules/@contrast/route-coverage/lib/install/express/express5.js +0 -538
- package/node_modules/abort-controller/LICENSE +0 -21
- package/node_modules/abort-controller/README.md +0 -98
- package/node_modules/abort-controller/browser.js +0 -13
- package/node_modules/abort-controller/browser.mjs +0 -11
- package/node_modules/abort-controller/dist/abort-controller.d.ts +0 -43
- package/node_modules/abort-controller/dist/abort-controller.js +0 -127
- package/node_modules/abort-controller/dist/abort-controller.js.map +0 -1
- package/node_modules/abort-controller/dist/abort-controller.mjs +0 -118
- package/node_modules/abort-controller/dist/abort-controller.mjs.map +0 -1
- package/node_modules/abort-controller/dist/abort-controller.umd.js +0 -5
- package/node_modules/abort-controller/dist/abort-controller.umd.js.map +0 -1
- package/node_modules/abort-controller/package.json +0 -97
- package/node_modules/abort-controller/polyfill.js +0 -21
- package/node_modules/abort-controller/polyfill.mjs +0 -19
- package/node_modules/base64-js/LICENSE +0 -21
- package/node_modules/base64-js/README.md +0 -34
- package/node_modules/base64-js/base64js.min.js +0 -1
- package/node_modules/base64-js/index.d.ts +0 -3
- package/node_modules/base64-js/index.js +0 -150
- package/node_modules/base64-js/package.json +0 -47
- package/node_modules/buffer/AUTHORS.md +0 -73
- package/node_modules/buffer/LICENSE +0 -21
- package/node_modules/buffer/README.md +0 -410
- package/node_modules/buffer/index.d.ts +0 -194
- package/node_modules/buffer/index.js +0 -2106
- package/node_modules/buffer/package.json +0 -93
- package/node_modules/event-target-shim/LICENSE +0 -22
- package/node_modules/event-target-shim/README.md +0 -293
- package/node_modules/event-target-shim/dist/event-target-shim.js +0 -871
- package/node_modules/event-target-shim/dist/event-target-shim.js.map +0 -1
- package/node_modules/event-target-shim/dist/event-target-shim.mjs +0 -862
- package/node_modules/event-target-shim/dist/event-target-shim.mjs.map +0 -1
- package/node_modules/event-target-shim/dist/event-target-shim.umd.js +0 -6
- package/node_modules/event-target-shim/dist/event-target-shim.umd.js.map +0 -1
- package/node_modules/event-target-shim/index.d.ts +0 -399
- package/node_modules/event-target-shim/package.json +0 -82
- package/node_modules/events/.airtap.yml +0 -15
- package/node_modules/events/.github/FUNDING.yml +0 -12
- package/node_modules/events/.travis.yml +0 -18
- package/node_modules/events/History.md +0 -118
- package/node_modules/events/LICENSE +0 -22
- package/node_modules/events/Readme.md +0 -50
- package/node_modules/events/events.js +0 -497
- package/node_modules/events/package.json +0 -37
- package/node_modules/events/security.md +0 -10
- package/node_modules/events/tests/add-listeners.js +0 -111
- package/node_modules/events/tests/check-listener-leaks.js +0 -101
- package/node_modules/events/tests/common.js +0 -104
- package/node_modules/events/tests/errors.js +0 -13
- package/node_modules/events/tests/events-list.js +0 -28
- package/node_modules/events/tests/events-once.js +0 -234
- package/node_modules/events/tests/index.js +0 -64
- package/node_modules/events/tests/legacy-compat.js +0 -16
- package/node_modules/events/tests/listener-count.js +0 -37
- package/node_modules/events/tests/listeners-side-effects.js +0 -56
- package/node_modules/events/tests/listeners.js +0 -168
- package/node_modules/events/tests/max-listeners.js +0 -47
- package/node_modules/events/tests/method-names.js +0 -35
- package/node_modules/events/tests/modify-in-emit.js +0 -90
- package/node_modules/events/tests/num-args.js +0 -60
- package/node_modules/events/tests/once.js +0 -83
- package/node_modules/events/tests/prepend.js +0 -31
- package/node_modules/events/tests/remove-all-listeners.js +0 -133
- package/node_modules/events/tests/remove-listeners.js +0 -212
- package/node_modules/events/tests/set-max-listeners-side-effects.js +0 -31
- package/node_modules/events/tests/special-event-names.js +0 -45
- package/node_modules/events/tests/subclass.js +0 -66
- package/node_modules/events/tests/symbols.js +0 -25
- package/node_modules/fast-redact/.github/workflows/ci.yml +0 -37
- package/node_modules/fast-redact/LICENSE +0 -21
- package/node_modules/fast-redact/benchmark/index.js +0 -223
- package/node_modules/fast-redact/example/default-usage.js +0 -14
- package/node_modules/fast-redact/example/intermediate-wildcard-array.js +0 -11
- package/node_modules/fast-redact/example/multi-wildcard-array-depth.js +0 -11
- package/node_modules/fast-redact/example/multi-wildcard-array-end.js +0 -11
- package/node_modules/fast-redact/example/multi-wildcard-array.js +0 -11
- package/node_modules/fast-redact/example/serialize-false.js +0 -11
- package/node_modules/fast-redact/example/serialize-function.js +0 -4
- package/node_modules/fast-redact/example/top-wildcard-object.js +0 -9
- package/node_modules/fast-redact/index.js +0 -56
- package/node_modules/fast-redact/lib/modifiers.js +0 -291
- package/node_modules/fast-redact/lib/parse.js +0 -44
- package/node_modules/fast-redact/lib/redactor.js +0 -108
- package/node_modules/fast-redact/lib/restorer.js +0 -92
- package/node_modules/fast-redact/lib/rx.js +0 -16
- package/node_modules/fast-redact/lib/state.js +0 -20
- package/node_modules/fast-redact/lib/validator.js +0 -33
- package/node_modules/fast-redact/package.json +0 -50
- package/node_modules/fast-redact/readme.md +0 -282
- package/node_modules/fast-redact/test/index.js +0 -1502
- package/node_modules/ieee754/LICENSE +0 -11
- package/node_modules/ieee754/README.md +0 -51
- package/node_modules/ieee754/index.d.ts +0 -10
- package/node_modules/ieee754/index.js +0 -85
- package/node_modules/ieee754/package.json +0 -52
- package/node_modules/pino/.eslintignore +0 -2
- package/node_modules/pino/.eslintrc +0 -8
- package/node_modules/pino/.github/workflows/bench.yml +0 -61
- package/node_modules/pino/.github/workflows/ci.yml +0 -86
- package/node_modules/pino/.github/workflows/lock-threads.yml +0 -30
- package/node_modules/pino/.github/workflows/package-manager-ci.yml +0 -99
- package/node_modules/pino/.github/workflows/target-main.yml +0 -23
- package/node_modules/pino/.taprc.yaml +0 -8
- package/node_modules/pino/docsify/sidebar.md +0 -26
- package/node_modules/pino/favicon-16x16.png +0 -0
- package/node_modules/pino/favicon-32x32.png +0 -0
- package/node_modules/pino/lib/worker-pipeline.js +0 -38
- package/node_modules/pino/node_modules/sonic-boom/.eslintignore +0 -2
- package/node_modules/pino/node_modules/sonic-boom/.husky/pre-commit +0 -4
- package/node_modules/pino/node_modules/sonic-boom/.taprc.yaml +0 -11
- package/node_modules/pino/node_modules/sonic-boom/README.md +0 -151
- package/node_modules/pino/node_modules/sonic-boom/bench.js +0 -98
- package/node_modules/pino/node_modules/sonic-boom/check.js +0 -18
- package/node_modules/pino/node_modules/sonic-boom/example.js +0 -8
- package/node_modules/pino/node_modules/sonic-boom/fixtures/firehose.js +0 -22
- package/node_modules/pino/node_modules/sonic-boom/index.js +0 -690
- package/node_modules/pino/node_modules/sonic-boom/package.json +0 -50
- package/node_modules/pino/node_modules/sonic-boom/test/destroy.test.js +0 -49
- package/node_modules/pino/node_modules/sonic-boom/test/end.test.js +0 -98
- package/node_modules/pino/node_modules/sonic-boom/test/flush-sync.test.js +0 -140
- package/node_modules/pino/node_modules/sonic-boom/test/flush.test.js +0 -419
- package/node_modules/pino/node_modules/sonic-boom/test/fsync.test.js +0 -63
- package/node_modules/pino/node_modules/sonic-boom/test/helper.js +0 -42
- package/node_modules/pino/node_modules/sonic-boom/test/minlength.test.js +0 -35
- package/node_modules/pino/node_modules/sonic-boom/test/mode.test.js +0 -116
- package/node_modules/pino/node_modules/sonic-boom/test/reopen.test.js +0 -239
- package/node_modules/pino/node_modules/sonic-boom/test/retry.test.js +0 -414
- package/node_modules/pino/node_modules/sonic-boom/test/sync.test.js +0 -261
- package/node_modules/pino/node_modules/sonic-boom/test/write.test.js +0 -465
- package/node_modules/pino/node_modules/sonic-boom/types/index.d.ts +0 -62
- package/node_modules/pino/node_modules/sonic-boom/types/tests/test.ts +0 -4
- package/node_modules/pino/pino-banner.png +0 -0
- package/node_modules/pino/pino-logo-hire.png +0 -0
- package/node_modules/pino/pino-tree.png +0 -0
- package/node_modules/pino/pretty-demo.png +0 -0
- package/node_modules/pino/test/errorKey.test.js +0 -34
- package/node_modules/pino/test/transport/core.test.ts +0 -236
- package/node_modules/pino-std-serializers/.taprc +0 -2
- package/node_modules/process/.eslintrc +0 -21
- package/node_modules/process/LICENSE +0 -22
- package/node_modules/process/README.md +0 -26
- package/node_modules/process/browser.js +0 -184
- package/node_modules/process/index.js +0 -2
- package/node_modules/process/package.json +0 -27
- package/node_modules/process/test.js +0 -199
- package/node_modules/process-warning/.taprc +0 -2
- package/node_modules/readable-stream/LICENSE +0 -47
- package/node_modules/readable-stream/README.md +0 -116
- package/node_modules/readable-stream/lib/_stream_duplex.js +0 -4
- package/node_modules/readable-stream/lib/_stream_passthrough.js +0 -4
- package/node_modules/readable-stream/lib/_stream_readable.js +0 -4
- package/node_modules/readable-stream/lib/_stream_transform.js +0 -4
- package/node_modules/readable-stream/lib/_stream_writable.js +0 -4
- package/node_modules/readable-stream/lib/internal/streams/add-abort-signal.js +0 -52
- package/node_modules/readable-stream/lib/internal/streams/buffer_list.js +0 -157
- package/node_modules/readable-stream/lib/internal/streams/compose.js +0 -194
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -290
- package/node_modules/readable-stream/lib/internal/streams/duplex.js +0 -143
- package/node_modules/readable-stream/lib/internal/streams/duplexify.js +0 -378
- package/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +0 -286
- package/node_modules/readable-stream/lib/internal/streams/from.js +0 -98
- package/node_modules/readable-stream/lib/internal/streams/lazy_transform.js +0 -51
- package/node_modules/readable-stream/lib/internal/streams/legacy.js +0 -89
- package/node_modules/readable-stream/lib/internal/streams/operators.js +0 -457
- package/node_modules/readable-stream/lib/internal/streams/passthrough.js +0 -39
- package/node_modules/readable-stream/lib/internal/streams/pipeline.js +0 -471
- package/node_modules/readable-stream/lib/internal/streams/readable.js +0 -1290
- package/node_modules/readable-stream/lib/internal/streams/state.js +0 -39
- package/node_modules/readable-stream/lib/internal/streams/transform.js +0 -180
- package/node_modules/readable-stream/lib/internal/streams/utils.js +0 -327
- package/node_modules/readable-stream/lib/internal/streams/writable.js +0 -819
- package/node_modules/readable-stream/lib/internal/validators.js +0 -530
- package/node_modules/readable-stream/lib/ours/browser.js +0 -35
- package/node_modules/readable-stream/lib/ours/errors.js +0 -343
- package/node_modules/readable-stream/lib/ours/index.js +0 -65
- package/node_modules/readable-stream/lib/ours/primordials.js +0 -124
- package/node_modules/readable-stream/lib/ours/util/inspect.js +0 -55
- package/node_modules/readable-stream/lib/ours/util.js +0 -148
- package/node_modules/readable-stream/lib/stream/promises.js +0 -43
- package/node_modules/readable-stream/lib/stream.js +0 -143
- package/node_modules/readable-stream/package.json +0 -88
- package/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/safe-buffer/index.js +0 -65
- package/node_modules/safe-buffer/package.json +0 -51
- package/node_modules/string_decoder/LICENSE +0 -48
- package/node_modules/string_decoder/README.md +0 -47
- package/node_modules/string_decoder/lib/string_decoder.js +0 -296
- package/node_modules/string_decoder/package.json +0 -34
|
@@ -1,1502 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { test } = require('tap')
|
|
4
|
-
const fastRedact = require('..')
|
|
5
|
-
|
|
6
|
-
const censor = '[REDACTED]'
|
|
7
|
-
const censorFct = value => !value ? value : 'xxx' + value.substr(-2)
|
|
8
|
-
const censorWithPath = (v, p) => p.join('.') + ' ' + censorFct(v)
|
|
9
|
-
|
|
10
|
-
test('returns no-op when passed no paths [serialize: false]', ({ end, doesNotThrow }) => {
|
|
11
|
-
const redact = fastRedact({ paths: [], serialize: false })
|
|
12
|
-
doesNotThrow(() => redact({}))
|
|
13
|
-
doesNotThrow(() => {
|
|
14
|
-
const o = redact({})
|
|
15
|
-
redact.restore(o)
|
|
16
|
-
})
|
|
17
|
-
end()
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
test('returns serializer when passed no paths [serialize: default]', ({ end, is }) => {
|
|
21
|
-
is(fastRedact({ paths: [] }), JSON.stringify)
|
|
22
|
-
is(fastRedact(), JSON.stringify)
|
|
23
|
-
end()
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test('throws when passed non-object using defaults', ({ end, throws }) => {
|
|
27
|
-
const redact = fastRedact({ paths: ['a.b.c'] })
|
|
28
|
-
throws(() => redact(1))
|
|
29
|
-
end()
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test('throws when passed non-object number using [strict: true]', ({ end, throws }) => {
|
|
33
|
-
const redact = fastRedact({ paths: ['a.b.c'], strict: true })
|
|
34
|
-
throws(() => redact(1))
|
|
35
|
-
end()
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
test('returns JSON.stringified value when passed non-object using [strict: false] and no serialize option', ({ end, is, doesNotThrow }) => {
|
|
39
|
-
const redactDefaultSerialize = fastRedact({ paths: ['a.b.c'], strict: false })
|
|
40
|
-
|
|
41
|
-
// expectedOutputs holds `JSON.stringify`ied versions of each primitive.
|
|
42
|
-
// We write them out explicitly though to make the test a bit clearer.
|
|
43
|
-
const primitives = [null, undefined, 'A', 1, false]
|
|
44
|
-
const expectedOutputs = ['null', undefined, '"A"', '1', 'false']
|
|
45
|
-
|
|
46
|
-
primitives.forEach((it, i) => {
|
|
47
|
-
doesNotThrow(() => redactDefaultSerialize(it))
|
|
48
|
-
const res = redactDefaultSerialize(it)
|
|
49
|
-
is(res, expectedOutputs[i])
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
end()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
test('returns custom serialized value when passed non-object using [strict: false, serialize: fn]', ({ end, is, doesNotThrow }) => {
|
|
56
|
-
const customSerialize = (v) => `Hello ${v}!`
|
|
57
|
-
const redactCustomSerialize = fastRedact({
|
|
58
|
-
paths: ['a.b.c'],
|
|
59
|
-
strict: false,
|
|
60
|
-
serialize: customSerialize
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
const primitives = [null, undefined, 'A', 1, false]
|
|
64
|
-
|
|
65
|
-
primitives.forEach((it) => {
|
|
66
|
-
doesNotThrow(() => redactCustomSerialize(it))
|
|
67
|
-
const res = redactCustomSerialize(it)
|
|
68
|
-
is(res, customSerialize(it))
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
end()
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
test('returns original value when passed non-object using [strict: false, serialize: false]', ({ end, is, doesNotThrow }) => {
|
|
75
|
-
const redactSerializeFalse = fastRedact({
|
|
76
|
-
paths: ['a.b.c'],
|
|
77
|
-
strict: false,
|
|
78
|
-
serialize: false
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
const primitives = [null, undefined, 'A', 1, false]
|
|
82
|
-
|
|
83
|
-
primitives.forEach((it) => {
|
|
84
|
-
doesNotThrow(() => redactSerializeFalse(it))
|
|
85
|
-
const res = redactSerializeFalse(it)
|
|
86
|
-
is(res, it)
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
end()
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
test('returns original value when passed non-object at wildcard key', ({ end, doesNotThrow, strictSame }) => {
|
|
93
|
-
const redactSerializeFalse = fastRedact({
|
|
94
|
-
paths: ['a.*'],
|
|
95
|
-
strict: false,
|
|
96
|
-
serialize: false
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
const primitives = [null, undefined, 'A', 1, false]
|
|
100
|
-
|
|
101
|
-
primitives.forEach((a) => {
|
|
102
|
-
doesNotThrow(() => redactSerializeFalse({ a }))
|
|
103
|
-
const res = redactSerializeFalse({ a })
|
|
104
|
-
strictSame(res, { a })
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
end()
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
test('returns censored values when passed array at wildcard key', ({ end, strictSame }) => {
|
|
111
|
-
const redactSerializeFalse = fastRedact({
|
|
112
|
-
paths: ['a.*'],
|
|
113
|
-
strict: false,
|
|
114
|
-
serialize: false
|
|
115
|
-
})
|
|
116
|
-
const res = redactSerializeFalse({ a: ['redact', 'me'] })
|
|
117
|
-
strictSame(res.a, [censor, censor])
|
|
118
|
-
end()
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
test('throws if a path is not a string', ({ end, throws }) => {
|
|
122
|
-
const invalidTypeMsg = 'fast-redact - Paths must be (non-empty) strings'
|
|
123
|
-
throws((e) => {
|
|
124
|
-
fastRedact({ paths: [1] })
|
|
125
|
-
}, Error(invalidTypeMsg))
|
|
126
|
-
throws((e) => {
|
|
127
|
-
fastRedact({ paths: [null] })
|
|
128
|
-
}, Error(invalidTypeMsg))
|
|
129
|
-
throws((e) => {
|
|
130
|
-
fastRedact({ paths: [undefined] })
|
|
131
|
-
}, Error(invalidTypeMsg))
|
|
132
|
-
throws((e) => {
|
|
133
|
-
fastRedact({ paths: [{}] })
|
|
134
|
-
}, Error(invalidTypeMsg))
|
|
135
|
-
throws((e) => {
|
|
136
|
-
fastRedact({ paths: [[null]] })
|
|
137
|
-
}, Error(invalidTypeMsg))
|
|
138
|
-
end()
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
test('throws when passed illegal paths', ({ end, throws }) => {
|
|
142
|
-
const err = (s) => Error(`fast-redact – Invalid path (${s})`)
|
|
143
|
-
throws((e) => {
|
|
144
|
-
fastRedact({ paths: ['@'] })
|
|
145
|
-
}, err('@'))
|
|
146
|
-
throws((e) => {
|
|
147
|
-
fastRedact({ paths: ['0'] })
|
|
148
|
-
}, err('0'))
|
|
149
|
-
throws((e) => {
|
|
150
|
-
fastRedact({ paths: ['〇'] })
|
|
151
|
-
}, err('〇'))
|
|
152
|
-
throws((e) => {
|
|
153
|
-
fastRedact({ paths: ['a.1.c'] })
|
|
154
|
-
}, err('a.1.c'))
|
|
155
|
-
throws((e) => {
|
|
156
|
-
fastRedact({ paths: ['a..c'] })
|
|
157
|
-
}, err('a..c'))
|
|
158
|
-
throws((e) => {
|
|
159
|
-
fastRedact({ paths: ['1..c'] })
|
|
160
|
-
}, err('1..c'))
|
|
161
|
-
throws((e) => {
|
|
162
|
-
fastRedact({ paths: ['a = b'] })
|
|
163
|
-
}, err('a = b'))
|
|
164
|
-
throws((e) => {
|
|
165
|
-
fastRedact({ paths: ['a(b)'] })
|
|
166
|
-
}, err('a(b)'))
|
|
167
|
-
throws((e) => {
|
|
168
|
-
fastRedact({ paths: ['//a.b.c'] })
|
|
169
|
-
}, err('//a.b.c'))
|
|
170
|
-
throws((e) => {
|
|
171
|
-
fastRedact({ paths: ['\\a.b.c'] })
|
|
172
|
-
}, err('\\a.b.c'))
|
|
173
|
-
throws((e) => {
|
|
174
|
-
fastRedact({ paths: ['a.#.c'] })
|
|
175
|
-
}, err('a.#.c'))
|
|
176
|
-
throws((e) => {
|
|
177
|
-
fastRedact({ paths: ['~~a.b.c'] })
|
|
178
|
-
}, err('~~a.b.c'))
|
|
179
|
-
throws((e) => {
|
|
180
|
-
fastRedact({ paths: ['^a.b.c'] })
|
|
181
|
-
}, err('^a.b.c'))
|
|
182
|
-
throws((e) => {
|
|
183
|
-
fastRedact({ paths: ['a + b'] })
|
|
184
|
-
}, err('a + b'))
|
|
185
|
-
throws((e) => {
|
|
186
|
-
fastRedact({ paths: ['return a + b'] })
|
|
187
|
-
}, err('return a + b'))
|
|
188
|
-
throws((e) => {
|
|
189
|
-
fastRedact({ paths: ['a / b'] })
|
|
190
|
-
}, err('a / b'))
|
|
191
|
-
throws((e) => {
|
|
192
|
-
fastRedact({ paths: ['a * b'] })
|
|
193
|
-
}, err('a * b'))
|
|
194
|
-
throws((e) => {
|
|
195
|
-
fastRedact({ paths: ['a - b'] })
|
|
196
|
-
}, err('a - b'))
|
|
197
|
-
throws((e) => {
|
|
198
|
-
fastRedact({ paths: ['a ** b'] })
|
|
199
|
-
}, err('a ** b'))
|
|
200
|
-
throws((e) => {
|
|
201
|
-
fastRedact({ paths: ['a % b'] })
|
|
202
|
-
}, err('a % b'))
|
|
203
|
-
throws((e) => {
|
|
204
|
-
fastRedact({ paths: ['a.b*.c'] })
|
|
205
|
-
}, err('a.b*.c'))
|
|
206
|
-
throws((e) => {
|
|
207
|
-
fastRedact({ paths: ['a;global.foo = "bar"'] })
|
|
208
|
-
}, err('a;global.foo = "bar"'))
|
|
209
|
-
throws((e) => {
|
|
210
|
-
fastRedact({ paths: ['a;while(1){}'] })
|
|
211
|
-
}, err('a;while(1){}'))
|
|
212
|
-
throws((e) => {
|
|
213
|
-
fastRedact({ paths: ['a//'] })
|
|
214
|
-
}, err('a//'))
|
|
215
|
-
throws((e) => {
|
|
216
|
-
fastRedact({ paths: ['a/*foo*/'] })
|
|
217
|
-
}, err('a/*foo*/'))
|
|
218
|
-
throws((e) => {
|
|
219
|
-
fastRedact({ paths: ['a,o.b'] })
|
|
220
|
-
}, err('a,o.b'))
|
|
221
|
-
throws((e) => {
|
|
222
|
-
fastRedact({ paths: ['a = o.b'] })
|
|
223
|
-
}, err('a = o.b'))
|
|
224
|
-
throws((e) => {
|
|
225
|
-
fastRedact({ paths: ['a\n'] })
|
|
226
|
-
}, err('a\n'))
|
|
227
|
-
throws((e) => {
|
|
228
|
-
fastRedact({ paths: ['a\r'] })
|
|
229
|
-
}, err('a\r'))
|
|
230
|
-
throws((e) => {
|
|
231
|
-
fastRedact({ paths: [''] })
|
|
232
|
-
}, err(''))
|
|
233
|
-
throws((e) => {
|
|
234
|
-
fastRedact({ paths: ['[""""]'] })
|
|
235
|
-
}, err('[""""]'))
|
|
236
|
-
end()
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
test('throws if a custom serializer is used and remove is true', ({ end, throws }) => {
|
|
240
|
-
throws(() => {
|
|
241
|
-
fastRedact({ paths: ['a'], serialize: (o) => o, remove: true })
|
|
242
|
-
}, Error('fast-redact – remove option may only be set when serializer is JSON.stringify'))
|
|
243
|
-
end()
|
|
244
|
-
})
|
|
245
|
-
|
|
246
|
-
test('throws if serialize is false and remove is true', ({ end, throws }) => {
|
|
247
|
-
throws(() => {
|
|
248
|
-
fastRedact({ paths: ['a'], serialize: false, remove: true })
|
|
249
|
-
}, Error('fast-redact – remove option may only be set when serializer is JSON.stringify'))
|
|
250
|
-
end()
|
|
251
|
-
})
|
|
252
|
-
|
|
253
|
-
test('supports path segments that aren\'t identifiers if bracketed', ({ end, strictSame }) => {
|
|
254
|
-
const redactSerializeFalse = fastRedact({
|
|
255
|
-
paths: ['a[""]', 'a["x-y"]', 'a[\'"y"\']', "a['\\'x\\'']"],
|
|
256
|
-
serialize: false,
|
|
257
|
-
censor: 'X'
|
|
258
|
-
})
|
|
259
|
-
|
|
260
|
-
const res = redactSerializeFalse({ a: { '': 'Hi!', 'x-y': 'Hi!', '"y"': 'Hi!', "'x'": 'Hi!' } })
|
|
261
|
-
strictSame(res, { a: { '': 'X', 'x-y': 'X', '"y"': 'X', "'x'": 'X' } })
|
|
262
|
-
end()
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
test('supports consecutive bracketed path segments', ({ end, strictSame }) => {
|
|
266
|
-
const redactSerializeFalse = fastRedact({
|
|
267
|
-
paths: ['a[""]["y"]'],
|
|
268
|
-
serialize: false,
|
|
269
|
-
censor: 'X'
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
const res = redactSerializeFalse({ a: { '': { 'y': 'Hi!' } } })
|
|
273
|
-
strictSame(res, { a: { '': { 'y': 'X' } } })
|
|
274
|
-
end()
|
|
275
|
-
})
|
|
276
|
-
|
|
277
|
-
test('supports leading bracketed widcard', ({ end, strictSame }) => {
|
|
278
|
-
const redactSerializeFalse = fastRedact({
|
|
279
|
-
paths: ['[*]["y"]'],
|
|
280
|
-
serialize: false,
|
|
281
|
-
censor: 'X'
|
|
282
|
-
})
|
|
283
|
-
|
|
284
|
-
const res = redactSerializeFalse({ 'x': { 'y': 'Hi!' } })
|
|
285
|
-
strictSame(res, { 'x': { 'y': 'X' } })
|
|
286
|
-
end()
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
test('masks according to supplied censor', ({ end, is }) => {
|
|
290
|
-
const censor = 'test'
|
|
291
|
-
const redact = fastRedact({ paths: ['a'], censor, serialize: false })
|
|
292
|
-
is(redact({ a: 'a' }).a, censor)
|
|
293
|
-
end()
|
|
294
|
-
})
|
|
295
|
-
|
|
296
|
-
test('redact.restore function is available when serialize is false', ({ end, is }) => {
|
|
297
|
-
const censor = 'test'
|
|
298
|
-
const redact = fastRedact({ paths: ['a'], censor, serialize: false })
|
|
299
|
-
is(typeof redact.restore, 'function')
|
|
300
|
-
end()
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
test('redact.restore function places original values back in place', ({ end, is }) => {
|
|
304
|
-
const censor = 'test'
|
|
305
|
-
const redact = fastRedact({ paths: ['a'], censor, serialize: false })
|
|
306
|
-
const o = { a: 'a' }
|
|
307
|
-
redact(o)
|
|
308
|
-
is(o.a, censor)
|
|
309
|
-
redact.restore(o)
|
|
310
|
-
is(o.a, 'a')
|
|
311
|
-
end()
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
test('redact.restore function places original values back in place when called twice and the first call is precensored', ({ end, is }) => {
|
|
315
|
-
const censor = 'test'
|
|
316
|
-
const redact = fastRedact({ paths: ['a'], censor, serialize: false })
|
|
317
|
-
const o1 = { a: censor }
|
|
318
|
-
const o2 = { a: 'a' }
|
|
319
|
-
redact(o1)
|
|
320
|
-
is(o1.a, censor)
|
|
321
|
-
redact.restore(o1)
|
|
322
|
-
is(o1.a, censor)
|
|
323
|
-
redact(o2)
|
|
324
|
-
is(o2.a, censor)
|
|
325
|
-
redact.restore(o2)
|
|
326
|
-
is(o2.a, 'a')
|
|
327
|
-
end()
|
|
328
|
-
})
|
|
329
|
-
|
|
330
|
-
test('masks according to supplied censor function', ({ end, is }) => {
|
|
331
|
-
const redact = fastRedact({ paths: ['a'], censor: censorFct, serialize: false })
|
|
332
|
-
is(redact({ a: '0123456' }).a, 'xxx56')
|
|
333
|
-
end()
|
|
334
|
-
})
|
|
335
|
-
|
|
336
|
-
test('masks according to supplied censor function with wildcards', ({ end, is }) => {
|
|
337
|
-
const redact = fastRedact({ paths: '*', censor: censorFct, serialize: false })
|
|
338
|
-
is(redact({ a: '0123456' }).a, 'xxx56')
|
|
339
|
-
end()
|
|
340
|
-
})
|
|
341
|
-
|
|
342
|
-
test('masks according to supplied censor function with nested wildcards', ({ end, is }) => {
|
|
343
|
-
const redact = fastRedact({ paths: ['*.b'], censor: censorFct, serialize: false })
|
|
344
|
-
is(redact({ a: { b: '0123456' } }).a.b, 'xxx56')
|
|
345
|
-
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.b, 'xxx56')
|
|
346
|
-
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.d, 'pristine')
|
|
347
|
-
end()
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
test('does not increment secret size', ({ end, is, same }) => {
|
|
351
|
-
const redact = fastRedact({ paths: ['x', '*.b'], censor: censorFct, serialize: false })
|
|
352
|
-
is(redact({ a: { b: '0123456' } }).a.b, 'xxx56')
|
|
353
|
-
same(Object.keys(redact.state.secret), ['x'])
|
|
354
|
-
const intialSecretSize = JSON.stringify(redact.state.secret).length
|
|
355
|
-
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.b, 'xxx56')
|
|
356
|
-
same(Object.keys(redact.state.secret), ['x'])
|
|
357
|
-
is(JSON.stringify(redact.state.secret).length, intialSecretSize)
|
|
358
|
-
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.d, 'pristine')
|
|
359
|
-
same(Object.keys(redact.state.secret), ['x'])
|
|
360
|
-
is(JSON.stringify(redact.state.secret).length, intialSecretSize)
|
|
361
|
-
end()
|
|
362
|
-
})
|
|
363
|
-
|
|
364
|
-
test('masks according to supplied censor-with-path function', ({ end, is }) => {
|
|
365
|
-
const redact = fastRedact({ paths: ['a'], censor: censorWithPath, serialize: false })
|
|
366
|
-
is(redact({ a: '0123456' }).a, 'a xxx56')
|
|
367
|
-
end()
|
|
368
|
-
})
|
|
369
|
-
|
|
370
|
-
test('masks according to supplied censor-with-path function with wildcards', ({ end, is }) => {
|
|
371
|
-
const redact = fastRedact({ paths: '*', censor: censorWithPath, serialize: false })
|
|
372
|
-
is(redact({ a: '0123456' }).a, 'a xxx56')
|
|
373
|
-
end()
|
|
374
|
-
})
|
|
375
|
-
|
|
376
|
-
test('masks according to supplied censor-with-path function with nested wildcards', ({ end, is }) => {
|
|
377
|
-
const redact = fastRedact({ paths: ['*.b'], censor: censorWithPath, serialize: false })
|
|
378
|
-
is(redact({ a: { b: '0123456' } }).a.b, 'a.b xxx56')
|
|
379
|
-
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.b, 'c.b xxx56')
|
|
380
|
-
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.d, 'pristine')
|
|
381
|
-
end()
|
|
382
|
-
})
|
|
383
|
-
|
|
384
|
-
test('redact.restore function places original values back in place with censor function', ({ end, is }) => {
|
|
385
|
-
const redact = fastRedact({ paths: ['a'], censor: censorFct, serialize: false })
|
|
386
|
-
const o = { a: 'qwerty' }
|
|
387
|
-
redact(o)
|
|
388
|
-
is(o.a, 'xxxty')
|
|
389
|
-
redact.restore(o)
|
|
390
|
-
is(o.a, 'qwerty')
|
|
391
|
-
end()
|
|
392
|
-
})
|
|
393
|
-
|
|
394
|
-
test('serializes with JSON.stringify by default', ({ end, is }) => {
|
|
395
|
-
const redact = fastRedact({ paths: ['a'] })
|
|
396
|
-
const o = { a: 'a' }
|
|
397
|
-
is(redact(o), `{"a":"${censor}"}`)
|
|
398
|
-
is(o.a, 'a')
|
|
399
|
-
end()
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
test('removes during serialization instead of redacting when remove option is true', ({ end, is }) => {
|
|
403
|
-
const redact = fastRedact({ paths: ['a'], remove: true })
|
|
404
|
-
const o = { a: 'a', b: 'b' }
|
|
405
|
-
is(redact(o), `{"b":"b"}`)
|
|
406
|
-
is(o.a, 'a')
|
|
407
|
-
end()
|
|
408
|
-
})
|
|
409
|
-
|
|
410
|
-
test('serializes with JSON.stringify if serialize is true', ({ end, is }) => {
|
|
411
|
-
const redact = fastRedact({ paths: ['a'], serialize: true })
|
|
412
|
-
const o = { a: 'a' }
|
|
413
|
-
is(redact(o), `{"a":"${censor}"}`)
|
|
414
|
-
is(o.a, 'a')
|
|
415
|
-
end()
|
|
416
|
-
})
|
|
417
|
-
|
|
418
|
-
test('serializes with JSON.stringify if serialize is not a function', ({ end, is }) => {
|
|
419
|
-
const redact = fastRedact({ paths: ['a'], serialize: {} })
|
|
420
|
-
const o = { a: 'a' }
|
|
421
|
-
is(redact(o), `{"a":"${censor}"}`)
|
|
422
|
-
is(o.a, 'a')
|
|
423
|
-
end()
|
|
424
|
-
})
|
|
425
|
-
|
|
426
|
-
test('serializes with custom serializer if supplied', ({ end, is }) => {
|
|
427
|
-
const redact = fastRedact({ paths: ['a'], serialize: (o) => JSON.stringify(o, 0, 2) })
|
|
428
|
-
const o = { a: 'a' }
|
|
429
|
-
is(redact(o), `{\n "a": "${censor}"\n}`)
|
|
430
|
-
is(o.a, 'a')
|
|
431
|
-
end()
|
|
432
|
-
})
|
|
433
|
-
|
|
434
|
-
test('redacts parent keys', ({ end, is }) => {
|
|
435
|
-
const redact = fastRedact({ paths: ['a.b.c'], serialize: false })
|
|
436
|
-
const result = redact({ a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
437
|
-
is(result.a.b.c, censor)
|
|
438
|
-
end()
|
|
439
|
-
})
|
|
440
|
-
|
|
441
|
-
test('supports paths with array indexes', ({ end, same }) => {
|
|
442
|
-
const redact = fastRedact({ paths: ['insideArray.like[3].this'], serialize: false })
|
|
443
|
-
same(redact({ insideArray: { like: ['a', 'b', 'c', { this: { foo: 'meow' } }] } }), { insideArray: { like: ['a', 'b', 'c', { this: censor }] } })
|
|
444
|
-
end()
|
|
445
|
-
})
|
|
446
|
-
|
|
447
|
-
test('censor may be any type, including function', ({ end, same }) => {
|
|
448
|
-
const redactToString = fastRedact({ paths: ['a.b.c', 'a.b.d.*'], censor: 'censor', serialize: false })
|
|
449
|
-
const redactToUndefined = fastRedact({ paths: ['a.b.c', 'a.b.d.*'], censor: undefined, serialize: false })
|
|
450
|
-
const sym = Symbol('sym')
|
|
451
|
-
const redactToSymbol = fastRedact({ paths: ['a.b.c', 'a.b.d.*'], censor: sym, serialize: false })
|
|
452
|
-
const redactToNumber = fastRedact({ paths: ['a.b.c', 'a.b.d.*'], censor: 0, serialize: false })
|
|
453
|
-
const redactToBoolean = fastRedact({ paths: ['a.b.c', 'a.b.d.*'], censor: false, serialize: false })
|
|
454
|
-
const redactToNull = fastRedact({ paths: ['a.b.c', 'a.b.d.*'], censor: null, serialize: false })
|
|
455
|
-
const redactToObject = fastRedact({ paths: ['a.b.c', 'a.b.d.*'], censor: { redacted: true }, serialize: false })
|
|
456
|
-
const redactToArray = fastRedact({ paths: ['a.b.c', 'a.b.d.*'], censor: ['redacted'], serialize: false })
|
|
457
|
-
const redactToBuffer = fastRedact({ paths: ['a.b.c', 'a.b.d.*'], censor: Buffer.from('redacted'), serialize: false })
|
|
458
|
-
const redactToError = fastRedact({ paths: ['a.b.c', 'a.b.d.*'], censor: Error('redacted'), serialize: false })
|
|
459
|
-
const redactToFunction = fastRedact({ paths: ['a.b.c', 'a.b.d.*'], censor: () => 'redacted', serialize: false })
|
|
460
|
-
same(redactToString({ a: { b: { c: 's', d: { x: 's', y: 's' } } } }), { a: { b: { c: 'censor', d: { x: 'censor', y: 'censor' } } } })
|
|
461
|
-
same(redactToUndefined({ a: { b: { c: 's', d: { x: 's', y: 's' } } } }), { a: { b: { c: undefined, d: { x: undefined, y: undefined } } } })
|
|
462
|
-
same(redactToSymbol({ a: { b: { c: 's', d: { x: 's', y: 's' } } } }), { a: { b: { c: sym, d: { x: sym, y: sym } } } })
|
|
463
|
-
same(redactToNumber({ a: { b: { c: 's', d: { x: 's', y: 's' } } } }), { a: { b: { c: 0, d: { x: 0, y: 0 } } } })
|
|
464
|
-
same(redactToBoolean({ a: { b: { c: 's', d: { x: 's', y: 's' } } } }), { a: { b: { c: false, d: { x: false, y: false } } } })
|
|
465
|
-
same(redactToNull({ a: { b: { c: 's', d: { x: 's', y: 's' } } } }), { a: { b: { c: null, d: { x: null, y: null } } } })
|
|
466
|
-
same(redactToObject({ a: { b: { c: 's', d: { x: 's', y: 's' } } } }), { a: { b: { c: { redacted: true }, d: { x: { redacted: true }, y: { redacted: true } } } } })
|
|
467
|
-
same(redactToArray({ a: { b: { c: 's', d: { x: 's', y: 's' } } } }), { a: { b: { c: ['redacted'], d: { x: ['redacted'], y: ['redacted'] } } } })
|
|
468
|
-
same(redactToBuffer({ a: { b: { c: 's', d: { x: 's', y: 's' } } } }), { a: { b: { c: Buffer.from('redacted'), d: { x: Buffer.from('redacted'), y: Buffer.from('redacted') } } } })
|
|
469
|
-
same(redactToError({ a: { b: { c: 's', d: { x: 's', y: 's' } } } }), { a: { b: { c: Error('redacted'), d: { x: Error('redacted'), y: Error('redacted') } } } })
|
|
470
|
-
same(redactToFunction({ a: { b: { c: 's', d: { x: 's', y: 's' } } } }), { a: { b: { c: 'redacted', d: { x: 'redacted', y: 'redacted' } } } })
|
|
471
|
-
end()
|
|
472
|
-
})
|
|
473
|
-
|
|
474
|
-
test('supports multiple paths from the same root', ({ end, same }) => {
|
|
475
|
-
const redact = fastRedact({ paths: ['deep.bar.shoe', 'deep.baz.shoe', 'deep.foo', 'deep.not.there.sooo', 'deep.fum.shoe'], serialize: false })
|
|
476
|
-
same(redact({ deep: { bar: 'hmm', baz: { shoe: { k: 1 } }, foo: {}, fum: { shoe: 'moo' } } }), { deep: { bar: 'hmm', baz: { shoe: censor }, foo: censor, fum: { shoe: censor } } })
|
|
477
|
-
end()
|
|
478
|
-
})
|
|
479
|
-
|
|
480
|
-
test('supports strings in bracket notation paths (single quote)', ({ end, is }) => {
|
|
481
|
-
const redact = fastRedact({ paths: [`a['@#!='].c`], serialize: false })
|
|
482
|
-
const result = redact({ a: { '@#!=': { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
483
|
-
is(result.a['@#!='].c, censor)
|
|
484
|
-
end()
|
|
485
|
-
})
|
|
486
|
-
|
|
487
|
-
test('supports strings in bracket notation paths (double quote)', ({ end, is }) => {
|
|
488
|
-
const redact = fastRedact({ paths: [`a["@#!="].c`], serialize: false })
|
|
489
|
-
const result = redact({ a: { '@#!=': { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
490
|
-
is(result.a['@#!='].c, censor)
|
|
491
|
-
end()
|
|
492
|
-
})
|
|
493
|
-
|
|
494
|
-
test('supports strings in bracket notation paths (backtick quote)', ({ end, is }) => {
|
|
495
|
-
const redact = fastRedact({ paths: ['a[`@#!=`].c'], serialize: false })
|
|
496
|
-
const result = redact({ a: { '@#!=': { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
497
|
-
is(result.a['@#!='].c, censor)
|
|
498
|
-
end()
|
|
499
|
-
})
|
|
500
|
-
|
|
501
|
-
test('allows * within a bracket notation string', ({ end, is }) => {
|
|
502
|
-
const redact = fastRedact({ paths: ['a["*"].c'], serialize: false })
|
|
503
|
-
const result = redact({ a: { '*': { c: 's', x: 1 } } })
|
|
504
|
-
is(result.a['*'].c, censor)
|
|
505
|
-
is(result.a['*'].x, 1)
|
|
506
|
-
end()
|
|
507
|
-
})
|
|
508
|
-
|
|
509
|
-
test('redacts parent keys – restore', ({ end, is }) => {
|
|
510
|
-
const redact = fastRedact({ paths: ['a.b.c'], serialize: false })
|
|
511
|
-
const result = redact({ a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
512
|
-
is(result.a.b.c, censor)
|
|
513
|
-
redact.restore(result)
|
|
514
|
-
is(result.a.b.c, 's')
|
|
515
|
-
end()
|
|
516
|
-
})
|
|
517
|
-
|
|
518
|
-
test('handles null proto objects', ({ end, is }) => {
|
|
519
|
-
const redact = fastRedact({ paths: ['a.b.c'], serialize: false })
|
|
520
|
-
const result = redact({ __proto__: null, a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
521
|
-
is(result.a.b.c, censor)
|
|
522
|
-
end()
|
|
523
|
-
})
|
|
524
|
-
|
|
525
|
-
test('handles null proto objects – restore', ({ end, is }) => {
|
|
526
|
-
const redact = fastRedact({ paths: ['a.b.c'], serialize: false })
|
|
527
|
-
const result = redact({ __proto__: null, a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
528
|
-
is(result.a.b.c, censor)
|
|
529
|
-
redact.restore(result, 's')
|
|
530
|
-
is(result.a.b.c, 's')
|
|
531
|
-
end()
|
|
532
|
-
})
|
|
533
|
-
|
|
534
|
-
test('handles paths that do not match object structure', ({ end, same }) => {
|
|
535
|
-
const redact = fastRedact({ paths: ['x.y.z'], serialize: false })
|
|
536
|
-
same(redact({ a: { b: { c: 's' } } }), { a: { b: { c: 's' } } })
|
|
537
|
-
end()
|
|
538
|
-
})
|
|
539
|
-
|
|
540
|
-
test('ignores missing paths in object', ({ end, same }) => {
|
|
541
|
-
const redact = fastRedact({ paths: ['a.b.c', 'a.z.d', 'a.b.z'], serialize: false })
|
|
542
|
-
same(redact({ a: { b: { c: 's' } } }), { a: { b: { c: censor } } })
|
|
543
|
-
end()
|
|
544
|
-
})
|
|
545
|
-
|
|
546
|
-
test('ignores missing paths in object – restore', ({ end, doesNotThrow }) => {
|
|
547
|
-
const redact = fastRedact({ paths: ['a.b.c', 'a.z.d', 'a.b.z'], serialize: false })
|
|
548
|
-
const o = { a: { b: { c: 's' } } }
|
|
549
|
-
redact(o)
|
|
550
|
-
doesNotThrow(() => {
|
|
551
|
-
redact.restore(o)
|
|
552
|
-
})
|
|
553
|
-
|
|
554
|
-
end()
|
|
555
|
-
})
|
|
556
|
-
|
|
557
|
-
test('gracefully handles primitives that match intermediate keys in paths', ({ end, same }) => {
|
|
558
|
-
const redact = fastRedact({ paths: ['a.b.c', 'a.b.c.d'], serialize: false })
|
|
559
|
-
same(redact({ a: { b: null } }), { a: { b: null } })
|
|
560
|
-
same(redact({ a: { b: 's' } }), { a: { b: 's' } })
|
|
561
|
-
same(redact({ a: { b: 1 } }), { a: { b: 1 } })
|
|
562
|
-
same(redact({ a: { b: undefined } }), { a: { b: undefined } })
|
|
563
|
-
same(redact({ a: { b: true } }), { a: { b: true } })
|
|
564
|
-
const sym = Symbol('sym')
|
|
565
|
-
same(redact({ a: { b: sym } }), { a: { b: sym } })
|
|
566
|
-
end()
|
|
567
|
-
})
|
|
568
|
-
|
|
569
|
-
test('handles circulars', ({ end, is, same }) => {
|
|
570
|
-
const redact = fastRedact({ paths: ['bar.baz.baz'], serialize: false })
|
|
571
|
-
const bar = { b: 2 }
|
|
572
|
-
const o = { a: 1, bar }
|
|
573
|
-
bar.baz = bar
|
|
574
|
-
o.bar.baz = o.bar
|
|
575
|
-
same(redact(o), { a: 1, bar: { b: 2, baz: censor } })
|
|
576
|
-
end()
|
|
577
|
-
})
|
|
578
|
-
|
|
579
|
-
test('handles circulars – restore', ({ end, is, same }) => {
|
|
580
|
-
const redact = fastRedact({ paths: ['bar.baz.baz'], serialize: false })
|
|
581
|
-
const bar = { b: 2 }
|
|
582
|
-
const o = { a: 1, bar }
|
|
583
|
-
bar.baz = bar
|
|
584
|
-
o.bar.baz = o.bar
|
|
585
|
-
is(o.bar.baz, bar)
|
|
586
|
-
redact(o)
|
|
587
|
-
is(o.bar.baz, censor)
|
|
588
|
-
redact.restore(o)
|
|
589
|
-
is(o.bar.baz, bar)
|
|
590
|
-
end()
|
|
591
|
-
})
|
|
592
|
-
|
|
593
|
-
test('handles circulars and cross references – restore', ({ end, is, same }) => {
|
|
594
|
-
const redact = fastRedact({ paths: ['bar.baz.baz', 'cf.bar'], serialize: false })
|
|
595
|
-
const bar = { b: 2 }
|
|
596
|
-
const o = { a: 1, bar, cf: { bar } }
|
|
597
|
-
bar.baz = bar
|
|
598
|
-
o.bar.baz = o.bar
|
|
599
|
-
is(o.bar.baz, bar)
|
|
600
|
-
is(o.cf.bar, bar)
|
|
601
|
-
redact(o)
|
|
602
|
-
is(o.bar.baz, censor)
|
|
603
|
-
is(o.cf.bar, censor)
|
|
604
|
-
redact.restore(o)
|
|
605
|
-
is(o.bar.baz, bar)
|
|
606
|
-
is(o.cf.bar, bar)
|
|
607
|
-
end()
|
|
608
|
-
})
|
|
609
|
-
|
|
610
|
-
test('ultimate wildcards – shallow', ({ end, same }) => {
|
|
611
|
-
const redact = fastRedact({ paths: ['test.*'], serialize: false })
|
|
612
|
-
same(redact({ test: { baz: 1, bar: 'private' } }), { test: { baz: censor, bar: censor } })
|
|
613
|
-
end()
|
|
614
|
-
})
|
|
615
|
-
|
|
616
|
-
test('ultimate wildcards – deep', ({ end, same }) => {
|
|
617
|
-
const redact = fastRedact({ paths: ['deep.bar.baz.ding.*'], serialize: false })
|
|
618
|
-
same(redact({ deep: { a: 1, bar: { b: 2, baz: { c: 3, ding: { d: 4, e: 5, f: 'six' } } } } }), { deep: { a: 1, bar: { b: 2, baz: { c: 3, ding: { d: censor, e: censor, f: censor } } } } })
|
|
619
|
-
end()
|
|
620
|
-
})
|
|
621
|
-
|
|
622
|
-
test('ultimate wildcards - array – shallow', ({ end, same }) => {
|
|
623
|
-
const redact = fastRedact({ paths: ['array[*]'], serialize: false })
|
|
624
|
-
same(redact({ array: ['a', 'b', 'c', 'd'] }), { array: [censor, censor, censor, censor] })
|
|
625
|
-
end()
|
|
626
|
-
})
|
|
627
|
-
|
|
628
|
-
test('ultimate wildcards – array – deep', ({ end, same }) => {
|
|
629
|
-
const redact = fastRedact({ paths: ['deepArray.down.here[*]'], serialize: false })
|
|
630
|
-
same(redact({ deepArray: { down: { here: ['a', 'b', 'c'] } } }), { deepArray: { down: { here: [censor, censor, censor] } } })
|
|
631
|
-
end()
|
|
632
|
-
})
|
|
633
|
-
|
|
634
|
-
test('ultimate wildcards – array – single index', ({ end, same }) => {
|
|
635
|
-
const redact = fastRedact({ paths: ['insideArray.like[3].this.*'], serialize: false })
|
|
636
|
-
same(redact({ insideArray: { like: ['a', 'b', 'c', { this: { foo: 'meow' } }] } }), { insideArray: { like: ['a', 'b', 'c', { this: { foo: censor } }] } })
|
|
637
|
-
end()
|
|
638
|
-
})
|
|
639
|
-
|
|
640
|
-
test('ultimate wildcards - handles null proto objects', ({ end, is }) => {
|
|
641
|
-
const redact = fastRedact({ paths: ['a.b.c'], serialize: false })
|
|
642
|
-
const result = redact({ __proto__: null, a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
643
|
-
is(result.a.b.c, censor)
|
|
644
|
-
end()
|
|
645
|
-
})
|
|
646
|
-
|
|
647
|
-
test('ultimate wildcards - handles paths that do not match object structure', ({ end, same }) => {
|
|
648
|
-
const redact = fastRedact({ paths: ['x.y.z'], serialize: false })
|
|
649
|
-
same(redact({ a: { b: { c: 's' } } }), { a: { b: { c: 's' } } })
|
|
650
|
-
end()
|
|
651
|
-
})
|
|
652
|
-
|
|
653
|
-
test('ultimate wildcards - gracefully handles primitives that match intermediate keys in paths', ({ end, same }) => {
|
|
654
|
-
const redact = fastRedact({ paths: ['a.b.c', 'a.b.c.d'], serialize: false })
|
|
655
|
-
same(redact({ a: { b: null } }), { a: { b: null } })
|
|
656
|
-
same(redact({ a: { b: 's' } }), { a: { b: 's' } })
|
|
657
|
-
same(redact({ a: { b: 1 } }), { a: { b: 1 } })
|
|
658
|
-
same(redact({ a: { b: undefined } }), { a: { b: undefined } })
|
|
659
|
-
same(redact({ a: { b: true } }), { a: { b: true } })
|
|
660
|
-
const sym = Symbol('sym')
|
|
661
|
-
same(redact({ a: { b: sym } }), { a: { b: sym } })
|
|
662
|
-
end()
|
|
663
|
-
})
|
|
664
|
-
|
|
665
|
-
test('ultimate wildcards – handles circulars', ({ end, is, same }) => {
|
|
666
|
-
const redact = fastRedact({ paths: ['bar.baz.*'], serialize: false })
|
|
667
|
-
const bar = { b: 2 }
|
|
668
|
-
const o = { a: 1, bar }
|
|
669
|
-
bar.baz = bar
|
|
670
|
-
o.bar.baz = o.bar
|
|
671
|
-
same(redact(o), { a: 1, bar: { b: censor, baz: censor } })
|
|
672
|
-
end()
|
|
673
|
-
})
|
|
674
|
-
|
|
675
|
-
test('ultimate wildcards – handles circulars – restore', ({ end, is }) => {
|
|
676
|
-
const redact = fastRedact({ paths: ['bar.baz.*'], serialize: false })
|
|
677
|
-
const bar = { b: 2 }
|
|
678
|
-
const o = { a: 1, bar }
|
|
679
|
-
bar.baz = bar
|
|
680
|
-
o.bar.baz = o.bar
|
|
681
|
-
is(o.bar.baz, bar)
|
|
682
|
-
redact(o)
|
|
683
|
-
is(o.bar.baz, censor)
|
|
684
|
-
redact.restore(o)
|
|
685
|
-
is(o.bar.baz, bar)
|
|
686
|
-
end()
|
|
687
|
-
})
|
|
688
|
-
|
|
689
|
-
test('ultimate multi wildcards – handles circulars – restore', ({ end, is, same }) => {
|
|
690
|
-
const redact = fastRedact({ paths: ['bar.*.baz.*.b'], serialize: false })
|
|
691
|
-
const bar = { b: 2 }
|
|
692
|
-
const o = { a: 1, bar }
|
|
693
|
-
bar.baz = bar
|
|
694
|
-
o.bar.baz = o.bar
|
|
695
|
-
is(o.bar.baz, bar)
|
|
696
|
-
redact(o)
|
|
697
|
-
is(o.bar.baz.b, censor)
|
|
698
|
-
redact.restore(o)
|
|
699
|
-
same(o.bar.baz, bar)
|
|
700
|
-
end()
|
|
701
|
-
})
|
|
702
|
-
|
|
703
|
-
test('ultimate wildcards – handles circulars and cross references – restore', ({ end, is }) => {
|
|
704
|
-
const redact = fastRedact({ paths: ['bar.baz.*', 'cf.*'], serialize: false })
|
|
705
|
-
const bar = { b: 2 }
|
|
706
|
-
const o = { a: 1, bar, cf: { bar } }
|
|
707
|
-
bar.baz = bar
|
|
708
|
-
o.bar.baz = o.bar
|
|
709
|
-
is(o.bar.baz, bar)
|
|
710
|
-
is(o.cf.bar, bar)
|
|
711
|
-
redact(o)
|
|
712
|
-
is(o.bar.baz, censor)
|
|
713
|
-
is(o.cf.bar, censor)
|
|
714
|
-
redact.restore(o)
|
|
715
|
-
is(o.bar.baz, bar)
|
|
716
|
-
is(o.cf.bar, bar)
|
|
717
|
-
end()
|
|
718
|
-
})
|
|
719
|
-
|
|
720
|
-
test('static + wildcards', ({ end, is }) => {
|
|
721
|
-
const redact = fastRedact({ paths: ['a.b.c', 'a.d.*', 'a.b.z.*'], serialize: false })
|
|
722
|
-
const result = redact({ a: { b: { c: 's', z: { x: 's', y: 's' } }, d: { a: 's', b: 's', c: 's' } } })
|
|
723
|
-
|
|
724
|
-
is(result.a.b.c, censor)
|
|
725
|
-
is(result.a.d.a, censor)
|
|
726
|
-
is(result.a.d.b, censor)
|
|
727
|
-
is(result.a.d.c, censor)
|
|
728
|
-
is(result.a.b.z.x, censor)
|
|
729
|
-
is(result.a.b.z.y, censor)
|
|
730
|
-
end()
|
|
731
|
-
})
|
|
732
|
-
|
|
733
|
-
test('static + wildcards reuse', ({ end, is }) => {
|
|
734
|
-
const redact = fastRedact({ paths: ['a.b.c', 'a.d.*'], serialize: false })
|
|
735
|
-
const result = redact({ a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
736
|
-
|
|
737
|
-
is(result.a.b.c, censor)
|
|
738
|
-
is(result.a.d.a, censor)
|
|
739
|
-
is(result.a.d.b, censor)
|
|
740
|
-
is(result.a.d.c, censor)
|
|
741
|
-
|
|
742
|
-
redact.restore(result)
|
|
743
|
-
|
|
744
|
-
const result2 = redact({ a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
745
|
-
is(result2.a.b.c, censor)
|
|
746
|
-
is(result2.a.d.a, censor)
|
|
747
|
-
is(result2.a.d.b, censor)
|
|
748
|
-
is(result2.a.d.c, censor)
|
|
749
|
-
|
|
750
|
-
redact.restore(result2)
|
|
751
|
-
end()
|
|
752
|
-
})
|
|
753
|
-
|
|
754
|
-
test('parent wildcard – first position', ({ end, is }) => {
|
|
755
|
-
const redact = fastRedact({ paths: ['*.c'], serialize: false })
|
|
756
|
-
const result = redact({ b: { c: 's' }, d: { a: 's', b: 's', c: 's' } })
|
|
757
|
-
is(result.b.c, censor)
|
|
758
|
-
is(result.d.a, 's')
|
|
759
|
-
is(result.d.b, 's')
|
|
760
|
-
is(result.d.c, censor)
|
|
761
|
-
end()
|
|
762
|
-
})
|
|
763
|
-
|
|
764
|
-
test('parent wildcard – one following key', ({ end, is }) => {
|
|
765
|
-
const redact = fastRedact({ paths: ['a.*.c'], serialize: false })
|
|
766
|
-
const result = redact({ a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
767
|
-
is(result.a.b.c, censor)
|
|
768
|
-
is(result.a.d.a, 's')
|
|
769
|
-
is(result.a.d.b, 's')
|
|
770
|
-
is(result.a.d.c, censor)
|
|
771
|
-
end()
|
|
772
|
-
})
|
|
773
|
-
|
|
774
|
-
test('restore parent wildcard – one following key', ({ end, is }) => {
|
|
775
|
-
const redact = fastRedact({ paths: ['a.*.c'], serialize: false })
|
|
776
|
-
const result = redact({ a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
777
|
-
redact.restore(result)
|
|
778
|
-
is(result.a.b.c, 's')
|
|
779
|
-
is(result.a.d.a, 's')
|
|
780
|
-
is(result.a.d.b, 's')
|
|
781
|
-
is(result.a.d.c, 's')
|
|
782
|
-
end()
|
|
783
|
-
})
|
|
784
|
-
|
|
785
|
-
test('parent wildcard – one following key – reuse', ({ end, is }) => {
|
|
786
|
-
const redact = fastRedact({ paths: ['a.*.c'], serialize: false })
|
|
787
|
-
const result = redact({ a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
788
|
-
is(result.a.b.c, censor)
|
|
789
|
-
is(result.a.d.a, 's')
|
|
790
|
-
is(result.a.d.b, 's')
|
|
791
|
-
is(result.a.d.c, censor)
|
|
792
|
-
const result2 = redact({ a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
793
|
-
is(result2.a.b.c, censor)
|
|
794
|
-
is(result2.a.d.a, 's')
|
|
795
|
-
is(result2.a.d.b, 's')
|
|
796
|
-
is(result2.a.d.c, censor)
|
|
797
|
-
redact.restore(result2)
|
|
798
|
-
end()
|
|
799
|
-
})
|
|
800
|
-
|
|
801
|
-
test('parent wildcard – two following keys', ({ end, is }) => {
|
|
802
|
-
const redact = fastRedact({ paths: ['a.*.x.c'], serialize: false })
|
|
803
|
-
const result = redact({ a: { b: { x: { c: 's' } }, d: { x: { a: 's', b: 's', c: 's' } } } })
|
|
804
|
-
is(result.a.b.x.c, censor)
|
|
805
|
-
is(result.a.d.x.a, 's')
|
|
806
|
-
is(result.a.d.x.b, 's')
|
|
807
|
-
is(result.a.d.x.c, censor)
|
|
808
|
-
end()
|
|
809
|
-
})
|
|
810
|
-
|
|
811
|
-
test('multi object wildcard', ({ end, is }) => {
|
|
812
|
-
const redact = fastRedact({ paths: ['a.*.x.*.c'], serialize: false })
|
|
813
|
-
const result = redact({ a: { b: { x: { z: { c: 's' } } }, d: { x: { u: { a: 's', b: 's', c: 's' } } } } })
|
|
814
|
-
is(result.a.b.x.z.c, censor)
|
|
815
|
-
is(result.a.d.x.u.a, 's')
|
|
816
|
-
is(result.a.d.x.u.b, 's')
|
|
817
|
-
is(result.a.d.x.u.c, censor)
|
|
818
|
-
redact.restore(result)
|
|
819
|
-
is(result.a.b.x.z.c, 's')
|
|
820
|
-
is(result.a.d.x.u.a, 's')
|
|
821
|
-
is(result.a.d.x.u.b, 's')
|
|
822
|
-
is(result.a.d.x.u.c, 's')
|
|
823
|
-
end()
|
|
824
|
-
})
|
|
825
|
-
|
|
826
|
-
test('parent wildcard – two following keys – reuse', ({ end, is }) => {
|
|
827
|
-
const redact = fastRedact({ paths: ['a.*.x.c'], serialize: false })
|
|
828
|
-
const result = redact({ a: { b: { x: { c: 's' } }, d: { x: { a: 's', b: 's', c: 's' } } } })
|
|
829
|
-
is(result.a.b.x.c, censor)
|
|
830
|
-
is(result.a.d.x.a, 's')
|
|
831
|
-
is(result.a.d.x.b, 's')
|
|
832
|
-
is(result.a.d.x.c, censor)
|
|
833
|
-
redact.restore(result)
|
|
834
|
-
const result2 = redact({ a: { b: { x: { c: 's' } }, d: { x: { a: 's', b: 's', c: 's' } } } })
|
|
835
|
-
is(result2.a.b.x.c, censor)
|
|
836
|
-
is(result2.a.d.x.a, 's')
|
|
837
|
-
is(result2.a.d.x.b, 's')
|
|
838
|
-
is(result2.a.d.x.c, censor)
|
|
839
|
-
end()
|
|
840
|
-
})
|
|
841
|
-
|
|
842
|
-
test('restore parent wildcard – two following keys', ({ end, is }) => {
|
|
843
|
-
const redact = fastRedact({ paths: ['a.*.x.c'], serialize: false })
|
|
844
|
-
const result = redact({ a: { b: { x: { c: 's' } }, d: { x: { a: 's', b: 's', c: 's' } } } })
|
|
845
|
-
redact.restore(result)
|
|
846
|
-
is(result.a.b.x.c, 's')
|
|
847
|
-
is(result.a.d.x.a, 's')
|
|
848
|
-
is(result.a.d.x.b, 's')
|
|
849
|
-
is(result.a.d.x.c, 's')
|
|
850
|
-
end()
|
|
851
|
-
})
|
|
852
|
-
|
|
853
|
-
test('parent wildcard - array', ({ end, is }) => {
|
|
854
|
-
const redact = fastRedact({ paths: ['a.b[*].x'], serialize: false })
|
|
855
|
-
const result = redact({ a: { b: [{ x: 1 }, { a: 2 }], d: { a: 's', b: 's', c: 's' } } })
|
|
856
|
-
is(result.a.b[0].x, censor)
|
|
857
|
-
is(result.a.b[1].a, 2)
|
|
858
|
-
is(result.a.d.a, 's')
|
|
859
|
-
is(result.a.d.b, 's')
|
|
860
|
-
end()
|
|
861
|
-
})
|
|
862
|
-
|
|
863
|
-
test('multiple wildcards', ({ end, is }) => {
|
|
864
|
-
const redact = fastRedact({ paths: ['a[*].c[*].d'], serialize: false })
|
|
865
|
-
const obj = {
|
|
866
|
-
a: [
|
|
867
|
-
{ c: [{ d: '1', e: '2' }, { d: '1', e: '3' }, { d: '1', e: '4' }] },
|
|
868
|
-
{ c: [{ d: '1', f: '5' }] },
|
|
869
|
-
{ c: [{ d: '2', g: '6' }] }
|
|
870
|
-
]
|
|
871
|
-
}
|
|
872
|
-
const result = redact(obj)
|
|
873
|
-
is(result.a[0].c[0].d, censor)
|
|
874
|
-
is(result.a[0].c[0].e, '2')
|
|
875
|
-
is(result.a[0].c[1].d, censor)
|
|
876
|
-
is(result.a[0].c[1].e, '3')
|
|
877
|
-
is(result.a[0].c[2].d, censor)
|
|
878
|
-
is(result.a[0].c[2].e, '4')
|
|
879
|
-
is(result.a[1].c[0].d, censor)
|
|
880
|
-
is(result.a[1].c[0].f, '5')
|
|
881
|
-
is(result.a[2].c[0].d, censor)
|
|
882
|
-
is(result.a[2].c[0].g, '6')
|
|
883
|
-
redact.restore(result)
|
|
884
|
-
is(result.a[0].c[0].d, '1')
|
|
885
|
-
is(result.a[0].c[0].e, '2')
|
|
886
|
-
is(result.a[0].c[1].d, '1')
|
|
887
|
-
is(result.a[0].c[1].e, '3')
|
|
888
|
-
is(result.a[0].c[2].d, '1')
|
|
889
|
-
is(result.a[0].c[2].e, '4')
|
|
890
|
-
is(result.a[1].c[0].d, '1')
|
|
891
|
-
is(result.a[1].c[0].f, '5')
|
|
892
|
-
is(result.a[2].c[0].d, '2')
|
|
893
|
-
is(result.a[2].c[0].g, '6')
|
|
894
|
-
end()
|
|
895
|
-
})
|
|
896
|
-
|
|
897
|
-
test('multiple wildcards - censor function', ({ end, is }) => {
|
|
898
|
-
const redact = fastRedact({ paths: ['a[*].c[*].d'], censor: censorFct, serialize: false })
|
|
899
|
-
const obj = {
|
|
900
|
-
a: [
|
|
901
|
-
{ c: [{ d: '1', e: '2' }, { d: '1', e: '3' }, { d: '1', e: '4' }] },
|
|
902
|
-
{ c: [{ d: '1', f: '5' }] },
|
|
903
|
-
{ c: [{ d: '2', g: '6' }] }
|
|
904
|
-
]
|
|
905
|
-
}
|
|
906
|
-
const result = redact(obj)
|
|
907
|
-
is(result.a[0].c[0].d, 'xxx1')
|
|
908
|
-
is(result.a[0].c[0].e, '2')
|
|
909
|
-
is(result.a[0].c[1].d, 'xxx1')
|
|
910
|
-
is(result.a[0].c[1].e, '3')
|
|
911
|
-
is(result.a[0].c[2].d, 'xxx1')
|
|
912
|
-
is(result.a[0].c[2].e, '4')
|
|
913
|
-
is(result.a[1].c[0].d, 'xxx1')
|
|
914
|
-
is(result.a[1].c[0].f, '5')
|
|
915
|
-
is(result.a[2].c[0].d, 'xxx2')
|
|
916
|
-
is(result.a[2].c[0].g, '6')
|
|
917
|
-
end()
|
|
918
|
-
})
|
|
919
|
-
|
|
920
|
-
test('multiple wildcards end', ({ end, is, same }) => {
|
|
921
|
-
const redact = fastRedact({ paths: ['a[*].c.d[*]'], serialize: false })
|
|
922
|
-
const obj = {
|
|
923
|
-
a: [
|
|
924
|
-
{ c: { d: [ '1', '2' ], e: '3' } },
|
|
925
|
-
{ c: { d: [ '1' ], f: '4' } },
|
|
926
|
-
{ c: { d: [ '1' ], g: '5' } }
|
|
927
|
-
]
|
|
928
|
-
}
|
|
929
|
-
const result = redact(obj)
|
|
930
|
-
same(result.a[0].c.d, [censor, censor])
|
|
931
|
-
is(result.a[0].c.e, '3')
|
|
932
|
-
same(result.a[1].c.d, [censor])
|
|
933
|
-
is(result.a[1].c.f, '4')
|
|
934
|
-
same(result.a[2].c.d, [censor])
|
|
935
|
-
is(result.a[2].c.g, '5')
|
|
936
|
-
end()
|
|
937
|
-
})
|
|
938
|
-
|
|
939
|
-
test('multiple wildcards depth after n wildcard', ({ end, is }) => {
|
|
940
|
-
const redact = fastRedact({ paths: ['a[*].c.d[*].i'], serialize: false })
|
|
941
|
-
const obj = {
|
|
942
|
-
a: [
|
|
943
|
-
{ c: { d: [ { i: '1', j: '2' } ], e: '3' } },
|
|
944
|
-
{ c: { d: [ { i: '1', j: '2' }, { i: '1', j: '3' } ], f: '4' } },
|
|
945
|
-
{ c: { d: [ { i: '1', j: '2' } ], g: '5' } }
|
|
946
|
-
]
|
|
947
|
-
}
|
|
948
|
-
const result = redact(obj)
|
|
949
|
-
is(result.a[0].c.d[0].i, censor)
|
|
950
|
-
is(result.a[0].c.d[0].j, '2')
|
|
951
|
-
is(result.a[0].c.e, '3')
|
|
952
|
-
is(result.a[1].c.d[0].i, censor)
|
|
953
|
-
is(result.a[1].c.d[0].j, '2')
|
|
954
|
-
is(result.a[1].c.d[1].i, censor)
|
|
955
|
-
is(result.a[1].c.d[1].j, '3')
|
|
956
|
-
is(result.a[1].c.f, '4')
|
|
957
|
-
is(result.a[2].c.d[0].i, censor)
|
|
958
|
-
is(result.a[2].c.d[0].j, '2')
|
|
959
|
-
is(result.a[2].c.g, '5')
|
|
960
|
-
end()
|
|
961
|
-
})
|
|
962
|
-
|
|
963
|
-
test('parent wildcards – array – single index', ({ end, same }) => {
|
|
964
|
-
const redact = fastRedact({ paths: ['insideArray.like[3].*.foo'], serialize: false })
|
|
965
|
-
same(redact({ insideArray: { like: ['a', 'b', 'c', { this: { foo: 'meow' } }] } }), { insideArray: { like: ['a', 'b', 'c', { this: { foo: censor } }] } })
|
|
966
|
-
end()
|
|
967
|
-
})
|
|
968
|
-
|
|
969
|
-
test('parent wildcards - handles null proto objects', ({ end, is }) => {
|
|
970
|
-
const redact = fastRedact({ paths: ['a.*.c'], serialize: false })
|
|
971
|
-
const result = redact({ __proto__: null, a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
972
|
-
is(result.a.b.c, censor)
|
|
973
|
-
end()
|
|
974
|
-
})
|
|
975
|
-
|
|
976
|
-
test('parent wildcards - handles paths that do not match object structure', ({ end, same }) => {
|
|
977
|
-
const redact = fastRedact({ paths: ['a.*.y.z'], serialize: false })
|
|
978
|
-
same(redact({ a: { b: { c: 's' } } }), { a: { b: { c: 's' } } })
|
|
979
|
-
end()
|
|
980
|
-
})
|
|
981
|
-
|
|
982
|
-
test('parent wildcards - gracefully handles primitives that match intermediate keys in paths', ({ end, same }) => {
|
|
983
|
-
const redact = fastRedact({ paths: ['a.*.c'], serialize: false })
|
|
984
|
-
same(redact({ a: { b: null } }), { a: { b: null } })
|
|
985
|
-
same(redact({ a: { b: 's' } }), { a: { b: 's' } })
|
|
986
|
-
same(redact({ a: { b: 1 } }), { a: { b: 1 } })
|
|
987
|
-
same(redact({ a: { b: undefined } }), { a: { b: undefined } })
|
|
988
|
-
same(redact({ a: { b: true } }), { a: { b: true } })
|
|
989
|
-
const sym = Symbol('sym')
|
|
990
|
-
same(redact({ a: { b: sym } }), { a: { b: sym } })
|
|
991
|
-
end()
|
|
992
|
-
})
|
|
993
|
-
|
|
994
|
-
test('parent wildcards – handles circulars', ({ end, same }) => {
|
|
995
|
-
const redact = fastRedact({ paths: ['x.*.baz'], serialize: false })
|
|
996
|
-
const bar = { b: 2 }
|
|
997
|
-
const o = { x: { a: 1, bar } }
|
|
998
|
-
bar.baz = bar
|
|
999
|
-
o.x.bar.baz = o.x.bar
|
|
1000
|
-
same(redact(o), { x: { a: 1, bar: { b: 2, baz: censor } } })
|
|
1001
|
-
end()
|
|
1002
|
-
})
|
|
1003
|
-
|
|
1004
|
-
test('parent wildcards – handles circulars – restore', ({ end, is }) => {
|
|
1005
|
-
const redact = fastRedact({ paths: ['x.*.baz'], serialize: false })
|
|
1006
|
-
const bar = { b: 2 }
|
|
1007
|
-
const o = { x: { a: 1, bar } }
|
|
1008
|
-
bar.baz = bar
|
|
1009
|
-
o.x.bar.baz = o.x.bar
|
|
1010
|
-
is(o.x.bar.baz, bar)
|
|
1011
|
-
redact(o)
|
|
1012
|
-
is(o.x.a, 1)
|
|
1013
|
-
is(o.x.bar.baz, censor)
|
|
1014
|
-
redact.restore(o)
|
|
1015
|
-
is(o.x.bar.baz, bar)
|
|
1016
|
-
end()
|
|
1017
|
-
})
|
|
1018
|
-
|
|
1019
|
-
test('parent wildcards – handles circulars and cross references – restore', ({ end, is }) => {
|
|
1020
|
-
const redact = fastRedact({ paths: ['x.*.baz', 'x.*.cf.bar'], serialize: false })
|
|
1021
|
-
const bar = { b: 2 }
|
|
1022
|
-
const o = { x: { a: 1, bar, y: { cf: { bar } } } }
|
|
1023
|
-
bar.baz = bar
|
|
1024
|
-
o.x.bar.baz = o.x.bar
|
|
1025
|
-
is(o.x.bar.baz, bar)
|
|
1026
|
-
is(o.x.y.cf.bar, bar)
|
|
1027
|
-
redact(o)
|
|
1028
|
-
is(o.x.bar.baz, censor)
|
|
1029
|
-
is(o.x.y.cf.bar, censor)
|
|
1030
|
-
redact.restore(o)
|
|
1031
|
-
is(o.x.bar.baz, bar)
|
|
1032
|
-
is(o.x.y.cf.bar, bar)
|
|
1033
|
-
end()
|
|
1034
|
-
})
|
|
1035
|
-
|
|
1036
|
-
test('parent wildcards – handles missing paths', ({ end, is }) => {
|
|
1037
|
-
const redact = fastRedact({ paths: ['z.*.baz'] })
|
|
1038
|
-
const o = { a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } }
|
|
1039
|
-
is(redact(o), JSON.stringify(o))
|
|
1040
|
-
end()
|
|
1041
|
-
})
|
|
1042
|
-
|
|
1043
|
-
test('ultimate wildcards – handles missing paths', ({ end, is }) => {
|
|
1044
|
-
const redact = fastRedact({ paths: ['z.*'] })
|
|
1045
|
-
const o = { a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } }
|
|
1046
|
-
is(redact(o), JSON.stringify(o))
|
|
1047
|
-
end()
|
|
1048
|
-
})
|
|
1049
|
-
|
|
1050
|
-
test('parent wildcards – removes during serialization instead of redacting when remove option is true', ({ end, is }) => {
|
|
1051
|
-
const redact = fastRedact({ paths: ['a.*.c'], remove: true })
|
|
1052
|
-
const o = { a: { b: { c: 'c' }, x: { c: 1 } } }
|
|
1053
|
-
is(redact(o), `{"a":{"b":{},"x":{}}}`)
|
|
1054
|
-
end()
|
|
1055
|
-
})
|
|
1056
|
-
|
|
1057
|
-
test('ultimate wildcards – removes during serialization instead of redacting when remove option is true', ({ end, is }) => {
|
|
1058
|
-
const redact = fastRedact({ paths: ['a.b.*'], remove: true })
|
|
1059
|
-
const o = { a: { b: { c: 'c' }, x: { c: 1 } } }
|
|
1060
|
-
is(redact(o), `{"a":{"b":{},"x":{"c":1}}}`)
|
|
1061
|
-
end()
|
|
1062
|
-
})
|
|
1063
|
-
|
|
1064
|
-
test('supports leading bracket notation', ({ end, is }) => {
|
|
1065
|
-
const redact = fastRedact({ paths: ['["a"].b.c'] })
|
|
1066
|
-
const o = { a: { b: { c: 'd' } } }
|
|
1067
|
-
is(redact(o), `{"a":{"b":{"c":"${censor}"}}}`)
|
|
1068
|
-
end()
|
|
1069
|
-
})
|
|
1070
|
-
|
|
1071
|
-
test('supports leading bracket notation containing non-legal keyword characters', ({ end, is }) => {
|
|
1072
|
-
const redact = fastRedact({ paths: ['["a-x"].b.c'] })
|
|
1073
|
-
const o = { 'a-x': { b: { c: 'd' } } }
|
|
1074
|
-
is(redact(o), `{"a-x":{"b":{"c":"${censor}"}}}`)
|
|
1075
|
-
end()
|
|
1076
|
-
})
|
|
1077
|
-
|
|
1078
|
-
test('supports single leading bracket', ({ end, is }) => {
|
|
1079
|
-
const censor = 'test'
|
|
1080
|
-
const redact = fastRedact({ paths: ['["a"]'], censor, serialize: false })
|
|
1081
|
-
is(redact({ a: 'a' }).a, censor)
|
|
1082
|
-
end()
|
|
1083
|
-
})
|
|
1084
|
-
|
|
1085
|
-
test('supports single leading bracket containing non-legal keyword characters', ({ end, is }) => {
|
|
1086
|
-
const censor = 'test'
|
|
1087
|
-
const redact = fastRedact({ paths: ['["a-x"]'], censor, serialize: false })
|
|
1088
|
-
is(redact({ 'a-x': 'a' })['a-x'], censor)
|
|
1089
|
-
end()
|
|
1090
|
-
})
|
|
1091
|
-
|
|
1092
|
-
test('(leading brackets) ultimate wildcards – handles circulars and cross references – restore', ({ end, is }) => {
|
|
1093
|
-
const redact = fastRedact({ paths: ['bar.baz.*', 'cf.*'], serialize: false })
|
|
1094
|
-
const bar = { b: 2 }
|
|
1095
|
-
const o = { a: 1, bar, cf: { bar } }
|
|
1096
|
-
bar.baz = bar
|
|
1097
|
-
o.bar.baz = o.bar
|
|
1098
|
-
is(o.bar.baz, bar)
|
|
1099
|
-
is(o.cf.bar, bar)
|
|
1100
|
-
redact(o)
|
|
1101
|
-
is(o.bar.baz, censor)
|
|
1102
|
-
is(o.cf.bar, censor)
|
|
1103
|
-
redact.restore(o)
|
|
1104
|
-
is(o.bar.baz, bar)
|
|
1105
|
-
is(o.cf.bar, bar)
|
|
1106
|
-
end()
|
|
1107
|
-
})
|
|
1108
|
-
|
|
1109
|
-
test('(leading brackets) parent wildcards – handles circulars and cross references – restore', ({ end, is }) => {
|
|
1110
|
-
const redact = fastRedact({ paths: ['["x"].*.baz', '["x"].*.cf.bar'], serialize: false })
|
|
1111
|
-
const bar = { b: 2 }
|
|
1112
|
-
const o = { x: { a: 1, bar, y: { cf: { bar } } } }
|
|
1113
|
-
bar.baz = bar
|
|
1114
|
-
o.x.bar.baz = o.x.bar
|
|
1115
|
-
is(o.x.bar.baz, bar)
|
|
1116
|
-
is(o.x.y.cf.bar, bar)
|
|
1117
|
-
redact(o)
|
|
1118
|
-
is(o.x.bar.baz, censor)
|
|
1119
|
-
is(o.x.y.cf.bar, censor)
|
|
1120
|
-
redact.restore(o)
|
|
1121
|
-
is(o.x.bar.baz, bar)
|
|
1122
|
-
is(o.x.y.cf.bar, bar)
|
|
1123
|
-
end()
|
|
1124
|
-
})
|
|
1125
|
-
|
|
1126
|
-
test('(leading brackets) ultimate wildcards – handles missing paths', ({ end, is }) => {
|
|
1127
|
-
const redact = fastRedact({ paths: ['["z"].*'] })
|
|
1128
|
-
const o = { a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } }
|
|
1129
|
-
is(redact(o), JSON.stringify(o))
|
|
1130
|
-
end()
|
|
1131
|
-
})
|
|
1132
|
-
|
|
1133
|
-
test('(leading brackets) static + wildcards reuse', ({ end, is }) => {
|
|
1134
|
-
const redact = fastRedact({ paths: ['["a"].b.c', '["a"].d.*'], serialize: false })
|
|
1135
|
-
const result = redact({ a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
1136
|
-
|
|
1137
|
-
is(result.a.b.c, censor)
|
|
1138
|
-
is(result.a.d.a, censor)
|
|
1139
|
-
is(result.a.d.b, censor)
|
|
1140
|
-
is(result.a.d.c, censor)
|
|
1141
|
-
|
|
1142
|
-
redact.restore(result)
|
|
1143
|
-
|
|
1144
|
-
const result2 = redact({ a: { b: { c: 's' }, d: { a: 's', b: 's', c: 's' } } })
|
|
1145
|
-
is(result2.a.b.c, censor)
|
|
1146
|
-
is(result2.a.d.a, censor)
|
|
1147
|
-
is(result2.a.d.b, censor)
|
|
1148
|
-
is(result2.a.d.c, censor)
|
|
1149
|
-
|
|
1150
|
-
redact.restore(result2)
|
|
1151
|
-
end()
|
|
1152
|
-
})
|
|
1153
|
-
|
|
1154
|
-
test('correctly restores original object when a path does not match object', ({ end, is }) => {
|
|
1155
|
-
const redact = fastRedact({ paths: ['foo.bar'], strict: false })
|
|
1156
|
-
const o = {}
|
|
1157
|
-
is(redact({ foo: o }), '{"foo":{}}')
|
|
1158
|
-
is(o.hasOwnProperty('bar'), false)
|
|
1159
|
-
end()
|
|
1160
|
-
})
|
|
1161
|
-
|
|
1162
|
-
test('correctly restores original object when a matching path has value of `undefined`', ({ end, is }) => {
|
|
1163
|
-
const redact = fastRedact({ paths: ['foo.bar'], strict: false })
|
|
1164
|
-
const o = { bar: undefined }
|
|
1165
|
-
is(redact({ foo: o }), '{"foo":{}}')
|
|
1166
|
-
is(o.hasOwnProperty('bar'), true)
|
|
1167
|
-
is(o.bar, undefined)
|
|
1168
|
-
end()
|
|
1169
|
-
})
|
|
1170
|
-
|
|
1171
|
-
test('correctly restores keys matching a static path and a wildcard', ({ end, is }) => {
|
|
1172
|
-
const redact = fastRedact({
|
|
1173
|
-
paths: ['a', '*.b', 'x.b'],
|
|
1174
|
-
serialize: false
|
|
1175
|
-
})
|
|
1176
|
-
const o = { x: { a: 'a', b: 'b' } }
|
|
1177
|
-
redact(o)
|
|
1178
|
-
is(o.x.a, 'a')
|
|
1179
|
-
is(o.x.b, '[REDACTED]')
|
|
1180
|
-
redact.restore(o)
|
|
1181
|
-
is(o.x.a, 'a')
|
|
1182
|
-
is(o.x.b, 'b')
|
|
1183
|
-
end()
|
|
1184
|
-
})
|
|
1185
|
-
|
|
1186
|
-
test('correctly restores keys matching multiple wildcards', ({ end, is }) => {
|
|
1187
|
-
const redact = fastRedact({
|
|
1188
|
-
paths: ['a', '*.b', 'x.*', 'y.*.z'],
|
|
1189
|
-
serialize: false
|
|
1190
|
-
})
|
|
1191
|
-
const o = { x: { a: 'a', b: 'b' }, y: { f: { z: 'z' } } }
|
|
1192
|
-
redact(o)
|
|
1193
|
-
is(o.x.a, '[REDACTED]')
|
|
1194
|
-
is(o.x.b, '[REDACTED]')
|
|
1195
|
-
is(o.y.f.z, '[REDACTED]')
|
|
1196
|
-
redact.restore(o)
|
|
1197
|
-
is(o.x.a, 'a')
|
|
1198
|
-
is(o.x.b, 'b')
|
|
1199
|
-
is(o.y.f.z, 'z')
|
|
1200
|
-
end()
|
|
1201
|
-
})
|
|
1202
|
-
|
|
1203
|
-
test('handles multiple paths with leading brackets', ({ end, is }) => {
|
|
1204
|
-
const redact = fastRedact({ paths: ['["x-y"]', '["y-x"]'] })
|
|
1205
|
-
const o = { 'x-y': 'test', 'y-x': 'test2' }
|
|
1206
|
-
is(redact(o), '{"x-y":"[REDACTED]","y-x":"[REDACTED]"}')
|
|
1207
|
-
end()
|
|
1208
|
-
})
|
|
1209
|
-
|
|
1210
|
-
test('handles objects with and then without target paths', ({ end, is }) => {
|
|
1211
|
-
const redact = fastRedact({ paths: ['test'] })
|
|
1212
|
-
const o1 = { test: 'check' }
|
|
1213
|
-
const o2 = {}
|
|
1214
|
-
is(redact(o1), '{"test":"[REDACTED]"}')
|
|
1215
|
-
is(redact(o2), '{}')
|
|
1216
|
-
// run each check twice to ensure no mutations
|
|
1217
|
-
is(redact(o1), '{"test":"[REDACTED]"}')
|
|
1218
|
-
is(redact(o2), '{}')
|
|
1219
|
-
is('test' in o1, true)
|
|
1220
|
-
is('test' in o2, false)
|
|
1221
|
-
end()
|
|
1222
|
-
})
|
|
1223
|
-
|
|
1224
|
-
test('handles leading wildcards and null values', ({ end, is }) => {
|
|
1225
|
-
const redact = fastRedact({ paths: ['*.test'] })
|
|
1226
|
-
const o = { prop: null }
|
|
1227
|
-
is(redact(o), '{"prop":null}')
|
|
1228
|
-
is(o.prop, null)
|
|
1229
|
-
end()
|
|
1230
|
-
})
|
|
1231
|
-
|
|
1232
|
-
test('handles keys with dots', ({ end, is }) => {
|
|
1233
|
-
const redactSingleQ = fastRedact({ paths: [`a['b.c']`], serialize: false })
|
|
1234
|
-
const redactDoubleQ = fastRedact({ paths: [`a["b.c"]`], serialize: false })
|
|
1235
|
-
const redactBacktickQ = fastRedact({ paths: ['a[`b.c`]'], serialize: false })
|
|
1236
|
-
const redactNum = fastRedact({ paths: [`a[-1.2]`], serialize: false })
|
|
1237
|
-
const redactLeading = fastRedact({ paths: [`["b.c"]`], serialize: false })
|
|
1238
|
-
is(redactSingleQ({ a: { 'b.c': 'x', '-1.2': 'x' } }).a['b.c'], censor)
|
|
1239
|
-
is(redactDoubleQ({ a: { 'b.c': 'x', '-1.2': 'x' } }).a['b.c'], censor)
|
|
1240
|
-
is(redactBacktickQ({ a: { 'b.c': 'x', '-1.2': 'x' } }).a['b.c'], censor)
|
|
1241
|
-
is(redactNum({ a: { 'b.c': 'x', '-1.2': 'x' } }).a['-1.2'], censor)
|
|
1242
|
-
is(redactLeading({ 'b.c': 'x', '-1.2': 'x' })['b.c'], censor)
|
|
1243
|
-
end()
|
|
1244
|
-
})
|
|
1245
|
-
|
|
1246
|
-
test('handles multi wildcards within arrays', ({ end, is }) => {
|
|
1247
|
-
const redact = fastRedact({
|
|
1248
|
-
paths: ['a[*].x.d[*].i.*']
|
|
1249
|
-
})
|
|
1250
|
-
const o = {
|
|
1251
|
-
a: [ { x: { d: [ { j: { i: 'R' } }, { i: 'R', j: 'NR' } ] } } ]
|
|
1252
|
-
}
|
|
1253
|
-
is(redact(o), '{"a":[{"x":{"d":["[REDACTED]","[REDACTED]"]}}]}')
|
|
1254
|
-
end()
|
|
1255
|
-
})
|
|
1256
|
-
|
|
1257
|
-
test('handles multi wildcards within arrays with a censorFct', ({ end, is }) => {
|
|
1258
|
-
const redact = fastRedact({
|
|
1259
|
-
paths: ['a[*].x.d[*].i.*.i'],
|
|
1260
|
-
censor: censorWithPath
|
|
1261
|
-
})
|
|
1262
|
-
const o = {
|
|
1263
|
-
a: [
|
|
1264
|
-
{ x: { d: [ { i: 'R', j: 'NR' } ] } }
|
|
1265
|
-
]
|
|
1266
|
-
}
|
|
1267
|
-
is(redact(o), '{"a":[{"x":{"d":[{"i":"a.0.x.d.*.i.*.i xxxR","j":"NR"}]}}]}')
|
|
1268
|
-
end()
|
|
1269
|
-
})
|
|
1270
|
-
|
|
1271
|
-
test('handles multi wildcards within arrays with undefined values', ({ end, is }) => {
|
|
1272
|
-
const redact = fastRedact({
|
|
1273
|
-
paths: ['a[*].x.d[*].i.*.i']
|
|
1274
|
-
})
|
|
1275
|
-
const o = {
|
|
1276
|
-
a: [
|
|
1277
|
-
{ x: { d: [ { i: undefined, j: 'NR' } ] } }
|
|
1278
|
-
]
|
|
1279
|
-
}
|
|
1280
|
-
is(redact(o), '{"a":[{"x":{"d":[{"i":"[REDACTED]","j":"NR"}]}}]}')
|
|
1281
|
-
end()
|
|
1282
|
-
})
|
|
1283
|
-
|
|
1284
|
-
test('handles multi wildcards with objects containing nulls', ({ end, is }) => {
|
|
1285
|
-
const redact = fastRedact({
|
|
1286
|
-
paths: ['*.*.x'],
|
|
1287
|
-
serialize: false,
|
|
1288
|
-
censor: '[REDACTED]'
|
|
1289
|
-
})
|
|
1290
|
-
const o = { a: { b: null } }
|
|
1291
|
-
is(redact(o), o)
|
|
1292
|
-
end()
|
|
1293
|
-
})
|
|
1294
|
-
|
|
1295
|
-
test('handles multi wildcards with pattern repetition', ({ end, is }) => {
|
|
1296
|
-
const redact = fastRedact({
|
|
1297
|
-
paths: ['*.d', '*.*.d', '*.*.*.d']
|
|
1298
|
-
})
|
|
1299
|
-
const o = {
|
|
1300
|
-
x: { c: { d: 'hide me', e: 'leave me be' } },
|
|
1301
|
-
y: { c: { d: 'and me', f: 'I want to live' } },
|
|
1302
|
-
z: { c: { d: 'and also I', g: 'I want to run in a stream' } }
|
|
1303
|
-
}
|
|
1304
|
-
is(redact(o), '{"x":{"c":{"d":"[REDACTED]","e":"leave me be"}},"y":{"c":{"d":"[REDACTED]","f":"I want to live"}},"z":{"c":{"d":"[REDACTED]","g":"I want to run in a stream"}}}')
|
|
1305
|
-
end()
|
|
1306
|
-
})
|
|
1307
|
-
|
|
1308
|
-
test('restores multi wildcards with pattern repetition', ({ end, is }) => {
|
|
1309
|
-
const redact = fastRedact({
|
|
1310
|
-
paths: ['*.d', '*.*.d', '*.*.*.d']
|
|
1311
|
-
})
|
|
1312
|
-
const o = {
|
|
1313
|
-
x: { c: { d: 'hide me', e: 'leave me be' } },
|
|
1314
|
-
y: { c: { d: 'and me', f: 'I want to live' } },
|
|
1315
|
-
z: { c: { d: 'and also I', g: 'I want to run in a stream' } }
|
|
1316
|
-
}
|
|
1317
|
-
redact(o)
|
|
1318
|
-
is(o.x.c.d, 'hide me')
|
|
1319
|
-
is(o.y.c.d, 'and me')
|
|
1320
|
-
is(o.z.c.d, 'and also I')
|
|
1321
|
-
end()
|
|
1322
|
-
})
|
|
1323
|
-
|
|
1324
|
-
test('multi level wildcards with level > 3', ({ end, is }) => {
|
|
1325
|
-
const redact = fastRedact({ paths: ['*.*.*.c', '*.*.*.*.c'] })
|
|
1326
|
-
const o = {
|
|
1327
|
-
a: {
|
|
1328
|
-
b: {
|
|
1329
|
-
x: {
|
|
1330
|
-
c: 's'
|
|
1331
|
-
}
|
|
1332
|
-
},
|
|
1333
|
-
d: {
|
|
1334
|
-
x: {
|
|
1335
|
-
u: {
|
|
1336
|
-
a: 's',
|
|
1337
|
-
b: 's',
|
|
1338
|
-
c: 's'
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
is(redact(o), '{"a":{"b":{"x":{"c":"[REDACTED]"}},"d":{"x":{"u":{"a":"s","b":"s","c":"[REDACTED]"}}}}}')
|
|
1345
|
-
end()
|
|
1346
|
-
})
|
|
1347
|
-
|
|
1348
|
-
test('multi level wildcards at nested level inside object', ({ end, is }) => {
|
|
1349
|
-
const redact = fastRedact({ paths: ['a.*.*.c', 'a.d.*.*.c'] })
|
|
1350
|
-
const o = {
|
|
1351
|
-
a: {
|
|
1352
|
-
b: {
|
|
1353
|
-
x: {
|
|
1354
|
-
c: 's'
|
|
1355
|
-
}
|
|
1356
|
-
},
|
|
1357
|
-
d: {
|
|
1358
|
-
x: {
|
|
1359
|
-
u: {
|
|
1360
|
-
a: 's',
|
|
1361
|
-
b: 's',
|
|
1362
|
-
c: 's'
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
is(redact(o), '{"a":{"b":{"x":{"c":"[REDACTED]"}},"d":{"x":{"u":{"a":"s","b":"s","c":"[REDACTED]"}}}}}')
|
|
1369
|
-
end()
|
|
1370
|
-
})
|
|
1371
|
-
|
|
1372
|
-
test('multi level wildcards with level > 3 with serialize false', ({ end, is }) => {
|
|
1373
|
-
const redact = fastRedact({ paths: ['*.*.*.c', '*.*.*.*.c'], serialize: false })
|
|
1374
|
-
const result = redact({ a: { b: { x: { c: 's' } }, d: { x: { u: { a: 's', b: 's', c: 's' } } } } })
|
|
1375
|
-
is(result.a.b.x.c, censor)
|
|
1376
|
-
is(result.a.d.x.u.a, 's')
|
|
1377
|
-
is(result.a.d.x.u.b, 's')
|
|
1378
|
-
is(result.a.d.x.u.c, censor)
|
|
1379
|
-
redact.restore(result)
|
|
1380
|
-
is(result.a.b.x.c, 's')
|
|
1381
|
-
is(result.a.d.x.u.a, 's')
|
|
1382
|
-
is(result.a.d.x.u.b, 's')
|
|
1383
|
-
is(result.a.d.x.u.c, 's')
|
|
1384
|
-
end()
|
|
1385
|
-
})
|
|
1386
|
-
|
|
1387
|
-
test('multi level wildcards at nested level inside object with serialize false', ({ end, is }) => {
|
|
1388
|
-
const redact = fastRedact({ paths: ['a.*.*.c', 'a.d.*.*.c'], serialize: false })
|
|
1389
|
-
const result = redact({ a: { b: { x: { c: 's' } }, d: { x: { u: { a: 's', b: 's', c: 's' } } } } })
|
|
1390
|
-
is(result.a.b.x.c, censor)
|
|
1391
|
-
is(result.a.d.x.u.a, 's')
|
|
1392
|
-
is(result.a.d.x.u.b, 's')
|
|
1393
|
-
is(result.a.d.x.u.c, censor)
|
|
1394
|
-
redact.restore(result)
|
|
1395
|
-
is(result.a.b.x.c, 's')
|
|
1396
|
-
is(result.a.d.x.u.a, 's')
|
|
1397
|
-
is(result.a.d.x.u.b, 's')
|
|
1398
|
-
is(result.a.d.x.u.c, 's')
|
|
1399
|
-
end()
|
|
1400
|
-
})
|
|
1401
|
-
|
|
1402
|
-
test('restores nested wildcard values', ({ end, is }) => {
|
|
1403
|
-
const o = { a: { b: [{ c: [
|
|
1404
|
-
{ d: '123' },
|
|
1405
|
-
{ d: '456' }
|
|
1406
|
-
] }] } }
|
|
1407
|
-
|
|
1408
|
-
const censor = 'censor'
|
|
1409
|
-
const paths = ['a.b[*].c[*].d']
|
|
1410
|
-
const redact = fastRedact({ paths, censor, serialize: false })
|
|
1411
|
-
|
|
1412
|
-
redact(o)
|
|
1413
|
-
is(o.a.b[0].c[0].d, censor)
|
|
1414
|
-
is(o.a.b[0].c[1].d, censor)
|
|
1415
|
-
redact.restore(o)
|
|
1416
|
-
is(o.a.b[0].c[0].d, '123')
|
|
1417
|
-
is(o.a.b[0].c[1].d, '456')
|
|
1418
|
-
end()
|
|
1419
|
-
})
|
|
1420
|
-
|
|
1421
|
-
test('restores multi nested wildcard values', ({ end, is }) => {
|
|
1422
|
-
const o = {
|
|
1423
|
-
a: {
|
|
1424
|
-
b1: {
|
|
1425
|
-
c1: {
|
|
1426
|
-
d1: { e: '123' },
|
|
1427
|
-
d2: { e: '456' }
|
|
1428
|
-
},
|
|
1429
|
-
c2: {
|
|
1430
|
-
d1: { e: '789' },
|
|
1431
|
-
d2: { e: '012' }
|
|
1432
|
-
}
|
|
1433
|
-
},
|
|
1434
|
-
b2: {
|
|
1435
|
-
c1: {
|
|
1436
|
-
d1: { e: '345' },
|
|
1437
|
-
d2: { e: '678' }
|
|
1438
|
-
},
|
|
1439
|
-
c2: {
|
|
1440
|
-
d1: { e: '901' },
|
|
1441
|
-
d2: { e: '234' }
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
const o2 = {
|
|
1447
|
-
a: {
|
|
1448
|
-
b1: {
|
|
1449
|
-
c1: {
|
|
1450
|
-
d1: { e: '123' },
|
|
1451
|
-
d2: { e: '456' }
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
const censor = 'censor'
|
|
1458
|
-
const paths = ['a.*.*.*.e']
|
|
1459
|
-
const redact = fastRedact({ paths, censor, serialize: false })
|
|
1460
|
-
|
|
1461
|
-
redact(o)
|
|
1462
|
-
is(o.a.b1.c1.d1.e, censor)
|
|
1463
|
-
is(o.a.b1.c1.d2.e, censor)
|
|
1464
|
-
is(o.a.b1.c2.d1.e, censor)
|
|
1465
|
-
is(o.a.b1.c2.d2.e, censor)
|
|
1466
|
-
is(o.a.b2.c1.d1.e, censor)
|
|
1467
|
-
is(o.a.b2.c1.d2.e, censor)
|
|
1468
|
-
is(o.a.b2.c2.d1.e, censor)
|
|
1469
|
-
is(o.a.b2.c2.d2.e, censor)
|
|
1470
|
-
redact.restore(o)
|
|
1471
|
-
is(o.a.b1.c1.d1.e, '123')
|
|
1472
|
-
is(o.a.b1.c1.d2.e, '456')
|
|
1473
|
-
is(o.a.b1.c2.d1.e, '789')
|
|
1474
|
-
is(o.a.b1.c2.d2.e, '012')
|
|
1475
|
-
is(o.a.b2.c1.d1.e, '345')
|
|
1476
|
-
is(o.a.b2.c1.d2.e, '678')
|
|
1477
|
-
is(o.a.b2.c2.d1.e, '901')
|
|
1478
|
-
is(o.a.b2.c2.d2.e, '234')
|
|
1479
|
-
|
|
1480
|
-
redact(o2)
|
|
1481
|
-
is(o2.a.b1.c1.d1.e, censor)
|
|
1482
|
-
is(o2.a.b1.c1.d2.e, censor)
|
|
1483
|
-
redact.restore(o2)
|
|
1484
|
-
is(o2.a.b1.c1.d1.e, '123')
|
|
1485
|
-
is(o2.a.b1.c1.d2.e, '456')
|
|
1486
|
-
|
|
1487
|
-
end()
|
|
1488
|
-
})
|
|
1489
|
-
|
|
1490
|
-
test('redact multi trailing wildcard', ({ end, is }) => {
|
|
1491
|
-
const o = { a: { b: { c: 'value' } } }
|
|
1492
|
-
|
|
1493
|
-
const censor = 'censor'
|
|
1494
|
-
const paths = ['a.*.*']
|
|
1495
|
-
const redact = fastRedact({ paths, censor, serialize: false })
|
|
1496
|
-
|
|
1497
|
-
redact(o)
|
|
1498
|
-
is(o.a.b.c, censor)
|
|
1499
|
-
redact.restore(o)
|
|
1500
|
-
is(o.a.b.c, 'value')
|
|
1501
|
-
end()
|
|
1502
|
-
})
|