mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Java: add summary model and test for File.getName
This commit is contained in:
@@ -63,6 +63,7 @@ extensions:
|
||||
- ["java.io", "File", True, "getAbsolutePath", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
|
||||
- ["java.io", "File", True, "getCanonicalFile", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
|
||||
- ["java.io", "File", True, "getCanonicalPath", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
|
||||
- ["java.io", "File", True, "getName", "()", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
|
||||
- ["java.io", "File", True, "toPath", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
|
||||
- ["java.io", "File", True, "toString", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
|
||||
- ["java.io", "File", True, "toURI", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"]
|
||||
@@ -91,4 +92,3 @@ extensions:
|
||||
extensible: neutralModel
|
||||
data:
|
||||
- ["java.io", "File", "exists", "()", "manual"]
|
||||
- ["java.io", "File", "getName", "()", "manual"] # ! unsure if should be neutral model
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
@@ -60,6 +61,9 @@ public class Test {
|
||||
Exception e1 = new IOException((String)source());
|
||||
sink((String)e1.getMessage()); // $hasValueFlow
|
||||
|
||||
File f = (File)source();
|
||||
sink(f.getName()); // $hasTaintFlow
|
||||
|
||||
// java.lang
|
||||
Exception e2 = new Exception((String)source());
|
||||
sink((String)e2.getMessage()); // $hasValueFlow
|
||||
|
||||
Reference in New Issue
Block a user