mirror of
https://github.com/github/codeql.git
synced 2026-05-04 13:15:21 +02:00
[Java] JDK Collection lambda models
Adds support for data flow tracking through simple JDK collection functional APIs. - `Iterable::forEach` - `Iterator::forEachRemaining` - `Map::forEach` Replaces #5871 Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>
This commit is contained in:
@@ -25,5 +25,57 @@ public class Test {
|
||||
Iterator<String> it = m.values().iterator();
|
||||
String x5 = it.next();
|
||||
sink(x5); // Flow
|
||||
|
||||
it.forEachRemaining(x6 -> {
|
||||
sink(x6); // Flow
|
||||
});
|
||||
|
||||
m.forEach((x7_k, x8_v) -> {
|
||||
sink(x7_k); // No flow
|
||||
sink(x8_v); // Flow
|
||||
});
|
||||
|
||||
m.entrySet().forEach(entry -> {
|
||||
String x9 = entry.getKey();
|
||||
String x10 = entry.getValue();
|
||||
sink(x9); // No flow
|
||||
sink(x10); // Flow
|
||||
});
|
||||
}
|
||||
|
||||
public void run2() {
|
||||
HashMap<String, String> m = new HashMap<>();
|
||||
|
||||
m.put(tainted, tainted);
|
||||
|
||||
m.forEach((x11_k, x12_v) -> {
|
||||
sink(x11_k); // Flow
|
||||
sink(x12_v); // Flow
|
||||
});
|
||||
|
||||
m.entrySet().forEach(entry -> {
|
||||
String x13 = entry.getKey();
|
||||
String x14 = entry.getValue();
|
||||
sink(x13); // Flow
|
||||
sink(x14); // Flow
|
||||
});
|
||||
}
|
||||
|
||||
public void run3() {
|
||||
Set<String> s = new HashSet<>();
|
||||
String x15 = s.iterator().next();
|
||||
sink(x15); // No flow
|
||||
|
||||
s.forEach(x16 -> {
|
||||
sink(x16); // No flow
|
||||
});
|
||||
|
||||
s.add(tainted);
|
||||
String x17 = s.iterator().next();
|
||||
sink(x17); // Flow
|
||||
|
||||
s.forEach(x18 -> {
|
||||
sink(x18); // Flow
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user