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 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ module Impl {
exists(this.getField(pragma[only_bind_into](pos)))
}

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

/** Gets the tuple field that matches the `pos`th pattern of this pattern. */
pragma[nomagic]
TupleField getTupleField(int pos) {
Expand Down
10 changes: 6 additions & 4 deletions rust/ql/lib/codeql/rust/frameworks/Poem.qll
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
private import rust
private import codeql.rust.Concepts
private import codeql.rust.dataflow.DataFlow
private import codeql.rust.internal.TypeInference
private import codeql.rust.internal.Type

/**
* Parameters of a handler function
*/
private class PoemHandlerParam extends RemoteSource::Range {
PoemHandlerParam() {
exists(TupleStructPat param |
param.getResolvedPath() = ["crate::web::query::Query", "crate::web::path::Path"]
|
this.asPat().getPat() = param.getAField()
exists(TupleStructPat param, Type t |
this.asPat().getPat() = param.getAField() and
t = inferType(param) and
param.getStruct().getCanonicalPath() = ["poem::web::query::Query", "poem::web::path::Path"]
)
}
}