From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 7E3581FF0B7 for ; Fri, 13 Nov 2026 21:34:21 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E29B4216BC; Fri, 13 Nov 2026 21:34:00 +0100 (CET) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v5 04/19] api: plugins/storage/plugin: handle sensitive properties in schema Date: Fri, 13 Nov 2026 21:33:08 +0100 Message-ID: <20261113203330.932813-5-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261113203330.932813-1-m.carrara@proxmox.com> References: <20261113203330.932813-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794602018866 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.297 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 65C7YCZ7RXLTYMUOATKJCIH7BM3FFHHX X-Message-ID-Hash: 65C7YCZ7RXLTYMUOATKJCIH7BM3FFHHX X-MailFrom: m.carrara@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 CC: Alfonso Kuen , Thomas Ellmenreich , Jakob Klocker X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Since the introduction of the `sensitive` keyword in our JSON schema implementation, properties may be marked as secrets directly as part of their own schema (in `properties()`). This keyword is already included in the schemas of properties that declare it. As a fallback, i.e. if the property does not declare the keyword at all, use the `sensitive_properties()` sub from the plugin API. Note that this helper also handles plugins not having a 'sensitive-properties' hash in their `plugindata()`, but still reuse certain builtin sensitive properties. Always set the key to either 0 or 1, so that the returned schema has the same shape for every property. Signed-off-by: Max R. Carrara --- src/PVE/API2/Plugins/Storage/Plugin.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/PVE/API2/Plugins/Storage/Plugin.pm b/src/PVE/API2/Plugins/Storage/Plugin.pm index 7d697d06..1635a763 100644 --- a/src/PVE/API2/Plugins/Storage/Plugin.pm +++ b/src/PVE/API2/Plugins/Storage/Plugin.pm @@ -55,19 +55,27 @@ my sub get_schema_for_plugin : prototype($) ($plugin) { # since `init_isolated()` automatically adds properties to options that # were not specified explicitly my $pdata = $plugin->private(); my $options = $pdata->{options}->{$type}; + # also covers the fallback for plugins without 'sensitive-properties' in their plugindata() + my $sensitive = { map { $_ => 1 } PVE::Storage::Plugin::sensitive_properties($type)->@* }; + my $schema = {}; for my $option (keys $options->%*) { my $prop_schema = PVE::RESTHandler::api_dump_remove_refs( PVE::Storage::Plugin->get_property_schema($type, $option)); # Deep clone to prevent any accidental Perl-esque side effects, because # we are memoizing each schema through $PLUGIN_SCHEMAS my $property = dclone($prop_schema); + + if (!defined($property->{sensitive})) { + $property->{sensitive} = $sensitive->{$option} ? 1 : 0; + } + $schema->{$option} = $property; for my $opt_key (keys $options->{$option}->%*) { $property->{$opt_key} = $options->{$option}->{$opt_key}; } -- 2.47.3