-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DI] Implement PII redaction (#5053)
The algorithm will look for: - names of variables - names of object properties - names of keys in maps The names will be matched against a disallow-list and if a match is found, its value will be redacted. The list is hardcoded and can be found here: packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js It's possible to add names to the list using the following environment variable: DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS Or it's possible to remove names from the list using the following environment variable: DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS Each environment variable takes a list of names separated by commas. Support for redacting instances of specific classes is not included in this commit.
- Loading branch information
Showing
14 changed files
with
449 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict' | ||
|
||
const { assert } = require('chai') | ||
const { setup } = require('./utils') | ||
|
||
// Default settings is tested in unit tests, so we only need to test the env vars here | ||
describe('Dynamic Instrumentation snapshot PII redaction', function () { | ||
describe('DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS=foo,bar', function () { | ||
const t = setup({ env: { DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS: 'foo,bar' } }) | ||
|
||
it('should respect DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS', function (done) { | ||
t.triggerBreakpoint() | ||
|
||
t.agent.on('debugger-input', ({ payload: [{ 'debugger.snapshot': { captures } }] }) => { | ||
const { locals } = captures.lines[t.breakpoint.line] | ||
|
||
assert.deepPropertyVal(locals, 'foo', { type: 'string', notCapturedReason: 'redactedIdent' }) | ||
assert.deepPropertyVal(locals, 'bar', { type: 'string', notCapturedReason: 'redactedIdent' }) | ||
assert.deepPropertyVal(locals, 'baz', { type: 'string', value: 'c' }) | ||
|
||
// existing redaction should not be impacted | ||
assert.deepPropertyVal(locals, 'secret', { type: 'string', notCapturedReason: 'redactedIdent' }) | ||
|
||
done() | ||
}) | ||
|
||
t.agent.addRemoteConfig(t.generateRemoteConfig({ captureSnapshot: true })) | ||
}) | ||
}) | ||
|
||
describe('DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS=secret', function () { | ||
const t = setup({ env: { DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS: 'secret' } }) | ||
|
||
it('should respect DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS', function (done) { | ||
t.triggerBreakpoint() | ||
|
||
t.agent.on('debugger-input', ({ payload: [{ 'debugger.snapshot': { captures } }] }) => { | ||
const { locals } = captures.lines[t.breakpoint.line] | ||
|
||
assert.deepPropertyVal(locals, 'secret', { type: 'string', value: 'shh!' }) | ||
assert.deepPropertyVal(locals, 'password', { type: 'string', notCapturedReason: 'redactedIdent' }) | ||
|
||
done() | ||
}) | ||
|
||
t.agent.addRemoteConfig(t.generateRemoteConfig({ captureSnapshot: true })) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict' | ||
|
||
require('dd-trace/init') | ||
const Fastify = require('fastify') | ||
|
||
const fastify = Fastify() | ||
|
||
fastify.get('/', function () { | ||
/* eslint-disable no-unused-vars */ | ||
const foo = 'a' | ||
const bar = 'b' | ||
const baz = 'c' | ||
const secret = 'shh!' | ||
const password = 'shh!' | ||
/* eslint-enable no-unused-vars */ | ||
|
||
return { hello: 'world' } // BREAKPOINT: / | ||
}) | ||
|
||
fastify.listen({ port: process.env.APP_PORT }, (err) => { | ||
if (err) { | ||
fastify.log.error(err) | ||
process.exit(1) | ||
} | ||
process.send({ port: process.env.APP_PORT }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.