pinojs / pino

🌲 super fast, all natural json logger
http://getpino.io
MIT License
14.22k stars 874 forks source link

Redact mutates the original object #1575

Closed AlexRex closed 5 months ago

AlexRex commented 2 years ago

We noticed that redact is mutating the original object, and not bringing back its properties.

Snippet to reproduce:

import pino from 'pino'

const config: pino.LoggerOptions = {
  level: 'debug',
  redact: [ // Eliminate these fields from the logs!
    'context.password',
    'password',
    'context.*.password',
    'context[*].password'
  ]
}

const logger = pino(config)

const test = {
  whatever: { password: '1234' }
}

logger.info({ context: test }, 'info')

console.log(test) //  { whatever: { password: '[Redacted]' } }

Versions used:

"pino": "7.11.0",
"pino-pretty": "7.6.1"
AlexRex commented 2 years ago

Noticed some related issues, but looks like this is still not fixed: https://github.com/pinojs/pino/issues/1320 https://github.com/pinojs/pino/issues/1321

mcollina commented 2 years ago

This is due to the fact that you have multiple patterns covering the same object. There is likely one more bug. Would you like to send a PR?

stefanwaldhauser commented 1 year ago

Just encountered this bug in a project. Seems to still exist in the newest version

matthiasg commented 7 months ago

Just fell into that. Our forwarded requests internally lost authentication cookies.

paths: [
      // Requests
      // 'req.headers.cookie', // <- Adding this prevents cookies from being forwarded for http-proxy
      'req.headers["sec-ch-ua"]',
      'req.headers["sec-ch-ua-mobile"]',
      'req.headers["sec-ch-ua-platform"]',
      'req.headers.dnt',
      'req.headers["sec-fetch-dest"]',
      'req.headers["sec-fetch-user"]',
      'req.headers["sec-fetch-mode"]',
      'req.headers["sec-fetch-site"]',
      'req.headers.connection',
      // Raw (emitted by proxying to by api v4)
      'req.raw',
      'res.raw',
      'res.request.raw',
      // Responses
      'res.headers',
    ],
srzainab commented 7 months ago

Just ran into this as well on our production servers. Causing all sorts of issues. Any ideas on a fix?

emmyakin commented 5 months ago

FWIW, I tested this in the latest version v9.1.0, and can no longer reproduce

github-actions[bot] commented 4 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.