Skip to content

Commit 821b4c7

Browse files
committed
Kotlin: Add Array.get(_) support to taint tracking
1 parent 9953794 commit 821b4c7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

java/ql/lib/semmle/code/java/dataflow/internal/ContainerFlow.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import semmle.code.java.Maps
44
private import semmle.code.java.dataflow.SSA
55
private import DataFlowUtil
66

7+
private class ArrayType extends RefType {
8+
ArrayType() { this.getSourceDeclaration().getASourceSupertype*() instanceof Array }
9+
}
10+
711
private class EntryType extends RefType {
812
EntryType() {
913
this.getSourceDeclaration().getASourceSupertype*().hasQualifiedName("java.util", "Map$Entry")
@@ -470,6 +474,14 @@ predicate arrayReadStep(Node node1, Node node2, Type elemType) {
470474
node2.asExpr() = aa
471475
)
472476
or
477+
exists(Expr arr, Call call |
478+
arr = node1.asExpr() and
479+
call = node2.asExpr() and
480+
arr.getType() instanceof ArrayType and
481+
call.getCallee().getName() = "get" and
482+
call.getQualifier() = arr
483+
)
484+
or
473485
exists(Array arr |
474486
enhancedForStmtStep(node1, node2, arr) and
475487
arr.getComponentType() = elemType

0 commit comments

Comments
 (0)