File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
java/ql/test/query-tests/security/CWE-023/semmle/tests Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change 1414| PartialPathTraversalTest.java:176:14:176:65 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
1515| PartialPathTraversalTest.java:194:18:194:87 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
1616| PartialPathTraversalTest.java:212:14:212:64 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
17+ | PartialPathTraversalTest.java:234:14:234:54 | startsWith(...) | Partial Path Traversal Vulnerability due to insufficient guard against path traversal. |
Original file line number Diff line number Diff line change @@ -228,6 +228,14 @@ void foo24(File parent) throws IOException {
228228 }
229229 }
230230
231+ void foo25 (File parent ) throws IOException {
232+ String path = parent .getCanonicalPath ();
233+ path += File .separator ;
234+ if (!dir ().getCanonicalPath ().startsWith (path )) { // $ SPURIOUS: Alert[java/partial-path-traversal-from-remote] Alert[java/partial-path-traversal]
235+ throw new IOException ("Invalid directory: " + dir ().getCanonicalPath ());
236+ }
237+ }
238+
231239 public void doesNotFlagOptimalSafeVersion (File parent ) throws IOException {
232240 if (!dir ().toPath ().normalize ().startsWith (parent .toPath ())) { // Safe
233241 throw new IOException ("Path traversal attempt: " + dir ().getCanonicalPath ());
You can’t perform that action at this time.
0 commit comments