Update RegExp handling and add test case

Co-authored-by: erik-krogh <erik-krogh@github.com>
This commit is contained in:
Napalys Klicius
2024-11-28 14:10:50 +01:00
committed by Napalys
parent fd773603e6
commit 9ca0fe4cbf
2 changed files with 2 additions and 1 deletions

View File

@@ -40,7 +40,7 @@ module CleartextLogging {
exists(this.getRawReplacement().getStringValue()) and
exists(DataFlow::RegExpCreationNode regexpObj |
this.(StringReplaceCall).getRegExp() = regexpObj and
regexpObj.getRoot() = any(RegExpDot term)
regexpObj.getRoot() = any(RegExpDot term).getRootTerm()
)
}
}

View File

@@ -181,4 +181,5 @@ const debug = require('debug')('test');
console.log(password.replace(new RegExp(".", "g"), "*")); // OK
console.log(password.replace(new RegExp("."), "*")); // NOT OK
console.log(password.replace(new RegExp(".", unknownFlags()), "*")); // OK -- Most likely not a problem.
console.log(password.replace(new RegExp("pre_._suf", "g"), "*")); // OK
})();