davidmarkclements / fast-redact

very fast object redaction
MIT License
284 stars 30 forks source link

Redaction is mutating objects in v3.4.0 #70

Closed steven-voltz closed 7 months ago

steven-voltz commented 8 months ago

When upgrading to v3.4.0, I noticed that redaction was causing the actual objects being redacted to be mutated, such that values are redacted beyond the scope of the logging.

To reproduce:

import pino from "pino";

const p = pino({
  level: process.env.LOG_LEVEL || "info",
  redact: [
    "items[*].name",
  ],
});

const toRedact = { items: [{ name: "John" }] };
const logger = p.child({ property: "value" });

logger.info(toRedact);

console.log('Printing response', toRedact);

logger.info(toRedact);

console.log('Printing response', toRedact);

This will result in the final console.log() statement to print out Printing response { items: [ { name: '[Redacted]' } ] }, showing that the actual value of name has been changed beyond the scope of pino logging. This behavior is not present in v3.3.0.

mcollina commented 7 months ago

fixed in v3.4.1