Skip to content

Rust: Update PoemHandlerParam to use getCanonicalPath #19801

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Jun 17, 2025

Update PoemHandlerParam to use getCanonicalPath rather than getResolvedPath.

@hvitved

@Copilot Copilot AI review requested due to automatic review settings June 17, 2025 14:57
@geoffw0 geoffw0 requested a review from a team as a code owner June 17, 2025 14:57
@geoffw0 geoffw0 added the Rust Pull requests that update Rust code label Jun 17, 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 PoemHandlerParam predicate to use getCanonicalPath on an inferred type rather than the deprecated getResolvedPath.

  • Added imports for TypeInference and Type
  • Switched from matching getResolvedPath to inferring the type and checking its canonical path
  • Refactored the exists clause to bind the inferred type and perform the new path comparison
Comments suppressed due to low confidence (3)

rust/ql/lib/codeql/rust/frameworks/Poem.qll:16

  • [nitpick] The variable name t is ambiguous; consider renaming it to paramType or inferredType for clarity.
    exists(TupleStructPat param, Type t |

rust/ql/lib/codeql/rust/frameworks/Poem.qll:12

  • The doc comment still refers to handler parameters in terms of path resolution; update it to mention canonical path checking via type inference.
 * Parameters of a handler function

rust/ql/lib/codeql/rust/frameworks/Poem.qll:16

  • Add unit tests for PoemHandlerParam to cover both Query and Path cases with the new canonical path logic.
    exists(TupleStructPat param, Type t |

paldepind
paldepind previously approved these changes Jun 17, 2025
Comment on lines 18 to 19
t = inferType(param) and
t.(StructType).asItemNode().(Addressable).getCanonicalPath() =
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to add this predicate to TupleStructPatImpl.qll:

    /** Gets the struct matched by this pattern. */
    Struct getStruct() { result = PathResolution::resolvePath(this.getPath()) }

and then change the above to param.getStruct().getCanonicalPath() = ....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

this.asPat().getPat() = param.getAField()
exists(TupleStructPat param, Type t |
this.asPat().getPat() = param.getAField() and
t = inferType(param) and
Copy link
Contributor

Choose a reason for hiding this comment

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

Should now be removed (as well as the two imports).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, the heat must be getting to me. Now done.

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