diff --git a/packages/dd-trace/test/plugins/util/redis.spec.js b/packages/dd-trace/test/plugins/util/redis.spec.js index c79cb6a22..d09ddc183 100644 --- a/packages/dd-trace/test/plugins/util/redis.spec.js +++ b/packages/dd-trace/test/plugins/util/redis.spec.js @@ -80,5 +80,55 @@ describe('plugins/util/redis', () => { expect(rawCommand.substr(0, 10)).to.equal('GET aaaaaa') expect(rawCommand.substr(990)).to.equal('aaaaaaa...') }) + + it('should not log the password from AUTH commands (lowercase)', () => { + span = redis.instrument(tracer, config, '0', 'auth', ['secret-password']) + + const rawCommand = span.context()._tags['redis.raw_command'] + + expect(rawCommand).to.equal('AUTH') + expect(rawCommand).to.not.include('secret-password') + }) + + it('should not log the password from AUTH commands (uppercase)', () => { + span = redis.instrument(tracer, config, '0', 'AUTH', ['secret-password']) + + const rawCommand = span.context()._tags['redis.raw_command'] + + expect(rawCommand).to.equal('AUTH') + expect(rawCommand).to.not.include('secret-password') + }) + + it('should not log username and password from AUTH commands with multiple args', () => { + span = redis.instrument(tracer, config, '0', 'auth', ['username', 'secret-password']) + + const rawCommand = span.context()._tags['redis.raw_command'] + + expect(rawCommand).to.equal('AUTH') + expect(rawCommand).to.not.include('secret-password') + expect(rawCommand).to.not.include('username') + }) + + it('should still set resource.name for AUTH commands', () => { + span = redis.instrument(tracer, config, '0', 'auth', ['secret-password']) + + expect(span.context()._tags).to.have.property('resource.name', 'auth') + }) + + it('should still include arguments for non-AUTH commands (preservation)', () => { + span = redis.instrument(tracer, config, '0', 'get', ['mykey']) + + const rawCommand = span.context()._tags['redis.raw_command'] + + expect(rawCommand).to.equal('GET mykey') + }) + + it('should still include arguments for SET command (preservation)', () => { + span = redis.instrument(tracer, config, '0', 'set', ['foo', 'bar']) + + const rawCommand = span.context()._tags['redis.raw_command'] + + expect(rawCommand).to.equal('SET foo bar') + }) }) }) diff --git a/test_commands.json b/test_commands.json new file mode 100644 index 000000000..3cc4332bb --- /dev/null +++ b/test_commands.json @@ -0,0 +1,3 @@ +{ + "test_commands": ["npx mocha --exit --file packages/dd-trace/test/setup/core.js packages/dd-trace/test/plugins/util/redis.spec.js"] +} diff --git a/mimo_test_command.sh b/mimo_test_command.sh new file mode 100755 --- /dev/null +++ b/mimo_test_command.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -uo pipefail +cd /testbed +rc=0 +npx mocha --exit --file packages/dd-trace/test/setup/core.js packages/dd-trace/test/plugins/util/redis.spec.js +rc=$(( rc | $? )) +exit $rc