-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
security: use quote with command, shell and validate with variable
Skip only if variable is checked. Also ensure systemd.unit contents is about okay. This disables possibility to have something that needs to be quoted there. But as ansible misses proper way to ensure right quotation (see man systemd.syntax), it is better to fail such configs.
- Loading branch information
Showing
7 changed files
with
80 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
- name: Test hostkeys | ||
hosts: all | ||
environment: | ||
TMPDIR: >- | ||
/tmp/a {{ __badflag }} ' {{ __badflag }} '" {{ __badflag }} "b | ||
vars: | ||
__sshd_test_backup_files: | ||
- /etc/ssh/sshd_config | ||
- /etc/ssh/sshd_config.d/00-ansible_system_role.conf | ||
__badflag: >- | ||
$(touch -- "$(echo {{ '/tmp/BADFLAG' | b64encode }} | base64 -d)") | ||
tasks: | ||
- name: Ensure BADFLAG does not exist | ||
ansible.builtin.file: | ||
path: /tmp/BADFLAG | ||
state: absent | ||
|
||
- name: Assert TMPDIR is set | ||
ansible.builtin.assert: | ||
that: | ||
- ansible_facts.env.TMPDIR != '' | ||
|
||
- name: "Backup configuration files" | ||
ansible.builtin.include_tasks: tasks/backup.yml | ||
|
||
- name: Create BAD TMPDIR | ||
ansible.builtin.file: | ||
state: directory | ||
path: "{{ ansible_facts.env.TMPDIR }}" | ||
mode: '0755' | ||
|
||
- name: Configure sshd with BAD config | ||
ansible.builtin.include_role: | ||
name: ansible-sshd | ||
vars: | ||
sshd_skip_defaults: true | ||
sshd_verify_hostkeys: [] | ||
sshd_config_file: "/tmp/sshd.d/foo.conf" | ||
|
||
- name: Verify the options are correctly set | ||
tags: tests::verify | ||
block: | ||
- name: Flush handlers | ||
ansible.builtin.meta: flush_handlers | ||
|
||
- name: Get status BADFLAG | ||
ansible.builtin.stat: | ||
path: /tmp/BADFLAG | ||
register: badflag | ||
|
||
- name: Ensure BADFLAG does not exist | ||
ansible.builtin.assert: | ||
that: | ||
- not badflag.stat.exists | ||
|
||
- name: Remove BAD TMPDIR | ||
ansible.builtin.file: | ||
state: absent | ||
path: "{{ ansible_facts.env.TMPDIR }}" | ||
|
||
- name: "Restore configuration files" | ||
ansible.builtin.include_tasks: tasks/restore.yml |