From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 37E691FF13B for ; Wed, 22 Apr 2026 13:20:06 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B2D041A4DF; Wed, 22 Apr 2026 13:15:36 +0200 (CEST) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v1 52/54] test: add tests guarding against subdir scanning for vtypes Date: Wed, 22 Apr 2026 13:13:18 +0200 Message-ID: <20260422111322.257380-53-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260422111322.257380-1-m.carrara@proxmox.com> References: <20260422111322.257380-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776856371787 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.082 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 Message-ID-Hash: WIMUEPSP5XRY72JZLZBAZ2DBU3XAW3PJ X-Message-ID-Hash: WIMUEPSP5XRY72JZLZBAZ2DBU3XAW3PJ X-MailFrom: m.carrara@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add tests that guard against implementing nested subdirectory scanning for the 'backup' volume type in `parser_tests.pl`, and for the 'images' and 'backup' volume types in `path_to_volume_id_test.pm`. For the 'backup' vtype, also add a comment above the parser's corresponding regex that we do not allow nested subdirs there. This is done mainly to prevent implementing subdir scanning blindly in the future for these two volume types. While adding support for subdir scanning for the 'backup' volume type would probably be fairly trivial, there is also no (known) need for it currently. For the 'images' type, there currently is no plan or need to support subdir scanning, and it would probably not make much sense anyway. Signed-off-by: Max R. Carrara --- src/PVE/Storage/Common/Parse.pm | 1 + src/PVE/Storage/Common/test/parser_tests.pl | 40 +++++++++++++++++++++ src/test/path_to_volume_id_test.pm | 11 ++++++ 3 files changed, 52 insertions(+) diff --git a/src/PVE/Storage/Common/Parse.pm b/src/PVE/Storage/Common/Parse.pm index 6bab7e28..b33fe78e 100644 --- a/src/PVE/Storage/Common/Parse.pm +++ b/src/PVE/Storage/Common/Parse.pm @@ -103,6 +103,7 @@ my $RE_GUEST_VZDUMP_BACKUP_FILE_NAME = qr! - [^/]+ !xn; +# NOTE: Not supporting subdirectories here. my $RE_BACKUP_FILE_PATH = qr! (? (? diff --git a/src/PVE/Storage/Common/test/parser_tests.pl b/src/PVE/Storage/Common/test/parser_tests.pl index a788f2ab..882c0675 100755 --- a/src/PVE/Storage/Common/test/parser_tests.pl +++ b/src/PVE/Storage/Common/test/parser_tests.pl @@ -474,6 +474,46 @@ my $volname_cases_backup_invalid = [ }, expected => undef, }, + { + description => "Subdirectory (backup)", + args => { + path => 'subdir/vzdump-qemu-16110-2020_03_30-21_12_40.tar.gz', + vtype => 'backup', + }, + expected => undef, + }, + { + description => "Nested subdirectory (backup)", + args => { + path => 'deeply/nested/subdir/vzdump-qemu-16110-2020_03_30-21_12_40.tar.gz', + vtype => 'backup', + }, + expected => undef, + }, + { + description => "Parent dir reference in path (beginning) (backup)", + args => { + path => '../vzdump-lxc-16112-2020_03_30-21_49_30.tar.gz', + vtype => 'backup', + }, + expected => undef, + }, + { + description => "Parent dir reference in path (middle) (backup)", + args => { + path => 'subdir/../vzdump-lxc-16112-2020_03_30-21_49_30.tar.gz', + vtype => 'backup', + }, + expected => undef, + }, + { + description => "Parent dir reference in path (end) (backup)", + args => { + path => 'subdir/vzdump-lxc-16112-2020_03_30-21_49_30.tar.gz/..', + vtype => 'backup', + }, + expected => undef, + }, ]; my $volname_cases_snippets_valid = [ diff --git a/src/test/path_to_volume_id_test.pm b/src/test/path_to_volume_id_test.pm index 3bfb37a6..2eb17e9e 100644 --- a/src/test/path_to_volume_id_test.pm +++ b/src/test/path_to_volume_id_test.pm @@ -246,11 +246,22 @@ my $tests = [ file => "$DEFAULT_STORAGE_DIR/dump/vzdump-qemu-16110-2020_03_30-21_12_40.vms.gz", expected => [''], }, + { + description => 'Backup, nested subdirectories, vma.gz', + file => + "$DEFAULT_STORAGE_DIR/dump/foo/bar/baz/vzdump-qemu-16110-2020_03_30-21_11_40.vma.gz", + expected => [''], + }, { description => 'Image, string as vmid in folder name', file => "$DEFAULT_STORAGE_DIR/images/ssss/vm-1234-disk-0.qcow2", expected => [''], }, + { + description => 'Image, additional nested subdirectories before vmid', + file => "$DEFAULT_STORAGE_DIR/images/foo/bar/baz/1234/vm-1234-disk-0.qcow2", + expected => [''], + }, { description => 'Import, non ova/ovf/disk image in import dir', file => "$DEFAULT_STORAGE_DIR/import/test.foo", -- 2.47.3