-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Update SqlxQuery, SqlxExecute to use getCanonicalPath #19802
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
base: main
Are you sure you want to change the base?
Conversation
I managed to make some progress; will continue investigations tomorrow. |
Just merged |
"crate::query::query", "crate::query_as::query_as", "crate::query_with::query_with", | ||
"crate::query_as_with::query_as_with", "crate::query_scalar::query_scalar", | ||
"crate::query_scalar_with::query_scalar_with", "crate::raw_sql::raw_sql" | ||
"sqlx_core::query::query", "sqlx_core::query_as::query_as", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This QLL file could be replaced by models as data, right?
@@ -33,7 +36,8 @@ private class SqlxExecute extends SqlExecution::Range { | |||
|
|||
SqlxExecute() { | |||
this.asExpr().getExpr() = call and | |||
call.(Resolvable).getResolvedPath() = "crate::executor::Executor::execute" | |||
call.getStaticTarget().(Addressable).getCanonicalPath() = | |||
"sqlx_core::executor::Executor::execute" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this should be something like
"sqlx_core::executor::Executor::execute" | |
"<sqlx_core::executor::Executor>::execute" |
let _ = conn.execute(safe_query_2.as_str()).await?; // $ sql-sink | ||
let _ = conn.execute(safe_query_3.as_str()).await?; // $ sql-sink | ||
let _ = conn.execute(unsafe_query_1.as_str()).await?; // $ sql-sink Alert[rust/sql-injection]=args1 | ||
let _ = conn.execute(safe_query_1.as_str()).await?; // $ MISSING: sql-sink |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we are able to infer that conn
has type PoolConnection
, we cannot currently infer that is in fact has type PoolConnection<MySql>
(#19954 or similar is needed for that).
Once we are able to do that, we need implicit dereferencing via
impl<DB: Database> Deref for PoolConnection<DB> {
type Target = DB::Connection;
fn deref(&self) -> &Self::Target {
&self.live.as_ref().expect(EXPECT_MSG).raw
}
}
to get to the type &MySqlConnection
, and then via impl<'c> Executor<'c> for &'c mut MySqlConnection
we can find execute
.
Update
SqlxQuery
,SqlxExecute
to usegetCanonicalPath
rather thangetResolvedPath
.At present we lose some results, presumably for similar reasons as we lose similar results in #19268 . I'd prefer we address the issue (and do a DCA run) before merging this.
@hvitved