Skip to content

Commit e673348

Browse files
committed
JS: now RegExp with unknown flags is not flagged as an issue within password Clear text storage of sensitive information
1 parent a2c4674 commit e673348

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/CleartextLoggingCustomizations.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module CleartextLogging {
3636
*/
3737
class MaskingReplacer extends Barrier, StringReplaceCall {
3838
MaskingReplacer() {
39-
this.isGlobal() and
39+
this.maybeGlobal() and
4040
exists(this.getRawReplacement().getStringValue()) and
4141
exists(DataFlow::RegExpCreationNode regexpObj |
4242
this.(StringReplaceCall).getRegExp() = regexpObj and

javascript/ql/test/query-tests/Security/CWE-312/CleartextLogging.expected

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ nodes
143143
| passwords.js:182:14:182:21 | password |
144144
| passwords.js:182:14:182:51 | passwor ... ), "*") |
145145
| passwords.js:182:14:182:51 | passwor ... ), "*") |
146-
| passwords.js:183:14:183:21 | password |
147-
| passwords.js:183:14:183:21 | password |
148-
| passwords.js:183:14:183:67 | passwor ... ), "*") |
149-
| passwords.js:183:14:183:67 | passwor ... ), "*") |
150146
| passwords_in_browser1.js:2:13:2:20 | password |
151147
| passwords_in_browser1.js:2:13:2:20 | password |
152148
| passwords_in_browser1.js:2:13:2:20 | password |
@@ -297,10 +293,6 @@ edges
297293
| passwords.js:182:14:182:21 | password | passwords.js:182:14:182:51 | passwor ... ), "*") |
298294
| passwords.js:182:14:182:21 | password | passwords.js:182:14:182:51 | passwor ... ), "*") |
299295
| passwords.js:182:14:182:21 | password | passwords.js:182:14:182:51 | passwor ... ), "*") |
300-
| passwords.js:183:14:183:21 | password | passwords.js:183:14:183:67 | passwor ... ), "*") |
301-
| passwords.js:183:14:183:21 | password | passwords.js:183:14:183:67 | passwor ... ), "*") |
302-
| passwords.js:183:14:183:21 | password | passwords.js:183:14:183:67 | passwor ... ), "*") |
303-
| passwords.js:183:14:183:21 | password | passwords.js:183:14:183:67 | passwor ... ), "*") |
304296
| passwords_in_browser1.js:2:13:2:20 | password | passwords_in_browser1.js:2:13:2:20 | password |
305297
| passwords_in_browser2.js:2:13:2:20 | password | passwords_in_browser2.js:2:13:2:20 | password |
306298
| passwords_in_server_1.js:6:13:6:20 | password | passwords_in_server_1.js:6:13:6:20 | password |
@@ -349,7 +341,6 @@ edges
349341
| passwords.js:173:17:173:26 | myPassword | passwords.js:173:17:173:26 | myPassword | passwords.js:173:17:173:26 | myPassword | This logs sensitive data returned by $@ as clear text. | passwords.js:173:17:173:26 | myPassword | an access to myPassword |
350342
| passwords.js:176:17:176:26 | myPasscode | passwords.js:176:17:176:26 | myPasscode | passwords.js:176:17:176:26 | myPasscode | This logs sensitive data returned by $@ as clear text. | passwords.js:176:17:176:26 | myPasscode | an access to myPasscode |
351343
| passwords.js:182:14:182:51 | passwor ... ), "*") | passwords.js:182:14:182:21 | password | passwords.js:182:14:182:51 | passwor ... ), "*") | This logs sensitive data returned by $@ as clear text. | passwords.js:182:14:182:21 | password | an access to password |
352-
| passwords.js:183:14:183:67 | passwor ... ), "*") | passwords.js:183:14:183:21 | password | passwords.js:183:14:183:67 | passwor ... ), "*") | This logs sensitive data returned by $@ as clear text. | passwords.js:183:14:183:21 | password | an access to password |
353344
| passwords_in_server_1.js:6:13:6:20 | password | passwords_in_server_1.js:6:13:6:20 | password | passwords_in_server_1.js:6:13:6:20 | password | This logs sensitive data returned by $@ as clear text. | passwords_in_server_1.js:6:13:6:20 | password | an access to password |
354345
| passwords_in_server_2.js:3:13:3:20 | password | passwords_in_server_2.js:3:13:3:20 | password | passwords_in_server_2.js:3:13:3:20 | password | This logs sensitive data returned by $@ as clear text. | passwords_in_server_2.js:3:13:3:20 | password | an access to password |
355346
| passwords_in_server_3.js:2:13:2:20 | password | passwords_in_server_3.js:2:13:2:20 | password | passwords_in_server_3.js:2:13:2:20 | password | This logs sensitive data returned by $@ as clear text. | passwords_in_server_3.js:2:13:2:20 | password | an access to password |

javascript/ql/test/query-tests/Security/CWE-312/passwords.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,5 @@ const debug = require('debug')('test');
180180
console.log(password.replace(/./g, "*")); // OK
181181
console.log(password.replace(new RegExp(".", "g"), "*")); // OK
182182
console.log(password.replace(new RegExp("."), "*")); // NOT OK
183-
console.log(password.replace(new RegExp(".", unknownFlags()), "*")); // OK -- Currently flagged, though maybe it should not be.
183+
console.log(password.replace(new RegExp(".", unknownFlags()), "*")); // OK -- Most likely not a problem.
184184
})();

0 commit comments

Comments
 (0)