From 30f705822d12eebb8d50bf01c7aaa61151abed1e Mon Sep 17 00:00:00 2001 From: Taus Date: Fri, 11 Jul 2025 14:58:03 +0000 Subject: [PATCH] JavaScript: Add test where `outDir` resolves to an unwanted path --- .../semmle/js/extractor/test/AutoBuildTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/javascript/extractor/test/com/semmle/js/extractor/test/AutoBuildTests.java b/javascript/extractor/test/com/semmle/js/extractor/test/AutoBuildTests.java index 95f68aaf99a..e6b168ac340 100644 --- a/javascript/extractor/test/com/semmle/js/extractor/test/AutoBuildTests.java +++ b/javascript/extractor/test/com/semmle/js/extractor/test/AutoBuildTests.java @@ -265,6 +265,21 @@ public class AutoBuildTests { runTest(); } + @Test + public void skipFilesInTsconfigOutDirWithRelativePath() throws IOException { + // Test that outDir with relative path "somedir/.." (resolves to root) is ignored + addFile(true, LGTM_SRC, "tsconfig.json"); + Path config = Paths.get(LGTM_SRC.toString(), "tsconfig.json"); + Files.write(config, + "{\"compilerOptions\":{\"outDir\":\"somedir/..\"}}".getBytes(StandardCharsets.UTF_8)); + + // All files should be extracted since outDir resolving to root should be ignored + addFile(true, LGTM_SRC, "src", "app.ts"); + addFile(true, LGTM_SRC, "main.js"); + + runTest(); + } + @Test public void includeFile() throws IOException { envVars.put("LGTM_INDEX_INCLUDE", "tst.js");