Skip to content

Commit f32c77c

Browse files
committed
Qldoc and formatting changes
1 parent 6832333 commit f32c77c

File tree

11 files changed

+76
-86
lines changed

11 files changed

+76
-86
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ private class RemoteTaintedMethod extends Method {
286286

287287
private class PlayRequestGetMethod extends Method {
288288
PlayRequestGetMethod() {
289-
this.getDeclaringType() instanceof PlayMVCHTTPRequestHeader and
289+
this.getDeclaringType() instanceof PlayMvcHttpRequestHeader and
290290
this.hasName(["queryString", "getQueryString", "header", "getHeader"])
291291
}
292292
}
Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,48 @@
1+
/**
2+
* Provides classes and predicates for working with the `play` package.
3+
*/
4+
15
import java
26

37
/**
4-
* Play MVC Framework Result Class
8+
* A `play.mvc.Result` class.
59
*/
6-
class PlayMVCResultClass extends Class {
7-
PlayMVCResultClass() { this.hasQualifiedName("play.mvc", "Result") }
10+
class PlayMvcResultClass extends Class {
11+
PlayMvcResultClass() { this.hasQualifiedName("play.mvc", "Result") }
812
}
913

1014
/**
11-
* Play MVC Framework Results Class
12-
*
13-
* Documentation: https://www.playframework.com/documentation/2.8.x/JavaActions
15+
* A `play.mvc.Results` class.
1416
*/
15-
class PlayMVCResultsClass extends Class {
16-
PlayMVCResultsClass() { this.hasQualifiedName("play.mvc", "Results") }
17+
class PlayMvcResultsClass extends Class {
18+
PlayMvcResultsClass() { this.hasQualifiedName("play.mvc", "Results") }
1719
}
1820

1921
/**
20-
* Play MVC Framework HTTP Request Header Class
22+
* A `play.mvc.Http$RequestHeader` class.
2123
*/
22-
class PlayMVCHTTPRequestHeader extends RefType {
23-
PlayMVCHTTPRequestHeader() { this.hasQualifiedName("play.mvc", "Http$RequestHeader") }
24+
class PlayMvcHttpRequestHeader extends RefType {
25+
PlayMvcHttpRequestHeader() { this.hasQualifiedName("play.mvc", "Http$RequestHeader") }
2426
}
2527

2628
/**
27-
* Play Framework Explicit Body Parser Annotation
28-
*
29-
* Documentation: https://www.playframework.com/documentation/2.8.x/JavaBodyParsers#Choosing-an-explicit-body-parser
29+
* A `play.mvc.BodyParser<>$Of"` annotation.
3030
*/
3131
class PlayBodyParserAnnotation extends Annotation {
3232
PlayBodyParserAnnotation() { this.getType().hasQualifiedName("play.mvc", "BodyParser<>$Of") }
3333
}
3434

3535
/**
36-
* Play Framework AddCSRFToken Annotation
37-
*
38-
* Documentation: https://www.playframework.com/documentation/2.8.x/JavaCsrf
36+
* A `play.filters.csrf.AddCSRFToken` annotation.
3937
*/
40-
class PlayAddCSRFTokenAnnotation extends Annotation {
41-
PlayAddCSRFTokenAnnotation() {
38+
class PlayAddCsrfTokenAnnotation extends Annotation {
39+
PlayAddCsrfTokenAnnotation() {
4240
this.getType().hasQualifiedName("play.filters.csrf", "AddCSRFToken")
4341
}
4442
}
4543

4644
/**
47-
* Play Framework Async Promise - Gets the Promise<Result> Generic Member/Type of (play.libs.F)
48-
*
49-
* Documentation: https://www.playframework.com/documentation/2.5.1/api/java/play/libs/F.Promise.html
45+
* A member with qualified name `F.Promise<Result>` of package `play.libs.F`.
5046
*/
5147
class PlayAsyncResultPromise extends Member {
5248
PlayAsyncResultPromise() {
@@ -59,9 +55,7 @@ class PlayAsyncResultPromise extends Member {
5955
}
6056

6157
/**
62-
* Play Framework Async Generic Result - Gets the CompletionStage<Result> Generic Type of (java.util.concurrent)
63-
*
64-
* Documentation: https://www.playframework.com/documentation/2.6.x/JavaAsync
58+
* A type with qualified name `CompletionStage<Result>` of package `java.util.concurrent`.
6559
*/
6660
class PlayAsyncResultCompletionStage extends Type {
6761
PlayAsyncResultCompletionStage() {
@@ -71,7 +65,7 @@ class PlayAsyncResultCompletionStage extends Type {
7165
}
7266

7367
/**
74-
* Play Framework Controllers which extends PlayMVCController recursively - Used to find all Controllers
68+
* A class which extends PlayMvcController recursively to find all controllers.
7569
*/
7670
class PlayController extends Class {
7771
PlayController() {
@@ -80,9 +74,9 @@ class PlayController extends Class {
8074
}
8175

8276
/**
83-
* Play Framework Controller Action Methods - Mappings to route files
77+
* A method to find PlayFramework controller action methods, these are mapping's to route files.
8478
*
85-
* Sample Route - `POST /login @com.company.Application.login()`
79+
* Sample Route - `POST /login @com.company.Application.login()`.
8680
*
8781
* Example - class get's `index` & `login` as valid action methods.
8882
* ```
@@ -96,24 +90,22 @@ class PlayController extends Class {
9690
* }
9791
* }
9892
* ```
99-
*
100-
* Documentation: https://www.playframework.com/documentation/2.8.x/JavaActions
10193
*/
10294
class PlayControllerActionMethod extends Method {
10395
PlayControllerActionMethod() {
10496
this = any(PlayController c).getAMethod() and
10597
(
10698
this.getReturnType() instanceof PlayAsyncResultPromise or
107-
this.getReturnType() instanceof PlayMVCResultClass or
99+
this.getReturnType() instanceof PlayMvcResultClass or
108100
this.getReturnType() instanceof PlayAsyncResultCompletionStage
109101
)
110102
}
111103
}
112104

113105
/**
114-
* Play Action-Method parameters. These are a source of user input
106+
* The PlayFramework action method parameters, these are a source of user input.
115107
*
116-
* Example - Class get's `username` & `password` as valid parameters
108+
* Example - `username` & `password` are marked as valid parameters.
117109
* ```
118110
* public class Application extends Controller {
119111
* public Result index(String username, String password) {
@@ -132,36 +124,32 @@ class PlayActionMethodQueryParameter extends Parameter {
132124
}
133125

134126
/**
135-
* Play Framework HTTPRequestHeader Methods - `headers`, `getQueryString`, `getHeader`
136-
*
137-
* Documentation: https://www.playframework.com/documentation/2.6.0/api/java/play/mvc/Http.RequestHeader.html
127+
* A PlayFramework HttpRequestHeader method, some of these are `headers`, `getQueryString`, `getHeader`.
138128
*/
139-
class PlayMVCHTTPRequestHeaderMethods extends Method {
140-
PlayMVCHTTPRequestHeaderMethods() { this.getDeclaringType() instanceof PlayMVCHTTPRequestHeader }
129+
class PlayMvcHttpRequestHeaderMethods extends Method {
130+
PlayMvcHttpRequestHeaderMethods() { this.getDeclaringType() instanceof PlayMvcHttpRequestHeader }
141131

142132
/**
143-
* Gets all references to play.mvc.HTTP.RequestHeader `getQueryString` method
133+
* A reference to the `getQueryString` method.
144134
*/
145135
MethodAccess getAQueryStringAccess() {
146136
this.hasName("getQueryString") and result = this.getAReference()
147137
}
148138
}
149139

150140
/**
151-
* Play Framework mvc.Results Methods - `ok`, `status`, `redirect`
152-
*
153-
* Documentation: https://www.playframework.com/documentation/2.5.8/api/java/play/mvc/Results.html
141+
* A PlayFramework results method, some of these are `ok`, `status`, `redirect`.
154142
*/
155-
class PlayMVCResultsMethods extends Method {
156-
PlayMVCResultsMethods() { this.getDeclaringType() instanceof PlayMVCResultsClass }
143+
class PlayMvcResultsMethods extends Method {
144+
PlayMvcResultsMethods() { this.getDeclaringType() instanceof PlayMvcResultsClass }
157145

158146
/**
159-
* Gets all references to play.mvc.Results `ok` method
147+
* A reference to the play.mvc.Results `ok` method.
160148
*/
161149
MethodAccess getAnOkAccess() { this.hasName("ok") and result = this.getAReference() }
162150

163151
/**
164-
* Gets all references to play.mvc.Results `redirect` method
152+
* A reference to the play.mvc.Results `redirect` method.
165153
*/
166154
MethodAccess getARedirectAccess() { this.hasName("redirect") and result = this.getAReference() }
167155
}
Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1+
import java.util.concurrent.CompletableFuture;
2+
import java.util.concurrent.CompletionStage;
3+
import play.filters.csrf.AddCSRFToken;
4+
import play.libs.F;
5+
import play.mvc.BodyParser;
16
import play.mvc.Controller;
27
import play.mvc.Http.*;
38
import play.mvc.Result;
4-
import play.filters.csrf.AddCSRFToken;
5-
import play.libs.F;
6-
import java.util.concurrent.CompletionStage;
7-
89

910
public class PlayResource extends Controller {
1011

11-
public Result index(String username, String password) {
12-
String append_token = "password" + password;
13-
return ok("Working");
14-
}
12+
@AddCSRFToken
13+
public Result index() {
14+
response().setHeader("X-Play-QL", "1");
15+
return ok("It works!");
16+
}
1517

16-
public Result session_redirect_me() {
17-
String url = request().getQueryString("url");
18-
redirect(url);
19-
}
18+
@BodyParser.Of()
19+
public Result session_redirect_me(String uri) {
20+
String url = request().getQueryString("url");
21+
return redirect(url);
22+
}
2023

21-
public F.Promise<Result> async_promise(String token) {
22-
ok(token);
23-
}
24+
public F.Promise<Result> async_promise(String token) {
25+
return F.Promise.pure(ok(token));
26+
}
2427

25-
public CompletionStage<Result> async_completionstage(String complete) {
26-
String return_code = "complete" + complete;
27-
ok("Async completion Stage");
28-
}
28+
public CompletionStage<Result> async_completionstage(String uri) {
29+
return CompletableFuture.completedFuture(ok("Async completion Stage"));
30+
}
2931

30-
public String not_playactionmethod(String no_action) {
31-
String return_code = no_action;
32-
return return_code;
33-
}
32+
public String not_playactionmethod(String no_action) {
33+
String return_code = no_action;
34+
return return_code;
35+
}
3436
}

java/ql/test/library-tests/dataflow/taintsources/remote.expected

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,12 @@
2323
| IntentSources.java:33:20:33:33 | getIntent(...) | IntentSources.java:33:20:33:33 | getIntent(...) |
2424
| IntentSources.java:33:20:33:33 | getIntent(...) | IntentSources.java:33:20:33:55 | getStringExtra(...) |
2525
| IntentSources.java:33:20:33:33 | getIntent(...) | IntentSources.java:34:29:34:35 | trouble |
26-
| PlayResource.java:11:25:11:39 | username | PlayResource.java:11:25:11:39 | username |
27-
| PlayResource.java:11:42:11:56 | password | PlayResource.java:11:42:11:56 | password |
28-
| PlayResource.java:11:42:11:56 | password | PlayResource.java:12:31:12:51 | ... + ... |
29-
| PlayResource.java:11:42:11:56 | password | PlayResource.java:12:44:12:51 | password |
30-
| PlayResource.java:17:22:17:52 | getQueryString(...) | PlayResource.java:17:22:17:52 | getQueryString(...) |
31-
| PlayResource.java:21:44:21:55 | token | ../../../stubs/playframework-2.6.x/play/mvc/Results.java:261:27:261:40 | content |
32-
| PlayResource.java:21:44:21:55 | token | PlayResource.java:21:44:21:55 | token |
33-
| PlayResource.java:21:44:21:55 | token | PlayResource.java:22:12:22:16 | token |
34-
| PlayResource.java:25:58:25:72 | complete | PlayResource.java:25:58:25:72 | complete |
35-
| PlayResource.java:25:58:25:72 | complete | PlayResource.java:26:30:26:50 | ... + ... |
36-
| PlayResource.java:25:58:25:72 | complete | PlayResource.java:26:43:26:50 | complete |
26+
| PlayResource.java:19:37:19:46 | uri | PlayResource.java:19:37:19:46 | uri |
27+
| PlayResource.java:20:18:20:48 | getQueryString(...) | PlayResource.java:20:18:20:48 | getQueryString(...) |
28+
| PlayResource.java:24:42:24:53 | token | ../../../stubs/playframework-2.6.x/play/mvc/Results.java:261:27:261:40 | content |
29+
| PlayResource.java:24:42:24:53 | token | PlayResource.java:24:42:24:53 | token |
30+
| PlayResource.java:24:42:24:53 | token | PlayResource.java:25:30:25:34 | token |
31+
| PlayResource.java:28:56:28:65 | uri | PlayResource.java:28:56:28:65 | uri |
3732
| RmiFlowImpl.java:4:30:4:40 | path | RmiFlowImpl.java:4:30:4:40 | path |
3833
| RmiFlowImpl.java:4:30:4:40 | path | RmiFlowImpl.java:5:20:5:31 | ... + ... |
3934
| RmiFlowImpl.java:4:30:4:40 | path | RmiFlowImpl.java:5:28:5:31 | path |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import semmle.code.java.frameworks.play.Play
22

3-
from PlayAddCSRFTokenAnnotation token
3+
from PlayAddCsrfTokenAnnotation token
44
select token
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| resources/Resource.java:12:3:12:15 | AddCSRFToken |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import semmle.code.java.frameworks.play.Play
2+
3+
from PlayAddCsrfTokenAnnotation token
4+
select token
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import semmle.code.java.frameworks.play.Play
22

3-
from PlayMVCHTTPRequestHeader c
3+
from PlayMvcHttpRequestHeader c
44
select c.getQualifiedName(), c.getAMethod().getQualifiedName()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import semmle.code.java.frameworks.play.Play
22

3-
from PlayMVCResultClass m
3+
from PlayMvcResultClass m
44
select m.getQualifiedName()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import semmle.code.java.frameworks.play.Play
22

3-
from PlayMVCResultsClass m
3+
from PlayMvcResultsClass m
44
select m.getQualifiedName(), m.getAMethod().getQualifiedName()

0 commit comments

Comments
 (0)