mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Java: add test case
This commit is contained in:
27
java/ql/test/library-tests/dataflow/implicit-read/A.java
Normal file
27
java/ql/test/library-tests/dataflow/implicit-read/A.java
Normal file
@@ -0,0 +1,27 @@
|
||||
public class A {
|
||||
String field;
|
||||
|
||||
static String source(String name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
static void sink(Object o) {}
|
||||
|
||||
static String step(Object o) {
|
||||
return "";
|
||||
}
|
||||
|
||||
static Object getA() {
|
||||
A a = new A();
|
||||
a.field = source("source");
|
||||
return a;
|
||||
}
|
||||
|
||||
static void test() {
|
||||
Object object = getA();
|
||||
|
||||
sink(step(object)); // $ hasTaintFlow=source
|
||||
sink(object); // $ SPURIOUS: hasTaintFlow=source
|
||||
sink(((A)object).field); // $ hasTaintFlow=source
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user