Rust: Update StartswithCall to use getCanonicalPath#20226
Merged
geoffw0 merged 3 commits intogithub:mainfrom Aug 14, 2025
Merged
Rust: Update StartswithCall to use getCanonicalPath#20226geoffw0 merged 3 commits intogithub:mainfrom
geoffw0 merged 3 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the StartswithCall class in Rust CodeQL to use getCanonicalPath for method resolution and adds comprehensive test coverage for path injection scenarios. The change improves the reliability of detecting safe path access checks by using a more robust method resolution approach.
Key changes:
- Updates method resolution in
StartswithCallfromgetResolvedPath()togetStaticTarget().getCanonicalPath() - Adds extensive test cases covering various path injection scenarios including canonicalization patterns
- Enhances test infrastructure to track barriers, normalizers, and safe access checks
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/frameworks/stdlib/Stdlib.qll | Updates StartswithCall to use getCanonicalPath for more reliable method resolution |
| rust/ql/test/query-tests/security/CWE-022/src/main.rs | Adds comprehensive test cases with annotations for path injection scenarios |
| rust/ql/test/query-tests/security/CWE-022/TaintedPathSinks.ql | Expands test infrastructure to track additional path injection elements |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Contributor
Author
|
Thanks. |
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.
Update
StartswithCallto usegetCanonicalPath. The solution was written by @hvitved in #20224 . I've added test coverage (in particular the annotationpath-injection-checked), and this shows that the new solution sometimes works - suggesting that we have the right expression but probably type inference is lost in many cases (e.g. at a priorcanonicalize).