Skip to content

Commit 89ee2b9

Browse files
authored
Merge pull request github#12911 from atorralba/atorralba/java/filecopyutils-file-sinks
Java: Fix FileCopyUtils.copy models
2 parents a9d3445 + e3d93c3 commit 89ee2b9

File tree

6 files changed

+280
-257
lines changed

6 files changed

+280
-257
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Changed some models of Spring's `FileCopyUtils.copy` to be path injection sinks instead of summaries.

java/ql/lib/ext/org.springframework.util.model.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
extensions:
2+
- addsTo:
3+
pack: codeql/java-all
4+
extensible: sinkModel
5+
data:
6+
- ["org.springframework.util", "FileCopyUtils", False, "copy", "(byte[],File)", "", "Argument[1]", "create-file", "manual"]
7+
- ["org.springframework.util", "FileCopyUtils", False, "copy", "(File,File)", "", "Argument[0]", "read-file", "manual"]
8+
- ["org.springframework.util", "FileCopyUtils", False, "copy", "(File,File)", "", "Argument[1]", "create-file", "manual"]
9+
210
- addsTo:
311
pack: codeql/java-all
412
extensible: summaryModel
@@ -42,7 +50,10 @@ extensions:
4250
- ["org.springframework.util", "FastByteArrayOutputStream", False, "toByteArray", "", "", "Argument[this]", "ReturnValue", "taint", "manual"]
4351
- ["org.springframework.util", "FastByteArrayOutputStream", False, "write", "", "", "Argument[0]", "Argument[this]", "taint", "manual"]
4452
- ["org.springframework.util", "FastByteArrayOutputStream", False, "writeTo", "", "", "Argument[this]", "Argument[0]", "taint", "manual"]
45-
- ["org.springframework.util", "FileCopyUtils", False, "copy", "", "", "Argument[0]", "Argument[1]", "taint", "manual"]
53+
- ["org.springframework.util", "FileCopyUtils", False, "copy", "(byte[],OutputStream)", "", "Argument[0]", "Argument[1]", "taint", "manual"]
54+
- ["org.springframework.util", "FileCopyUtils", False, "copy", "(InputStream,OutputStream)", "", "Argument[0]", "Argument[1]", "taint", "manual"]
55+
- ["org.springframework.util", "FileCopyUtils", False, "copy", "(Reader,Writer)", "", "Argument[0]", "Argument[1]", "taint", "manual"]
56+
- ["org.springframework.util", "FileCopyUtils", False, "copy", "(String,Writer)", "", "Argument[0]", "Argument[1]", "taint", "manual"]
4657
- ["org.springframework.util", "FileCopyUtils", False, "copyToByteArray", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
4758
- ["org.springframework.util", "FileCopyUtils", False, "copyToString", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
4859
- ["org.springframework.util", "FileSystemUtils", False, "copyRecursively", "(java.io.File,java.io.File)", "", "Argument[0]", "Argument[1]", "taint", "manual"]

java/ql/test/library-tests/frameworks/spring/util/Test.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -380,20 +380,6 @@ public void test() throws Exception {
380380
FileCopyUtils.copy(in, out);
381381
sink(out); // $hasTaintFlow
382382
}
383-
{
384-
// "org.springframework.util;FileCopyUtils;false;copy;;;Argument[0];Argument[1];taint;manual"
385-
File out = null;
386-
byte[] in = (byte[])source();
387-
FileCopyUtils.copy(in, out);
388-
sink(out); // $hasTaintFlow
389-
}
390-
{
391-
// "org.springframework.util;FileCopyUtils;false;copy;;;Argument[0];Argument[1];taint;manual"
392-
File out = null;
393-
File in = (File)source();
394-
FileCopyUtils.copy(in, out);
395-
sink(out); // $hasTaintFlow
396-
}
397383
{
398384
// "org.springframework.util;FileCopyUtils;false;copyToByteArray;;;Argument[0];ReturnValue;taint;manual"
399385
byte[] out = null;

0 commit comments

Comments
 (0)