Skip to content

Commit 5a18775

Browse files
committed
update test cases of __tests__/ dir
since we want to check if a jwt related sink is in this dir or not
1 parent 6ecd8b7 commit 5a18775

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

javascript/ql/test/query-tests/Security/CWE-798/HardcodedCredentials.expected

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,13 @@ nodes
344344
| __tests__/HardcodedCredentialsDemo.js:8:19:8:28 | 'hgfedcba' |
345345
| __tests__/HardcodedCredentialsDemo.js:8:19:8:28 | 'hgfedcba' |
346346
| __tests__/HardcodedCredentialsDemo.js:8:19:8:28 | 'hgfedcba' |
347+
| __tests__/HardcodedCredentialsDemo.js:18:9:18:43 | secretKey |
348+
| __tests__/HardcodedCredentialsDemo.js:18:21:18:43 | "myHard ... ateKey" |
349+
| __tests__/HardcodedCredentialsDemo.js:18:21:18:43 | "myHard ... ateKey" |
350+
| __tests__/HardcodedCredentialsDemo.js:21:24:21:32 | secretKey |
351+
| __tests__/HardcodedCredentialsDemo.js:21:24:21:32 | secretKey |
352+
| __tests__/HardcodedCredentialsDemo.js:28:31:28:39 | secretKey |
353+
| __tests__/HardcodedCredentialsDemo.js:28:31:28:39 | secretKey |
347354
edges
348355
| HardcodedCredentials.js:5:15:5:22 | 'dbuser' | HardcodedCredentials.js:5:15:5:22 | 'dbuser' |
349356
| HardcodedCredentials.js:8:19:8:28 | 'hgfedcba' | HardcodedCredentials.js:8:19:8:28 | 'hgfedcba' |
@@ -525,6 +532,12 @@ edges
525532
| HardcodedCredentials.js:414:21:414:43 | "myHard ... ateKey" | HardcodedCredentials.js:414:9:414:43 | secretKey |
526533
| __tests__/HardcodedCredentialsDemo.js:5:15:5:22 | 'dbuser' | __tests__/HardcodedCredentialsDemo.js:5:15:5:22 | 'dbuser' |
527534
| __tests__/HardcodedCredentialsDemo.js:8:19:8:28 | 'hgfedcba' | __tests__/HardcodedCredentialsDemo.js:8:19:8:28 | 'hgfedcba' |
535+
| __tests__/HardcodedCredentialsDemo.js:18:9:18:43 | secretKey | __tests__/HardcodedCredentialsDemo.js:21:24:21:32 | secretKey |
536+
| __tests__/HardcodedCredentialsDemo.js:18:9:18:43 | secretKey | __tests__/HardcodedCredentialsDemo.js:21:24:21:32 | secretKey |
537+
| __tests__/HardcodedCredentialsDemo.js:18:9:18:43 | secretKey | __tests__/HardcodedCredentialsDemo.js:28:31:28:39 | secretKey |
538+
| __tests__/HardcodedCredentialsDemo.js:18:9:18:43 | secretKey | __tests__/HardcodedCredentialsDemo.js:28:31:28:39 | secretKey |
539+
| __tests__/HardcodedCredentialsDemo.js:18:21:18:43 | "myHard ... ateKey" | __tests__/HardcodedCredentialsDemo.js:18:9:18:43 | secretKey |
540+
| __tests__/HardcodedCredentialsDemo.js:18:21:18:43 | "myHard ... ateKey" | __tests__/HardcodedCredentialsDemo.js:18:9:18:43 | secretKey |
528541
#select
529542
| HardcodedCredentials.js:5:15:5:22 | 'dbuser' | HardcodedCredentials.js:5:15:5:22 | 'dbuser' | HardcodedCredentials.js:5:15:5:22 | 'dbuser' | The hard-coded value "dbuser" is used as $@. | HardcodedCredentials.js:5:15:5:22 | 'dbuser' | user name |
530543
| HardcodedCredentials.js:8:19:8:28 | 'hgfedcba' | HardcodedCredentials.js:8:19:8:28 | 'hgfedcba' | HardcodedCredentials.js:8:19:8:28 | 'hgfedcba' | The hard-coded value "hgfedcba" is used as $@. | HardcodedCredentials.js:8:19:8:28 | 'hgfedcba' | password |

javascript/ql/test/query-tests/Security/CWE-798/__tests__/HardcodedCredentialsDemo.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,24 @@
1010
});
1111
client.connect();
1212
})();
13+
14+
(function () {
15+
const JwtStrategy = require('passport-jwt').Strategy;
16+
const passport = require('passport')
17+
18+
var secretKey = "myHardCodedPrivateKey";
19+
20+
const opts = {}
21+
opts.secretOrKey = secretKey; // NOT OK
22+
passport.use(new JwtStrategy(opts, function (jwt_payload, done) {
23+
return done(null, false);
24+
}));
25+
26+
passport.use(new JwtStrategy({
27+
secretOrKeyProvider: function (request, rawJwtToken, done) {
28+
return done(null, secretKey) // NOT OK
29+
}
30+
}, function (jwt_payload, done) {
31+
return done(null, false);
32+
}));
33+
})();

0 commit comments

Comments
 (0)