security(import): reject path-traversal filenames in MassImportService.processRows #650
@@ -512,6 +512,18 @@ class MassImportServiceTest {
|
|||||||
assertThat(result).isFalse();
|
assertThat(result).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void isValidImportFilename_returnsTrue_whenFilenameHasLeadingDot() {
|
||||||
|
boolean result = ReflectionTestUtils.invokeMethod(service, "isValidImportFilename", ".hidden.pdf");
|
||||||
|
assertThat(result).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void isValidImportFilename_returnsTrue_whenFilenameHasSpaces() {
|
||||||
|
boolean result = ReflectionTestUtils.invokeMethod(service, "isValidImportFilename", "Brief an Oma.pdf");
|
||||||
|
assertThat(result).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void processRows_skipsRowAndContinues_whenFilenameIsPathTraversal() {
|
void processRows_skipsRowAndContinues_whenFilenameIsPathTraversal() {
|
||||||
when(documentService.findByOriginalFilename("legitimate.pdf")).thenReturn(Optional.empty());
|
when(documentService.findByOriginalFilename("legitimate.pdf")).thenReturn(Optional.empty());
|
||||||
|
|||||||
Reference in New Issue
Block a user