From: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
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 [thread overview]
Message-ID: <20260206161236.335026-3-a.bied-charreton@proxmox.com> (raw)
In-Reply-To: <20260206161236.335026-1-a.bied-charreton@proxmox.com>
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 <a.bied-charreton@proxmox.com>
---
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
next prev 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 ` Arthur Bied-Charreton [this message]
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 ` [PATCH proxmox v2 1/1] fix #7077: Improve SDN ID validation " Arthur Bied-Charreton
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-3-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.