Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top level redacting with censor function #613

Closed
runk opened this issue Mar 20, 2019 · 4 comments · Fixed by #617
Closed

Top level redacting with censor function #613

runk opened this issue Mar 20, 2019 · 4 comments · Fixed by #617

Comments

@runk
Copy link
Contributor

runk commented Mar 20, 2019

Currently, if I want to use wildcard redaction with a custom censor function it omits the object from the output.

Broken test for reference:

test('redact – supports top level wildcard', async ({ is }) => {
  const stream = sink()
  const instance = pino({
    redact: {
      paths: ['*'],
      censor: () => '[Redacted]'
      // replacing it with string `censor: '[Redacted]'` solves the problem
    }
  }, stream)
  instance.info({
    req: {
      id: 7915,
      method: 'GET',
      url: '/',
      headers: {
        host: 'localhost:3000',
        connection: 'keep-alive',
        cookie: 'SESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1;'
      },
      remoteAddress: '::ffff:127.0.0.1',
      remotePort: 58022
    }
  })
  const { req } = await once(stream, 'data')
  is(req, '[Redacted]')
})

This is the place where it seems to be breaking: https://github.com/pinojs/pino/blob/master/lib/redaction.js#L75 - obviously fn cannot be serialized, which gives undefined as result, which leads to situation when object is omitted from output at all.

@mcollina
Copy link
Member

Would you like to send a PR here or in fast-redact to address this problem?

@davidmarkclements
Copy link
Member

davidmarkclements commented Mar 20, 2019 via email

@runk
Copy link
Contributor Author

runk commented Mar 20, 2019

It's seems to be an issue of pino itself, so has to be fixed in here perhaps. Let me see what I can do.

@github-actions
Copy link

github-actions bot commented Feb 7, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants