mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Fix partial path traversal Java example Again
The original wouldn't compile, and the fix made by #11899 is sub-optimal. This keeps the entire comparision using the Java `Path` object, which is optimal. Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>
This commit is contained in:
committed by
Jonathan Leitschuh
parent
b9d409279b
commit
0d774a647c
@@ -225,6 +225,12 @@ public class PartialPathTraversalTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 doesNotFlag() {
|
||||
"hello".startsWith("goodbye");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user