allow dots in path validation and check host_root_path for traversal

This commit is contained in:
2026-07-16 16:58:20 -04:00
parent 8208f3f779
commit eba541a2e2
+5 -4
View File
@@ -18,11 +18,12 @@
that: that:
- app_name is defined - app_name is defined
- app_name | length > 0 - app_name | length > 0
- app_name is match('^[a-zA-Z0-9_-]+$') - app_name is match('^[a-zA-Z0-9_.-]+$')
- host_root_path is defined - host_root_path is defined
- host_root_path | length > 0 - host_root_path | length > 0
- host_root_path is match('^/[a-zA-Z0-9/_-]*$') - host_root_path is match('^/[a-zA-Z0-9./_-]*$')
fail_msg: "Validation failed for {{ app_name | default('undefined') }}: Required variables missing or contain invalid characters. app_name and host_root_path must be defined and contain only alphanumeric, underscore, hyphen, and slash characters." - not (host_root_path is match('.*\.\..*'))
fail_msg: "Validation failed for {{ app_name | default('undefined') }}: Required variables missing or contain invalid characters. app_name and host_root_path must be defined, contain only alphanumeric, dot, underscore, hyphen, and slash characters, and must not contain path traversal sequences."
- name: Set compose source type - name: Set compose source type
ansible.builtin.set_fact: ansible.builtin.set_fact:
@@ -43,7 +44,7 @@
- name: Validate directory paths - name: Validate directory paths
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- app_dir is match('^/[a-zA-Z0-9/_-]*$') - app_dir is match('^/[a-zA-Z0-9./_-]*$')
- not (app_dir is match('.*\.\..*')) - not (app_dir is match('.*\.\..*'))
fail_msg: "Security validation failed for {{ app_name }}: app_dir '{{ app_dir }}' contains invalid characters or path traversal sequences" fail_msg: "Security validation failed for {{ app_name }}: app_dir '{{ app_dir }}' contains invalid characters or path traversal sequences"