From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id BCB031FF187 for <inbox@lore.proxmox.com>; Mon, 26 May 2025 11:52:48 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4E09A2E85B; Mon, 26 May 2025 11:52:59 +0200 (CEST) From: Lukas Wagner <l.wagner@proxmox.com> To: pve-devel@lists.proxmox.com Date: Mon, 26 May 2025 11:52:20 +0200 Message-Id: <20250526095220.132201-1-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.019 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [webhook.rs, self.name] Subject: [pve-devel] [PATCH proxmox] notify: switch to proxmox-base64 X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> This also fixes any warnings that were shown during compilation because we were using the deprecated `base64::encode/decode` functions. Signed-off-by: Lukas Wagner <l.wagner@proxmox.com> --- Intended for the trixie bootstrap work on the master branch. Notes: Could probably also use the serde helpers from proxmox-base64 to deserialize the KeyAndBase64 val struct, but I'd rather do this separately. proxmox-notify/Cargo.toml | 6 +++--- proxmox-notify/src/api/webhook.rs | 8 +++----- proxmox-notify/src/endpoints/webhook.rs | 8 ++++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/proxmox-notify/Cargo.toml b/proxmox-notify/Cargo.toml index 471eaf23..920224ef 100644 --- a/proxmox-notify/Cargo.toml +++ b/proxmox-notify/Cargo.toml @@ -13,7 +13,6 @@ rust-version.workspace = true [dependencies] anyhow.workspace = true -base64 = { workspace = true, optional = true } const_format.workspace = true handlebars = { workspace = true } http = { workspace = true, optional = true } @@ -26,6 +25,7 @@ regex.workspace = true serde = { workspace = true, features = ["derive"] } serde_json.workspace = true +proxmox-base64 = { workspace = true, optional = true } proxmox-http = { workspace = true, features = ["client-sync"], optional = true } proxmox-http-error.workspace = true proxmox-human-byte.workspace = true @@ -40,9 +40,9 @@ proxmox-uuid = { workspace = true, features = ["serde"] } [features] default = ["sendmail", "gotify", "smtp", "webhook"] mail-forwarder = ["dep:mail-parser", "dep:proxmox-sys", "proxmox-sendmail/mail-forwarder"] -sendmail = ["dep:proxmox-sys", "dep:base64", "dep:proxmox-sendmail"] +sendmail = ["dep:proxmox-sys", "dep:proxmox-sendmail"] gotify = ["dep:proxmox-http", "dep:http"] pve-context = ["dep:proxmox-sys"] pbs-context = ["dep:proxmox-sys"] smtp = ["dep:lettre"] -webhook = ["dep:base64", "dep:http", "dep:percent-encoding", "dep:proxmox-http"] +webhook = ["dep:http", "dep:percent-encoding", "dep:proxmox-base64", "dep:proxmox-http"] diff --git a/proxmox-notify/src/api/webhook.rs b/proxmox-notify/src/api/webhook.rs index 31c5c869..9d904d0b 100644 --- a/proxmox-notify/src/api/webhook.rs +++ b/proxmox-notify/src/api/webhook.rs @@ -294,8 +294,6 @@ mod tests { use super::*; use crate::{api::test_helpers::empty_config, endpoints::webhook::HttpMethod}; - use base64::encode; - pub fn add_default_webhook_endpoint(config: &mut Config) -> Result<(), HttpError> { add_endpoint( config, @@ -308,7 +306,7 @@ mod tests { "application/json", ) .into()], - body: Some(encode("this is the body")), + body: Some(proxmox_base64::encode("this is the body")), comment: Some("comment".into()), disable: Some(false), secret: vec![KeyAndBase64Val::new_with_plain_value("token", "secret").into()], @@ -388,9 +386,9 @@ mod tests { .secret; assert_eq!(secrets[1].name, "token".to_string()); - assert_eq!(secrets[1].value, Some(encode("secret"))); + assert_eq!(secrets[1].value, Some(proxmox_base64::encode("secret"))); assert_eq!(secrets[0].name, "token2".to_string()); - assert_eq!(secrets[0].value, Some(encode("newsecret"))); + assert_eq!(secrets[0].value, Some(proxmox_base64::encode("newsecret"))); // Test property deletion update_endpoint( diff --git a/proxmox-notify/src/endpoints/webhook.rs b/proxmox-notify/src/endpoints/webhook.rs index a210b94c..0167efcf 100644 --- a/proxmox-notify/src/endpoints/webhook.rs +++ b/proxmox-notify/src/endpoints/webhook.rs @@ -200,7 +200,7 @@ pub struct KeyAndBase64Val { impl KeyAndBase64Val { #[cfg(test)] pub fn new_with_plain_value(name: &str, value: &str) -> Self { - let value = base64::encode(value); + let value = proxmox_base64::encode(value); Self { name: name.into(), @@ -214,7 +214,7 @@ impl KeyAndBase64Val { /// text. pub fn decode_value(&self) -> Result<String, Error> { let value = self.value.as_deref().unwrap_or_default(); - let bytes = base64::decode(value).map_err(|_| { + let bytes = proxmox_base64::decode(value).map_err(|_| { Error::Generic(format!( "could not decode base64 value with key '{}'", self.name @@ -374,7 +374,7 @@ impl WebhookEndpoint { fn base64_decode(&self, s: &str) -> Result<String, Error> { // Also here, TODO: revisit Error variants for the *whole* crate. - let s = base64::decode(s) + let s = proxmox_base64::decode(s) .map_err(|err| Error::Generic(format!("could not decode base64 value: {err}")))?; String::from_utf8(s).map_err(|err| { @@ -549,7 +549,7 @@ hello%20world header: vec![ KeyAndBase64Val::new_with_plain_value("X-Severity", "{{ severity }}").into(), ], - body: Some(base64::encode(body_template)), + body: Some(proxmox_base64::encode(body_template)), ..Default::default() }, private_config: WebhookPrivateConfig { -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel