开发者社区> 镜像站> NPM> @perform/lambda-powertools-middleware-obfuscater
@perform/lambda-powertools-middleware-obfuscater

Middy middleware to obfuscate the event for logging

Moved to @dazn/lambda-powertools-middleware-obfuscater - please migrate to the new package by Tuesday 20th August 2019 as this package will be made private.
Last updated a year ago by automation-drone .
MIT · Original npm · Tarball · package.json
$ cnpm install @perform/lambda-powertools-middleware-obfuscater 
SYNC missed versions from official npm registry.

lambda-powertools-middleware-obfuscater

A Middy middleware that will enable debug logging for a configurable % of invocations. Defaults is 1%.

Main features:

  • records an error log message with the invocation event as attribute when an invocation errors. These invocation errors may be obfuscated to avoid the leaking of Personal Identifiable Information.

Getting Started

Install from NPM: npm install @perform/lambda-powertools-middleware-obfuscater

Alternatively, if you use the template @perform/lambda-powertools-pattern-obfuscate then this would be configured for you.

API

Accepts a configuration object of the following shape:

{
  obfuscationFilter: string array formatted like ["object.key.to.obfuscate"]
}
  { 
    Records: [
        { firstName: "personal" secondName: "identifiable" email: "inform@ti.on" },
        { firstName: "second" secondName: "personal" email: "inform@ti.on" }
      ]
  }

  // To filter the above object you would pass 
  const obfuscationFilter = ["Records.*.firstName", "Records.*.secondName", "Records.*.email"]

The output would be...

{ 
  Records: [
      { firstName: "********" secondName: "************" email: "******@**.**" },
      { firstName: "******" secondName: "********" email: "******@**.**" }
    ]
}

similarly, you can filter entire objects, for instance.

  const obfuscationFilter = ["Records.*.personal"]
  { 
    Records: [
      { personal: { firstName: "********" secondName: "************" email: "******@**.**" } }.
      { personal: { firstName: "******" secondName: "********" email: "******@**.**", address: { postcode: "******", street: "* ****** ***", country: "**" }}}
    ]
  }

This will recursively filter every object and subobjects

const middy = require('middy')
const obfuscatedLogging = require('@perform/lambda-powertools-middleware-obfuscater')

const handler = async (event, context) => {
  return 42
}

module.exports = middy(handler)
  .use(obfuscatedLogging({ sampleRate: 0.01, obfuscationFilters: ["example.example"] }))
}

This middleware is often used alongside the @perform/lambda-powertools-middleware-correlation-ids middleware to implement sample logging. It's recommended that you use the @perform/lambda-powertools-pattern-obfuscate which configures both to enable debug logging at 1% of invocations.

Current Tags

  • 1.8.0                                ...           latest (a year ago)

17 Versions

  • 1.8.0 [deprecated]           ...           a year ago
  • 1.5.0 [deprecated]           ...           a year ago
  • 1.3.0 [deprecated]           ...           a year ago
  • 1.1.7 [deprecated]           ...           2 years ago
  • 1.1.5 [deprecated]           ...           2 years ago
  • 1.1.1 [deprecated]           ...           2 years ago
  • 1.1.0 [deprecated]           ...           2 years ago
  • 1.0.1 [deprecated]           ...           2 years ago
  • 1.0.0 [deprecated]           ...           2 years ago
  • 0.10.7 [deprecated]           ...           2 years ago
  • 0.10.6 [deprecated]           ...           2 years ago
  • 0.10.5 [deprecated]           ...           2 years ago
  • 0.10.4 [deprecated]           ...           2 years ago
  • 0.10.3 [deprecated]           ...           2 years ago
  • 0.10.2 [deprecated]           ...           2 years ago
  • 0.10.1 [deprecated]           ...           2 years ago
  • 0.10.0 [deprecated]           ...           2 years ago
Maintainers (326)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (2)