Merge pull request #117 from esben-semmle/js/push-sort-taint-steps

JS: support `push` and `sort` taint steps for arrays
This commit is contained in:
Max Schaefer
2018-09-03 09:20:35 +01:00
committed by GitHub
4 changed files with 28 additions and 1 deletions

View File

@@ -214,6 +214,9 @@ module TaintTracking {
m.getMethodName() = "map" and
m.getArgument(0) = f and // Require the argument to be a closure to avoid spurious call/return flow
pred = f.getAReturnedExpr().flow())
or
// `array.push(e)`: if `e` is tainted, then so is `array`
succ.(DataFlow::SourceNode).getAMethodCall("push").getAnArgument() = pred
)
or
// reading from a tainted object yields a tainted result
@@ -508,6 +511,19 @@ module TaintTracking {
}
}
/**
* A taint propagating data flow edge arising from sorting.
*/
private class SortTaintStep extends AdditionalTaintStep, DataFlow::MethodCallNode {
SortTaintStep() {
getMethodName() = "sort"
}
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
pred = getReceiver() and succ = this
}
}
/**
* A conditional checking a tainted string against a regular expression, which is
* considered to be a sanitizer for all configurations.