diff --git a/examples/local_federation/instance.rs b/examples/local_federation/instance.rs index 2ea3e40..ad1fd12 100644 --- a/examples/local_federation/instance.rs +++ b/examples/local_federation/instance.rs @@ -29,7 +29,7 @@ pub async fn new_instance( .signed_fetch_actor(&system_user) .app_data(database) .url_verifier(Box::new(MyUrlVerifier())) - .debug(false) + .debug(true) .build() .await?; Ok(config) diff --git a/src/activity_sending.rs b/src/activity_sending.rs index 1c84757..4971485 100644 --- a/src/activity_sending.rs +++ b/src/activity_sending.rs @@ -136,8 +136,8 @@ impl SendActivityTask { } } -pub(crate) async fn build_tasks<'a, Activity, Datatype, ActorType>( - activity: &'a Activity, +pub(crate) async fn build_tasks( + activity: &Activity, actor: &ActorType, inboxes: Vec, data: &Data, diff --git a/src/fetch/object_id.rs b/src/fetch/object_id.rs index 108dc1a..d9dcbe2 100644 --- a/src/fetch/object_id.rs +++ b/src/fetch/object_id.rs @@ -360,6 +360,7 @@ const _IMPL_DIESEL_NEW_TYPE_FOR_OBJECT_ID: () = { } }; +/// Shared test code #[cfg(test)] #[allow(clippy::unwrap_used)] pub mod tests { diff --git a/src/fetch/webfinger.rs b/src/fetch/webfinger.rs index a804a34..2140392 100644 --- a/src/fetch/webfinger.rs +++ b/src/fetch/webfinger.rs @@ -57,9 +57,12 @@ where .splitn(2, '@') .collect_tuple() .ok_or(WebFingerError::WrongFormat.into_crate_error())?; - if !DOMAIN_REGEX.is_match(domain) { + + // For production mode make sure that domain doesnt contain any port or path. + if !data.config.debug && !DOMAIN_REGEX.is_match(domain) { return Err(Error::UrlVerificationError("Invalid characters in domain").into()); } + let protocol = if data.config.debug { "http" } else { "https" }; let fetch_url = format!("{protocol}://{domain}/.well-known/webfinger?resource=acct:{identifier}"); diff --git a/src/http_signatures.rs b/src/http_signatures.rs index aa526f9..f4f94e1 100644 --- a/src/http_signatures.rs +++ b/src/http_signatures.rs @@ -277,6 +277,7 @@ pub(crate) fn verify_body_hash( Ok(()) } +/// Shared test code #[cfg(test)] #[allow(clippy::unwrap_used)] pub mod test { @@ -378,6 +379,7 @@ pub mod test { assert_eq!(invalid, Err(Error::ActivityBodyDigestInvalid)); } + /// Return hardcoded keypair pub fn test_keypair() -> Keypair { let rsa = RsaPrivateKey::from_pkcs1_pem(PRIVATE_KEY).unwrap(); let pkey = RsaPublicKey::from(&rsa);