From 0f5d8615f443831c4d3b0abd9ad1123513d9bd11 Mon Sep 17 00:00:00 2001 From: MCorange99 Date: Sat, 30 Mar 2024 18:25:34 +0200 Subject: [PATCH] asluihd --- src/database/models/tokens.rs | 2 +- src/web/routes/api/webhooks/github/mod.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/database/models/tokens.rs b/src/database/models/tokens.rs index 4a0f637..3efc748 100644 --- a/src/database/models/tokens.rs +++ b/src/database/models/tokens.rs @@ -104,7 +104,7 @@ impl Token { -const TOKEN_CHARSET: &'static [char] = &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '_', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; +const TOKEN_CHARSET: &'static [char] = &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; fn generate_token(len: u8) -> String { let mut token = String::new(); diff --git a/src/web/routes/api/webhooks/github/mod.rs b/src/web/routes/api/webhooks/github/mod.rs index 9f4e671..0419db6 100644 --- a/src/web/routes/api/webhooks/github/mod.rs +++ b/src/web/routes/api/webhooks/github/mod.rs @@ -24,18 +24,22 @@ pub async fn handler(req: HttpRequest, token: web::Path, body: Bytes, db }; let Some(event_type) = req.headers().get("X-GitHub-Event") else { + log::debug!("No X-GitHub-Event header"); return Ok(HttpResponse::BadRequest()); }; let Ok(event_type) = event_type.to_str() else { + log::debug!("Bad X-GitHub-Event header"); return Ok(HttpResponse::BadRequest()); }; let Ok(json) = String::from_utf8(body.to_vec()) else { + log::debug!("Bad request body"); return Ok(HttpResponse::BadRequest()); }; let Ok(event) = types::Event::from_raw_json(event_type, json.clone()) else { + log::debug!("Bad request body json"); return Ok(HttpResponse::BadRequest()); };