Skip to content

Commit 029e1d4

Browse files
authored
Merge pull request github#12081 from jcogs33/jcogs33/update-some-Files-sinks
Java: update `createTempDirectory` and `copy` "create-file" sinks
2 parents e40bb6a + e4c8387 commit 029e1d4

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Removed the first argument of `java.nio.file.Files#createTempDirectory(String,FileAttribute[])` as a "create-file" sink.
5+
* Added the first argument of `java.nio.file.Files#copy` as a "read-file" sink for the `java/path-injection` query.

java/ql/lib/ext/java.nio.file.model.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ extensions:
33
pack: codeql/java-all
44
extensible: sinkModel
55
data:
6+
- ["java.nio.file", "Files", False, "copy", "", "", "Argument[0]", "read-file", "manual"]
67
- ["java.nio.file", "Files", False, "copy", "", "", "Argument[1]", "create-file", "manual"]
78
- ["java.nio.file", "Files", False, "createDirectories", "", "", "Argument[0]", "create-file", "manual"]
89
- ["java.nio.file", "Files", False, "createDirectory", "", "", "Argument[0]", "create-file", "manual"]
910
- ["java.nio.file", "Files", False, "createFile", "", "", "Argument[0]", "create-file", "manual"]
1011
- ["java.nio.file", "Files", False, "createLink", "", "", "Argument[0]", "create-file", "manual"]
1112
- ["java.nio.file", "Files", False, "createSymbolicLink", "", "", "Argument[0]", "create-file", "manual"]
12-
- ["java.nio.file", "Files", False, "createTempDirectory", "", "", "Argument[0]", "create-file", "manual"]
13+
- ["java.nio.file", "Files", False, "createTempDirectory", "(Path,String,FileAttribute[])", "", "Argument[0]", "create-file", "manual"]
1314
- ["java.nio.file", "Files", False, "createTempFile", "(Path,String,String,FileAttribute[])", "", "Argument[0]", "create-file", "manual"]
1415
- ["java.nio.file", "Files", False, "move", "", "", "Argument[1]", "create-file", "manual"]
1516
- ["java.nio.file", "Files", False, "newBufferedWriter", "", "", "Argument[0]", "create-file", "manual"]

java/ql/lib/semmle/code/java/dataflow/ExternalFlow.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ module ModelValidation {
261261
[
262262
"open-url", "jndi-injection", "ldap", "sql", "jdbc-url", "logging", "mvel", "xpath",
263263
"groovy", "xss", "ognl-injection", "intent-start", "pending-intent-sent",
264-
"url-open-stream", "url-redirect", "create-file", "write-file", "set-hostname-verifier",
265-
"header-splitting", "information-leak", "xslt", "jexl", "bean-validation", "ssti",
266-
"fragment-injection"
264+
"url-open-stream", "url-redirect", "create-file", "read-file", "write-file",
265+
"set-hostname-verifier", "header-splitting", "information-leak", "xslt", "jexl",
266+
"bean-validation", "ssti", "fragment-injection"
267267
] and
268268
not kind.matches("regex-use%") and
269269
not kind.matches("qltest%") and

java/ql/src/Security/CWE/CWE-022/TaintedPath.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TaintedPathConfig extends TaintTracking::Configuration {
2929
override predicate isSink(DataFlow::Node sink) {
3030
sink.asExpr() = any(PathCreation p).getAnInput()
3131
or
32-
sinkNode(sink, "create-file")
32+
sinkNode(sink, ["create-file", "read-file"])
3333
}
3434

3535
override predicate isSanitizer(DataFlow::Node sanitizer) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
| p;PrivateFlowViaPublicInterface$SPI;true;openStream;();;Argument[-1];create-file;generated |
2+
| p;Sinks;true;copyFileToDirectory;(Path,Path,CopyOption[]);;Argument[0];read-file;generated |
23
| p;Sinks;true;copyFileToDirectory;(Path,Path,CopyOption[]);;Argument[1];create-file;generated |
34
| p;Sinks;true;readUrl;(URL,Charset);;Argument[0];open-url;generated |
45
| p;Sources;true;readUrl;(URL);;Argument[0];open-url;generated |

0 commit comments

Comments
 (0)