Centralize and model additional path creations.

This commit is contained in:
intrigus
2020-07-03 00:25:27 +02:00
parent e167b87150
commit 641c5df79f
7 changed files with 264 additions and 76 deletions

View File

@@ -0,0 +1,21 @@
| PathCreation.java:13:18:13:32 | new File(...) |
| PathCreation.java:14:19:14:40 | new File(...) |
| PathCreation.java:18:18:18:49 | new File(...) |
| PathCreation.java:18:27:18:41 | new File(...) |
| PathCreation.java:22:18:22:41 | new File(...) |
| PathCreation.java:26:18:26:31 | of(...) |
| PathCreation.java:27:19:27:39 | of(...) |
| PathCreation.java:31:18:31:40 | of(...) |
| PathCreation.java:35:18:35:33 | get(...) |
| PathCreation.java:36:19:36:41 | get(...) |
| PathCreation.java:40:18:40:42 | get(...) |
| PathCreation.java:44:18:44:56 | getPath(...) |
| PathCreation.java:45:19:45:64 | getPath(...) |
| PathCreation.java:49:18:49:31 | of(...) |
| PathCreation.java:49:18:49:53 | resolveSibling(...) |
| PathCreation.java:53:18:53:31 | of(...) |
| PathCreation.java:53:18:53:46 | resolve(...) |
| PathCreation.java:57:25:57:45 | new FileWriter(...) |
| PathCreation.java:61:25:61:45 | new FileReader(...) |
| PathCreation.java:65:32:65:58 | new FileOutputStream(...) |
| PathCreation.java:69:31:69:56 | new FileInputStream(...) |

View File

@@ -0,0 +1,71 @@
import java.io.File;
import java.io.FileWriter;
import java.io.FileReader;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.FileSystems;
import java.net.URI;
class PathCreation {
public void testNewFileWithString() {
File f = new File("dir");
File f2 = new File("dir", "sub");
}
public void testNewFileWithFileString() {
File f = new File(new File("dir"), "sub");
}
public void testNewFileWithURI() {
File f = new File(new URI("dir"));
}
public void testPathOfWithString() {
Path p = Path.of("dir");
Path p2 = Path.of("dir", "sub");
}
public void testPathOfWithURI() {
Path p = Path.of(new URI("dir"));
}
public void testPathsGetWithString() {
Path p = Paths.get("dir");
Path p2 = Paths.get("dir", "sub");
}
public void testPathsGetWithURI() {
Path p = Paths.get(new URI("dir"));
}
public void testFileSystemGetPathWithString() {
Path p = FileSystems.getDefault().getPath("dir");
Path p2 = FileSystems.getDefault().getPath("dir", "sub");
}
public void testPathResolveSiblingWithString() {
Path p = Path.of("dir").resolveSibling("sub");
}
public void testPathResolveWithString() {
Path p = Path.of("dir").resolve("sub");
}
public void testNewFileWriterWithString() {
FileWriter fw = new FileWriter("dir");
}
public void testNewFileReaderWithString() {
FileReader fr = new FileReader("dir");
}
public void testNewFileOutputStreamWithString() {
FileOutputStream fos = new FileOutputStream("dir");
}
public void testNewFileInputStreamWithString() {
FileInputStream fis = new FileInputStream("dir");
}
}

View File

@@ -0,0 +1,5 @@
import java
import semmle.code.java.security.PathCreation
from PathCreation path
select path