Skip to content

Commit 2f17943

Browse files
committed
Update qldoc
1 parent cb01613 commit 2f17943

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

java/ql/src/experimental/Security/CWE/CWE-598/SensitiveGetQuery.ql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import semmle.code.java.dataflow.TaintTracking
1313
import semmle.code.java.security.SensitiveActions
1414
import DataFlow::PathGraph
1515

16-
/** Finds variables that hold sensitive information judging by their names. */
16+
/** A variable that holds sensitive information judging by its name. */
1717
class SensitiveInfoExpr extends Expr {
1818
SensitiveInfoExpr() {
1919
exists(Variable v | this = v.getAnAccess() |
2020
v.getName().regexpMatch(getCommonSensitiveInfoRegex()) and
21-
not v.getName().regexpMatch("token.*") // exclude ^token$ and ^token.* since sensitive tokens are in the form of accessToken, authToken, ...
21+
not v.getName().regexpMatch("token.*") // exclude ^token.* since sensitive tokens are usually in the form of accessToken, authToken, ...
2222
)
2323
}
2424
}
@@ -31,14 +31,14 @@ class DoGetServletMethod extends Method {
3131
DoGetServletMethod() { isGetServletMethod(this) }
3232
}
3333

34-
/** Holds if `ma` is called from the `doGet` method of `HttpServlet`. */
35-
predicate isServletGetCall(MethodAccess ma) {
34+
/** Holds if `ma` is (perhaps indirectly) called from the `doGet` method of `HttpServlet`. */
35+
predicate isReachableFromServletDoGet(MethodAccess ma) {
3636
ma.getEnclosingCallable() instanceof DoGetServletMethod
3737
or
3838
exists(Method pm, MethodAccess pma |
3939
ma.getEnclosingCallable() = pm and
4040
pma.getMethod() = pm and
41-
isServletGetCall(pma)
41+
isReachableFromServletDoGet(pma)
4242
)
4343
}
4444

@@ -48,12 +48,12 @@ class RequestGetParamSource extends DataFlow::ExprNode {
4848
exists(MethodAccess ma |
4949
isRequestGetParamMethod(ma) and
5050
ma = this.asExpr() and
51-
isServletGetCall(ma)
51+
isReachableFromServletDoGet(ma)
5252
)
5353
}
5454
}
5555

56-
/** Taint configuration tracking flow from the `ServletRequest` of a GET request handler to an expression whose name suggests it holds security-sensitive data. */
56+
/** A taint configuration tracking flow from the `ServletRequest` of a GET request handler to an expression whose name suggests it holds security-sensitive data. */
5757
class SensitiveGetQueryConfiguration extends TaintTracking::Configuration {
5858
SensitiveGetQueryConfiguration() { this = "SensitiveGetQueryConfiguration" }
5959

java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import javax.servlet.ServletException;
77

88
public class SensitiveGetQuery extends HttpServlet {
9-
// BAD - Tests sending sensitive information in a GET request.
9+
// BAD - Tests retrieving sensitive information through `request.getParameter()` in a GET request.
1010
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
1111
String username = request.getParameter("username");
1212
String password = request.getParameter("password");
@@ -18,7 +18,7 @@ void processUserInfo(String username, String password) {
1818
System.out.println("username = " + username+"; password "+password);
1919
}
2020

21-
// GOOD - Tests sending sensitive information in a POST request.
21+
// GOOD - Tests retrieving sensitive information through `request.getParameter()` in a POST request.
2222
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
2323
String password = request.getParameter("password");
2424
System.out.println("password = " + password);

java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import javax.servlet.ServletException;
88

99
public class SensitiveGetQuery2 extends HttpServlet {
10-
// BAD - Tests sending sensitive information in a GET request.
10+
// BAD - Tests retrieving sensitive information through `request.getParameterMap()` in a GET request.
1111
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
1212
Map map = request.getParameterMap();
1313
String username = (String) map.get("username");
@@ -19,7 +19,7 @@ void processUserInfo(String username, String password) {
1919
System.out.println("username = " + username+"; password "+password);
2020
}
2121

22-
// GOOD - Tests sending sensitive information in a POST request.
22+
// GOOD - Tests retrieving sensitive information through `request.getParameterMap()` in a POST request.
2323
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
2424
Map map = request.getParameterMap();
2525
String username = (String) map.get("username");

java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery3.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import javax.servlet.ServletException;
77

88
public class SensitiveGetQuery3 extends HttpServlet {
9-
// BAD - Tests sending sensitive information in a GET request.
9+
// BAD - Tests retrieving sensitive information through a wrapper call in a GET request.
1010
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
1111
String username = getRequestParameter(request, "username");
1212
String password = getRequestParameter(request, "password");
@@ -17,7 +17,7 @@ String getRequestParameter(HttpServletRequest request, String paramName) {
1717
return request.getParameter(paramName);
1818
}
1919

20-
// GOOD - Tests sending sensitive information in a POST request.
20+
// GOOD - Tests retrieving sensitive information through a wrapper call in a POST request.
2121
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
2222
String username = getRequestParameter(request, "username");
2323
String password = getRequestParameter(request, "password");

java/ql/test/experimental/query-tests/security/CWE-598/SensitiveGetQuery4.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import javax.servlet.ServletException;
77

88
public class SensitiveGetQuery4 extends HttpServlet {
9-
// BAD - Tests sending sensitive information in a GET request.
9+
// BAD - Tests retrieving non-sensitive tokens and sensitive tokens in a GET request.
1010
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
1111
String username = getRequestParameter(request, "username");
1212
String token = getRequestParameter(request, "token");
@@ -20,7 +20,7 @@ String getRequestParameter(HttpServletRequest request, String paramName) {
2020
return request.getParameter(paramName);
2121
}
2222

23-
// GOOD - Tests sending sensitive information in a POST request.
23+
// GOOD - Tests retrieving non-sensitive tokens and sensitive tokens in a POST request.
2424
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
2525
String username = getRequestParameter(request, "username");
2626
String token = getRequestParameter(request, "token");

0 commit comments

Comments
 (0)