mirror of
https://github.com/github/codeql.git
synced 2026-04-24 16:25:15 +02:00
Java: convert PartialPathTraversalFromRemote test to .qlref
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
| PartialPathTraversalTest.java:10:14:10:73 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:17:9:17:72 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:29:14:29:58 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:35:14:35:63 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:42:14:42:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:49:14:49:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:53:14:53:65 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:61:14:61:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:64:14:64:65 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:75:14:75:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:94:14:94:63 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:102:14:102:63 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:105:14:105:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:173:14:173:63 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:191:18:191:87 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:209:14:209:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:13:14:13:75 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:20:9:20:74 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:32:14:32:60 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:38:14:38:65 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:45:14:45:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:52:14:52:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:56:14:56:65 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:64:14:64:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:67:14:67:65 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:78:14:78:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:97:14:97:65 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:105:14:105:65 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:108:14:108:66 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:176:14:176:65 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:194:18:194:87 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
| PartialPathTraversalTest.java:212:14:212:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
#select
|
||||
| PartialPathTraversalTest.java:13:14:13:37 | getCanonicalPath(...) | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:13:14:13:37 | getCanonicalPath(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:20:10:20:33 | getCanonicalPath(...) | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:20:10:20:33 | getCanonicalPath(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:32:14:32:37 | getCanonicalPath(...) | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:32:14:32:37 | getCanonicalPath(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:38:14:38:37 | getCanonicalPath(...) | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:38:14:38:37 | getCanonicalPath(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:45:14:45:26 | canonicalPath | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:45:14:45:26 | canonicalPath | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:52:14:52:26 | canonicalPath | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:52:14:52:26 | canonicalPath | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:56:14:56:27 | canonicalPath2 | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:56:14:56:27 | canonicalPath2 | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:64:14:64:26 | canonicalPath | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:64:14:64:26 | canonicalPath | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:67:14:67:27 | canonicalPath2 | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:67:14:67:27 | canonicalPath2 | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:97:14:97:37 | getCanonicalPath(...) | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:97:14:97:37 | getCanonicalPath(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:105:14:105:37 | getCanonicalPath(...) | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:105:14:105:37 | getCanonicalPath(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:108:14:108:37 | getCanonicalPath(...) | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:108:14:108:37 | getCanonicalPath(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:176:14:176:37 | getCanonicalPath(...) | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:176:14:176:37 | getCanonicalPath(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:194:18:194:47 | getCanonicalPath(...) | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:194:18:194:47 | getCanonicalPath(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
| PartialPathTraversalTest.java:212:14:212:26 | canonicalPath | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:212:14:212:26 | canonicalPath | Partial Path Traversal Vulnerability due to insufficient guard against path traversal from $@. | PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | user-supplied data |
|
||||
edges
|
||||
| PartialPathTraversalTest.java:13:14:13:18 | dir(...) : File | PartialPathTraversalTest.java:13:14:13:37 | getCanonicalPath(...) | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:20:10:20:14 | dir(...) : File | PartialPathTraversalTest.java:20:10:20:33 | getCanonicalPath(...) | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:32:14:32:18 | dir(...) : File | PartialPathTraversalTest.java:32:14:32:37 | getCanonicalPath(...) | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:38:14:38:18 | dir(...) : File | PartialPathTraversalTest.java:38:14:38:37 | getCanonicalPath(...) | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:44:32:44:36 | dir(...) : File | PartialPathTraversalTest.java:44:32:44:55 | getCanonicalPath(...) : String | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:44:32:44:55 | getCanonicalPath(...) : String | PartialPathTraversalTest.java:45:14:45:26 | canonicalPath | provenance | |
|
||||
| PartialPathTraversalTest.java:51:32:51:36 | dir(...) : File | PartialPathTraversalTest.java:51:32:51:55 | getCanonicalPath(...) : String | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:51:32:51:55 | getCanonicalPath(...) : String | PartialPathTraversalTest.java:52:14:52:26 | canonicalPath | provenance | |
|
||||
| PartialPathTraversalTest.java:55:33:55:37 | dir(...) : File | PartialPathTraversalTest.java:55:33:55:56 | getCanonicalPath(...) : String | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:55:33:55:56 | getCanonicalPath(...) : String | PartialPathTraversalTest.java:56:14:56:27 | canonicalPath2 | provenance | |
|
||||
| PartialPathTraversalTest.java:62:32:62:36 | dir(...) : File | PartialPathTraversalTest.java:62:32:62:55 | getCanonicalPath(...) : String | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:62:32:62:55 | getCanonicalPath(...) : String | PartialPathTraversalTest.java:64:14:64:26 | canonicalPath | provenance | |
|
||||
| PartialPathTraversalTest.java:63:33:63:37 | dir(...) : File | PartialPathTraversalTest.java:63:33:63:56 | getCanonicalPath(...) : String | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:63:33:63:56 | getCanonicalPath(...) : String | PartialPathTraversalTest.java:67:14:67:27 | canonicalPath2 | provenance | |
|
||||
| PartialPathTraversalTest.java:97:14:97:18 | dir(...) : File | PartialPathTraversalTest.java:97:14:97:37 | getCanonicalPath(...) | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:105:14:105:18 | dir(...) : File | PartialPathTraversalTest.java:105:14:105:37 | getCanonicalPath(...) | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:108:14:108:18 | dir(...) : File | PartialPathTraversalTest.java:108:14:108:37 | getCanonicalPath(...) | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:176:14:176:18 | dir(...) : File | PartialPathTraversalTest.java:176:14:176:37 | getCanonicalPath(...) | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:186:25:186:30 | path(...) : String[] | PartialPathTraversalTest.java:188:23:188:23 | p : String | provenance | |
|
||||
| PartialPathTraversalTest.java:188:13:188:14 | sb [post update] : StringBuilder | PartialPathTraversalTest.java:191:27:191:28 | sb : StringBuilder | provenance | |
|
||||
| PartialPathTraversalTest.java:188:23:188:23 | p : String | PartialPathTraversalTest.java:188:13:188:14 | sb [post update] : StringBuilder | provenance | MaD:8 |
|
||||
| PartialPathTraversalTest.java:191:27:191:28 | sb : StringBuilder | PartialPathTraversalTest.java:191:27:191:39 | toString(...) : String | provenance | MaD:9 |
|
||||
| PartialPathTraversalTest.java:191:27:191:39 | toString(...) : String | PartialPathTraversalTest.java:192:37:192:44 | filePath : String | provenance | |
|
||||
| PartialPathTraversalTest.java:192:28:192:45 | new File(...) : File | PartialPathTraversalTest.java:194:18:194:28 | encodedFile : File | provenance | |
|
||||
| PartialPathTraversalTest.java:192:37:192:44 | filePath : String | PartialPathTraversalTest.java:192:28:192:45 | new File(...) : File | provenance | MaD:4 |
|
||||
| PartialPathTraversalTest.java:194:18:194:28 | encodedFile : File | PartialPathTraversalTest.java:194:18:194:47 | getCanonicalPath(...) | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:211:46:211:50 | dir(...) : File | PartialPathTraversalTest.java:211:46:211:69 | getCanonicalPath(...) : String | provenance | MaD:6 |
|
||||
| PartialPathTraversalTest.java:211:46:211:69 | getCanonicalPath(...) : String | PartialPathTraversalTest.java:212:14:212:26 | canonicalPath | provenance | |
|
||||
| PartialPathTraversalTest.java:252:45:252:117 | new BufferedReader(...) : BufferedReader | PartialPathTraversalTest.java:253:31:253:44 | filenameReader : BufferedReader | provenance | |
|
||||
| PartialPathTraversalTest.java:252:64:252:116 | new InputStreamReader(...) : InputStreamReader | PartialPathTraversalTest.java:252:45:252:117 | new BufferedReader(...) : BufferedReader | provenance | MaD:2 |
|
||||
| PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | PartialPathTraversalTest.java:252:64:252:116 | new InputStreamReader(...) : InputStreamReader | provenance | Src:MaD:1 MaD:7 |
|
||||
| PartialPathTraversalTest.java:253:31:253:44 | filenameReader : BufferedReader | PartialPathTraversalTest.java:253:31:253:55 | readLine(...) : String | provenance | MaD:3 |
|
||||
| PartialPathTraversalTest.java:253:31:253:55 | readLine(...) : String | PartialPathTraversalTest.java:254:29:254:36 | filename : String | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:13:14:13:18 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:20:10:20:14 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:32:14:32:18 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:38:14:38:18 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:44:32:44:36 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:51:32:51:36 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:55:33:55:37 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:62:32:62:36 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:63:33:63:37 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:97:14:97:18 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:105:14:105:18 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:108:14:108:18 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:176:14:176:18 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:211:46:211:50 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | PartialPathTraversalTest.java:261:16:261:20 | dir(...) : File | provenance | |
|
||||
| PartialPathTraversalTest.java:254:29:254:36 | filename : String | PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | provenance | MaD:4 |
|
||||
| PartialPathTraversalTest.java:261:16:261:20 | dir(...) : File | PartialPathTraversalTest.java:261:16:261:38 | getAbsolutePath(...) : String | provenance | MaD:5 |
|
||||
| PartialPathTraversalTest.java:261:16:261:38 | getAbsolutePath(...) : String | PartialPathTraversalTest.java:261:16:261:60 | split(...) : String[] | provenance | MaD:10 |
|
||||
| PartialPathTraversalTest.java:261:16:261:60 | split(...) : String[] | PartialPathTraversalTest.java:186:25:186:30 | path(...) : String[] | provenance | |
|
||||
models
|
||||
| 1 | Source: java.net; Socket; false; getInputStream; (); ; ReturnValue; remote; manual |
|
||||
| 2 | Summary: java.io; BufferedReader; false; BufferedReader; ; ; Argument[0]; Argument[this]; taint; manual |
|
||||
| 3 | Summary: java.io; BufferedReader; true; readLine; ; ; Argument[this]; ReturnValue; taint; manual |
|
||||
| 4 | Summary: java.io; File; false; File; ; ; Argument[0]; Argument[this]; taint; manual |
|
||||
| 5 | Summary: java.io; File; true; getAbsolutePath; ; ; Argument[this]; ReturnValue; taint; manual |
|
||||
| 6 | Summary: java.io; File; true; getCanonicalPath; ; ; Argument[this]; ReturnValue; taint; manual |
|
||||
| 7 | Summary: java.io; InputStreamReader; false; InputStreamReader; ; ; Argument[0]; Argument[this]; taint; manual |
|
||||
| 8 | Summary: java.lang; AbstractStringBuilder; true; append; ; ; Argument[0]; Argument[this]; taint; manual |
|
||||
| 9 | Summary: java.lang; CharSequence; true; toString; ; ; Argument[this]; ReturnValue; taint; manual |
|
||||
| 10 | Summary: java.lang; String; false; split; ; ; Argument[this]; ReturnValue; taint; manual |
|
||||
nodes
|
||||
| PartialPathTraversalTest.java:13:14:13:18 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:13:14:13:37 | getCanonicalPath(...) | semmle.label | getCanonicalPath(...) |
|
||||
| PartialPathTraversalTest.java:20:10:20:14 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:20:10:20:33 | getCanonicalPath(...) | semmle.label | getCanonicalPath(...) |
|
||||
| PartialPathTraversalTest.java:32:14:32:18 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:32:14:32:37 | getCanonicalPath(...) | semmle.label | getCanonicalPath(...) |
|
||||
| PartialPathTraversalTest.java:38:14:38:18 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:38:14:38:37 | getCanonicalPath(...) | semmle.label | getCanonicalPath(...) |
|
||||
| PartialPathTraversalTest.java:44:32:44:36 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:44:32:44:55 | getCanonicalPath(...) : String | semmle.label | getCanonicalPath(...) : String |
|
||||
| PartialPathTraversalTest.java:45:14:45:26 | canonicalPath | semmle.label | canonicalPath |
|
||||
| PartialPathTraversalTest.java:51:32:51:36 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:51:32:51:55 | getCanonicalPath(...) : String | semmle.label | getCanonicalPath(...) : String |
|
||||
| PartialPathTraversalTest.java:52:14:52:26 | canonicalPath | semmle.label | canonicalPath |
|
||||
| PartialPathTraversalTest.java:55:33:55:37 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:55:33:55:56 | getCanonicalPath(...) : String | semmle.label | getCanonicalPath(...) : String |
|
||||
| PartialPathTraversalTest.java:56:14:56:27 | canonicalPath2 | semmle.label | canonicalPath2 |
|
||||
| PartialPathTraversalTest.java:62:32:62:36 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:62:32:62:55 | getCanonicalPath(...) : String | semmle.label | getCanonicalPath(...) : String |
|
||||
| PartialPathTraversalTest.java:63:33:63:37 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:63:33:63:56 | getCanonicalPath(...) : String | semmle.label | getCanonicalPath(...) : String |
|
||||
| PartialPathTraversalTest.java:64:14:64:26 | canonicalPath | semmle.label | canonicalPath |
|
||||
| PartialPathTraversalTest.java:67:14:67:27 | canonicalPath2 | semmle.label | canonicalPath2 |
|
||||
| PartialPathTraversalTest.java:97:14:97:18 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:97:14:97:37 | getCanonicalPath(...) | semmle.label | getCanonicalPath(...) |
|
||||
| PartialPathTraversalTest.java:105:14:105:18 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:105:14:105:37 | getCanonicalPath(...) | semmle.label | getCanonicalPath(...) |
|
||||
| PartialPathTraversalTest.java:108:14:108:18 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:108:14:108:37 | getCanonicalPath(...) | semmle.label | getCanonicalPath(...) |
|
||||
| PartialPathTraversalTest.java:176:14:176:18 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:176:14:176:37 | getCanonicalPath(...) | semmle.label | getCanonicalPath(...) |
|
||||
| PartialPathTraversalTest.java:186:25:186:30 | path(...) : String[] | semmle.label | path(...) : String[] |
|
||||
| PartialPathTraversalTest.java:188:13:188:14 | sb [post update] : StringBuilder | semmle.label | sb [post update] : StringBuilder |
|
||||
| PartialPathTraversalTest.java:188:23:188:23 | p : String | semmle.label | p : String |
|
||||
| PartialPathTraversalTest.java:191:27:191:28 | sb : StringBuilder | semmle.label | sb : StringBuilder |
|
||||
| PartialPathTraversalTest.java:191:27:191:39 | toString(...) : String | semmle.label | toString(...) : String |
|
||||
| PartialPathTraversalTest.java:192:28:192:45 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| PartialPathTraversalTest.java:192:37:192:44 | filePath : String | semmle.label | filePath : String |
|
||||
| PartialPathTraversalTest.java:194:18:194:28 | encodedFile : File | semmle.label | encodedFile : File |
|
||||
| PartialPathTraversalTest.java:194:18:194:47 | getCanonicalPath(...) | semmle.label | getCanonicalPath(...) |
|
||||
| PartialPathTraversalTest.java:211:46:211:50 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:211:46:211:69 | getCanonicalPath(...) : String | semmle.label | getCanonicalPath(...) : String |
|
||||
| PartialPathTraversalTest.java:212:14:212:26 | canonicalPath | semmle.label | canonicalPath |
|
||||
| PartialPathTraversalTest.java:252:45:252:117 | new BufferedReader(...) : BufferedReader | semmle.label | new BufferedReader(...) : BufferedReader |
|
||||
| PartialPathTraversalTest.java:252:64:252:116 | new InputStreamReader(...) : InputStreamReader | semmle.label | new InputStreamReader(...) : InputStreamReader |
|
||||
| PartialPathTraversalTest.java:252:86:252:106 | getInputStream(...) : InputStream | semmle.label | getInputStream(...) : InputStream |
|
||||
| PartialPathTraversalTest.java:253:31:253:44 | filenameReader : BufferedReader | semmle.label | filenameReader : BufferedReader |
|
||||
| PartialPathTraversalTest.java:253:31:253:55 | readLine(...) : String | semmle.label | readLine(...) : String |
|
||||
| PartialPathTraversalTest.java:254:20:254:37 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| PartialPathTraversalTest.java:254:29:254:36 | filename : String | semmle.label | filename : String |
|
||||
| PartialPathTraversalTest.java:261:16:261:20 | dir(...) : File | semmle.label | dir(...) : File |
|
||||
| PartialPathTraversalTest.java:261:16:261:38 | getAbsolutePath(...) : String | semmle.label | getAbsolutePath(...) : String |
|
||||
| PartialPathTraversalTest.java:261:16:261:60 | split(...) : String[] | semmle.label | split(...) : String[] |
|
||||
subpaths
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import java
|
||||
import utils.test.InlineExpectationsTest
|
||||
import semmle.code.java.security.PartialPathTraversalQuery
|
||||
|
||||
class TestRemoteSource extends RemoteFlowSource {
|
||||
TestRemoteSource() { this.asParameter().hasName(["dir", "path"]) }
|
||||
|
||||
override string getSourceType() { result = "TestSource" }
|
||||
}
|
||||
|
||||
module Test implements TestSig {
|
||||
string getARelevantTag() { result = "hasTaintFlow" }
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
tag = "hasTaintFlow" and
|
||||
exists(DataFlow::Node sink | PartialPathTraversalFromRemoteFlow::flowTo(sink) |
|
||||
sink.getLocation() = location and
|
||||
element = sink.toString() and
|
||||
value = ""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeTest<Test>
|
||||
@@ -0,0 +1,4 @@
|
||||
query: Security/CWE/CWE-023/PartialPathTraversalFromRemote.ql
|
||||
postprocess:
|
||||
- utils/test/PrettyPrintModels.ql
|
||||
- utils/test/InlineExpectationsTestQuery.ql
|
||||
@@ -1,68 +1,71 @@
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import static java.io.File.separatorChar;
|
||||
import java.nio.file.Files;
|
||||
import java.net.Socket;
|
||||
|
||||
|
||||
public class PartialPathTraversalTest {
|
||||
public void esapiExample(File dir, File parent) throws IOException {
|
||||
if (!dir.getCanonicalPath().startsWith(parent.getCanonicalPath())) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
public void esapiExample(File parent) throws IOException {
|
||||
if (!dir().getCanonicalPath().startsWith(parent.getCanonicalPath())) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
void foo1(File dir, File parent) throws IOException {
|
||||
(dir.getCanonicalPath()).startsWith((parent.getCanonicalPath())); // $hasTaintFlow
|
||||
void foo1(File parent) throws IOException {
|
||||
(dir().getCanonicalPath()).startsWith((parent.getCanonicalPath())); // $ Alert
|
||||
}
|
||||
|
||||
void foo2(File dir, File parent) throws IOException {
|
||||
dir.getCanonicalPath();
|
||||
void foo2(File parent) throws IOException {
|
||||
dir().getCanonicalPath();
|
||||
if ("potato".startsWith(parent.getCanonicalPath())) {
|
||||
System.out.println("Hello!");
|
||||
}
|
||||
}
|
||||
|
||||
void foo3(File dir, File parent) throws IOException {
|
||||
void foo3(File parent) throws IOException {
|
||||
String parentPath = parent.getCanonicalPath();
|
||||
if (!dir.getCanonicalPath().startsWith(parentPath)) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentPath)) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo4(File dir) throws IOException {
|
||||
if (!dir.getCanonicalPath().startsWith("/usr" + "/dir")) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
void foo4() throws IOException {
|
||||
if (!dir().getCanonicalPath().startsWith("/usr" + "/dir")) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo5(File dir, File parent) throws IOException {
|
||||
String canonicalPath = dir.getCanonicalPath();
|
||||
if (!canonicalPath.startsWith(parent.getCanonicalPath())) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
void foo5(File parent) throws IOException {
|
||||
String canonicalPath = dir().getCanonicalPath();
|
||||
if (!canonicalPath.startsWith(parent.getCanonicalPath())) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo6(File dir, File parent) throws IOException {
|
||||
String canonicalPath = dir.getCanonicalPath();
|
||||
if (!canonicalPath.startsWith(parent.getCanonicalPath())) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
void foo6(File parent) throws IOException {
|
||||
String canonicalPath = dir().getCanonicalPath();
|
||||
if (!canonicalPath.startsWith(parent.getCanonicalPath())) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
String canonicalPath2 = dir.getCanonicalPath();
|
||||
if (!canonicalPath2.startsWith(parent.getCanonicalPath())) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
String canonicalPath2 = dir().getCanonicalPath();
|
||||
if (!canonicalPath2.startsWith(parent.getCanonicalPath())) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo7(File dir, File parent) throws IOException {
|
||||
String canonicalPath = dir.getCanonicalPath();
|
||||
String canonicalPath2 = dir.getCanonicalPath();
|
||||
if (!canonicalPath.startsWith(parent.getCanonicalPath())) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
String canonicalPath = dir().getCanonicalPath();
|
||||
String canonicalPath2 = dir().getCanonicalPath();
|
||||
if (!canonicalPath.startsWith(parent.getCanonicalPath())) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
if (!canonicalPath2.startsWith(parent.getCanonicalPath())) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!canonicalPath2.startsWith(parent.getCanonicalPath())) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,70 +75,70 @@ public class PartialPathTraversalTest {
|
||||
|
||||
void foo8(File parent) throws IOException {
|
||||
String canonicalPath = getChild().getCanonicalPath();
|
||||
if (!canonicalPath.startsWith(parent.getCanonicalPath())) {
|
||||
if (!canonicalPath.startsWith(parent.getCanonicalPath())) {
|
||||
throw new IOException("Invalid directory: " + getChild().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo9(File dir, File parent) throws IOException {
|
||||
if (!dir.getCanonicalPath().startsWith(parent.getCanonicalPath() + File.separator)) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
void foo9(File parent) throws IOException {
|
||||
if (!dir().getCanonicalPath().startsWith(parent.getCanonicalPath() + File.separator)) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo10(File dir, File parent) throws IOException {
|
||||
if (!dir.getCanonicalPath().startsWith(parent.getCanonicalPath() + File.separatorChar)) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
void foo10(File parent) throws IOException {
|
||||
if (!dir().getCanonicalPath().startsWith(parent.getCanonicalPath() + File.separatorChar)) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo11(File dir, File parent) throws IOException {
|
||||
void foo11(File parent) throws IOException {
|
||||
String parentCanonical = parent.getCanonicalPath();
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical)) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical)) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo12(File dir, File parent) throws IOException {
|
||||
void foo12(File parent) throws IOException {
|
||||
String parentCanonical = parent.getCanonicalPath();
|
||||
String parentCanonical2 = parent.getCanonicalPath();
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical)) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical)) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical2)) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical2)) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo13(File dir, File parent) throws IOException {
|
||||
void foo13(File parent) throws IOException {
|
||||
String parentCanonical = parent.getCanonicalPath() + File.separatorChar;
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo14(File dir, File parent) throws IOException {
|
||||
void foo14(File parent) throws IOException {
|
||||
String parentCanonical = parent.getCanonicalPath() + separatorChar;
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo15(File dir, File parent) throws IOException {
|
||||
String parentCanonical = parent.getCanonicalPath() + File.separatorChar;
|
||||
String parentCanonical2 = parent.getCanonicalPath() + File.separatorChar;
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical2)) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical2)) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo16(File dir, File parent) throws IOException {
|
||||
void foo16(File parent) throws IOException {
|
||||
String parentCanonical = parent.getCanonicalPath() + File.separator;
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +148,7 @@ public class PartialPathTraversalTest {
|
||||
"UnusedAssignment",
|
||||
"ResultOfMethodCallIgnored"
|
||||
})
|
||||
void foo17(File dir, File parent, boolean branch) throws IOException {
|
||||
void foo17(File parent, boolean branch) throws IOException {
|
||||
String parentCanonical = null;
|
||||
"test ".startsWith("somethingElse");
|
||||
if (branch) {
|
||||
@@ -153,8 +156,8 @@ public class PartialPathTraversalTest {
|
||||
} else {
|
||||
parentCanonical = parent.getCanonicalPath() + File.separatorChar;
|
||||
}
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,24 +166,24 @@ public class PartialPathTraversalTest {
|
||||
if (branch) {
|
||||
parentCanonical = parent.getCanonicalPath() + File.separatorChar;
|
||||
}
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical)) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo19(File dir, File parent) throws IOException {
|
||||
void foo19(File parent) throws IOException {
|
||||
String parentCanonical = parent.getCanonicalPath() + "/potato";
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical)) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical)) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
private File cacheDir;
|
||||
|
||||
InputStream foo20(String... path) {
|
||||
InputStream foo20() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(cacheDir.getAbsolutePath());
|
||||
for (String p : path) {
|
||||
for (String p : path()) {
|
||||
sb.append(File.separatorChar);
|
||||
sb.append(p);
|
||||
}
|
||||
@@ -188,7 +191,7 @@ public class PartialPathTraversalTest {
|
||||
String filePath = sb.toString();
|
||||
File encodedFile = new File(filePath);
|
||||
try {
|
||||
if (!encodedFile.getCanonicalPath().startsWith(cacheDir.getCanonicalPath())) { // $hasTaintFlow
|
||||
if (!encodedFile.getCanonicalPath().startsWith(cacheDir.getCanonicalPath())) { // $ Alert
|
||||
return null;
|
||||
}
|
||||
return Files.newInputStream(encodedFile.toPath());
|
||||
@@ -197,37 +200,37 @@ public class PartialPathTraversalTest {
|
||||
}
|
||||
}
|
||||
|
||||
void foo21(File dir, File parent) throws IOException {
|
||||
void foo21(File parent) throws IOException {
|
||||
String parentCanonical = parent.getCanonicalPath();
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical + File.separator)) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical + File.separator)) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo22(File dir, File dir2, File parent, boolean conditional) throws IOException {
|
||||
String canonicalPath = conditional ? dir.getCanonicalPath() : dir2.getCanonicalPath();
|
||||
if (!canonicalPath.startsWith(parent.getCanonicalPath())) { // $hasTaintFlow
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
void foo22(File dir2, File parent, boolean conditional) throws IOException {
|
||||
String canonicalPath = conditional ? dir().getCanonicalPath() : dir2.getCanonicalPath();
|
||||
if (!canonicalPath.startsWith(parent.getCanonicalPath())) { // $ Alert
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo23(File dir, File parent) throws IOException {
|
||||
void foo23(File parent) throws IOException {
|
||||
String parentCanonical = parent.getCanonicalPath();
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical + "/")) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical + "/")) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
void foo24(File dir, File parent) throws IOException {
|
||||
void foo24(File parent) throws IOException {
|
||||
String parentCanonical = parent.getCanonicalPath();
|
||||
if (!dir.getCanonicalPath().startsWith(parentCanonical + '/')) {
|
||||
throw new IOException("Invalid directory: " + dir.getCanonicalPath());
|
||||
if (!dir().getCanonicalPath().startsWith(parentCanonical + '/')) {
|
||||
throw new IOException("Invalid directory: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
public void doesNotFlagOptimalSafeVersion(File dir, File parent) throws IOException {
|
||||
if (!dir.toPath().normalize().startsWith(parent.toPath())) { // Safe
|
||||
throw new IOException("Path traversal attempt: " + dir.getCanonicalPath());
|
||||
public void doesNotFlagOptimalSafeVersion(File parent) throws IOException {
|
||||
if (!dir().toPath().normalize().startsWith(parent.toPath())) { // Safe
|
||||
throw new IOException("Path traversal attempt: " + dir().getCanonicalPath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,4 +245,19 @@ public class PartialPathTraversalTest {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Socket sock;
|
||||
|
||||
File dir() {
|
||||
try {
|
||||
BufferedReader filenameReader = new BufferedReader(new InputStreamReader(sock.getInputStream(), "UTF-8")); // $ Source
|
||||
String filename = filenameReader.readLine();
|
||||
return new File(filename);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to read from socket", e);
|
||||
}
|
||||
}
|
||||
|
||||
String[] path() {
|
||||
return dir().getAbsolutePath().split(File.separator);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user