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 7449E6A3C4 for ; Wed, 16 Mar 2022 11:09:09 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6B2BA261CC for ; Wed, 16 Mar 2022 11:09:09 +0100 (CET) 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 87EDC261C3 for ; Wed, 16 Mar 2022 11:09:08 +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 53C2B46E44 for ; Wed, 16 Mar 2022 11:09:08 +0100 (CET) Date: Wed, 16 Mar 2022 11:08:59 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20220314090307.1130083-1-d.csapak@proxmox.com> <20220314090307.1130083-2-d.csapak@proxmox.com> In-Reply-To: <20220314090307.1130083-2-d.csapak@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1647424380.fqb9guy34f.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.185 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 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 cluster 2/3] Cluster: add get_guest_config_properties 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, 16 Mar 2022 10:09:09 -0000 this and the other one existing one might also warrant a comment=20 indicating that you possibly still want to parse/validate/filter the=20 result before passing it along further up the stack (or that it should=20 only be used for very simple keys?) - if no vmid is passed, the result needs to be filtered by access to not=20 leak information - if property is anything but a very simple type, validation might be=20 important (for lock it's not that bad since that is just a simple=20 enum, so a bogus/invalid value will likely just look weird, for the=20 `tags` property it's also not that bad since those are just simple lists of strings, but who knows what this will get used for=20 down the line ;)) also depending on whether the msg format gets changed this will need=20 adapation obviously. On March 14, 2022 10:03 am, Dominik Csapak wrote: > akin to get_guest_config_property, but with a list of properties. > uses the new CFS_IPC_GET_GUEST_CONFIG_PROPERTIES >=20 > Signed-off-by: Dominik Csapak > --- > data/PVE/Cluster.pm | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) >=20 > diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm > index 765fb43..c65ba17 100644 > --- a/data/PVE/Cluster.pm > +++ b/data/PVE/Cluster.pm > @@ -340,6 +340,27 @@ sub get_node_kv { > return $res; > } > =20 > +# properties: an array-ref of config properties you want to get, e.g., t= his > +# is perfect to get multiple properties of a guest _fast_ > +# (>100 faster than manual parsing here) > +# vmid: optional, if a valid is passed we only check that one, else retu= rn all > +# NOTE: does *not* searches snapshot and PENDING entries sections! > +sub get_guest_config_properties { > + my ($properties, $vmid) =3D @_; > + > + die "properties required" if !defined($properties); > + > + my $bindata =3D pack "VC", $vmid // 0, scalar(@$properties); length of $properties actually has a limit which should maybe be checked=20 here as well? I mean it is rather unlikely to be misused in practice,=20 and will print a warning that the `C` wraps the value here, but.. > + for my $property (@$properties) { > + die "property name cannot be longer than 254 chars\n" > + if length($property) > 254; > + $bindata .=3D pack "C/Z*", $property; like indicated in the other patch's comments, this is a rather strange=20 encoding (flashbacks to ASN.1 ;)) and shouldn't be needed. > + } > + my $res =3D $ipcc_send_rec_json->(CFS_IPC_GET_GUEST_CONFIG_PROPERTIE= S, $bindata); > + > + return $res; > +} > + > # property: a config property you want to get, e.g., this is perfect to = get > # the 'lock' entry of a guest _fast_ (>100 faster than manual parsing he= re) > # vmid: optipnal, if a valid is passed we only check that one, else retu= rn all > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20