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 EDB7CC75F for ; Wed, 4 May 2022 08:24:18 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DD9AA89FC for ; Wed, 4 May 2022 08:23:48 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 694B889EF for ; Wed, 4 May 2022 08:23:48 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 404C142ADB for ; Wed, 4 May 2022 08:23:48 +0200 (CEST) Message-ID: <06c00d65-ce59-876b-65a2-62af59b7bdd9@proxmox.com> Date: Wed, 4 May 2022 08:23:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:100.0) Gecko/20100101 Thunderbird/100.0 Content-Language: en-GB To: Proxmox VE development discussion , Fabian Ebner References: <20220503111800.64511-1-f.ebner@proxmox.com> <20220503111800.64511-3-f.ebner@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20220503111800.64511-3-f.ebner@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 1.459 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -2.871 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH/RFC v2 manager 3/3] vzdump: notes-template: replace unknown variable with error string 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: Wed, 04 May 2022 06:24:19 -0000 Am 5/3/22 um 13:18 schrieb Fabian Ebner: > rather than not setting the notes at all. They still can contain > useful information, and it likely is surprising to users to lose all > of the note when an unkown variable (or simply mistyped) is provided. > This feels like approaching the problem from the wrong end to me, why not check on add? For jobs that's relatively simple and for manual VZDump runs we could explicitly do the check to, e.g. something like (for jobs only & untested): ----8<---- diff --git a/PVE/API2/Backup.pm b/PVE/API2/Backup.pm index 5d36789a..35482bc7 100644 --- a/PVE/API2/Backup.pm +++ b/PVE/API2/Backup.pm @@ -206,6 +206,18 @@ __PACKAGE__->register_method({ $param->{enabled} = 1 if !defined($param->{enabled}); + if (my $tmpl = $param->{'notes-template'}) { + my $problematic = []; + while($tmpl =~ /\{\{([^\s{}]+)\}\}/g) { + my $var = $1; + push @$problematic, "'$var' at char " . ((pos $tmpl) - length($var)) + if $var !~ /^(cluster|guestname|node|vmid)$/; + } + if (scalar(@$problematic)) { + raise_param_exc({ 'notes-template' => "found unknown variables: " . join(', ', @$problematic) }); + } + } + # autogenerate id for api compatibility FIXME remove with 8.0 my $id = extract_param($param, 'id') // UUID::uuid();