test: ensure we don't allow path traversal with win

This commit is contained in:
Connor Tumbleson 2019-05-07 18:06:07 -04:00 committed by Connor Tumbleson
parent 47854ec757
commit 4aa933b31a
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75

View File

@ -71,6 +71,18 @@ public class UnknownDirectoryTraversalTest extends BaseTest {
BrutIO.sanitizeUnknownFile(sTmpDir, ""); BrutIO.sanitizeUnknownFile(sTmpDir, "");
} }
@Test(expected = TraversalUnknownFileException.class)
public void invalidBackwardPathOnWindows() throws IOException, BrutException {
String invalidPath;
if (! OSDetection.isWindows()) {
invalidPath = "../../app";
} else {
invalidPath = "..\\..\\app.exe";
}
BrutIO.sanitizeUnknownFile(sTmpDir, invalidPath);
}
@Test @Test
public void validDirectoryFileTest() throws IOException, BrutException { public void validDirectoryFileTest() throws IOException, BrutException {
String validFilename = BrutIO.sanitizeUnknownFile(sTmpDir, "dir" + File.separator + "file"); String validFilename = BrutIO.sanitizeUnknownFile(sTmpDir, "dir" + File.separator + "file");