From b9e17f74d1bf7f089cffd82be2c0e82338838e23 Mon Sep 17 00:00:00 2001 From: Mark Bolwell Date: Wed, 12 Apr 2023 13:05:26 +0100 Subject: [PATCH 1/4] updated controls Signed-off-by: Mark Bolwell --- tasks/section_6/cis_6.1.x.yml | 77 +++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/tasks/section_6/cis_6.1.x.yml b/tasks/section_6/cis_6.1.x.yml index 298492d..24fc9ab 100644 --- a/tasks/section_6/cis_6.1.x.yml +++ b/tasks/section_6/cis_6.1.x.yml @@ -160,22 +160,27 @@ label: "{{ item.mount }}" when: item['device'].startswith('/dev') and not 'bind' in item['options'] - - name: "6.1.10 | AUDIT | Ensure no unowned files or directories exist | Displaying any unowned files or directories" - ansible.builtin.debug: - msg: "Warning !! Manual intervention is required -- missing owner on items in {{ item.item.mount }}: {{ item.stdout_lines | join(', ') }}" + - name: "6.1.10 | AUDIT | Ensure no unowned files or directories exist | set fact" + ansible.builtin.set_fact: + rhel_09_6_1_10_unowned_files_found: true loop: "{{ rhel_09_6_1_10_audit.results }}" when: - - item.stdout_lines is defined - - item.stdout_lines | length > 0 + - item.stdout | length > 0 + + - name: "6.1.10 | AUDIT | Ensure no unowned files or directories exist | Displaying any unowned files or directories" + ansible.builtin.debug: + msg: "Warning!! Missing owner on items in {{ rhel_09_6_1_10_audit | json_query('results[*].stdout_lines[*]') | flatten }}" + when: + - rhel_09_6_1_10_unowned_files_found - name: "6.1.10 | AUDIT | Ensure no unowned files or directories exist | warning" ansible.builtin.import_tasks: warning_facts.yml vars: warn_control_id: '6.1.10' when: - - item.stdout_lines is defined - - item.stdout_lines | length > 0 - + - rhel_09_6_1_10_unowned_files_found + vars: + rhel_09_6_1_10_unowned_files_found: false when: - rhel9cis_rule_6_1_10 tags: @@ -199,21 +204,27 @@ label: "{{ item.mount }}" when: item['device'].startswith('/dev') and not 'bind' in item['options'] - - name: "6.1.11 | AUDIT | Ensure no ungrouped files or directories exist | Displaying all ungrouped files or directories" - ansible.builtin.debug: - msg: "Warning !! Manual intervention is required -- missing group on items in {{ item.item.mount }}: {{ item.stdout_lines | join(', ') }}" + - name: "6.1.11 | AUDIT | Ensure no ungrouped files or directories exist | set fact" + ansible.builtin.set_fact: + rhel_09_6_1_11_ungrouped_files_found: true loop: "{{ rhel_09_6_1_11_audit.results }}" when: - - item.stdout_lines is defined - - item.stdout_lines | length > 0 + - item.stdout | length > 0 + + - name: "6.1.11 | AUDIT | Ensure no ungrouped files or directories exist | Displaying all ungrouped files or directories" + ansible.builtin.debug: + msg: "Warning!! Missing group on items in {{ rhel_09_6_1_11_audit | json_query('results[*].stdout_lines[*]') | flatten }}" + when: + - rhel_09_6_1_11_ungrouped_files_found - name: "6.1.11 | AUDIT | Ensure no ungrouped files or directories exist | warning" ansible.builtin.import_tasks: warning_facts.yml vars: warn_control_id: '6.1.11' when: - - item.stdout_lines is defined - - item.stdout_lines | length > 0 + - rhel_09_6_1_11_ungrouped_files_found + vars: + - rhel_09_6_1_11_ungrouped_files_found: false when: - rhel9cis_rule_6_1_11 tags: @@ -244,24 +255,32 @@ ansible.builtin.shell: df {{ item.mount }} -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type f -perm -4000 failed_when: false changed_when: false - register: rhel_09_6_1_13_perms_results + register: rhel_09_6_1_13_suid_perms loop: "{{ ansible_mounts }}" loop_control: label: "{{ item.mount }}" + - name: "6.1.13 | AUDIT | Audit SUID executables | set fact SUID executables" + ansible.builtin.set_fact: + rhel8cis_6_1_13_suid_found: true + loop: "{{ rhel_09_6_1_13_suid_perms.results }}" + when: + - item.stdout | length > 0 + - name: "6.1.13 | AUDIT | Audit SUID executables | Alert SUID executables exist" ansible.builtin.debug: - msg: "Warning!! Manual intervention is required -- SUID set on items in {{ item.item.mount }}: {{ item.stout_lines | join(', ') }}" - loop: "{{ rhel_09_6_1_13_perms_results.stdout_lines }}" + msg: "Warning!! SUID set on items in {{ rhel_09_6_1_13_suid_perms | json_query('results[*].stdout_lines[*]') | flatten }}" when: - - rhel_09_6_1_13_perms_results.stdout is defined + - rhel8cis_6_1_13_suid_found - name: "6.1.13 | AUDIT | Audit SUID executables | Alert SUID executables exist | warning" ansible.builtin.import_tasks: warning_facts.yml vars: warn_control_id: '6.1.13' when: - - rhel_09_6_1_13_perms_results.stdout is defined + - rhel8cis_6_1_13_suid_found + vars: + rhel8cis_6_1_13_suid_found: false when: - rhel9cis_rule_6_1_13 tags: @@ -278,24 +297,32 @@ ansible.builtin.shell: df {{ item.mount }} -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type f -perm -2000 failed_when: false changed_when: false - register: rhel_09_6_1_14_perms_results + register: rhel_09_6_1_14_sgid_perms loop: "{{ ansible_mounts }}" loop_control: label: "{{ item.mount }}" + - name: "6.1.14 | AUDIT | Audit SGID executables | Set fact SGID executables" + ansible.builtin.set_fact: + rhel8cis_6_1_14_sgid_found: true + loop: "{{ rhel_09_6_1_14_sgid_perms.results }}" + when: + - item.stdout | length > 0 + - name: "6.1.14 | AUDIT | Audit SGID executables | Alert SGID executables exist" ansible.builtin.debug: - msg: "Manual intervention is required -- SGID set on items in {{ item.item.mount }}: {{ item.stout_lines | join(', ') }}" - loop: "{{ rhel_09_6_1_14_perms_results.stdout_lines }}" + msg: "Warning!! SGID set on items in {{ rhel_09_6_1_14_sgid_perms | json_query('results[*].stdout_lines[*]') | flatten }}" when: - - rhel_09_6_1_14_perms_results.stdout is defined + - rhel8cis_6_1_14_sgid_found - name: "6.1.14 | AUDIT | Audit SGID executables| warning" ansible.builtin.import_tasks: warning_facts.yml vars: warn_control_id: '6.1.14' when: - - rhel_09_6_1_14_perms_results.stdout is defined + - rhel8cis_6_1_14_sgid_found + vars: + rhel8cis_6_1_14_sgid_found: false when: - rhel9cis_rule_6_1_14 tags: From f66c74f60138249ffcbfc70a1e50790d37adeb71 Mon Sep 17 00:00:00 2001 From: Mark Bolwell Date: Wed, 12 Apr 2023 13:05:35 +0100 Subject: [PATCH 2/4] updated Signed-off-by: Mark Bolwell --- Changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Changelog.md b/Changelog.md index 0560901..5f990a3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # Changes to rhel9CIS +## 1.0.7 + +lint and yamll updates +improvemnst to 6.1.10, 6.1.11, 6.1.13, 6.1.14 + ## 1.0.6 updated ymlalint as galaxy doenst honouyr local settings From 120a0ea7514b8a0484e7abe1c19be2edaa44fc17 Mon Sep 17 00:00:00 2001 From: Mark Bolwell Date: Wed, 12 Apr 2023 13:10:42 +0100 Subject: [PATCH 3/4] updated layout Signed-off-by: Mark Bolwell --- tasks/section_6/cis_6.1.x.yml | 36 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/tasks/section_6/cis_6.1.x.yml b/tasks/section_6/cis_6.1.x.yml index 24fc9ab..480329a 100644 --- a/tasks/section_6/cis_6.1.x.yml +++ b/tasks/section_6/cis_6.1.x.yml @@ -164,21 +164,18 @@ ansible.builtin.set_fact: rhel_09_6_1_10_unowned_files_found: true loop: "{{ rhel_09_6_1_10_audit.results }}" - when: - - item.stdout | length > 0 + when: item.stdout | length > 0 - name: "6.1.10 | AUDIT | Ensure no unowned files or directories exist | Displaying any unowned files or directories" ansible.builtin.debug: msg: "Warning!! Missing owner on items in {{ rhel_09_6_1_10_audit | json_query('results[*].stdout_lines[*]') | flatten }}" - when: - - rhel_09_6_1_10_unowned_files_found + when: rhel_09_6_1_10_unowned_files_found - name: "6.1.10 | AUDIT | Ensure no unowned files or directories exist | warning" ansible.builtin.import_tasks: warning_facts.yml vars: warn_control_id: '6.1.10' - when: - - rhel_09_6_1_10_unowned_files_found + when: rhel_09_6_1_10_unowned_files_found vars: rhel_09_6_1_10_unowned_files_found: false when: @@ -208,21 +205,18 @@ ansible.builtin.set_fact: rhel_09_6_1_11_ungrouped_files_found: true loop: "{{ rhel_09_6_1_11_audit.results }}" - when: - - item.stdout | length > 0 + when: item.stdout | length > 0 - name: "6.1.11 | AUDIT | Ensure no ungrouped files or directories exist | Displaying all ungrouped files or directories" ansible.builtin.debug: msg: "Warning!! Missing group on items in {{ rhel_09_6_1_11_audit | json_query('results[*].stdout_lines[*]') | flatten }}" - when: - - rhel_09_6_1_11_ungrouped_files_found + when: rhel_09_6_1_11_ungrouped_files_found - name: "6.1.11 | AUDIT | Ensure no ungrouped files or directories exist | warning" ansible.builtin.import_tasks: warning_facts.yml vars: warn_control_id: '6.1.11' - when: - - rhel_09_6_1_11_ungrouped_files_found + when: rhel_09_6_1_11_ungrouped_files_found vars: - rhel_09_6_1_11_ungrouped_files_found: false when: @@ -264,21 +258,18 @@ ansible.builtin.set_fact: rhel8cis_6_1_13_suid_found: true loop: "{{ rhel_09_6_1_13_suid_perms.results }}" - when: - - item.stdout | length > 0 + when: item.stdout | length > 0 - name: "6.1.13 | AUDIT | Audit SUID executables | Alert SUID executables exist" ansible.builtin.debug: msg: "Warning!! SUID set on items in {{ rhel_09_6_1_13_suid_perms | json_query('results[*].stdout_lines[*]') | flatten }}" - when: - - rhel8cis_6_1_13_suid_found + when: rhel8cis_6_1_13_suid_found - name: "6.1.13 | AUDIT | Audit SUID executables | Alert SUID executables exist | warning" ansible.builtin.import_tasks: warning_facts.yml vars: warn_control_id: '6.1.13' - when: - - rhel8cis_6_1_13_suid_found + when: rhel8cis_6_1_13_suid_found vars: rhel8cis_6_1_13_suid_found: false when: @@ -306,21 +297,18 @@ ansible.builtin.set_fact: rhel8cis_6_1_14_sgid_found: true loop: "{{ rhel_09_6_1_14_sgid_perms.results }}" - when: - - item.stdout | length > 0 + when: item.stdout | length > 0 - name: "6.1.14 | AUDIT | Audit SGID executables | Alert SGID executables exist" ansible.builtin.debug: msg: "Warning!! SGID set on items in {{ rhel_09_6_1_14_sgid_perms | json_query('results[*].stdout_lines[*]') | flatten }}" - when: - - rhel8cis_6_1_14_sgid_found + when: rhel8cis_6_1_14_sgid_found - name: "6.1.14 | AUDIT | Audit SGID executables| warning" ansible.builtin.import_tasks: warning_facts.yml vars: warn_control_id: '6.1.14' - when: - - rhel8cis_6_1_14_sgid_found + when: rhel8cis_6_1_14_sgid_found vars: rhel8cis_6_1_14_sgid_found: false when: From a5df4c2f3847e5e6b3a28de26004132c14dfc4dc Mon Sep 17 00:00:00 2001 From: Mark Bolwell Date: Thu, 13 Apr 2023 09:23:10 +0100 Subject: [PATCH 4/4] fix_typos Signed-off-by: Mark Bolwell --- tasks/section_6/cis_6.1.x.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tasks/section_6/cis_6.1.x.yml b/tasks/section_6/cis_6.1.x.yml index 480329a..8da977d 100644 --- a/tasks/section_6/cis_6.1.x.yml +++ b/tasks/section_6/cis_6.1.x.yml @@ -256,22 +256,22 @@ - name: "6.1.13 | AUDIT | Audit SUID executables | set fact SUID executables" ansible.builtin.set_fact: - rhel8cis_6_1_13_suid_found: true + rhel9_6_1_13_suid_found: true loop: "{{ rhel_09_6_1_13_suid_perms.results }}" when: item.stdout | length > 0 - name: "6.1.13 | AUDIT | Audit SUID executables | Alert SUID executables exist" ansible.builtin.debug: msg: "Warning!! SUID set on items in {{ rhel_09_6_1_13_suid_perms | json_query('results[*].stdout_lines[*]') | flatten }}" - when: rhel8cis_6_1_13_suid_found + when: rhel9_6_1_13_suid_found - name: "6.1.13 | AUDIT | Audit SUID executables | Alert SUID executables exist | warning" ansible.builtin.import_tasks: warning_facts.yml vars: warn_control_id: '6.1.13' - when: rhel8cis_6_1_13_suid_found + when: rhel9_6_1_13_suid_found vars: - rhel8cis_6_1_13_suid_found: false + rhel9_6_1_13_suid_found: false when: - rhel9cis_rule_6_1_13 tags: @@ -295,22 +295,22 @@ - name: "6.1.14 | AUDIT | Audit SGID executables | Set fact SGID executables" ansible.builtin.set_fact: - rhel8cis_6_1_14_sgid_found: true + rhel9_6_1_14_sgid_found: true loop: "{{ rhel_09_6_1_14_sgid_perms.results }}" when: item.stdout | length > 0 - name: "6.1.14 | AUDIT | Audit SGID executables | Alert SGID executables exist" ansible.builtin.debug: msg: "Warning!! SGID set on items in {{ rhel_09_6_1_14_sgid_perms | json_query('results[*].stdout_lines[*]') | flatten }}" - when: rhel8cis_6_1_14_sgid_found + when: rhel9_6_1_14_sgid_found - name: "6.1.14 | AUDIT | Audit SGID executables| warning" ansible.builtin.import_tasks: warning_facts.yml vars: warn_control_id: '6.1.14' - when: rhel8cis_6_1_14_sgid_found + when: rhel9_6_1_14_sgid_found vars: - rhel8cis_6_1_14_sgid_found: false + rhel9_6_1_14_sgid_found: false when: - rhel9cis_rule_6_1_14 tags: