mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user