ansible-lockdown / UBUNTU22-CIS

Ansible role for Ubuntu22 CIS Baseline
https://ansible-lockdown.readthedocs.io/en/latest/
MIT License
181 stars 80 forks source link

Wrong precondition in Control 1.1.1.2 #112

Closed bgro closed 10 months ago

bgro commented 1 year ago

Describe the Issue Control 1.1.1.2 has

 when:
      - ubtu22cis_rule_1_1_1_2
      - snap_pkg_mgr.stdout | length == 0

as precondition, but this will always fail, because the wordcount is returned rather than the findings:

- name: "PRELIM | Register if snap being used"
  ansible.builtin.shell: df -h | grep -wc "/snap"
  changed_when: false
  failed_when: snap_pkg_mgr.rc not in [ 0, 1 ]
  register: snap_pkg_mgr

Fixing this however leads to an error, because Ubuntu has squashfs built in. So this is another precondition to be checked.

Expected Behavior

Control should be executed if snap is not used and squashfs is not built in.

Actual Behavior

Hence, the control is never executed, even though if snap is not used.

Control(s) Affected

Environment (please complete the following information):

Additional Notes

Possible Solution

The correct precondition is snap_pkg_mgr.stdout == '0'

Also, a precondition checking whether squashfs is built in should be added.

I will provide a PR

uk-bolly commented 12 months ago

hi @bgro

This issue was merged to devel a couple of weeks ago. I will close this Issue, if this does not resolve your issue please reopen.

Many thanks as always

uk-bolly