Skip to content

Rust: Update RegexInjectionExtensions to use getCanonicalPath. #19735

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 12, 2025

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Jun 11, 2025

Update RegexInjectionExtensions.qll to use getCanonicalPath rather than getResolvedPath + getResolvedCrateOrigin.

@hvitved please confirm that this is the right direction we want to move in.

@Copilot Copilot AI review requested due to automatic review settings June 11, 2025 15:02
@geoffw0 geoffw0 added the Rust Pull requests that update Rust code label Jun 11, 2025
@geoffw0 geoffw0 requested a review from a team as a code owner June 11, 2025 15:02
@geoffw0 geoffw0 added the no-change-note-required This PR does not need a change note label Jun 11, 2025
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

Updates the NewSink class in RegexInjectionExtensions.qll to leverage getCanonicalPath for matching regex instantiations, replacing the previous getResolvedCrateOrigin + getResolvedPath approach.

  • Switch filtering to getCanonicalPath on the Addressable target
  • Replace CallExprCfgNode + PathExpr with CallExprBase + Addressable
  • Adjust argument extraction to use getArg(0) and refine literal exclusion
Comments suppressed due to low confidence (3)

rust/ql/lib/codeql/rust/security/regex/RegexInjectionExtensions.qll:57

  • [nitpick] Using getStaticTarget() may not capture macro-generated or dynamically-resolved targets; verify that all intended call sites are still covered with this change.
call.getStaticTarget() = a and

rust/ql/lib/codeql/rust/security/regex/RegexInjectionExtensions.qll:53

  • Consider adding or updating unit tests for NewSink to validate matching behavior with getCanonicalPath and prevent regressions.
private class NewSink extends Sink {

rust/ql/lib/codeql/rust/security/regex/RegexInjectionExtensions.qll:56

  • [nitpick] Switching from CallExprCfgNode to CallExprBase broadens matching to non-CFG call expressions; if the sink is intended for CFG nodes only, consider using CallExprCfgNode to maintain the original scope.
exists(CallExprBase call, Addressable a |

Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@geoffw0 geoffw0 merged commit fdf1dca into github:main Jun 12, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants