File size: 3,021 Bytes
838f976
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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