From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 628631FF0C0 for ; Wed, 18 Nov 2026 10:14:51 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 2143E2167B; Wed, 18 Nov 2026 10:14:41 +0100 (CET) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v3 48/51] test: add tests guarding against subdir scanning for vtypes Date: Wed, 18 Nov 2026 10:14:10 +0100 Message-ID: <20261118091416.27183-4-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118091416.27183-1-m.carrara@proxmox.com> References: <20261117203953.913035-1-m.carrara@proxmox.com> <20261118091416.27183-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: 1794993263287 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.235 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: LVXCVOQBOFAOX6PAGPGTBN5ZRZOVVODS X-Message-ID-Hash: LVXCVOQBOFAOX6PAGPGTBN5ZRZOVVODS 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 CC: Wolfgang Bumiller 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 0ecf7378..35d2007c 100644 --- a/src/PVE/Storage/Common/Parse.pm +++ b/src/PVE/Storage/Common/Parse.pm @@ -117,10 +117,11 @@ my $RE_GUEST_VZDUMP_BACKUP_FILE_NAME = qr! - (? openvz|lxc|qemu) - (? $RE_VMID) - ( $RE_GUEST_VZDUMP_BACKUP_FILE_TIMESTAMP | [^/]+ ) !xn; +# NOTE: Not supporting subdirectories here. my $RE_BACKUP_FILE_PATH = qr! (? (? ( ($RE_GUEST_VZDUMP_BACKUP_FILE_NAME) diff --git a/src/PVE/Storage/Common/test/parser_tests.pl b/src/PVE/Storage/Common/test/parser_tests.pl index ad3651e0..27280f13 100755 --- a/src/PVE/Storage/Common/test/parser_tests.pl +++ b/src/PVE/Storage/Common/test/parser_tests.pl @@ -566,10 +566,50 @@ my $volname_cases_backup_invalid = [ path => 'vzdump-qemu-16110-2020_03_30-21_12_40.tar.Gz', vtype => 'backup', }, 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 = [ # plain files { diff --git a/src/test/path_to_volume_id_test.pm b/src/test/path_to_volume_id_test.pm index 3cdf23ae..bcd9db9c 100644 --- a/src/test/path_to_volume_id_test.pm +++ b/src/test/path_to_volume_id_test.pm @@ -244,15 +244,26 @@ my $tests = [ { description => 'Backup, wrong format, qemu, vms.gz', 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", expected => [''], }, -- 2.47.3