Rust: Generate canonical paths for builtins#19732
Merged
hvitved merged 2 commits intogithub:mainfrom Jun 12, 2025
Merged
Conversation
6eb5bd6 to
69e549f
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR extends canonical path resolution to include Rust built-in types (e.g., str) by modeling them in the core crate and updates related tests.
- Extend
PathResolution.qllto recognize builtins undercore - Update test queries to import
PathResolutionandBuiltinsand cover atrimexample - Adjust expected outputs to include the generated
<core::str>::trimpath
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rust/ql/lib/codeql/rust/internal/PathResolution.qll | Include BuiltinType under core in hasChild to support builtins |
| rust/ql/test/extractor-tests/canonical_path/canonical_paths.ql | Import new modules and extend canonicalPath predicate for trim |
| rust/ql/test/extractor-tests/canonical_path/canonical_paths.expected | Add expected <core::str>::trim entry |
| rust/ql/test/extractor-tests/canonical_path/canonical_paths.qlref | Add query and post-process directives |
| rust/ql/test/extractor-tests/canonical_path_disabled/canonical_paths.qlref | Add query and post-process directives for disabled tests |
| rust/ql/test/extractor-tests/canonical_path_disabled/canonical_paths.expected | Add expected <core::str>::trim entry for disabled tests |
| import rust | ||
| import TestUtils | ||
| private import codeql.rust.internal.PathResolution | ||
| private import codeql.rust.frameworks.stdlib.Bultins |
There was a problem hiding this comment.
The module name Bultins appears misspelled; it should likely be Builtins to match the framework's naming.
Comment on lines
+378
to
+379
| this.getName() = "core" and | ||
| child instanceof Builtins::BuiltinType |
There was a problem hiding this comment.
[nitpick] Consider adding parentheses around the this.getName() = "core" and child instanceof Builtins::BuiltinType clause to make grouping explicit and improve readability.
Suggested change
| this.getName() = "core" and | |
| child instanceof Builtins::BuiltinType | |
| (this.getName() = "core" and | |
| child instanceof Builtins::BuiltinType) |
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.
For builtins, like
str, we model them as belonging to thecorecrate when computing canonical paths.