forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.java
More file actions
29 lines (22 loc) · 700 Bytes
/
Copy pathA.java
File metadata and controls
29 lines (22 loc) · 700 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
29
import java.util.function.*;
class A {
Object source(String label) { return null; }
void sink(Object o) { }
<T> T propagateTaint(Object arg) {
return (T)arg;
}
void test() {
// test type strengthening on outgoing through-flow edge
String s = this.<String>propagateTaint(source("A"));
sink(s); // $ hasValueFlow=A
// no strengthening
Object o = this.<Object>propagateTaint(source("B"));
sink(o); // $ hasValueFlow=B
// test type strengthening on ingoing through-flow edge
String s2 = apply((String arg) -> arg, source("C"));
sink(s2); // $ hasValueFlow=C
}
<T1, T2> T2 apply(Function<T1, T2> f, Object x) {
return f.apply((T1)x);
}
}