forked from ansible-lockdown/RHEL9-CIS
lint updates
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
parent
33340c7487
commit
1992eea6da
7 changed files with 45 additions and 40 deletions
|
|
@ -29,7 +29,7 @@
|
||||||
path: /etc/sysconfig/chronyd
|
path: /etc/sysconfig/chronyd
|
||||||
regexp: "^(#)?OPTIONS"
|
regexp: "^(#)?OPTIONS"
|
||||||
line: "OPTIONS=\"-u chrony\""
|
line: "OPTIONS=\"-u chrony\""
|
||||||
create: yes
|
create: true
|
||||||
mode: 0644
|
mode: 0644
|
||||||
when:
|
when:
|
||||||
- rhel9cis_rule_2_1_2
|
- rhel9cis_rule_2_1_2
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
shell: systemctl list-units --type=service
|
shell: systemctl list-units --type=service
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
check_mode: no
|
check_mode: false
|
||||||
register: rhel9cis_2_4_services
|
register: rhel9cis_2_4_services
|
||||||
|
|
||||||
- name: "2.4 | AUDIT | Ensure nonessential services are removed or masked | Display list of services"
|
- name: "2.4 | AUDIT | Ensure nonessential services are removed or masked | Display list of services"
|
||||||
|
|
@ -16,10 +16,10 @@
|
||||||
- "Please review to make sure all are essential"
|
- "Please review to make sure all are essential"
|
||||||
- "{{ rhel9cis_2_4_services.stdout_lines }}"
|
- "{{ rhel9cis_2_4_services.stdout_lines }}"
|
||||||
|
|
||||||
- name: "2.4 | AUDIT | Ensure nonessential services are removed or masked | Warn Count"
|
- name: "2.4 | AUDIT | Ensure nonessential services are removed or masked | Warn Count"
|
||||||
set_fact:
|
set_fact:
|
||||||
control_number: "{{ control_number }} + ['rule_2.4']"
|
control_number: "{{ control_number }} + ['rule_2.4']"
|
||||||
warn_count: "{{ warn_count|int + 1 }}"
|
warn_count: "{{ warn_count | int + 1 }}"
|
||||||
when:
|
when:
|
||||||
- rhel9cis_rule_2_4
|
- rhel9cis_rule_2_4
|
||||||
tags:
|
tags:
|
||||||
|
|
@ -28,4 +28,4 @@
|
||||||
- manual
|
- manual
|
||||||
- audit
|
- audit
|
||||||
- services
|
- services
|
||||||
- rule_2.4
|
- rule_2.4
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
flush_ipv6_route: true
|
flush_ipv6_route: true
|
||||||
|
|
||||||
- name: "3.1.1 | PATCH | Verify if IPv6 is enabled on the system"
|
- name: "3.1.1 | PATCH | Verify if IPv6 is enabled on the system"
|
||||||
debug:
|
debug:
|
||||||
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-disable_ipv6.conf"
|
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-disable_ipv6.conf"
|
||||||
when:
|
when:
|
||||||
- not rhel9cis_ipv6_required
|
- not rhel9cis_ipv6_required
|
||||||
|
|
@ -68,9 +68,9 @@
|
||||||
command: rpm -q NetworkManager
|
command: rpm -q NetworkManager
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
check_mode: no
|
check_mode: false
|
||||||
args:
|
args:
|
||||||
warn: no
|
warn: false
|
||||||
register: rhel_08_nmcli_available
|
register: rhel_08_nmcli_available
|
||||||
|
|
||||||
- name: "3.1.4 | AUDIT | Ensure wireless interfaces are disabled | Check if wifi is enabled"
|
- name: "3.1.4 | AUDIT | Ensure wireless interfaces are disabled | Check if wifi is enabled"
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,21 @@
|
||||||
set_fact:
|
set_fact:
|
||||||
sysctl_update: true
|
sysctl_update: true
|
||||||
flush_ipv4_route: true
|
flush_ipv4_route: true
|
||||||
|
|
||||||
- name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv4 forwarding"
|
- name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv4 forwarding"
|
||||||
debug:
|
debug:
|
||||||
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv4_sysctl.conf"
|
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv4_sysctl.conf"
|
||||||
- block:
|
|
||||||
- name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv6 forwarding | Set Fact"
|
|
||||||
set_fact:
|
|
||||||
flush_ipv6_route: true
|
|
||||||
|
|
||||||
- name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv6 forwarding"
|
- name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | IPv6"
|
||||||
debug:
|
block:
|
||||||
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv6_sysctl.conf"
|
- name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv6 forwarding | Set Fact"
|
||||||
|
set_fact:
|
||||||
|
flush_ipv6_route: true
|
||||||
|
|
||||||
|
- name: "3.2.1 | PATCH | Ensure IP forwarding is disabled | Disable IPv6 forwarding"
|
||||||
|
debug:
|
||||||
|
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv6_sysctl.conf"
|
||||||
|
|
||||||
when: rhel9cis_ipv6_required
|
when: rhel9cis_ipv6_required
|
||||||
when:
|
when:
|
||||||
- not rhel9cis_is_router
|
- not rhel9cis_is_router
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,15 @@
|
||||||
debug:
|
debug:
|
||||||
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv4_sysctl.conf"
|
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv4_sysctl.conf"
|
||||||
|
|
||||||
- block:
|
- name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv6"
|
||||||
- name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv6 | Set Fact"
|
block:
|
||||||
set_fact:
|
- name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv6 | Set Fact"
|
||||||
flush_ipv6_route: true
|
set_fact:
|
||||||
|
flush_ipv6_route: true
|
||||||
|
|
||||||
- name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv6"
|
- name: "3.3.1 | PATCH | Ensure source routed packets are not accepted | IPv6"
|
||||||
debug:
|
debug:
|
||||||
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv6_sysctl.conf"
|
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv6_sysctl.conf"
|
||||||
when: rhel9cis_ipv6_required
|
when: rhel9cis_ipv6_required
|
||||||
when:
|
when:
|
||||||
- rhel9cis_rule_3_3_1
|
- rhel9cis_rule_3_3_1
|
||||||
|
|
@ -39,14 +40,15 @@
|
||||||
debug:
|
debug:
|
||||||
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv4_sysctl.conf"
|
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv4_sysctl.conf"
|
||||||
|
|
||||||
- block:
|
- name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv6"
|
||||||
- name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv6 | Set Fact"
|
block:
|
||||||
set_fact:
|
- name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv6 | Set Fact"
|
||||||
flush_ipv6_route: true
|
set_fact:
|
||||||
|
flush_ipv6_route: true
|
||||||
|
|
||||||
- name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv6"
|
- name: "3.3.2 | PATCH | Ensure ICMP redirects are not accepted | IPv6"
|
||||||
debug:
|
debug:
|
||||||
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv6_sysctl.conf"
|
msg: "Control being set via Handler 'update sysctl' which writes to /etc/sysctl.d/60-netipv6_sysctl.conf"
|
||||||
when: rhel9cis_ipv6_required
|
when: rhel9cis_ipv6_required
|
||||||
when:
|
when:
|
||||||
- rhel9cis_rule_3_3_2
|
- rhel9cis_rule_3_3_2
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
systemd:
|
systemd:
|
||||||
name: nftables
|
name: nftables
|
||||||
state: stopped
|
state: stopped
|
||||||
masked: yes
|
masked: true
|
||||||
when:
|
when:
|
||||||
- rhel9cis_firewalld_nftables_state == "masked"
|
- rhel9cis_firewalld_nftables_state == "masked"
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
systemd:
|
systemd:
|
||||||
name: firewalld
|
name: firewalld
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: true
|
||||||
when:
|
when:
|
||||||
- rhel9cis_rule_3_4_1_4
|
- rhel9cis_rule_3_4_1_4
|
||||||
tags:
|
tags:
|
||||||
|
|
@ -90,7 +90,7 @@
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: ( firewalld_zone_set.rc not in [ 0, 1 ] )
|
failed_when: ( firewalld_zone_set.rc not in [ 0, 1 ] )
|
||||||
register: firewalld_zone_set
|
register: firewalld_zone_set
|
||||||
|
|
||||||
- name: "3.4.1.5 | AUDIT | Ensure firewalld default zone is set"
|
- name: "3.4.1.5 | AUDIT | Ensure firewalld default zone is set"
|
||||||
command: firewall-cmd --set-default-zone="{{ rhel9cis_default_zone }}"
|
command: firewall-cmd --set-default-zone="{{ rhel9cis_default_zone }}"
|
||||||
when:
|
when:
|
||||||
|
|
@ -112,7 +112,7 @@
|
||||||
shell: "nmcli -t connection show | awk -F: '{ if($4){print $4} }' | while read INT; do firewall-cmd --get-active-zones | grep -B1 $INT; done"
|
shell: "nmcli -t connection show | awk -F: '{ if($4){print $4} }' | while read INT; do firewall-cmd --get-active-zones | grep -B1 $INT; done"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
check_mode: no
|
check_mode: false
|
||||||
register: rhel9cis_3_4_1_6_interfacepolicy
|
register: rhel9cis_3_4_1_6_interfacepolicy
|
||||||
|
|
||||||
- name: "3.4.1.6 | AUDIT | Ensure network interfaces are assigned to appropriate zone | Get list of interfaces and polocies | Show the interface to policy"
|
- name: "3.4.1.6 | AUDIT | Ensure network interfaces are assigned to appropriate zone | Get list of interfaces and polocies | Show the interface to policy"
|
||||||
|
|
@ -135,7 +135,7 @@
|
||||||
shell: "firewall-cmd --get-active-zones | awk '!/:/ {print $1}' | while read ZN; do firewall-cmd --list-all --zone=$ZN; done"
|
shell: "firewall-cmd --get-active-zones | awk '!/:/ {print $1}' | while read ZN; do firewall-cmd --list-all --zone=$ZN; done"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
check_mode: no
|
check_mode: false
|
||||||
register: rhel9cis_3_4_1_7_servicesport
|
register: rhel9cis_3_4_1_7_servicesport
|
||||||
|
|
||||||
- name: "3.4.1.7 | AUDIT | Ensure firewalld drops unnecessary services and ports | Show services and ports"
|
- name: "3.4.1.7 | AUDIT | Ensure firewalld drops unnecessary services and ports | Show services and ports"
|
||||||
|
|
|
||||||
|
|
@ -105,14 +105,14 @@
|
||||||
- name: "3.4.2.5 | AUDIT | Ensure an nftables table exists | Alert on no tables | warning count"
|
- name: "3.4.2.5 | AUDIT | Ensure an nftables table exists | Alert on no tables | warning count"
|
||||||
set_fact:
|
set_fact:
|
||||||
control_number: "{{ control_number }} + [ 'rule_3.4.2.5' ]"
|
control_number: "{{ control_number }} + [ 'rule_3.4.2.5' ]"
|
||||||
warn_count: "{{ warn_count|int + 1 }}"
|
warn_count: "{{ warn_count | int + 1 }}"
|
||||||
when:
|
when:
|
||||||
- rhel9cis_3_4_2_5_nft_tables.stdout | length == 0
|
- rhel9cis_3_4_2_5_nft_tables.stdout | length == 0
|
||||||
- not rhel9cis_nft_tables_autonewtable
|
- not rhel9cis_nft_tables_autonewtable
|
||||||
|
|
||||||
- name: "3.4.2.5 | PATCH | Ensure a table exists | Create table if needed"
|
- name: "3.4.2.5 | PATCH | Ensure a table exists | Create table if needed"
|
||||||
command: nft create table inet "{{ rhel9cis_nft_tables_tablename }}"
|
command: nft create table inet "{{ rhel9cis_nft_tables_tablename }}"
|
||||||
failed_when: no
|
failed_when: false
|
||||||
when: rhel9cis_nft_tables_autonewtable
|
when: rhel9cis_nft_tables_autonewtable
|
||||||
when:
|
when:
|
||||||
- rhel9cis_firewall == "nftables"
|
- rhel9cis_firewall == "nftables"
|
||||||
|
|
@ -159,8 +159,8 @@
|
||||||
- name: "3.4.2.6 | PATCH | Ensure nftables base chains exist | Create chains if needed"
|
- name: "3.4.2.6 | PATCH | Ensure nftables base chains exist | Create chains if needed"
|
||||||
shell: "{{ item }}"
|
shell: "{{ item }}"
|
||||||
args:
|
args:
|
||||||
warn: no
|
warn: false
|
||||||
failed_when: no
|
failed_when: false
|
||||||
with_items:
|
with_items:
|
||||||
- nft create chain inet "{{ rhel9cis_nft_tables_tablename }}" input { type filter hook input priority 0 \; }
|
- nft create chain inet "{{ rhel9cis_nft_tables_tablename }}" input { type filter hook input priority 0 \; }
|
||||||
- nft create chain inet "{{ rhel9cis_nft_tables_tablename }}" forward { type filter hook forward priority 0 \; }
|
- nft create chain inet "{{ rhel9cis_nft_tables_tablename }}" forward { type filter hook forward priority 0 \; }
|
||||||
|
|
@ -322,7 +322,7 @@
|
||||||
- name: "3.4.2.10 | PATCH | Ensure nftables service is enabled"
|
- name: "3.4.2.10 | PATCH | Ensure nftables service is enabled"
|
||||||
service:
|
service:
|
||||||
name: nftables
|
name: nftables
|
||||||
enabled: yes
|
enabled: true
|
||||||
when:
|
when:
|
||||||
- rhel9cis_firewall == "nftables"
|
- rhel9cis_firewall == "nftables"
|
||||||
- rhel9cis_rule_3_4_2_10
|
- rhel9cis_rule_3_4_2_10
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue