From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 529671FF13E for ; Fri, 06 Feb 2026 17:12:37 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 792069D2F; Fri, 6 Feb 2026 17:13:11 +0100 (CET) From: Arthur Bied-Charreton To: pve-devel@lists.proxmox.com Subject: [PATCH pve-network v2 1/2] fix #7077: Enforce ID format in JSON schema definitions Date: Fri, 6 Feb 2026 17:12:33 +0100 Message-ID: <20260206161236.335026-3-a.bied-charreton@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260206161236.335026-1-a.bied-charreton@proxmox.com> References: <20260206161236.335026-1-a.bied-charreton@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -1.580 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 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods 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. RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record URIBL_BLACK 3 Contains an URL listed in the URIBL blacklist [plugin.pm] Message-ID-Hash: U7KPXX2WYOTTVS6RARJJK63PSD45JCQF X-Message-ID-Hash: U7KPXX2WYOTTVS6RARJJK63PSD45JCQF X-MailFrom: abied-charreton@jett.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add ID format constraints checked in registered formats' custom verifiers to JSON schema definitions, so that: 1. The constraints are visible in the API docs. 2. Length constraints are checked *before* regex, which will generate more precise error messages in case a regex has implicit length constraints Signed-off-by: Arthur Bied-Charreton --- src/PVE/Network/SDN/Controllers/IsisPlugin.pm | 3 +++ src/PVE/Network/SDN/Controllers/Plugin.pm | 3 +++ src/PVE/Network/SDN/Dns/Plugin.pm | 2 ++ src/PVE/Network/SDN/Fabrics.pm | 3 +++ src/PVE/Network/SDN/Ipams/Plugin.pm | 2 ++ src/PVE/Network/SDN/VnetPlugin.pm | 3 +++ src/PVE/Network/SDN/Zones/Plugin.pm | 3 +++ 7 files changed, 19 insertions(+) diff --git a/src/PVE/Network/SDN/Controllers/IsisPlugin.pm b/src/PVE/Network/SDN/Controllers/IsisPlugin.pm index 3a9acfd..4c11af3 100644 --- a/src/PVE/Network/SDN/Controllers/IsisPlugin.pm +++ b/src/PVE/Network/SDN/Controllers/IsisPlugin.pm @@ -43,6 +43,9 @@ sub properties { description => "Network Entity title for this node in the IS-IS network.", type => 'string', format => 'pve-sdn-isis-net', + pattern => '[a-fA-F0-9]{2}(\.[a-fA-F0-9]{4}){3,9}\.[a-fA-F0-9]{2}', + minLength => 20, + maxLength => 50, }, }; } diff --git a/src/PVE/Network/SDN/Controllers/Plugin.pm b/src/PVE/Network/SDN/Controllers/Plugin.pm index d70e518..73eaa0b 100644 --- a/src/PVE/Network/SDN/Controllers/Plugin.pm +++ b/src/PVE/Network/SDN/Controllers/Plugin.pm @@ -22,6 +22,9 @@ PVE::JSONSchema::register_standard_option( description => "The SDN controller object identifier.", type => 'string', format => 'pve-sdn-controller-id', + minLength => 2, + maxLength => 64, + pattern => '[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]', }, ); diff --git a/src/PVE/Network/SDN/Dns/Plugin.pm b/src/PVE/Network/SDN/Dns/Plugin.pm index 2864d4c..8e623ba 100644 --- a/src/PVE/Network/SDN/Dns/Plugin.pm +++ b/src/PVE/Network/SDN/Dns/Plugin.pm @@ -24,6 +24,8 @@ PVE::JSONSchema::register_standard_option( description => "The SDN dns object identifier.", type => 'string', format => 'pve-sdn-dns-id', + pattern => '[a-zA-Z][a-zA-Z0-9]*[a-zA-Z0-9]', + minLength => 2, }, ); diff --git a/src/PVE/Network/SDN/Fabrics.pm b/src/PVE/Network/SDN/Fabrics.pm index d90992a..c65eae6 100644 --- a/src/PVE/Network/SDN/Fabrics.pm +++ b/src/PVE/Network/SDN/Fabrics.pm @@ -28,6 +28,9 @@ PVE::JSONSchema::register_standard_option( description => "Identifier for SDN fabrics", type => 'string', format => 'pve-sdn-fabric-id', + pattern => '[a-zA-Z0-9][a-zA-Z0-9-]{0,6}[a-zA-Z0-9]', + minLength => 2, + maxLength => 8, }, ); diff --git a/src/PVE/Network/SDN/Ipams/Plugin.pm b/src/PVE/Network/SDN/Ipams/Plugin.pm index a986a92..422fbc8 100644 --- a/src/PVE/Network/SDN/Ipams/Plugin.pm +++ b/src/PVE/Network/SDN/Ipams/Plugin.pm @@ -25,6 +25,8 @@ PVE::JSONSchema::register_standard_option( description => "The SDN ipam object identifier.", type => 'string', format => 'pve-sdn-ipam-id', + pattern => '[a-zA-Z][a-zA-Z0-9]*[a-zA-Z0-9]', + minLength => 2, }, ); diff --git a/src/PVE/Network/SDN/VnetPlugin.pm b/src/PVE/Network/SDN/VnetPlugin.pm index 717438c..5ceb3a1 100644 --- a/src/PVE/Network/SDN/VnetPlugin.pm +++ b/src/PVE/Network/SDN/VnetPlugin.pm @@ -22,6 +22,9 @@ PVE::JSONSchema::register_standard_option( description => "The SDN vnet object identifier.", type => 'string', format => 'pve-sdn-vnet-id', + pattern => '[a-zA-Z][a-zA-Z0-9]*[a-zA-Z0-9]', + minLength => 2, + maxLength => 8, }, ); diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm index 826ebdf..2a02278 100644 --- a/src/PVE/Network/SDN/Zones/Plugin.pm +++ b/src/PVE/Network/SDN/Zones/Plugin.pm @@ -24,6 +24,9 @@ PVE::JSONSchema::register_standard_option( description => "The SDN zone object identifier.", type => 'string', format => 'pve-sdn-zone-id', + pattern => '[a-zA-Z][a-zA-Z0-9]*[a-zA-Z0-9]', + minLength => 2, + maxLength => 8, }, ); -- 2.47.3