Skip to content

Commit 619977c

Browse files
committed
use execute to avoid injection
1 parent 9c84cc2 commit 619977c

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ async fn main() -> Result<(), HttpgError> {
140140
// .route("/{path}/http", get(http).post(http))
141141
.route("/webpush", get(web_push).post(web_push))
142142
.route("/{path}/webpush", get(web_push).post(web_push))
143-
// .layer(axum::middleware::from_fn_with_state(state.clone(), pre))
144143
.route("/login", get(login).post(login))
145144
.route("/{path}/login", get(login).post(login))
146145
.fallback_service(ServeDir::new(httpg_config.public_dir))
@@ -517,7 +516,6 @@ async fn stream_query(
517516
};
518517

519518
tx.query_typed_raw("select set_config('httpg.query', $1, true)", [(serde_json::to_string(&query)?, Type::TEXT)]).await?;
520-
521519
tx.batch_execute(&pre(&biscuit, &anon_role)).await?;
522520

523521
let sql_params: Vec<(_, Type)> = query.params.iter().map(|param| {
@@ -545,7 +543,7 @@ async fn sse_query(
545543
Path(channel): Path<String>,
546544
) -> Result<impl IntoResponse, HttpgError> {
547545

548-
client.simple_query_raw(&format!("listen {channel}")).await?;
546+
client.execute(&format!("listen {channel}"), &[]).await?;
549547

550548
Ok(Sse::new(
551549
tokio_stream::wrappers::BroadcastStream::new(tx.subscribe())
@@ -639,6 +637,7 @@ async fn post_query(
639637
cancel_token: tx.cancel_token(),
640638
finished: false,
641639
};
640+
tx.query_typed_raw("select set_config('httpg.query', $1, true)", [(serde_json::to_string(&query)?, Type::TEXT)]).await?;
642641
tx.batch_execute(&pre(&biscuit, anon_role)).await?;
643642

644643
tx.query_typed_raw(

0 commit comments

Comments
 (0)