mirror of
https://github.com/github/codeql.git
synced 2026-02-15 22:43:43 +01:00
JavaScript: Ignore outDirs that would exclude everything
In #19680 we added support for automatically ignoring files in the `outDir` directory as specified in the TSconfig compiler options (as these files were likely duplicates of `.ts` file we were already scanning). However, in some cases people put `outDir: "."` or even `outDir: ".."` in their configuration, which had the side effect of excluding _all_ files, leading to a failed extraction. With the changes in this PR, we now ignore any `outDir`s that are not properly contained within the source root of the code being scanned. This should prevent the files from being extracted, while still allowing us to not double-scan files in, say, a `.github` directory, as seen in some Actions workflows.
This commit is contained in:
@@ -754,7 +754,11 @@ public class AutoBuild {
|
||||
continue;
|
||||
}
|
||||
Path odir = cfg.getParent().resolve(root.getCompilerOptions().getOutDir()).toAbsolutePath().normalize();
|
||||
outDirs.add(odir);
|
||||
// Only exclude outDirs that are proper subdirectories of the source root
|
||||
// This prevents excluding all code when outDir points outside the source root or to the source root itself
|
||||
if (tryRelativize(LGTM_SRC, odir) != null && !odir.equals(LGTM_SRC)) {
|
||||
outDirs.add(odir);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore malformed tsconfig or missing fields
|
||||
|
||||
Reference in New Issue
Block a user