remove FP from js/regexpinjection where no regexp was constructed

This commit is contained in:
Erik Krogh Kristensen
2019-12-16 16:36:58 +01:00
parent 5a6a2e8a68
commit 15d74b7d03
3 changed files with 17 additions and 1 deletions

View File

@@ -810,7 +810,8 @@ predicate isInterpretedAsRegExp(DataFlow::Node source) {
// The argument of a call that coerces the argument to a regular expression.
exists(MethodCallExpr mce, string methodName |
mce.getReceiver().analyze().getAType() = TTString() and
mce.getMethodName() = methodName
mce.getMethodName() = methodName and
not exists(DataFlow::FunctionNode func | func = DataFlow::valueNode(mce.getCallee()).getAFunctionValue() | not func.getFunction().inExternsFile())
|
methodName = "match" and source.asExpr() = mce.getArgument(0) and mce.getNumArgument() = 1
or

View File

@@ -50,4 +50,13 @@ app.get('/findKey', function(req, res) {
URI(`${protocol}://${host}${path}`).search(input); // OK, but still flagged
URI(`${protocol}://${host}${path}`).search(input).href(); // OK
unknown.search(input).unknown; // OK
});
import * as Search from './search';
app.get('/findKey', function(req, res) {
var key = req.param("key"), input = req.param("input");
Search.search(input); // OK!
});

View File

@@ -0,0 +1,6 @@
module.someOtherExport = true;
export function search(query) {
// Do nothing!
}