ansible-collection-hardening/molecule/ssh_hardening_bsd/verify.yml
schurzi 29f8a2fb78
add testing for OpenBSD and FreeBSD (#642)
* add testing for OpenBSD and FreeBSD

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* make python work

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* remove jinja template ...

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* make verify work

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* correct verify

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* correct verify

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* correct verify

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* correct verify

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* use right vm name for connect

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* add a bit of documentation

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* remove sudo

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* add weird OpenSBD workaround

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* make verify playbook more consistent

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* rename nonlinux to BSD

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* use openbsd7 for testing

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* correct use openbsd7 everywhere

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* add waivers

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* update waiver descriptions

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* use docker for inspec

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* keep looking right ;)

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* correct path to waivers

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* use ephemeral directory in docker

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* use bsd inspec profile

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* remove openbsd workaround

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* re-add openbsd workaround

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* commit suggestions

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* add supportet OS to metadata

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

* use current python

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>

---------

Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
2023-03-31 09:50:04 +02:00

55 lines
1.9 KiB
YAML

---
- name: OpenBSD workaround - inspec detects OpenSBD as unix and not linux compatible
hosts: all
become: true
tasks:
- name: use the type command instead of which to detect existing commands
file:
src: "/usr/bin/which"
dest: "/usr/bin/type"
state: hard
when: "lookup('env', 'MOLECULE_DISTRO') == 'openbsd7'"
- name: Verify
hosts: localhost
environment:
http_proxy: "{{ lookup('env', 'http_proxy') | default(omit) }}"
https_proxy: "{{ lookup('env', 'https_proxy') | default(omit) }}"
no_proxy: "{{ lookup('env', 'no_proxy') | default(omit) }}"
tasks:
- name: get ssh-config
command:
cmd: "vagrant ssh-config"
chdir: "{{ molecule_ephemeral_directory }}"
register: ssh_config
changed_when: false
- name: create ssh-config file
copy:
content: "{{ ssh_config.stdout_lines | join ('\n') }}"
dest: "{{ molecule_ephemeral_directory }}/ssh-config"
changed_when: false
- name: Execute cinc-auditor tests
command: >
docker run
--volume {{ molecule_ephemeral_directory }}:{{ molecule_ephemeral_directory }}
--volume ./waivers_{{ lookup('env', 'MOLECULE_DISTRO') }}.yaml:/waivers.yaml
docker.io/cincproject/auditor exec
--ssh-config-file={{ molecule_ephemeral_directory }}/ssh-config
-t ssh://{{ lookup('env', 'USER') }}
--sudo --no-show-progress --no-color
--waiver-file /waivers.yaml
--no-distinct-exit https://github.com/dev-sec/ssh-baseline/archive/refs/heads/master.zip
register: test_results
changed_when: false
ignore_errors: true
- name: Display details about the cinc-auditor results
debug:
msg: "{{ test_results.stdout_lines }}"
- name: Fail when tests fail
fail:
msg: "Inspec failed to validate"
when: test_results.rc != 0