forked from ansible-lockdown/RHEL9-CIS
replaced command with shell
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
parent
ac42f8a28f
commit
3b19db6812
19 changed files with 75 additions and 75 deletions
|
|
@ -45,7 +45,7 @@
|
|||
- rule_3_4_2_3
|
||||
|
||||
- name: "3.4.2.4 | L1 | PATCH | Ensure default zone is set"
|
||||
command: firewall-cmd --set-default-zone="{{ rhel9cis_default_zone }}"
|
||||
shell: firewall-cmd --set-default-zone="{{ rhel9cis_default_zone }}"
|
||||
when:
|
||||
- rhel9cis_firewall == "firewalld"
|
||||
- rhel9cis_rule_3_4_2_4
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
|
||||
- name: "3.4.3.1 | L1 | PATCH | Ensure iptables are flushed with nftables"
|
||||
command: ip6tables -F
|
||||
shell: ip6tables -F
|
||||
when:
|
||||
- rhel9cis_rule_3_4_3_1
|
||||
- rhel9cis_firewall != "iptables"
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
- name: "3.4.3.2 | L1 | AUDIT | Ensure an nftables table exists"
|
||||
block:
|
||||
- name: "3.4.3.2 | L1 | AUDIT | Ensure a table exists | Check for tables"
|
||||
command: nft list tables
|
||||
shell: nft list tables
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: rhel9cis_3_4_3_2_nft_tables
|
||||
|
|
@ -31,13 +31,13 @@
|
|||
debug:
|
||||
msg:
|
||||
- "Warning! You currently have no nft tables, please review your setup"
|
||||
- 'Use the command "nft create table inet <table name>" to create a new table'
|
||||
- 'Use the shell "nft create table inet <table name>" to create a new table'
|
||||
when:
|
||||
- rhel9cis_3_4_3_2_nft_tables.stdout | length == 0
|
||||
- not rhel9cis_nft_tables_autonewtable
|
||||
|
||||
- name: "3.4.3.2 | L1 | PATCH | Ensure a table exists | Create table if needed"
|
||||
command: nft create table inet "{{ rhel9cis_nft_tables_tablename }}"
|
||||
shell: nft create table inet "{{ rhel9cis_nft_tables_tablename }}"
|
||||
failed_when: no
|
||||
when: rhel9cis_nft_tables_autonewtable
|
||||
when:
|
||||
|
|
@ -120,15 +120,15 @@
|
|||
register: rhel9cis_3_4_3_4_ip6saddr
|
||||
|
||||
- name: "3.4.3.4 | L1 | PATCH | Ensure nftables loopback traffic is configured | Set iif lo accept rule"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input iif lo accept
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input iif lo accept
|
||||
when: '"iif \"lo\" accept" not in rhel9cis_3_4_3_4_iiflo.stdout'
|
||||
|
||||
- name: "3.4.3.4 | L1 | PATCH | Ensure nftables loopback traffic is configured | Set ip sddr rule"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip saddr 127.0.0.0/8 counter drop
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip saddr 127.0.0.0/8 counter drop
|
||||
when: '"ip saddr 127.0.0.0/8 counter packets 0 bytes 0 drop" not in rhel9cis_3_4_3_4_ipsaddr.stdout'
|
||||
|
||||
- name: "3.4.3.4 | L1 | PATCH | Ensure nftables loopback traffic is configured | Set ip6 saddr rule"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip6 saddr ::1 counter drop
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip6 saddr ::1 counter drop
|
||||
when: '"ip6 saddr ::1 counter packets 0 bytes 0 drop" not in rhel9cis_3_4_3_4_ip6saddr.stdout'
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
|
|
@ -154,27 +154,27 @@
|
|||
register: rhel9cis_3_4_3_5_outconnectionrule
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add input tcp established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol tcp ct state established accept
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol tcp ct state established accept
|
||||
when: '"ip protocol tcp ct state established accept" not in rhel9cis_3_4_3_5_inconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add input udp established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol udp ct state established accept
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol udp ct state established accept
|
||||
when: '"ip protocol udp ct state established accept" not in rhel9cis_3_4_3_5_inconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add input icmp established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol icmp ct state established accept
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input ip protocol icmp ct state established accept
|
||||
when: '"ip protocol icmp ct state established accept" not in rhel9cis_3_4_3_5_inconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add output tcp new, related, established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol tcp ct state new,related,established accept
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol tcp ct state new,related,established accept
|
||||
when: '"ip protocol tcp ct state established,related,new accept" not in rhel9cis_3_4_3_5_outconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add output udp new, related, established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol udp ct state new,related,established accept
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol udp ct state new,related,established accept
|
||||
when: '"ip protocol udp ct state established,related,new accept" not in rhel9cis_3_4_3_5_outconnectionrule.stdout'
|
||||
|
||||
- name: "3.4.3.5 | L1 | PATCH | Ensure nftables outbound and established connections are configured | Add output icmp new, related, established accept policy"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol icmp ct state new,related,established accept
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" output ip protocol icmp ct state new,related,established accept
|
||||
when: '"ip protocol icmp ct state established,related,new accept" not in rhel9cis_3_4_3_5_outconnectionrule.stdout'
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
|
|
@ -212,19 +212,19 @@
|
|||
register: rhel9cis_3_4_3_6_sshallowcheck
|
||||
|
||||
- name: "3.4.3.6 | L1 | PATCH | Ensure nftables default deny firewall policy | Enable SSH traffic"
|
||||
command: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input tcp dport ssh accept
|
||||
shell: nft add rule inet "{{ rhel9cis_nft_tables_tablename }}" input tcp dport ssh accept
|
||||
when: '"tcp dport ssh accept" not in rhel9cis_3_4_3_6_sshallowcheck.stdout'
|
||||
|
||||
- name: "3.4.3.6 | L1 | PATCH | Ensure nftables default deny firewall policy | Set hook input deny policy"
|
||||
command: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" input { policy drop \; }
|
||||
shell: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" input { policy drop \; }
|
||||
when: '"type filter hook input priority 0; policy drop;" not in rhel9cis_3_4_3_6_inputpolicy.stdout'
|
||||
|
||||
- name: "3.4.3.6 | L1 | PATCH | Ensure nftables default deny firewall policy | Create hook forward deny policy"
|
||||
command: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" forward { policy drop \; }
|
||||
shell: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" forward { policy drop \; }
|
||||
when: '"type filter hook forward priority 0; policy drop;" not in rhel9cis_3_4_3_6_forwardpolicy.stdout'
|
||||
|
||||
- name: "3.4.3.6 | L1 | PATCH | Ensure nftables default deny firewall policy | Create hook output deny policy"
|
||||
command: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" output { policy drop \; }
|
||||
shell: nft chain inet "{{ rhel9cis_nft_tables_tablename }}" output { policy drop \; }
|
||||
when: '"type filter hook output priority 0; policy drop;" not in rhel9cis_3_4_3_6_outputpolicy.stdout'
|
||||
when:
|
||||
- rhel9cis_firewall == "nftables"
|
||||
|
|
|
|||
|
|
@ -3,23 +3,21 @@
|
|||
- name: "3.5 | L1 | PATCH | Ensure wireless interfaces are disabled"
|
||||
block:
|
||||
- name: "3.5 | L1 | AUDIT | Ensure wireless interfaces are disabled | Check if nmcli command is available"
|
||||
command: rpm -q NetworkManager
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
shell: rpm -q NetworkManager
|
||||
# changed_when: false
|
||||
# failed_when: false
|
||||
check_mode: no
|
||||
args:
|
||||
warn: no
|
||||
register: rhel_09_nmcli_available
|
||||
|
||||
- name: "3.5 | L1 | AUDIT | Ensure wireless interfaces are disabled | Check if wifi is enabled"
|
||||
command: nmcli radio wifi
|
||||
shell: nmcli radio wifi
|
||||
register: rhel_09_wifi_enabled
|
||||
changed_when: rhel_09_wifi_enabled.stdout != "disabled"
|
||||
failed_when: false
|
||||
when: rhel_09_nmcli_available.rc == 0
|
||||
|
||||
- name: "3.5 | L1 | PATCH | Ensure wireless interfaces are disabled | Disable wifi if enabled"
|
||||
command: nmcli radio all off
|
||||
shell: nmcli radio all off
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
when: rhel_09_wifi_enabled is changed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue