Add shared codeql_canonical_path.dll with Go and Kotlin integrations#22104
Closed
Copilot wants to merge 8 commits into
Closed
Add shared codeql_canonical_path.dll with Go and Kotlin integrations#22104Copilot wants to merge 8 commits into
Copilot wants to merge 8 commits into
Conversation
- Add shared/canonicalize/ C++ DLL that resolves Windows paths via GetFinalPathNameByHandleW with a full-path cache (matching C#'s CanonicalPathCache strategy). - Add JNI interface (canonicalize_jni.cpp) for Kotlin/Java consumers. - Add NativeCanonicalizer.java to kotlin-extractor for loading the DLL and exposing a resolve() method. - Call NativeCanonicalizer.resolve() in FileUtil.tryMakeCanonical(). - Add go/extractor/canonicalize package (Windows + non-Windows impls). - Use canonicalize.CanonicalizePath() in go extractor normalizedPath(). - Update Bazel build files for all new targets and deps.
Replace std::rand() with std::mt19937 seeded by std::random_device for less predictable cache eviction. Also use .first from emplace() instead of structured binding with ignored second element.
Copilot
AI
changed the title
[WIP] Add shared native C++ library for canonicalizing Windows paths
Add shared codeql_canonical_path.dll with Go and Kotlin integrations
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a Windows-only shared native C++ library that canonicalizes paths via
GetFinalPathNameByHandleW(resolving subst drives, symlinks, junctions, and filename case), with a thread-safe full-path cache matching the C# extractor'sCanonicalPathCachestrategy. Consumed by the Kotlin and Go extractors, which previously had no equivalent.Shared C++ library (
shared/canonicalize/)canonicalize.h/cpp: SingletonPathCachewithstd::shared_mutexfor concurrent reads,GetFinalPathNameByHandleW-based resolution,std::mt19937random eviction at capacity (4096 entries), UNC prefix stripping, and parent-directory fallback for non-existent pathscanonicalize_jni.cpp: JNI entry point using the UTF-16 API — no encoding round-trip for Java stringsBUILD.bazel:cc_binary(DLL + JNI dep),cc_library, andpkg_filestargets; alltarget_compatible_with = ["@platforms//os:windows"]Kotlin integration (
java/kotlin-extractor/)NativeCanonicalizer.java: Loads the DLL from$CODEQL_DIST/tools/win64/in a static initializer; silently falls back if unavailable (non-Windows or DLL missing)FileUtil.java:tryMakeCanonical()now routes its result throughNativeCanonicalizer.resolve()in both the success and IOException-fallback pathsGo integration (
go/extractor/canonicalize/)canonicalize_windows.go: Dynamically loads the DLL viasyscall.LoadDLL; callscanonicalize_path_u8and frees withcanonicalize_free_u8(Go cannot callfree()directly across DLL boundary)canonicalize_other.go: Identity no-op on non-Windowsgo/extractor/extractor.go:normalizedPath()callscanonicalize.CanonicalizePath(path)afterfilepath.EvalSymlinksgo/BUILD.bazel: DLL packaged intotools/{CODEQL_PLATFORM}via a newcanonicalize-dllcodeql_pkg_filestarget added to thegopack