From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D048A61628 for ; Thu, 3 Dec 2020 10:16:53 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BD79525337 for ; Thu, 3 Dec 2020 10:16:23 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 3BF8B2532A for ; Thu, 3 Dec 2020 10:16:23 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id F3AE6446E3 for ; Thu, 3 Dec 2020 10:16:22 +0100 (CET) Date: Thu, 3 Dec 2020 10:16:19 +0100 (CET) From: Wolfgang Bumiller To: Thomas Lamprecht , Proxmox VE development discussion , Dominik Csapak Message-ID: <465555934.572.1606986979440@webmail.proxmox.com> In-Reply-To: References: <20201202092113.15911-1-d.csapak@proxmox.com> <20201202092113.15911-2-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.4-Rev14 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL 0.019 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [tools.pm] Subject: Re: [pve-devel] [PATCH common 1/1] tools: add extract_sensitive_params X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Dec 2020 09:16:53 -0000 > On 12/03/2020 9:47 AM Thomas Lamprecht wrote: > > > On 02.12.20 10:21, Dominik Csapak wrote: > > moved and generalized from pve-storage, since we'll need it > > in more places > > > > Signed-off-by: Dominik Csapak > > --- > > src/PVE/Tools.pm | 24 ++++++++++++++++++++++++ > > 1 file changed, 24 insertions(+) > > > > diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm > > index 4b445ea..bda236a 100644 > > --- a/src/PVE/Tools.pm > > +++ b/src/PVE/Tools.pm > > @@ -48,6 +48,7 @@ template_replace > > safe_print > > trim > > extract_param > > +extract_sensitive_params > > file_copy > > get_host_arch > > O_PATH > > @@ -807,6 +808,29 @@ sub extract_param { > > return $res; > > } > > > > can we have some short comment about what this does and when/why it can be useful here > > > +sub extract_sensitive_params :prototype($$$) { > > + my ($param, $sensitive_list, $delete_list) = @_; > > + > > + my $sensitive; > > I know auto vivification and such things exist, but I'd feel more comfortable > to set above explicitly to and empty hash {} . > > > + > > + my %delete = map { $_ => 1 } ($delete_list || [])->@*; > > + > > + # always extract sensitive keys, so they don't get written to the www-data readable scfg > > not only for scfg anymore, would drop that comment actually completely, that's rather > something for a method comment (see above) > > > + for my $opt (@$sensitive_list) { > > + # First handle deletions as explicitly setting `undef`, afterwards new values may override > > + # it. > > I know this is just copied, but there's no actual reason for setting to undef vs. > using delete encoded in that comment, it's just merely describing what one sees > when reading the code anyhow.. > > @Wolfgang, you as original author (pve-storage commit 72385de9e23df) why did you > used undef vs. delete? The update hooks in pve-storage don't get the deletion-list passed on as parameter, so I translated into putting `undef` into the parameter list.