From 64afa0fd8c863deb6a1568428dfaf2ce67ef9085 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 01:06:38 +0100 Subject: copyparty: never send the password to foreign hosts --- src/tasks/mod.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/tasks/mod.rs') diff --git a/src/tasks/mod.rs b/src/tasks/mod.rs index f0585ef..b492f61 100644 --- a/src/tasks/mod.rs +++ b/src/tasks/mod.rs @@ -125,19 +125,15 @@ async fn execute_audio_job(ctx: &CronContext, job: &crate::database::CronJob) { let channel_id = serenity::ChannelId::new(job.channel_id as u64); - // Build the full URL with password - let url = if audio_url.starts_with("http://") || audio_url.starts_with("https://") { - // Already a full URL (stored without password), append it now - if let Some(pw) = &ctx.copyparty.password { - format!("{audio_url}?pw={pw}") - } else { - audio_url.clone() - } - } else { - // Legacy relative path — build full URL with password - ctx.copyparty.build_url(audio_url) - }; - info!("Cron audio job {} playing: {url}", job.id); + // Authenticate only when the URL belongs to our Copyparty host; a cron + // job may point at an arbitrary third-party URL and must never receive + // the password. + let url = ctx.copyparty.build_url_for(audio_url); + info!( + "Cron audio job {} playing: {}", + job.id, + crate::copyparty::redact_url(&url) + ); let channel = match channel_id.to_channel(&ctx.http).await { Ok(serenity::Channel::Guild(ch)) => ch, other => { @@ -175,8 +171,11 @@ async fn execute_audio_job(ctx: &CronContext, job: &crate::database::CronJob) { } info!( - "Cron audio job {} playing '{}' (url: {url}) in guild {}", - job.id, audio_url, channel.guild_id + "Cron audio job {} playing '{}' (url: {}) in guild {}", + job.id, + audio_url, + crate::copyparty::redact_url(&url), + channel.guild_id ); } -- cgit v1.2.3