Skip to content

Commit 665d40d

Browse files
committed
Java: Convert file-path-injection to data extensions.
1 parent b61f515 commit 665d40d

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/java-all
4+
extensible: extExperimentalSourceModel
5+
data:
6+
- ["com.jfinal.core", "Controller", True, "get", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
7+
- ["com.jfinal.core", "Controller", True, "getBoolean", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
8+
- ["com.jfinal.core", "Controller", True, "getCookie", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
9+
- ["com.jfinal.core", "Controller", True, "getCookieObject", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
10+
- ["com.jfinal.core", "Controller", True, "getCookieObjects", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
11+
- ["com.jfinal.core", "Controller", True, "getCookieToInt", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
12+
- ["com.jfinal.core", "Controller", True, "getCookieToLong", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
13+
- ["com.jfinal.core", "Controller", True, "getDate", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
14+
- ["com.jfinal.core", "Controller", True, "getFile", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
15+
- ["com.jfinal.core", "Controller", True, "getFiles", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
16+
- ["com.jfinal.core", "Controller", True, "getHeader", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
17+
- ["com.jfinal.core", "Controller", True, "getInt", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
18+
- ["com.jfinal.core", "Controller", True, "getKv", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
19+
- ["com.jfinal.core", "Controller", True, "getLong", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
20+
- ["com.jfinal.core", "Controller", True, "getPara", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
21+
- ["com.jfinal.core", "Controller", True, "getParaMap", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
22+
- ["com.jfinal.core", "Controller", True, "getParaToBoolean", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
23+
- ["com.jfinal.core", "Controller", True, "getParaToDate", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
24+
- ["com.jfinal.core", "Controller", True, "getParaToInt", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
25+
- ["com.jfinal.core", "Controller", True, "getParaToLong", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
26+
- ["com.jfinal.core", "Controller", True, "getParaValues", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
27+
- ["com.jfinal.core", "Controller", True, "getParaValuesToInt", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]
28+
- ["com.jfinal.core", "Controller", True, "getParaValuesToLong", "", "", "ReturnValue", "remote", "manual", "file-path-injection"]

java/ql/src/experimental/Security/CWE/CWE-073/FilePathInjection.ql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@
1212
*/
1313

1414
import java
15+
import semmle.code.java.dataflow.ExternalFlow
1516
import semmle.code.java.dataflow.FlowSources
1617
import semmle.code.java.security.PathCreation
1718
import JFinalController
1819
import semmle.code.java.security.PathSanitizer
1920
import DataFlow::PathGraph
2021

22+
private class ActivateModels extends ActiveExperimentalModels {
23+
ActivateModels() { this = "file-path-injection" }
24+
}
25+
2126
/** A complementary sanitizer that protects against path traversal using path normalization. */
2227
class PathNormalizeSanitizer extends MethodAccess {
2328
PathNormalizeSanitizer() {

java/ql/src/experimental/Security/CWE/CWE-073/JFinalController.qll

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,3 @@ private class SetToGetAttributeStep extends AdditionalValueStep {
6161
)
6262
}
6363
}
64-
65-
/** Remote flow source models relating to `JFinal`. */
66-
private class JFinalControllerSource extends SourceModelCsv {
67-
override predicate row(string row) {
68-
row =
69-
[
70-
"com.jfinal.core;Controller;true;getCookie" + ["", "Object", "Objects", "ToInt", "ToLong"] +
71-
";;;ReturnValue;remote;manual",
72-
"com.jfinal.core;Controller;true;getFile" + ["", "s"] + ";;;ReturnValue;remote;manual",
73-
"com.jfinal.core;Controller;true;getHeader;;;ReturnValue;remote;manual",
74-
"com.jfinal.core;Controller;true;getKv;;;ReturnValue;remote;manual",
75-
"com.jfinal.core;Controller;true;getPara" +
76-
[
77-
"", "Map", "ToBoolean", "ToDate", "ToInt", "ToLong", "Values", "ValuesToInt",
78-
"ValuesToLong"
79-
] + ";;;ReturnValue;remote;manual",
80-
"com.jfinal.core;Controller;true;get" + ["", "Int", "Long", "Boolean", "Date"] +
81-
";;;ReturnValue;remote;manual"
82-
]
83-
}
84-
}

0 commit comments

Comments
 (0)