public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH common] schema: explicitly set min/max for vmid option
@ 2023-06-16  7:35 Fiona Ebner
  2023-06-16  8:23 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 4+ messages in thread
From: Fiona Ebner @ 2023-06-16  7:35 UTC (permalink / raw)
  To: pve-devel

The associated pve_verify_vmid() method already restricts the value
to this range, but this wouldn't be visible in the API viewer for
example [0].

The verify method is also called by qemu-server's qmextract, so it's
not possible to just drop the method right now.

[0]: https://forum.proxmox.com/threads/128845/post-564526

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/JSONSchema.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 60b02cb..7589bba 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -59,8 +59,10 @@ sub get_standard_option {
 
 register_standard_option('pve-vmid', {
     description => "The (unique) ID of the VM.",
-    type => 'integer', format => 'pve-vmid',
-    minimum => 1
+    type => 'integer',
+    format => 'pve-vmid',
+    minimum => 100,
+    maximum => 999_999_999,
 });
 
 register_standard_option('pve-node', {
-- 
2.39.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] applied: [PATCH common] schema: explicitly set min/max for vmid option
  2023-06-16  7:35 [pve-devel] [PATCH common] schema: explicitly set min/max for vmid option Fiona Ebner
@ 2023-06-16  8:23 ` Thomas Lamprecht
  2023-06-16  9:01   ` Fiona Ebner
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Lamprecht @ 2023-06-16  8:23 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fiona Ebner

Am 16/06/2023 um 09:35 schrieb Fiona Ebner:
> The associated pve_verify_vmid() method already restricts the value
> to this range, but this wouldn't be visible in the API viewer for
> example [0].
> 
> The verify method is also called by qemu-server's qmextract, so it's
> not possible to just drop the method right now.
> 
> [0]: https://forum.proxmox.com/threads/128845/post-564526
> 
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
>  src/PVE/JSONSchema.pm | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
>

applied, thanks!

let's see if we ever used values < 100 as some special thingy somwhere ;-P
(if, those things should probably just switch to another format)




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] applied: [PATCH common] schema: explicitly set min/max for vmid option
  2023-06-16  8:23 ` [pve-devel] applied: " Thomas Lamprecht
@ 2023-06-16  9:01   ` Fiona Ebner
  2023-06-16 10:40     ` Thomas Lamprecht
  0 siblings, 1 reply; 4+ messages in thread
From: Fiona Ebner @ 2023-06-16  9:01 UTC (permalink / raw)
  To: Thomas Lamprecht, Proxmox VE development discussion

Am 16.06.23 um 10:23 schrieb Thomas Lamprecht:
> Am 16/06/2023 um 09:35 schrieb Fiona Ebner:
>> The associated pve_verify_vmid() method already restricts the value
>> to this range, but this wouldn't be visible in the API viewer for
>> example [0].
>>
>> The verify method is also called by qemu-server's qmextract, so it's
>> not possible to just drop the method right now.
>>
>> [0]: https://forum.proxmox.com/threads/128845/post-564526
>>
>> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
>> ---
>>  src/PVE/JSONSchema.pm | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>>
> 
> applied, thanks!
> 
> let's see if we ever used values < 100 as some special thingy somwhere ;-P
> (if, those things should probably just switch to another format)

Even if, the problem is limited to cases where the format verification
wouldn't be done, but the min/max limits would apply. Can that even happen?




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] applied: [PATCH common] schema: explicitly set min/max for vmid option
  2023-06-16  9:01   ` Fiona Ebner
@ 2023-06-16 10:40     ` Thomas Lamprecht
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2023-06-16 10:40 UTC (permalink / raw)
  To: Fiona Ebner, Proxmox VE development discussion

Am 16/06/2023 um 11:01 schrieb Fiona Ebner:
>> let's see if we ever used values < 100 as some special thingy somwhere 😜
>> (if, those things should probably just switch to another format)
>
> Even if, the problem is limited to cases where the format verification
> wouldn't be done, but the min/max limits would apply. Can that even happen?

I really don't expect it, would need to manually extract the API schema
from the format and then use that to parse something – especially for such
simple formats (i.e., no format string composed of multiple properties)
I'd find that highly surprising; just saw a bit odd (perl) code already
to dare to rule the possibility of this out ;-)




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-16 10:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-16  7:35 [pve-devel] [PATCH common] schema: explicitly set min/max for vmid option Fiona Ebner
2023-06-16  8:23 ` [pve-devel] applied: " Thomas Lamprecht
2023-06-16  9:01   ` Fiona Ebner
2023-06-16 10:40     ` Thomas Lamprecht

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