trentm / node-bunyan

a simple and fast JSON logging module for node.js services
Other
7.15k stars 513 forks source link

Provide capability to redact sensitive information #718

Open tedyu opened 2 months ago

tedyu commented 2 months ago

This issue is for the feature of redaction.

With pino, we can do:

    redact: {
      paths: [
        'req.headers.authorization',
        '*.options.headers.authorization',
        '*.requestOptions.headers.authorization',

We can write custom serializer to recursively inspect the data to redact any sensitive attributes.

tedyu commented 2 months ago

It seems the redaction can be done in lib/bunyan.js:

// Serialize an HTTP request.
Logger.stdSerializers.req = function (req) {