-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Generate canonical paths for builtins #19732
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
Conversation
6eb5bd6 to
69e549f
Compare
There was a problem hiding this 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 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 |
Copilot
AI
Jun 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The module name Bultins appears misspelled; it should likely be Builtins to match the framework's naming.
| this.getName() = "core" and | ||
| child instanceof Builtins::BuiltinType |
Copilot
AI
Jun 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding parentheses around the this.getName() = "core" and child instanceof Builtins::BuiltinType clause to make grouping explicit and improve readability.
| this.getName() = "core" and | |
| child instanceof Builtins::BuiltinType | |
| (this.getName() = "core" and | |
| child instanceof Builtins::BuiltinType) |
redsun82
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
For builtins, like
str, we model them as belonging to thecorecrate when computing canonical paths.