Skip to content

Commit a1044e0

Browse files
committed
Add test case verifying isDescendant handles parent traversal ('..') safely without NPE
1 parent 9dd83a2 commit a1044e0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/src/test/java/hudson/FilePathTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,4 +1297,17 @@ private static File newFolder(File root, String... subDirs) throws IOException {
12971297
}
12981298
return result;
12991299
}
1300+
1301+
@Test
1302+
@Issue("SpotBugs")
1303+
public void testIsDescendantWithParentTraversal() throws Exception {
1304+
File tmp = Util.createTempDir();
1305+
try {
1306+
FilePath parent = new FilePath(tmp);
1307+
// This checks the specific case that causes getDirectChild to return null
1308+
assertFalse(parent.isDescendant(".."), "Parent directory '..' should not be a descendant");
1309+
} finally {
1310+
Util.deleteRecursive(tmp);
1311+
}
1312+
}
13001313
}

0 commit comments

Comments
 (0)