public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Dominik Csapak <d.csapak@proxmox.com>
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
Subject: Re: [pve-devel] [PATCH common 1/1] tools: add extract_sensitive_params
Date: Thu, 3 Dec 2020 09:47:28 +0100	[thread overview]
Message-ID: <f6c27cbe-d619-60b7-6c1d-582bfbc828b6@proxmox.com> (raw)
In-Reply-To: <20201202092113.15911-2-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
> ---
>  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?

> +	if (exists($delete{$opt})) {
> +	    $sensitive->{$opt} = undef;
> +	}
> +
> +	if (defined(my $value = extract_param($param, $opt))) {
> +	    $sensitive->{$opt} = $value;
> +	}
> +    }
> +
> +    return $sensitive;
> +}
> +
>  # Note: we use this to wait until vncterm/spiceterm is ready
>  sub wait_for_vnc_port {
>      my ($port, $family, $timeout) = @_;
> 






  reply	other threads:[~2020-12-03  8:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  9:21 [pve-devel] [PATCH common/storage/manager/docs] implement http api for influxdb status plugin Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH common 1/1] tools: add extract_sensitive_params Dominik Csapak
2020-12-03  8:47   ` Thomas Lamprecht [this message]
2020-12-03  9:16     ` Wolfgang Bumiller
2020-12-03  9:35       ` Thomas Lamprecht
2020-12-03 15:52   ` [pve-devel] applied: " Thomas Lamprecht
2020-12-02  9:21 ` [pve-devel] [PATCH storage 1/1] api: storage/config: use extract_sensitive_params from tools Dominik Csapak
2021-01-28 16:31   ` [pve-devel] applied: " Thomas Lamprecht
2020-12-02  9:21 ` [pve-devel] [PATCH manager 1/7] api: cluster/metricserver: prevent simultaneosly setting and deleting of property Dominik Csapak
2020-12-03  9:05   ` Thomas Lamprecht
2020-12-04 11:30     ` Dominik Csapak
2020-12-04 11:57       ` Thomas Lamprecht
2020-12-04 12:45         ` Thomas Lamprecht
2020-12-02  9:21 ` [pve-devel] [PATCH manager 2/7] status/plugin: extend send/_connect/_disconnect/test_connection Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 3/7] status/plugin: extend with add/update/delete hooks Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 4/7] status/influxdb: implement influxdb 2.x http api Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 5/7] status/influxdb: remove unnecessary comment Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 6/7] ui: add necessary fields for influxdb http api Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 7/7] ui: dc/MetricServerView: add onlineHelp to edit windows Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH docs 1/1] external metrics server: extend docs to explain http api Dominik Csapak
2021-01-28 16:36 ` [pve-devel] applied-series: [PATCH common/storage/manager/docs] implement http api for influxdb status plugin Thomas Lamprecht

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=f6c27cbe-d619-60b7-6c1d-582bfbc828b6@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=w.bumiller@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal