Skip to content

Commit ebbbda7

Browse files
committed
Ratpack tests all passing
Signed-off-by: Jonathan Leitschuh <[email protected]>
1 parent fe374f5 commit ebbbda7

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,19 @@ private class RatpackModel extends SummaryModelCsv {
6969
["ratpack.handling;", "ratpack.core.handling;"] +
7070
[
7171
"Context;true;parse;(ratpack.http.TypedData,ratpack.parse.Parse);;Argument[0];ReturnValue;taint",
72-
"Context;true;parse;(ratpack.core.http.TypedData,ratpack.core.parse.Parse);;Argument[0];ReturnValue;taint"
72+
"Context;true;parse;(ratpack.core.http.TypedData,ratpack.core.parse.Parse);;Argument[0];ReturnValue;taint",
73+
"Context;true;parse;(ratpack.core.http.TypedData,ratpack.core.parse.Parse);;Argument[0];MapKey of ReturnValue;taint",
74+
"Context;true;parse;(ratpack.core.http.TypedData,ratpack.core.parse.Parse);;Argument[0];MapValue of ReturnValue;taint"
7375
]
7476
or
7577
row =
7678
["ratpack.util;", "ratpack.func;"] +
7779
[
7880
"MultiValueMap;true;getAll;;;MapKey of Argument[-1];MapKey of ReturnValue;value",
79-
"MultiValueMap;true;getAll;;;MapValue of Argument[-1];Element of MapValue of ReturnValue;value",
80-
"MultiValueMap;true;asMultimap;;;Element of Argument[-1];Element of ReturnValue;value"
81+
"MultiValueMap;true;getAll;();;MapValue of Argument[-1];Element of MapValue of ReturnValue;value",
82+
"MultiValueMap;true;getAll;(Object);;MapValue of Argument[-1];Element of ReturnValue;value",
83+
"MultiValueMap;true;asMultimap;;;MapKey of Argument[-1];MapKey of ReturnValue;value",
84+
"MultiValueMap;true;asMultimap;;;MapValue of Argument[-1];Element of MapValue of ReturnValue;value"
8185
]
8286
}
8387
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
/**
2+
* Provides classes and predicates related to `ratpack.exec.*`.
3+
*/
4+
15
import java
26
private import semmle.code.java.dataflow.DataFlow
37
private import semmle.code.java.dataflow.FlowSteps
48
private import semmle.code.java.dataflow.ExternalFlow
59

610
/**
7-
* Ratpack methods that propagate user-supplied data as tainted.
11+
* Model for Ratpack `Promise` methods.
812
*/
913
private class RatpackExecModel extends SummaryModelCsv {
1014
override predicate row(string row) {
@@ -21,7 +25,7 @@ private class RatpackExecModel extends SummaryModelCsv {
2125
"map;;;ReturnValue of Argument[0];Element of ReturnValue;value",
2226
"blockingMap;;;Element of Argument[-1];Parameter[0] of Argument[0];value",
2327
"blockingMap;;;ReturnValue of Argument[0];Element of ReturnValue;value",
24-
"mapError;;;ReturnValue of Argument[0];Element of ReturnValue;value",
28+
"mapError;;;ReturnValue of Argument[1];Element of ReturnValue;value",
2529
// `apply` passes the qualifier to the function as the first argument
2630
"apply;;;Element of Argument[-1];Element of Parameter[0] of Argument[0];value",
2731
"apply;;;Element of ReturnValue of Argument[0];Element of ReturnValue;value",
@@ -41,7 +45,7 @@ private class RatpackExecModel extends SummaryModelCsv {
4145
// `flatMap` type methods return their returned `Promise`
4246
"flatMap;;;Element of Argument[-1];Parameter[0] of Argument[0];value",
4347
"flatMap;;;Element of ReturnValue of Argument[0];Element of ReturnValue;value",
44-
"flatMapError;;;Element of ReturnValue of Argument[0];Element of ReturnValue;value",
48+
"flatMapError;;;Element of ReturnValue of Argument[1];Element of ReturnValue;value",
4549
// `mapIf` methods conditionally map their values, or return themselves
4650
"mapIf;;;Element of Argument[-1];Parameter[0] of Argument[0];value",
4751
"mapIf;;;Element of Argument[-1];Parameter[0] of Argument[1];value",

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ void test5(Context ctx) {
9898
sink(form.file("questionable_file").getFileName()); //$hasTaintFlow
9999
sink(form.files("questionable_files")); //$hasTaintFlow
100100
sink(form.files()); //$hasTaintFlow
101-
sink(form.asMultimap()); //$hasTaintFlow
102-
sink(form.asMultimap().asMap()); //$hasTaintFlow
101+
sink(form.get("questionable_parameter")); //$hasTaintFlow
102+
sink(form.getAll().get("questionable_parameter").get(0)); //$hasTaintFlow
103+
sink(form.getAll("questionable_parameter").get(0)); //$hasTaintFlow
104+
sink(form.asMultimap().get("questionable_parameter")); //$hasTaintFlow // fails!
105+
sink(form.asMultimap().asMap()); //$hasTaintFlow // fails!
103106
});
104107
}
105108

0 commit comments

Comments
 (0)