mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-21 03:21:36 +01:00
avoid path traversal attack
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package sonia.scm.repository;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
@@ -20,4 +21,20 @@ class InitialRepositoryLocationResolverTest {
|
||||
assertThat(path).isRelative();
|
||||
assertThat(path.toString()).isEqualTo("repositories" + File.separator + "42");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldThrowIllegalArgumentExceptionIfIdHasASlash() {
|
||||
InitialRepositoryLocationResolver resolver = new InitialRepositoryLocationResolver();
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
resolver.getPath("../../../passwd");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldThrowIllegalArgumentExceptionIfIdHasABackSlash() {
|
||||
InitialRepositoryLocationResolver resolver = new InitialRepositoryLocationResolver();
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
resolver.getPath("..\\..\\..\\users.ntlm");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user