ansible-sshd/tests
Jakub Jelen d10f2ada11
fix: use quote with command, shell and validate with variable (#298)
* robustness: quote test backup/restore file names

This avoids issues if file names are not safepaths.

* security: use quote with command, shell and validate with variable

Skip quotation only if variable is checked.

Add test suit to excercise some quote use cases.

* robustness: fail if systemd.unit could have something in need of quote

Ensure systemd.unit contents is robust. This disables possibility to
have something that needs to be quoted there. But as ansible lacks
proper way to quote systemd unit files (see man systemd.syntax, rules
are not shell rules), it is better to fail such configs. If you are
trying to do that, you are doing it wrong anyway or have malicious
intent.

Also ensure similar issue with sysctl.conf.

Issue can be seen with `tests_hostkeys_unsafe_path.yml`, when adding
following to role params:

       sshd_install_service: true
       sshd_config_file: "{{ ansible_facts.env.TMPDIR }}/sshd.d/foo.conf"
       sshd_binary: "{{ ansible_facts.env.TMPDIR }}/sshd"
       __sshd_runtime_directory: "{{ ansible_facts.env.TMPDIR }}/run"

* tests: Quote also the source filename

Signed-off-by: Jakub Jelen <jjelen@redhat.com>

* tests: Add more negative test cases

Signed-off-by: Jakub Jelen <jjelen@redhat.com>

* tests: Skip the test with unsafe TMPDIR as it does not work on CentOS8

Signed-off-by: Jakub Jelen <jjelen@redhat.com>

* Move the variable checks to separate file ...

... and explain better why this is problematic

Drops also the check for internal variables as the user should not
bother with these.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>

---------

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Co-authored-by: Markus Linnala <Markus.Linnala@knowit.fi>
2024-09-12 07:24:22 +01:00
..
roles fix: Remove recursive loop created by symlink of entire role (#262) 2023-10-17 07:30:46 +01:00
tasks fix: use quote with command, shell and validate with variable (#298) 2024-09-12 07:24:22 +01:00
templates test: check generated files for ansible_managed, fingerprint 2023-04-26 07:52:03 -06:00
inventory Add tests 2015-01-12 21:01:08 +00:00
requirements.yml Add support for managing selinux and firewall on RHEL 2023-01-13 10:42:40 +01:00
tests_all_options.yml feat: Ubuntu noble (#290) 2024-06-21 09:12:02 +01:00
tests_alternative_file.yml Ubuntu 20 already supports drop-in directory 2024-01-22 16:41:33 +01:00
tests_alternative_file_role.yml Ubuntu 20 already supports drop-in directory 2024-01-22 16:41:33 +01:00
tests_backup.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_certificates.yml feat: manage ssh certificates (#252) 2023-09-11 14:39:03 +01:00
tests_config_namespace.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_default.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_default_include.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_duplicate_role.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_firewall_selinux.yml Support inject_facts_as_vars = false 2023-08-29 12:40:48 +02:00
tests_hostkeys.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_hostkeys_fips.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_hostkeys_missing.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_hostkeys_role.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_hostkeys_unsafe_path.yml fix: use quote with command, shell and validate with variable (#298) 2024-09-12 07:24:22 +01:00
tests_include_present.yml Ubuntu 20 already supports drop-in directory 2024-01-22 16:41:33 +01:00
tests_indent.yml Make sure the list options are correctly indented 2023-04-14 19:01:19 +02:00
tests_match.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_match_iterate.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_os_defaults.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_precedence.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_runtime_directory.yml docs: Fix spelling issues + fix reported issues (#274) 2024-01-29 17:55:43 +00:00
tests_second_service.yml feat: Ubuntu noble (#290) 2024-06-21 09:12:02 +01:00
tests_second_service_drop_in.yml feat: Ubuntu noble (#290) 2024-06-21 09:12:02 +01:00
tests_set_common.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_set_uncommon.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_sshd_enable.yml ansible-lint - align with current Ansible recommendations 2023-04-10 14:21:30 -06:00
tests_sysconfig.yml Add whitespace around the filter symbol 2024-01-22 16:41:33 +01:00
tests_systemd_services.yml feat: Ubuntu noble (#290) 2024-06-21 09:12:02 +01:00
tests_unsafe_options.yml fix: use quote with command, shell and validate with variable (#298) 2024-09-12 07:24:22 +01:00