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 0A1A31FF16B for ; Fri, 24 Oct 2025 16:43:01 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 94AEC23A76; Fri, 24 Oct 2025 16:43:29 +0200 (CEST) From: Hannes Laimer To: pdm-devel@lists.proxmox.com Date: Fri, 24 Oct 2025 16:42:48 +0200 Message-ID: <20251024144250.145205-3-h.laimer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251024144250.145205-1-h.laimer@proxmox.com> References: <20251024144250.145205-1-h.laimer@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761316964896 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.042 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. [verifiers.rs, generate.pl] Subject: [pdm-devel] [PATCH proxmox v2 2/3] pve-api-types: add regex for both storage- and bridge-pair X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" These are used for target storage and bridge mappings in remote migrations. For the list items we don't really need a verifier function so remove them and add regexes instead. What this is not doing is check for uniqueness of mappings in the list, but that is not really possible. Since we can't currently have verifiers on fields that are not strings. Signed-off-by: Hannes Laimer --- pve-api-types/generate.pl | 11 +++++++---- pve-api-types/src/types/verifiers.rs | 10 ---------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/pve-api-types/generate.pl b/pve-api-types/generate.pl index 75729b3c..9ea9aa4f 100644 --- a/pve-api-types/generate.pl +++ b/pve-api-types/generate.pl @@ -31,6 +31,9 @@ Schema2Rust::init_api($pve_api->{root}, \&lookup_format); # From JSONSchema.pm, but we can't use perl-re directly, particularly `qr//`... my $CONFIGID_RE = '^(?i:[a-z][a-z0-9_-]+)$'; +my $STORAGEID_RE = '(?i:[a-z][a-z0-9\-_.]*[a-z0-9])'; +my $BRIDGEID_RE = '[-_.\w\d]+'; + # Disable `#[api]` generation for now, it's incomplete/untested. #$Schema2Rust::API = 0; @@ -41,7 +44,7 @@ Schema2Rust::register_format('ipv4mask' => { code => 'verifiers::verify_ipv4_mas Schema2Rust::register_format('mac-addr' => { regex => '^(?i)[a-f0-9][02468ace](?::[a-f0-9]{2}){5}$' }); ## Schema2Rust::register_format('pve-acme-alias' => { code => 'verify_pve_acme_alias' }); ## Schema2Rust::register_format('pve-acme-domain' => { code => 'verify_pve_acme_domain' }); -Schema2Rust::register_format('pve-bridge-id' => { regex => '^[-_.\w\d]+$' }); +Schema2Rust::register_format('pve-bridge-id' => { regex => '^'.$BRIDGEID_RE.'$' }); Schema2Rust::register_format('pve-configid' => { regex => $CONFIGID_RE }); ## Schema2Rust::register_format('pve-groupid' => { code => 'verify_pve_groupid' }); Schema2Rust::register_format('pve-userid' => { code => 'verify_pve_userid' }); @@ -59,7 +62,7 @@ Schema2Rust::register_format('pve-qm-bootdev' => { unchecked => 1 }); Schema2Rust::register_format('pve-qm-bootdisk' => { regex => '^(ide|sata|scsi|virtio|efidisk|tpmstate)\d+$' }); Schema2Rust::register_format('pve-qm-usb-device' => { unchecked => 1 }); Schema2Rust::register_format('pve-startup-order' => { unchecked => 1 }); -Schema2Rust::register_format('pve-storage-id' => { regex => '^(?i:[a-z][a-z0-9\-_.]*[a-z0-9])$' }); +Schema2Rust::register_format('pve-storage-id' => { regex => '^'.$STORAGEID_RE.'$' }); Schema2Rust::register_format('pve-storage-content' => { type => 'StorageContent' }); Schema2Rust::register_format('pve-tag' => { regex => '^(?i)[a-z0-9_][a-z0-9_\-+.]*$' }); Schema2Rust::register_format('pve-volume-id' => { code => 'verifiers::verify_volume_id' }); @@ -75,8 +78,8 @@ Schema2Rust::register_format('lxc-ip-with-ll-iface' => { code => 'verifiers::ver Schema2Rust::register_format('pve-ct-timezone' => { regex => '^.*/.*$' }); Schema2Rust::register_format('pve-lxc-dev-string' => { code => 'verifiers::verify_pve_lxc_dev_string' }); ## -Schema2Rust::register_format('storage-pair' => { code => 'verifiers::verify_storage_pair' }); -Schema2Rust::register_format('bridge-pair' => { code => 'verifiers::verify_bridge_pair' }); +Schema2Rust::register_format('storage-pair' => { regex => '^'.$STORAGEID_RE.':'.$STORAGEID_RE.'|'.$STORAGEID_RE.'|1$' }); +Schema2Rust::register_format('bridge-pair' => { regex => '^'.$BRIDGEID_RE.':'.$BRIDGEID_RE.'|'.$BRIDGEID_RE.'|1$' }); Schema2Rust::register_format('pve-task-status-type' => { regex => '^(?i:ok|error|warning|unknown)$' }); diff --git a/pve-api-types/src/types/verifiers.rs b/pve-api-types/src/types/verifiers.rs index caefba1a..092893b3 100644 --- a/pve-api-types/src/types/verifiers.rs +++ b/pve-api-types/src/types/verifiers.rs @@ -194,16 +194,6 @@ pub fn verify_ip_with_ll_iface(s: &str) -> Result<(), Error> { verify_ip(s) } -pub fn verify_storage_pair(_s: &str) -> Result<(), Error> { - // FIXME: Implement this! - Ok(()) -} - -pub fn verify_bridge_pair(_s: &str) -> Result<(), Error> { - // FIXME: Implement this! - Ok(()) -} - pub fn verify_pve_lxc_dev_string(s: &str) -> Result<(), Error> { if !s.starts_with("/dev") || s.ends_with("/..") || s.contains("/..") { bail!("not a valid device string"); -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel