Skip to content

JavaScript: Ignore outDirs that would exclude everything #20030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tausbn
Copy link
Contributor

@tausbn tausbn commented Jul 11, 2025

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 outDirs 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.

tausbn added 2 commits July 11, 2025 13:28
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.
@tausbn tausbn marked this pull request as ready for review July 11, 2025 13:53
@Copilot Copilot AI review requested due to automatic review settings July 11, 2025 13:53
@tausbn tausbn requested a review from a team as a code owner July 11, 2025 13:53
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where the JavaScript extractor would incorrectly exclude all source files when outDir in tsconfig.json points to the source root directory (.) or parent directory (..). The fix ensures that only outDir configurations that are proper subdirectories of the source root are used for file exclusion.

  • Added validation to check if outDir is properly contained within the source root before excluding files
  • Enhanced test coverage with two new test cases for edge cases with outDir configuration
  • Updated change notes to document the fix

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java Adds logic to validate outDir is a proper subdirectory before excluding files
javascript/extractor/test/com/semmle/js/extractor/test/AutoBuildTests.java Adds test cases for outDir pointing to parent and source root directories
javascript/ql/lib/change-notes/2025-07-11-ignore-outdirs-that-would-exclude-everything.md Documents the fix in release notes

Napalys
Napalys previously approved these changes Jul 11, 2025
Copy link
Contributor

@Napalys Napalys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be silly but would it make sense to also add a test case where outDir would be someDir/../../ or similar?

Assuming the DCA looks good and you don't think we need such test case :shipit:

@tausbn
Copy link
Contributor Author

tausbn commented Jul 11, 2025

It might be silly but would it make sense to also add a test case where outDir would be someDir/../../ or similar?

That's a good idea. I'll add an extra test. (And assuming it doesn't reveal a bug in the implementation, I'll refrain from rerunning DCA as I'm only changing a test.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy