From 5bd73a2bccb04fb48faec629996b5200761f4511 Mon Sep 17 00:00:00 2001 From: Steve Marion Date: Wed, 10 May 2023 14:10:54 +0200 Subject: SONAR-19096 add non-null check on the sanitizing of the relative path. --- .../org/sonar/api/batch/fs/internal/DefaultIndexedFileTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sonar-plugin-api-impl/src/test') 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); + } } -- cgit v1.2.3