Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.1.15 is not printing messsage alert when SGID executables exist #247

Closed
boris-stojnev opened this issue Dec 14, 2022 · 4 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@boris-stojnev
Copy link

boris-stojnev commented Dec 14, 2022

Describe the Issue
First task in the block 6.1.15 is using a register variable with a loop, but that variable rhel_08_6_1_15_perms_results is wrongly used in the second and third task of the 6.1.15 block.

Expected Behavior
Print debug msg with items on which manual intervention is required.

Actual Behavior
Task 6.1.15 | AUDIT | Audit SGID executables | Alert SGID executables exist will always be skipped because the condition will never be accomplished.

Environment:

  • Ansible Version: 2.13.7
  • Host Python Version: /
  • Ansible Server Python Version: 3.8.10
  • Using branch: devel

Possible Solution
Each mount point entry will be in the list rhel_08_6_1_15_perms_results.results[].stdout_lines should be correct path.
Reference https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_loops.html#registering-variables-with-a-loop

Edit: The same issue for 6.1.14 as well

@boris-stojnev boris-stojnev added the bug Something isn't working label Dec 14, 2022
@boris-stojnev
Copy link
Author

I’m not very happy with this possible solution, but at least it prints warnings and it’s not misleading.

- name: "6.1.15 | AUDIT | Audit SGID executables"
  block:
      - name: "6.1.15 | AUDIT | Audit SGID executables | Find all SGID executables"
        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_08_6_1_15_perms_results
        with_items: "{{ ansible_mounts }}"
        loop_control:
            label: "{{ item.mount }}"

      - name: "6.1.15 | AUDIT | Audit SGID executables |  Alert no SGID executables exist"
        debug:
            msg: "Good news! We have not found any SGID executable files on your system"
        failed_when: false
        changed_when: false
        when: item.stdout == ""
        loop: "{{ rhel_08_6_1_15_perms_results.results }}"

      - name: "6.1.15 | AUDIT | Audit SGID executables |  Alert SGID executables exist"
        debug:
            msg: "Manual intervention is required -- SGID set on items in {{ item.item.mount }}: {{ item.stdout_lines | join(', ') }}"
        when: item.stdout != ""
        loop: "{{ rhel_08_6_1_15_perms_results.results }}"

      - name: "6.1.15 | AUDIT | Alert SGID executables exist - Manual | warning count"
        set_fact:
            control_number: "{{ control_number }} + [ 'rule_6.1.15' ]"
            warn_count: "{{ warn_count | int + 1 }}"
        when: item.stdout != ""
        loop: "{{ rhel_08_6_1_15_perms_results.results }}"

  when:
      - rhel8cis_rule_6_1_15
  tags:
      - level1-server
      - level1-workstation
      - manual
      - audit
      - files
      - rule_6.1.15

@uk-bolly uk-bolly self-assigned this Jan 24, 2023
uk-bolly added a commit that referenced this issue Apr 12, 2023
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
@uk-bolly
Copy link
Member

hi @boris-stojnev

Thank you for raising this issue, we've been working on a suitable solution for this issue.
There is a new PR raised now to address this issue. which we hope to get merged later today.
Apologies for the delay in addressing this issue.

many thanks

uk-bolly

@uk-bolly
Copy link
Member

hi @boris-stojnev

Thank you again for raising this issue and for your patience. This is now merged into devel.
We hope to merge into devel over the next week.

Many thanks

uk-bolly

@uk-bolly
Copy link
Member

uk-bolly commented Sep 6, 2023

hi @boris-stojnev

This issue has been merged into main. I will therefore close this issue. Please open an issue if you feel this is not resolved.

many thanks

uk-bolly

@uk-bolly uk-bolly closed this as completed Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants