diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 77174f221b0..4cd9c42e358 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -62,7 +62,7 @@ groupName: "diesel packages", }, { - matchDepNames: ["aws-ip-ranges", "github-meta"], + matchDepNames: ["aws-ip-ranges"], automerge: true, }, { diff --git a/Cargo.lock b/Cargo.lock index be05911e363..5e1aa9cf4ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1020,7 +1020,6 @@ dependencies = [ "dotenvy", "flate2", "futures-util", - "github-meta", "googletest", "hex", "http 1.1.0", @@ -1998,16 +1997,6 @@ dependencies = [ "url", ] -[[package]] -name = "github-meta" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a52c4a8e54d97193744f7968c46eed307569d6e6ab8062441a40d45e4856261e" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "globset" version = "0.4.15" diff --git a/Cargo.toml b/Cargo.toml index 50ba5456f68..c06def8a8af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,6 @@ diesel_migrations = { version = "=2.2.0", features = ["postgres"] } dotenvy = "=0.15.7" flate2 = "=1.0.34" futures-util = "=0.3.31" -github-meta = "=0.11.0" hex = "=0.4.3" http = "=1.1.0" http-body-util = "=0.1.2" diff --git a/src/ci.rs b/src/ci.rs deleted file mode 100644 index 81129be0896..00000000000 --- a/src/ci.rs +++ /dev/null @@ -1,60 +0,0 @@ -use crate::middleware::real_ip::RealIp; -use async_trait::async_trait; -use axum::extract::FromRequestParts; -use http::request::Parts; -use ipnetwork::IpNetwork; -use std::fmt::Display; -use std::net::IpAddr; -use std::sync::LazyLock; - -#[derive(Copy, Clone, Debug)] -pub enum CiService { - GitHubActions, -} - -impl Display for CiService { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - CiService::GitHubActions => write!(f, "GitHub Actions"), - } - } -} - -#[async_trait] -impl FromRequestParts for CiService { - type Rejection = (); - - async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result { - let real_ip = parts.extensions.get::().ok_or(())?; - - if is_github_actions_ip(real_ip) { - return Ok(CiService::GitHubActions); - } - - Err(()) - } -} - -fn is_github_actions_ip(ip: &IpAddr) -> bool { - static GITHUB_ACTIONS_CIDRS: LazyLock> = LazyLock::new(|| { - github_meta::META - .actions - .iter() - .filter_map(|cidr| parse_cidr(cidr, "GitHub Actions")) - .collect() - }); - - GITHUB_ACTIONS_CIDRS - .iter() - .any(|trusted_proxy| trusted_proxy.contains(*ip)) -} - -fn parse_cidr(cidr: &str, service: &'static str) -> Option { - match cidr.parse() { - Ok(ip_network) => Some(ip_network), - Err(error) => { - warn!(%cidr, %error, "Failed to parse {service} CIDR"); - None - } - } -} diff --git a/src/lib.rs b/src/lib.rs index b652eb2cd04..9733d5a9f65 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,6 @@ mod app; pub mod auth; pub mod boot; pub mod certs; -pub mod ci; pub mod cloudfront; pub mod config; pub mod controllers; diff --git a/src/middleware/log_request.rs b/src/middleware/log_request.rs index dfaec44bd0c..67974305afd 100644 --- a/src/middleware/log_request.rs +++ b/src/middleware/log_request.rs @@ -1,7 +1,6 @@ //! Log all requests in a format similar to Heroku's router, but with additional //! information that we care about like User-Agent -use crate::ci::CiService; use crate::controllers::util::RequestPartsExt; use crate::headers::XRequestId; use crate::middleware::normalize_path::OriginalPath; @@ -36,7 +35,6 @@ pub struct RequestMetadata { real_ip: Extension, user_agent: Option>, request_id: Option>, - ci_service: Option, } pub async fn log_requests( @@ -87,7 +85,6 @@ pub async fn log_requests( http.status_code = status.as_u16(), cause = response.extensions().get::().map(|e| e.0.as_str()).unwrap_or_default(), error.message = response.extensions().get::().map(|e| e.0.as_str()).unwrap_or_default(), - ci = %request_metadata.ci_service.map(|ci| ci.to_string()).unwrap_or_default(), %custom_metadata, "{method} {url} → {status} ({duration:?})", );