4
0
Fork 0

Merge pull request #405 from ansible-lockdown/pub_oct25

workflow and audit improvements
This commit is contained in:
Frederick Witty 2025-10-16 10:54:53 -04:00 committed by GitHub
commit 4cd3d8bab2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 29 additions and 93 deletions

View file

@ -17,12 +17,6 @@
# Allow manual running of workflow # Allow manual running of workflow
workflow_dispatch: workflow_dispatch:
# Allow permissions for AWS auth
permissions:
id-token: write
contents: read
pull-requests: read
# A workflow run is made up of one or more jobs # A workflow run is made up of one or more jobs
# that can run sequentially or in parallel # that can run sequentially or in parallel
jobs: jobs:
@ -30,6 +24,10 @@
welcome: welcome:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps: steps:
- uses: actions/first-interaction@main - uses: actions/first-interaction@main
with: with:
@ -45,6 +43,13 @@
playbook-test: playbook-test:
# The type of runner that the job will run on # The type of runner that the job will run on
runs-on: self-hosted runs-on: self-hosted
# Allow permissions for AWS auth
permissions:
id-token: write
contents: read
pull-requests: read
env: env:
ENABLE_DEBUG: ${{ vars.ENABLE_DEBUG }} ENABLE_DEBUG: ${{ vars.ENABLE_DEBUG }}
# Imported as a variable by terraform # Imported as a variable by terraform

View file

@ -10,6 +10,7 @@
- Added max-concurrent options for audit - Added max-concurrent options for audit
- work flow updates - work flow updates
- audit logic improvements - audit logic improvements
- auditd template 2.19 compatible
## 2.0.3 - Based on CIS v2.0.0 ## 2.0.3 - Based on CIS v2.0.0
- addressed issue #387, thank you @fragglexarmy - addressed issue #387, thank you @fragglexarmy

View file

@ -94,8 +94,6 @@ audit_max_concurrent: 50
## Only run Audit do not remediate ## Only run Audit do not remediate
audit_only: false audit_only: false
### As part of audit_only ### ### As part of audit_only ###
# This will enable files to be copied back to control node in audit_only mode
fetch_audit_files: false
# Path to copy the files to will create dir structure in audit_only mode # Path to copy the files to will create dir structure in audit_only mode
audit_capture_files_dir: /some/location to copy to on control node audit_capture_files_dir: /some/location to copy to on control node
############################# #############################

View file

@ -85,6 +85,7 @@
- name: Pre Audit | Capture audit data if json format - name: Pre Audit | Capture audit data if json format
ansible.builtin.shell: grep -E '\"summary-line.*Count:.*Failed' "{{ pre_audit_outfile }}" | cut -d'"' -f4 ansible.builtin.shell: grep -E '\"summary-line.*Count:.*Failed' "{{ pre_audit_outfile }}" | cut -d'"' -f4
changed_when: false changed_when: false
failed_when: pre_audit_summary.stderr | length > 0
register: pre_audit_summary register: pre_audit_summary
- name: Pre Audit | Set Fact for audit summary - name: Pre Audit | Set Fact for audit summary
@ -97,6 +98,7 @@
- name: Pre Audit | Capture audit data if documentation format - name: Pre Audit | Capture audit data if documentation format
ansible.builtin.shell: tail -2 "{{ pre_audit_outfile }}" | tac | tr '\n' ' ' ansible.builtin.shell: tail -2 "{{ pre_audit_outfile }}" | tac | tr '\n' ' '
changed_when: false changed_when: false
failed_when: pre_audit_summary.stderr | length > 0
register: pre_audit_summary register: pre_audit_summary
- name: Pre Audit | Set Fact for audit summary - name: Pre Audit | Set Fact for audit summary

View file

@ -37,7 +37,7 @@ rhel9cis_legacy_boot: {{ rhel9cis_legacy_boot }}
## Benchmark name used by auditing control role ## Benchmark name used by auditing control role
# The audit variable found at the base # The audit variable found at the base
## metadata for Audit benchmark ## metadata for Audit benchmark
benchmark_version: 'v2.0.0' benchmark_version: {{ benchmark_version }}
benchmark: RHEL9-CIS benchmark: RHEL9-CIS

View file

@ -10,12 +10,7 @@
{% endif %} {% endif %}
{% if rhel9cis_rule_6_3_3_2 %} {% if rhel9cis_rule_6_3_3_2 %}
{% set syscalls = ["execve"] %} {% set syscalls = ["execve"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{%- for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
{% endif %}
{% endfor -%}
-a always,exit -F arch=b64 -C euid!=uid -F auid!=unset -S {{ arch_syscalls|join(',') }} -k user_emulation -a always,exit -F arch=b64 -C euid!=uid -F auid!=unset -S {{ arch_syscalls|join(',') }} -k user_emulation
-a always,exit -F arch=b32 -C euid!=uid -F auid!=unset -S {{ arch_syscalls|join(',') }} -k user_emulation -a always,exit -F arch=b32 -C euid!=uid -F auid!=unset -S {{ arch_syscalls|join(',') }} -k user_emulation
{% endif %} {% endif %}
@ -24,33 +19,18 @@
{% endif %} {% endif %}
{% if rhel9cis_rule_6_3_3_4 %} {% if rhel9cis_rule_6_3_3_4 %}
{% set syscalls = ["adjtimex","settimeofday"] %} {% set syscalls = ["adjtimex","settimeofday"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -k time-change -a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -k time-change
-a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -k time-change -a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -k time-change
{% set syscalls = ["clock_settime"] %} {% set syscalls = ["clock_settime"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
-a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F a0=0x0 -k time-change -a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F a0=0x0 -k time-change
-a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F a0=0x0 -k time-change -a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F a0=0x0 -k time-change
{% endif %}
{% endfor %}
-w /etc/localtime -p wa -k time-change -w /etc/localtime -p wa -k time-change
{% endif %} {% endif %}
{% if rhel9cis_rule_6_3_3_5 %} {% if rhel9cis_rule_6_3_3_5 %}
{% set syscalls = ["sethostname","setdomainname"] %} {% set syscalls = ["sethostname","setdomainname"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -k system-locale -a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -k system-locale
-a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -k system-locale -a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -k system-locale
-w /etc/issue -p wa -k system-locale -w /etc/issue -p wa -k system-locale
@ -68,12 +48,7 @@
{% endif %} {% endif %}
{% if rhel9cis_rule_6_3_3_7 %} {% if rhel9cis_rule_6_3_3_7 %}
{% set syscalls = ["creat","open","openat","truncate","ftruncate"] %} {% set syscalls = ["creat","open","openat","truncate","ftruncate"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F exit=-EACCES -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k access -a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F exit=-EACCES -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k access
-a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F exit=-EPERM -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k access -a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F exit=-EPERM -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k access
-a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F exit=-EACCES -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k access -a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F exit=-EACCES -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k access
@ -91,62 +66,27 @@
{% endif %} {% endif %}
{% if rhel9cis_rule_6_3_3_9 %} {% if rhel9cis_rule_6_3_3_9 %}
{% set syscalls = ["chmod","fchmod","fchmodat"] %} {% set syscalls = ["chmod","fchmod","fchmodat"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod -a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod
{% set syscalls = ["chown","fchown","lchown","fchownat"] %} {% set syscalls = ["chown","fchown","lchown","fchownat"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod -a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod
{% set syscalls = ["setxattr","lsetxattr","fsetxattr","removexattr","lremovexattr","fremovexattr"] %} {% set syscalls = ["setxattr","lsetxattr","fsetxattr","removexattr","lremovexattr","fremovexattr"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod -a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod
{% set syscalls = ["chmod","fchmod","fchmodat"] %} {% set syscalls = ["chmod","fchmod","fchmodat"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod -a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod
{% set syscalls = ["chown","fchown","lchown","fchownat"] %} {% set syscalls = ["chown","fchown","lchown","fchownat"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod -a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod
{% set syscalls = ["setxattr","lsetxattr","fsetxattr","removexattr","lremovexattr","fremovexattr"] %} {% set syscalls = ["setxattr","lsetxattr","fsetxattr","removexattr","lremovexattr","fremovexattr"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod -a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k perm_mod
{% endif %} {% endif %}
{% if rhel9cis_rule_6_3_3_10 %} {% if rhel9cis_rule_6_3_3_10 %}
{% set syscalls = ["mount"] %} {% set syscalls = ["mount"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append(syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k mounts -a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k mounts
-a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k mounts -a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k mounts
{% endif %} {% endif %}
@ -161,12 +101,7 @@
{% endif %} {% endif %}
{% if rhel9cis_rule_6_3_3_13 %} {% if rhel9cis_rule_6_3_3_13 %}
{% set syscalls = ["unlink","unlinkat","rename","renameat"] %} {% set syscalls = ["unlink","unlinkat","rename","renameat"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append( syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k delete -a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k delete
-a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k delete -a always,exit -F arch=b32 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k delete
{% endif %} {% endif %}
@ -189,12 +124,7 @@
{% if rhel9cis_rule_6_3_3_19 %} {% if rhel9cis_rule_6_3_3_19 %}
-a always,exit -F path=/usr/bin/kmod -F perm=x -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k kernel_modules -a always,exit -F path=/usr/bin/kmod -F perm=x -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k kernel_modules
{% set syscalls = ["init_module","finit_module","delete_module","create_module","query_module"] %} {% set syscalls = ["init_module","finit_module","delete_module","create_module","query_module"] %}
{% set arch_syscalls = [] %} {% set arch_syscalls = syscalls | select("in", supported_syscalls) | list %}
{% for syscall in syscalls %}
{% if syscall in supported_syscalls %}
{{ arch_syscalls.append( syscall) }}
{% endif %}
{% endfor %}
-a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k kernel_modules -a always,exit -F arch=b64 -S {{ arch_syscalls|join(',') }} -F auid>={{ prelim_min_int_uid }} -F auid!=unset -k kernel_modules
{% endif %} {% endif %}
{% if rhel9cis_rule_6_3_3_20 %} {% if rhel9cis_rule_6_3_3_20 %}