Skip to content

Commit 21a018e

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: add summary model and test for File.getName
1 parent 939279a commit 21a018e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

java/ql/lib/ext/java.io.model.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extensions:
6363
- ["java.io", "File", True, "getAbsolutePath", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
6464
- ["java.io", "File", True, "getCanonicalFile", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
6565
- ["java.io", "File", True, "getCanonicalPath", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
66+
- ["java.io", "File", True, "getName", "()", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
6667
- ["java.io", "File", True, "toPath", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
6768
- ["java.io", "File", True, "toString", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
6869
- ["java.io", "File", True, "toURI", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
@@ -91,4 +92,3 @@ extensions:
9192
extensible: neutralModel
9293
data:
9394
- ["java.io", "File", "exists", "()", "manual"]
94-
- ["java.io", "File", "getName", "()", "manual"] # ! unsure if should be neutral model

java/ql/test/ext/TestModels/Test.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import java.io.IOException;
2+
import java.io.File;
23
import java.math.BigDecimal;
34
import java.sql.Connection;
45
import java.sql.DriverManager;
@@ -60,6 +61,9 @@ public void test() throws Exception {
6061
Exception e1 = new IOException((String)source());
6162
sink((String)e1.getMessage()); // $hasValueFlow
6263

64+
File f = (File)source();
65+
sink(f.getName()); // $hasTaintFlow
66+
6367
// java.lang
6468
Exception e2 = new Exception((String)source());
6569
sink((String)e2.getMessage()); // $hasValueFlow

0 commit comments

Comments
 (0)