Skip to content

Commit f7d63f8

Browse files
committed
Feedback incorporation and documentation updates
1 parent 33f7d52 commit f7d63f8

8 files changed

Lines changed: 135 additions & 0 deletions

File tree

java/ql/src/semmle/code/java/dataflow/FlowSources.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ private class MessageBodyReaderParameterSource extends RemoteFlowSource {
108108
override string getSourceType() { result = "MessageBodyReader parameter" }
109109
}
110110

111+
<<<<<<< HEAD
111112
private class SpringMultipartRequestSource extends RemoteFlowSource {
112113
SpringMultipartRequestSource() {
113114
exists(MethodAccess ma, Method m |
@@ -124,13 +125,19 @@ private class SpringMultipartRequestSource extends RemoteFlowSource {
124125
override string getSourceType() { result = "Spring MultipartRequest getter" }
125126
}
126127

128+
class PlayParameterSource extends RemoteFlowSource {
129+
PlayParameterSource() {
130+
exists(PlayActionMethodQueryParameter p | p = this.asParameter()) or
131+
exists(PlayMVCHTTPRequestHeaderMethods m | m.getQueryString().getAnArgument() = this.asExpr())
132+
=======
127133
class PlayParameterSource extends RemoteFlowSource {
128134
PlayParameterSource() {
129135
exists(PlayActionQueryParameter p | p = this.asParameter())
130136
or
131137
exists(PlayHTTPRequestHeaderMethods m |
132138
m.hasName("getQueryString") and m.getAParameter() = this.asParameter()
133139
)
140+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
134141
}
135142

136143
override string getSourceType() { result = "Play Query Parameters" }
@@ -279,10 +286,17 @@ private class RemoteTaintedMethod extends Method {
279286
}
280287
}
281288

289+
<<<<<<< HEAD
290+
private class PlayRequestGetMethod extends Method {
291+
PlayRequestGetMethod() {
292+
this.getDeclaringType() instanceof PlayMVCHTTPRequestHeader and
293+
this.hasName(["header", "getHeader"])
294+
=======
282295
private class PlayRequestGetMethod extends PlayHTTPRequestHeaderMethods {
283296
PlayRequestGetMethod() {
284297
this.hasName("Header") or
285298
this.hasName("getQueryString")
299+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
286300
}
287301
}
288302

java/ql/src/semmle/code/java/frameworks/play/PlayAddCSRFToken.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import java
22

33
/**
4+
<<<<<<< HEAD
5+
* Play Framework AddCSRFToken Annotation
6+
*
7+
* Documentation: https://www.playframework.com/documentation/2.8.x/JavaCsrf
8+
=======
49
* Play Framework AddCSRFToken
510
*
611
* @description Gets the methods using AddCSRFToken annotation.
712
* (https://www.playframework.com/documentation/2.6.x/JavaBodyParsers#Choosing-an-explicit-body-parser)
13+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
814
*/
915
class PlayAddCSRFTokenAnnotation extends Annotation {
1016
PlayAddCSRFTokenAnnotation() {

java/ql/src/semmle/code/java/frameworks/play/PlayAsyncResult.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import java
22

33
/**
4+
<<<<<<< HEAD
5+
* Play Framework Async Promise - Gets the Promise<Result> Generic Member/Type of (play.libs.F)
6+
*
7+
* Documentation: https://www.playframework.com/documentation/2.5.1/api/java/play/libs/F.Promise.html
8+
=======
49
* Play Framework Async Promise of Generic Result
510
*
611
* @description Gets the Promise<Result> Generic Type of (play.libs.F), This is async in 2.6x and below.
712
* (https://www.playframework.com/documentation/2.5.1/api/java/play/libs/F.Promise.html)
13+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
814
*/
915
class PlayAsyncResultPromise extends Member {
1016
PlayAsyncResultPromise() {
@@ -17,10 +23,16 @@ class PlayAsyncResultPromise extends Member {
1723
}
1824

1925
/**
26+
<<<<<<< HEAD
27+
* Play Framework Async Generic Result - Gets the CompletionStage<Result> Generic Type of (java.util.concurrent)
28+
*
29+
* Documentation: https://www.playframework.com/documentation/2.6.x/JavaAsync
30+
=======
2031
* Play Framework Async Generic Result extending generic promise API called CompletionStage.
2132
*
2233
* @description Gets the CompletionStage<Result> Generic Type of (java.util.concurrent)
2334
* (https://www.playframework.com/documentation/2.6.x/JavaAsync)
35+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
2436
*/
2537
class PlayAsyncResultCompletionStage extends Type {
2638
PlayAsyncResultCompletionStage() {

java/ql/src/semmle/code/java/frameworks/play/PlayBodyParser.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import java
22

33
/**
4+
<<<<<<< HEAD
5+
* Play Framework Explicit Body Parser Annotation
6+
*
7+
* Documentation: https://www.playframework.com/documentation/2.8.x/JavaBodyParsers#Choosing-an-explicit-body-parser
8+
=======
49
* Play Framework Explicit Body Parser
510
*
611
* @description Gets the methods using the explicit body parser annotation. The methods are usually controller action methods
712
* (https://www.playframework.com/documentation/2.8.x/JavaBodyParsers#Choosing-an-explicit-body-parser)
13+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
814
*/
915
class PlayBodyParserAnnotation extends Annotation {
1016
PlayBodyParserAnnotation() { this.getType().hasQualifiedName("play.mvc", "BodyParser<>$Of") }

java/ql/src/semmle/code/java/frameworks/play/PlayController.qll

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@ import semmle.code.java.frameworks.play.PlayMVCResult
44

55
/**
66
* Play MVC Framework Controller
7+
<<<<<<< HEAD
8+
=======
79
*
810
* @description Gets the play.mvc.Controller class
11+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
912
*/
1013
class PlayMVCControllerClass extends Class {
1114
PlayMVCControllerClass() { this.hasQualifiedName("play.mvc", "Controller") }
1215
}
1316

1417
/**
18+
<<<<<<< HEAD
19+
* Play Framework Controllers which extends/implements PlayMVCController recursively - Used to find all Controllers
20+
=======
1521
* Play Framework Controller which extends/implements
1622
*
1723
* @description Gets the classes which extends play.mvc.controller rescursively.
24+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
1825
*/
1926
class PlayController extends Class {
2027
PlayController() {
@@ -23,11 +30,32 @@ class PlayController extends Class {
2330
}
2431

2532
/**
33+
<<<<<<< HEAD
34+
* Play Framework Controller Action Methods - Mappings to route files
35+
*
36+
* Sample Route - `POST /login @com.linkedin.Application.login()`
37+
*
38+
* Example - class get's `index` & `login` as valid action methods.
39+
* ```
40+
* public class Application extends Controller {
41+
* public Result index(String username, String password) {
42+
* return ok("It works!");
43+
* }
44+
*
45+
* public Result login() {
46+
* return ok("Log me In!");
47+
* }
48+
* }
49+
* ```
50+
*
51+
* Documentation: https://www.playframework.com/documentation/2.8.x/JavaActions
52+
=======
2653
* Play Framework Controller Action Methods
2754
*
2855
* @description Gets the controller action methods defined against it.
2956
* (https://www.playframework.com/documentation/2.8.x/JavaActions)
3057
* @tip Checking for Public methods usually retrieves direct controller mapped methods defined in routes.
58+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
3159
*/
3260
class PlayControllerActionMethod extends Method {
3361
PlayControllerActionMethod() {
@@ -43,10 +71,26 @@ class PlayControllerActionMethod extends Method {
4371
}
4472

4573
/**
74+
<<<<<<< HEAD
75+
* Play Action-Method parameters. These are a source of user input
76+
*
77+
* Example - Class get's `username` & `password` as valid parameters
78+
* ```
79+
* public class Application extends Controller {
80+
* public Result index(String username, String password) {
81+
* return ok("It works!");
82+
* }
83+
* }
84+
* ```
85+
*/
86+
class PlayActionMethodQueryParameter extends Parameter {
87+
PlayActionMethodQueryParameter() {
88+
=======
4689
* Play Action-Method parameters, these are essentially part of routes.
4790
*/
4891
class PlayActionQueryParameter extends Parameter {
4992
PlayActionQueryParameter() {
93+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
5094
exists(PlayControllerActionMethod a |
5195
a.isPublic() and
5296
this = a.getAParameter()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
import java
22

33
/**
4+
<<<<<<< HEAD
5+
* Play MVC Framework HTTP Request Header Class
6+
=======
47
* Play MVC Framework HTTP Request Header
58
*
69
* @description Member of play.mvc.HTTP. Gets the play.mvc.HTTP$RequestHeader class/interface
10+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
711
*/
812
class PlayMVCHTTPRequestHeader extends RefType {
913
PlayMVCHTTPRequestHeader() { this.hasQualifiedName("play.mvc", "Http$RequestHeader") }
1014
}
1115

1216
/**
17+
<<<<<<< HEAD
18+
* Play Framework HTTPRequestHeader Methods - `headers`, `getQueryString`, `getHeader`
19+
*
20+
* Documentation: https://www.playframework.com/documentation/2.6.0/api/java/play/mvc/Http.RequestHeader.html
21+
*/
22+
class PlayMVCHTTPRequestHeaderMethods extends Method {
23+
PlayMVCHTTPRequestHeaderMethods() { this.getDeclaringType() instanceof PlayMVCHTTPRequestHeader }
24+
25+
/**
26+
* Gets all references to play.mvc.HTTP.RequestHeader `getQueryString` method
27+
*/
28+
MethodAccess getQueryString() {
29+
this.hasName("getQueryString") and result = this.getAReference()
30+
}
31+
32+
=======
1333
* Play Framework HTTP$RequestHeader Methods
1434
*
1535
* @description Gets the methods of play.mvc.HTTP$RequestHeader like - headers, getQueryString, getHeader, uri
1636
* (https://www.playframework.com/documentation/2.6.0/api/java/play/mvc/Http.RequestHeader.html)
1737
*/
1838
class PlayHTTPRequestHeaderMethods extends Method {
1939
PlayHTTPRequestHeaderMethods() { this.getDeclaringType() instanceof PlayMVCHTTPRequestHeader }
40+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
2041
}

java/ql/src/semmle/code/java/frameworks/play/PlayMVCResult.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import java
22

33
/**
4+
<<<<<<< HEAD
5+
* Play MVC Framework Result Class
6+
=======
47
* Play MVC Framework Result
58
*
69
* @description Gets the play.mvc.Result class - Used to set a HTTP result with a status code, a set of HTTP headers and a body to be sent to the web client.
710
* (https://www.playframework.com/documentation/2.8.x/JavaActions)
11+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
812
*/
913
class PlayMVCResultClass extends Class {
1014
PlayMVCResultClass() { this.hasQualifiedName("play.mvc", "Result") }

java/ql/src/semmle/code/java/frameworks/play/PlayMVCResults.qll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,43 @@
11
import java
22

33
/**
4+
<<<<<<< HEAD
5+
* Play MVC Framework Results Class
6+
*
7+
* Documentation: https://www.playframework.com/documentation/2.8.x/JavaActions
8+
=======
49
* Play MVC Framework Results
510
*
611
* @description Gets the play.mvc.Results class - Helper utilities to generate results
712
* (https://www.playframework.com/documentation/2.8.x/JavaActions)
13+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
814
*/
915
class PlayMVCResultsClass extends Class {
1016
PlayMVCResultsClass() { this.hasQualifiedName("play.mvc", "Results") }
1117
}
1218

1319
/**
20+
<<<<<<< HEAD
21+
* Play Framework mvc.Results Methods - `ok`, `status`, `redirect`
22+
*
23+
* Documentation: https://www.playframework.com/documentation/2.5.8/api/java/play/mvc/Results.html
24+
*/
25+
class PlayMVCResultsMethods extends Method {
26+
PlayMVCResultsMethods() { this.getDeclaringType() instanceof PlayMVCResultsClass }
27+
28+
/**
29+
* Gets all references to play.mvc.Results `ok` method
30+
*/
31+
MethodAccess getAnOkAccess() {
32+
this.hasName("ok") and result = this.getAReference()
33+
}
34+
35+
/**
36+
* Gets all references to play.mvc.Results `redirect` method
37+
*/
38+
MethodAccess getARedirectAccess() {
39+
this.hasName("redirect") and result = this.getAReference()
40+
=======
1441
* Play Framework mvc.Results Methods
1542
*
1643
* @description Gets the methods of play.mvc.Results like - ok, status, redirect etc.
@@ -31,5 +58,6 @@ class PlayHTTPResultsMethods extends Method {
3158
*/
3259
MethodAccess redirect() {
3360
exists(MethodAccess ma | ma = this.getAReference() and this.hasName("redirect") | result = ma)
61+
>>>>>>> fa523e456f96493dcc08b819ad4bd620cca789b8
3462
}
3563
}

0 commit comments

Comments
 (0)