aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl/src/test
diff options
context:
space:
mode:
authorSteve Marion <unknown>2023-05-10 14:10:54 +0200
committersonartech <sonartech@sonarsource.com>2023-05-12 20:02:41 +0000
commit5bd73a2bccb04fb48faec629996b5200761f4511 (patch)
tree002719d05bd95fcb0e3d9151dc7a7de224888a83 /sonar-plugin-api-impl/src/test
parent794259e7e6629d1058b2400020ce80823cf83f58 (diff)
downloadsonarqube-5bd73a2bccb04fb48faec629996b5200761f4511.tar.gz
sonarqube-5bd73a2bccb04fb48faec629996b5200761f4511.zip
SONAR-19096 add non-null check on the sanitizing of the relative path.
Diffstat (limited to 'sonar-plugin-api-impl/src/test')
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/DefaultIndexedFileTest.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/DefaultIndexedFileTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/DefaultIndexedFileTest.java
index 29edc62eaed..cec12d02a93 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/DefaultIndexedFileTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/DefaultIndexedFileTest.java
@@ -35,4 +35,12 @@ public class DefaultIndexedFileTest {
.isInstanceOf(IllegalStateException.class)
.hasMessageEndingWith("length (401) is longer than the maximum authorized (400)");
}
+
+ @Test
+ public void sanitize_shouldThrow_whenRelativePathIsInvalid() {
+ String invalidPath = "./../foo/bar";
+ Assertions.assertThatThrownBy(() -> DefaultIndexedFile.checkSanitize(invalidPath))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining(invalidPath);
+ }
}