Skip to content

Commit fe374f5

Browse files
committed
Ratpack: Add support for Promise::apply
Signed-off-by: Jonathan Leitschuh <[email protected]>
1 parent 6562ac3 commit fe374f5

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

java/ql/lib/semmle/code/java/frameworks/ratpack/RatpackExec.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ private class RatpackExecModel extends SummaryModelCsv {
2222
"blockingMap;;;Element of Argument[-1];Parameter[0] of Argument[0];value",
2323
"blockingMap;;;ReturnValue of Argument[0];Element of ReturnValue;value",
2424
"mapError;;;ReturnValue of Argument[0];Element of ReturnValue;value",
25+
// `apply` passes the qualifier to the function as the first argument
26+
"apply;;;Element of Argument[-1];Element of Parameter[0] of Argument[0];value",
27+
"apply;;;Element of ReturnValue of Argument[0];Element of ReturnValue;value",
2528
// `Promise` termination method
2629
"then;;;Element of Argument[-1];Parameter[0] of Argument[0];value",
2730
// 'next' accesses qualfier the 'Promise' value and also returns the qualifier

java/ql/test/library-tests/frameworks/ratpack/resources/Resource.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,26 @@ public static String identity(String input) {
230230
}
231231

232232
void test10() {
233+
String tainted = taint();
234+
Promise
235+
.value(tainted)
236+
.apply(Resource::promiseIdentity)
237+
.then(value -> {
238+
sink(value); //$hasTaintFlow
239+
});
240+
Promise
241+
.value("potato")
242+
.apply(Resource::promiseIdentity)
243+
.then(value -> {
244+
sink(value); // no taints flow
245+
});
246+
}
247+
248+
public static Promise<String> promiseIdentity(Promise<String> input) {
249+
return input.map(i -> i);
250+
}
251+
252+
void test11() {
233253
String tainted = taint();
234254
Promise
235255
.value(tainted)
@@ -245,7 +265,7 @@ void test10() {
245265
});
246266
}
247267

248-
void test11() {
268+
void test12() {
249269
String tainted = taint();
250270
Promise
251271
.sync(() -> tainted)

0 commit comments

Comments
 (0)