Skip to content

C++: Make Folder.getURL() consistent with Folder.getLocation()#3

Merged
jbj merged 1 commit into
github:masterfrom
ian-semmle:getURL
Aug 21, 2018
Merged

C++: Make Folder.getURL() consistent with Folder.getLocation()#3
jbj merged 1 commit into
github:masterfrom
ian-semmle:getURL

Conversation

@ian-semmle
Copy link
Copy Markdown
Contributor

This fixes confusing behaviour like:

from Element e, Folder f
where e = f
select e, f
file:///home/ian:0:0:0:0 | /home/ian | folder:///home/ian | /home/ian |

calumgrant pushed a commit to calumgrant/ql that referenced this pull request Aug 3, 2018
 JavaScript: Pull in changes up to 53548a6024b51
@jbj
Copy link
Copy Markdown
Contributor

jbj commented Aug 15, 2018

@ian-semmle This is blocked on our internal PR 27026, isn't it? If we make this change without agreeing on changing the spec first, then we're no longer following the spec.

Copy link
Copy Markdown
Contributor

@jbj jbj left a comment

Choose a reason for hiding this comment

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

The file system API spec now is updated to allow this change, so I'm happy to merge it.

@jbj jbj merged commit cb51a42 into github:master Aug 21, 2018
@ian-semmle ian-semmle deleted the getURL branch August 21, 2018 10:40
geoffw0 pushed a commit that referenced this pull request Jun 18, 2019
CPP: Fixes for C++: Mishandling Japanese Era and Leap Year in calculations #1354
aschackmull pushed a commit that referenced this pull request Jan 31, 2020
Java: Add unit test for ldap injection.
garbervetsky pushed a commit to shuvendu-lahiri/ql that referenced this pull request Dec 15, 2020
* --steps flag to run multiple steps

* README updated
aibaars added a commit that referenced this pull request Oct 14, 2021
Basic CodeQL extractor configuration and autobuild scripts
smowton referenced this pull request in smowton/codeql Oct 28, 2021
Kotlin: Add support for supertypes
geoffw0 pushed a commit that referenced this pull request May 31, 2022
Swift: Add swift-security-and-quality, swift-security-extended packs.
tiferet added a commit that referenced this pull request Aug 3, 2022
Feature selection: Use a shipping model with the new features excluding fileImports and calleeImports. Model #3.

github/ml-ql-adaptive-threat-modeling#1968 (comment)
aschackmull added a commit that referenced this pull request Mar 6, 2023
C++: Use refactored dataflow library in `cpp/command-line-injection`
MathiasVP pushed a commit that referenced this pull request May 9, 2023
Swift: Syntax for selecting `PostUpdateNode`s in CSV rows
jketema pushed a commit that referenced this pull request Sep 5, 2024
C++: Fix expected test results
dbartol pushed a commit that referenced this pull request Dec 18, 2024
nicolaswill added a commit that referenced this pull request May 12, 2025
Move language-agnostic model to shared library
owen-mc pushed a commit that referenced this pull request May 12, 2026
When CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_TESTS=true is set, the Go
extractor was incorrectly skipping internal test files (package foo)
at repository roots when the project contains nested test packages.

Root Cause:
The extractor selected package variants by longest ID string, but this
heuristic fails when nested packages have tests. For a package like
"github.com/go-git/go-git/v6", packages.Load returns multiple variants:

1. "github.com/go-git/go-git/v6" (19 files, production only)
2. "github.com/go-git/go-git/v6 [github.com/go-git/go-git/v6.test]"
   (39 files, production + 20 root tests) ← Should select this
3. "github.com/go-git/go-git/v6 [github.com/go-git/go-git/v6/plumbing/format/packfile.test]"
   (19 files, test dependency) ← Was incorrectly selected (longest string)

The old logic selected variant #3 (76 chars) over #2 (68 chars),
causing 20 root test files to be missing from the database.

Fix:
Replace string length comparison with a better heuristic that prefers:
1. Exact test packages (e.g., "pkg [pkg.test]") over nested dependencies
2. Packages with more Syntax nodes (more files to extract)
3. String length as a tiebreaker

This ensures the extractor selects the variant with the most complete
test coverage, particularly for root-level internal tests.

Testing:
- Added comprehensive unit tests covering the selection logic
- Tests simulate the real-world go-git scenario
- All tests pass

Impact:
Root-level external tests (package foo_test) were already extracted
correctly. This fix ensures internal tests (package foo) at the root
are now also extracted when they exist alongside nested test packages.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants