forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
28 lines (19 loc) · 684 Bytes
/
Copy pathTest.java
File metadata and controls
28 lines (19 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class Test {
public static void test(boolean inp) {
String directTaint = source();
String indirectTaint = source();
Object o = inp ? directTaint : new Outer(new Inner(indirectTaint, "not tainted"), "not tainted 2");
if (o instanceof String s) {
sink(s);
}
if (o instanceof Outer(Inner(String tainted, String notTainted), String alsoNotTainted)) {
sink(tainted);
sink(notTainted);
sink(alsoNotTainted);
}
}
public static String source() { return "tainted"; }
public static void sink(String sunk) { }
}
record Outer(Inner i, String otherField) { }
record Inner(String taintedField, String nonTaintedField) { }