Rust: Remove visibility check in path resolution#19431
Merged
hvitved merged 1 commit intogithub:mainfrom May 2, 2025
Merged
Conversation
edc38da to
a34952d
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR removes visibility checks during Rust path resolution and updates related test expectations to reflect the broader resolution scope. Key changes include:
- Removal of
isPublic/resolvePathPrivatelogic and related predicates. - Replacement of
resolvePath1withresolvePathFulland updatedresolvePathto favor source functions. - Updated expected outputs in consistency and dataflow tests to account for additional resolutions.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| rust/ql/test/query-tests/security/CWE-022/CONSISTENCY/PathResolutionConsistency.expected | Expanded expected path resolutions across multiple locations |
| rust/ql/test/library-tests/dataflow/modeled/inline-flow.expected | Added extra dataflow edges/nodes for inlined wrapper clones |
| rust/ql/lib/codeql/rust/internal/PathResolution.qll | Removed visibility‐based filtering, introduced resolvePathFull |
Comments suppressed due to low confidence (2)
rust/ql/lib/codeql/rust/internal/PathResolution.qll:1066
- [nitpick] No tests appear to cover the new resolvesSourceFunction predicate or the updated resolvePath filtering when both library and source functions are present. Add a test case where a function exists in source and in a dependency to verify that only the source version is returned.
private predicate resolvesSourceFunction(RelevantPath path) {
rust/ql/lib/codeql/rust/internal/PathResolution.qll:1134
- Using resolvePathFull here bypasses the filtering and caching logic in resolvePath (which prioritizes source functions and applies extractor workarounds). Consider calling resolvePath(path) or applying the same post-filter to maintain consistent behavior for use-tree imports.
result = resolvePathFull(tree.getPath())
a34952d to
73fa381
Compare
paldepind
approved these changes
May 2, 2025
Contributor
paldepind
left a comment
There was a problem hiding this comment.
Great :) Definitely seems nicer to have an over approximation than an under approximation.
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.
Visibility checking was originally introduced to reduce the number of path resolution inconsistencies. However, the current implementation is too restrictive, and my attempt to make it less restrictive is still not good enough.
So, instead I have come to the conclusion that we are better off without visibility checking. This also aligns with our general assumption that programs are valid, for instance our type inference logic does not actually check that the program is well-typed.
DCA shows that we gain an additional 4 % true-positive call edges (up 617,811 from 593,987).