Skip to content

Rust: Also take the std prelude into account when resolving paths #19611

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

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented May 28, 2025

In addition to the core prelude, also lookup names in the std prelude.

DCA looks OK; some more path resolution inconsistencies, which is not unexpected, and we see both performance improvements and regressions, which I suspect is mostly wobble.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label May 28, 2025
@hvitved hvitved force-pushed the rust/path-resolution-std-prelude branch from 93d20d1 to 3fa308e Compare May 28, 2025 14:57
@hvitved hvitved marked this pull request as ready for review June 2, 2025 06:52
@Copilot Copilot AI review requested due to automatic review settings June 2, 2025 06:52
@hvitved hvitved requested a review from a team as a code owner June 2, 2025 06:52
@hvitved hvitved requested a review from paldepind June 2, 2025 06:52
Copy link
Contributor

@Copilot Copilot AI left a 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 path resolution to consider items reexported by the std prelude in addition to the existing core prelude, and updates test expectations accordingly.

  • Update preludeEdge in PathResolution.qll to match on both "core" and "std" crates.
  • Adjust expected results in two consistency tests to reflect multiple resolutions from both preludes.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
rust/ql/lib/codeql/rust/internal/PathResolution.qll Expanded preludeEdge predicate to include std prelude.
rust/ql/test/query-tests/security/CWE-825/CONSISTENCY/PathResolutionConsistency.expected Added entries for both core and std crate resolutions.
rust/ql/test/query-tests/security/CWE-770/CONSISTENCY/PathResolutionConsistency.expected Added duplicate entries but missing core crate version.
Comments suppressed due to low confidence (1)

rust/ql/test/query-tests/security/CWE-770/CONSISTENCY/PathResolutionConsistency.expected:2

  • The expected output only includes the std crate ([email protected]) for this resolution. To mirror the CWE-825 test, add a separate entry for the core crate (e.g., [email protected]) so both preludes are covered.
| main.rs:218:14:218:17 | libc | file://:0:0:0:0 | Crate([email protected]) |

@geoffw0
Copy link
Contributor

geoffw0 commented Jun 2, 2025

DCA looks mildly positive, apart from regressions in path resolution inconsistencies (which we see in consistency tests as well).

@hvitved
Copy link
Contributor Author

hvitved commented Jun 2, 2025

DCA looks mildly positive, apart from regressions in path resolution inconsistencies (which we see in consistency tests as well).

I have started a new DCA run which uses DB caching, to rule out wobbliness caused by the extractor.

@hvitved hvitved merged commit bf39058 into github:main Jun 2, 2025
16 checks passed
@hvitved hvitved deleted the rust/path-resolution-std-prelude branch June 2, 2025 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants