-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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.qll
to recognize builtins undercore
- Update test queries to import
PathResolution
andBuiltins
and cover atrim
example - Adjust expected outputs to include the generated
<core::str>::trim
path
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 |
@@ -1,8 +1,20 @@ | |||
import rust | |||
import TestUtils | |||
private import codeql.rust.internal.PathResolution | |||
private import codeql.rust.frameworks.stdlib.Bultins |
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.
Copilot uses AI. Check for mistakes.
this.getName() = "core" and | ||
child instanceof Builtins::BuiltinType |
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) |
Copilot uses AI. Check for mistakes.
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 thecore
crate when computing canonical paths.