Skip to content

Commit 332197c

Browse files
fix: reject empty and path-traversal entries in backup_exclude_dirs
1 parent 4935e5b commit 332197c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

deployer/backup/task/backup_exclude_cache.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@
1010
foreach (get('backup_exclude_dirs') as $dir) {
1111
$dir = trim($dir, '/');
1212

13-
if (!test("[ -d {{ release_path }}/$dir ]")) {
13+
if ('' === $dir || in_array('..', explode('/', $dir), true) || in_array('.', explode('/', $dir), true)) {
14+
warning("Skipping invalid backup_exclude_dirs entry: \"$dir\"");
1415
continue;
1516
}
1617

17-
run("echo '" . CACHEDIR_TAG_SIGNATURE . "' > {{ release_path }}/$dir/CACHEDIR.TAG");
18+
if (!test("[ -d '{{ release_path }}/$dir' ]")) {
19+
continue;
20+
}
21+
22+
run("echo '" . CACHEDIR_TAG_SIGNATURE . "' > '{{ release_path }}/$dir/CACHEDIR.TAG'");
1823
debug("Tagged {{ release_path }}/$dir as excluded from backups (CACHEDIR.TAG)");
1924
}
2025
})

0 commit comments

Comments
 (0)