all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox v2 1/1] fix #7077: Improve SDN ID validation error messages
Date: Fri,  6 Feb 2026 17:12:36 +0100	[thread overview]
Message-ID: <20260206161236.335026-6-a.bied-charreton@proxmox.com> (raw)
In-Reply-To: <20260206161236.335026-1-a.bied-charreton@proxmox.com>

The regexes for verifying SDN (controller)? IDs have implicit `length >=
2` constraints resulting in less-than-ideal error messages in case of
length mismatch.

Add explicit length checks before checking the regexes.

Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
 pve-api-types/src/types/verifiers.rs | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/pve-api-types/src/types/verifiers.rs b/pve-api-types/src/types/verifiers.rs
index c45063b5..f731f13b 100644
--- a/pve-api-types/src/types/verifiers.rs
+++ b/pve-api-types/src/types/verifiers.rs
@@ -266,7 +266,11 @@ pub fn verify_vlan_id_or_range(s: &str) -> Result<(), Error> {
 
 pub fn verify_sdn_id(s: &str) -> Result<(), Error> {
     if s.len() > 8 {
-        bail!("SDN ID cannot be longer than 8 characters")
+        bail!("SDN ID cannot be longer than 8 characters");
+    }
+
+    if s.len() < 2 {
+        bail!("SDN ID cannot be shorter than 2 characters");
     }
 
     if !SDN_ID.is_match(s) {
@@ -278,7 +282,11 @@ pub fn verify_sdn_id(s: &str) -> Result<(), Error> {
 
 pub fn verify_sdn_controller_id(s: &str) -> Result<(), Error> {
     if s.len() > 64 {
-        bail!("SDN controller ID cannot be longer than 64 characters")
+        bail!("SDN controller ID cannot be longer than 64 characters");
+    }
+
+    if s.len() < 2 {
+        bail!("SDN controller ID cannot be shorter than 2 characters");
     }
 
     if !SDN_CONTROLLER_ID.is_match(s) {
-- 
2.47.3




      parent reply	other threads:[~2026-02-06 16:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-06 16:12 [PATCH proxmox, pve-{common,network,storage} v2 0/5] fix #7077: Improve error messages for ID verification Arthur Bied-Charreton
2026-02-06 16:12 ` [PATCH pve-common v2 1/1] fix #7077: Change JSON Schema attribute validation order Arthur Bied-Charreton
2026-02-06 16:12 ` [PATCH pve-network v2 1/2] fix #7077: Enforce ID format in JSON schema definitions Arthur Bied-Charreton
2026-02-06 16:12 ` [PATCH pve-network v2 2/2] sdn: Remove unneeded registered formats Arthur Bied-Charreton
2026-02-06 16:12 ` [PATCH pve-storage v2 1/1] fix #7077: lvm: Improve ID verification error messages Arthur Bied-Charreton
2026-02-06 16:12 ` Arthur Bied-Charreton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260206161236.335026-6-a.bied-charreton@proxmox.com \
    --to=a.bied-charreton@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal