Skip to content

Commit 8b5abb7

Browse files
authored
Merge pull request #136 from ansible-lockdown/Oct_issues
Oct issues
2 parents f062cac + bbe3d99 commit 8b5abb7

14 files changed

Lines changed: 112 additions & 96 deletions

File tree

.ansible-lint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ skip_list:
66
- 'no-changed-when'
77
- 'var-spacing'
88
- 'fqcn-builtins'
9+
- 'experimental'
10+
- 'name[casing]'
11+
- 'name[template]'
912
- '204'
1013
- '305'
1114
- '303'

.github/workflows/linux_benchmark_testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727

2828
steps:
29-
- uses: actions/first-interaction@v1.1.0
29+
- uses: actions/first-interaction@main
3030
with:
3131
repo-token: ${{ secrets.GITHUB_TOKEN }}
3232
pr-message: |-

.yamllint

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@ rules:
1414
spaces: 4
1515
# Requiring consistent indentation within a file, either indented or not
1616
indent-sequences: consistent
17-
truthy: disable
17+
level: error
1818
braces:
1919
max-spaces-inside: 1
2020
level: error
2121
brackets:
2222
max-spaces-inside: 1
2323
level: error
24-
indentation:
25-
indent-sequences: consistent
26-
level: error
2724
line-length: disable
2825
key-duplicates: enable
2926
new-line-at-end-of-file: enable

defaults/main.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ rhel8stig_tftp_required: false
579579
# RHEL-08-010140 and RHEL-08-020280
580580
# Password protect the boot loader
581581
rhel8stig_bootloader_password_hash: grub.pbkdf2.sha512.changethispassword
582-
rhel8stig_boot_superuser: root
582+
rhel8stig_boot_superuser: bootloader_admin
583583

584584
# AIDE settings
585585
# Set to false for fire and forget mode
@@ -782,10 +782,6 @@ rhel8stig_auditd_failure_flag: "{{ rhel8stig_availability_override | ternary(1,
782782
# REHL-08-010020
783783
rhel8stig_boot_part: "{{ rhel_08_boot_part.stdout }}"
784784

785-
#
786-
rhel8stig_machine_uses_uefi: "{{ rhel_08_sys_firmware_efi.stat.exists }}"
787-
rhel8stig_grub_cfg_path: "{{ rhel8stig_machine_uses_uefi | ternary('/boot/efi/EFI/' ~ (ansible_distribution | lower) ~ '/grub.cfg', '/boot/grub2/grub.cfg') }}"
788-
rhel8stig_grub_cfg_path_invalid: "{{ (not rhel8stig_machine_uses_uefi) | ternary('/boot/efi/EFI/' ~ (ansible_distribution | lower) ~ '/grub.cfg', '/boot/grub2/grub.cfg') }}"
789785

790786
# RHEL-08-010740/RHEL-08-010750
791787
rhel8stig_passwd_label: "{{ (this_item | default(item)).id }}: {{ (this_item | default(item)).dir }}"

handlers/main.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@
5757

5858
- name: confirm grub2 user cfg
5959
stat:
60-
path: "{{ rhel8stig_grub_cfg_path | dirname }}/user.cfg"
60+
path: "/etc/grub.d/01_users"
6161
changed_when: rhel8stig_grub2_user_cfg.stat.exists
6262
register: rhel8stig_grub2_user_cfg
6363
notify: make grub2 config
6464

6565
- name: make grub2 config
66-
command: /usr/sbin/grub2-mkconfig --output={{ rhel8stig_grub_cfg_path }}
66+
command: /usr/sbin/grub2-mkconfig --output={{ rhel8stig_bootloader_path }}/grub.cfg
6767
when:
6868
- rhel8stig_grub2_user_cfg.stat.exists
6969
- not rhel8stig_skip_for_travis
@@ -72,15 +72,12 @@
7272
- name: copy grub2 config to BIOS/UEFI to satisfy benchmark
7373
listen: make grub2 config
7474
copy:
75-
src: "{{ rhel8stig_grub_cfg_path | dirname }}/{{ item }}"
76-
dest: "{{ rhel8stig_grub_cfg_path_invalid | dirname }}/{{ item }}"
75+
src: "{{ rhel8stig_bootloader_path }}/grub.cfg"
76+
dest: "{{ rhel8stig_bootloader_path }}/grub.cfg"
7777
remote_src: true
7878
owner: root
7979
group: root
8080
mode: 0755
81-
with_items:
82-
- grub.cfg
83-
- user.cfg
8481
when:
8582
- rhel8stig_grub2_user_cfg.stat.exists
8683
- rhel8stig_workaround_for_disa_benchmark

meta/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ galaxy_info:
44
description: "Apply the DISA RHEL 8 STIG"
55
company: "MindPoint Group"
66
license: MIT
7-
# role_name: rhel8_stig
7+
role_name: rhel8_stig
8+
namespace: mindpointgroup
89
min_ansible_version: '2.9.0'
910
platforms:
1011
- name: EL
@@ -21,6 +22,7 @@ galaxy_info:
2122
- complianceascode
2223
- disa
2324
- rhel8
25+
- mindpoint
2426
collections:
2527
- community.general
2628
- community.crypto

site.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- hosts: all
2+
- hosts: all # noqa: name[play]
33
become: true
44

55
roles:

tasks/fix-cat1.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
block:
1919
- name: "HIGH | RHEL-08-010020 | PATCH | The Red Hat Enterprise Linux operating system must implement NIST FIPS-validated cryptography for the following: to provision digital signatures, to generate cryptographic hashes, and to protect data requiring data-at-rest protections in accordance with applicable federal laws, Executive Orders, directives, policies, regulations, and standards. | install FIPS"
2020
package:
21-
name: dracut-fips
21+
name:
22+
- dracut-fips
23+
- crypto-policies-scripts
2224
state: present
2325
notify:
2426
- rebuild initramfs
@@ -182,7 +184,7 @@
182184
"HIGH | RHEL-08-010140 | PATCH | RHEL 8 operating systems booted with United Extensible Firmware Interface (UEFI) implemented must require authentication upon booting into single-user mode and maintenance. | Set Grub Password"
183185
"HIGH | RHEL-08-010150 | PATCH | RHEL 8 operating systems booted with a BIOS must require authentication upon booting into single-user and maintenance modes. | Set Grub Password"
184186
lineinfile:
185-
path: "{{ rhel8stig_grub_cfg_path | dirname }}/user.cfg"
187+
path: "{{ rhel8stig_bootloader_path }}/user.cfg"
186188
create: true
187189
regexp: ^GRUB2_PASSWORD=
188190
line: "GRUB2_PASSWORD={{ rhel8stig_bootloader_password_hash }}"

tasks/fix-cat2.yml

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
- name: |
8686
"MEDIUM | RHEL-08-010040 | PATCH | RHEL 8 must display the Standard Mandatory DoD Notice and Consent Banner before granting local or remote access to the system via a ssh logon. | Set banner message""
8787
"MEDIUM | RHEL-08-010060 | PATCH | RHEL 8 must display the Standard Mandatory DoD Notice and Consent Banner before granting local or remote access to the system via a command line user logon. | Set banner message""
88-
copy:
88+
copy: # noqa: template-instead-of-copy
8989
dest: "{{ item }}"
9090
content: "{{ rhel8stig_logon_banner }}"
9191
owner: root
@@ -133,11 +133,12 @@
133133
- banner
134134

135135
- name: "MEDIUM | RHEL-08-010050 | PATCH | RHEL 8 must display the Standard Mandatory DoD Notice and Consent Banner before granting local or remote access to the system via a graphical user logon."
136-
copy:
136+
copy: # noqa: template-instead-of-copy
137137
dest: /etc/dconf/db/local.d/01-banner-message
138138
content: |
139139
[org/gnome/login-screen]
140140
banner-message-text='{{ rhel8stig_logon_banner | replace(newline, "\n") }}'
141+
banner-message-enable=true
141142
mode: '0644'
142143
owner: root
143144
group: root
@@ -293,18 +294,13 @@
293294
- name: |
294295
"MEDIUM | RHEL-08-010141 | PATCH | RHEL 8 operating systems booted with United Extensible Firmware Interface (UEFI) must require a unique superusers name upon booting into single-user mode and maintenance."
295296
"MEDIUM | RHEL-08-010149 | PATCH | RHEL 8 operating systems booted with a BIOS must require a unique superusers name upon booting into single-user and maintenance modes."
296-
lineinfile:
297-
dest: "{{ rhel8stig_grub_cfg_path | dirname }}/grub.cfg"
298-
regexp: "{{ item.regexp }}"
299-
line: "{{ item.line }}"
300-
insertafter: "{{ item.insertafter }}"
297+
template:
298+
src: 01_users.j2
299+
dest: /etc/grub.d/01_users
300+
owner: root
301+
group: root
302+
mode: 0644
301303
notify: confirm grub2 user cfg
302-
with_items:
303-
- { regexp: '^set superusers', line: 'set superusers="{{ rhel8stig_boot_superuser }}"', insertafter: '### BEGIN /etc/grub.d/01_users ###' }
304-
- { regexp: '^export superusers', line: 'export superusers', insertafter: '^set superusers' }
305-
- { regexp: '^password_pbkdf2', line: 'password_pbkdf2 {{ rhel8stig_boot_superuser }} ${GRUB2_PASSWORD}', insertafter: '^export superusers' }
306-
loop_control:
307-
label: "{{ item.line }}"
308304
when:
309305
- rhel_08_010141 or
310306
rhel_08_010149
@@ -772,33 +768,13 @@
772768
- ssh
773769

774770
- name: |
775-
"MEDIUM | RHEL-08-010290 | PATCH | The RHEL 8 SSH daemon must be configured to use only Message Authentication Codes (MACs) employing FIPS 140-2 validated cryptographic hash algorithms."
776-
"MEDIUM | RHEL-08-010291 | PATCH | The RHEL 8 operating system must implement DoD-approved encryption to protect the confidentiality of SSH connections."
777-
block:
778-
- name: |
779-
"MEDIUM | RHEL-08-010290 | AUDIT | The RHEL 8 SSH daemon must be configured to use only Message Authentication Codes (MACs) employing FIPS 140-2 validated cryptographic hash algorithms. | Get current FIPS mode state"
780-
"MEDIUM | RHEL-08-010291 | AUDIT | The RHEL 8 operating system must implement DoD-approved encryption to protect the confidentiality of SSH connections. | Get current FIPS mode state"
781-
command: fips-mode-setup --check
782-
changed_when: false
783-
failed_when: rhel_08_010290_pre_fips_check.stdout is not defined
784-
register: rhel_08_010290_pre_fips_check
785-
786-
- name: |
787-
"MEDIUM | RHEL-08-010290 | PATCH | The RHEL 8 SSH daemon must be configured to use only Message Authentication Codes (MACs) employing FIPS 140-2 validated cryptographic hash algorithms. | Enable FIPS"
788-
"MEDIUM | RHEL-08-010291 | PATCH | The RHEL 8 operating system must implement DoD-approved encryption to protect the confidentiality of SSH connections. | Enable FIPS"
789-
command: fips-mode-setup --enable
790-
register: rhel_08_010290_fips_enable
791-
notify: change_requires_reboot
792-
when: '"disabled" in rhel_08_010290_pre_fips_check.stdout'
793-
794-
- name: |
795-
"MEDIUM | RHEL-08-010290 | PATCH | The RHEL 8 SSH daemon must be configured to use only Message Authentication Codes (MACs) employing FIPS 140-2 validated cryptographic hash algorithms. | Add ssh ciphers"
796-
"MEDIUM | RHEL-08-010291 | PATCH | The RHEL 8 operating system must implement DoD-approved encryption to protect the confidentiality of SSH connections. | Add ssh ciphers"
797-
lineinfile:
798-
path: /etc/crypto-policies/back-ends/opensshserver.config
799-
regexp: '^CRYPTO_POLICY='
800-
line: CRYPTO_POLICY='{{ rhel8stig_ssh_server_crypto_settings }}'
801-
notify: change_requires_reboot
771+
"MEDIUM | RHEL-08-010290 | PATCH | The RHEL 8 SSH daemon must be configured to use only Message Authentication Codes (MACs) employing FIPS 140-2 validated cryptographic hash algorithms. | Add ssh ciphers"
772+
"MEDIUM | RHEL-08-010291 | PATCH | The RHEL 8 operating system must implement DoD-approved encryption to protect the confidentiality of SSH connections. | Add ssh ciphers"
773+
lineinfile:
774+
path: /etc/crypto-policies/back-ends/opensshserver.config
775+
regexp: '^CRYPTO_POLICY='
776+
line: CRYPTO_POLICY='{{ rhel8stig_ssh_server_crypto_settings }}'
777+
notify: change_requires_reboot
802778
when:
803779
- rhel_08_010290 or
804780
rhel_08_010291
@@ -872,7 +848,7 @@
872848
- name: "MEDIUM | RHEL-08-010295 | PATCH | The RHEL 8 operating system must implement DoD-approved TLS encryption in the GnuTLS package"
873849
lineinfile:
874850
path: /etc/crypto-policies/back-ends/gnutls.config
875-
regexp: '^(.*\+VERS-ALL:)'
851+
regexp: '^(.*)\+VERS-ALL:'
876852
line: '\1{{ rhel8stig_gnutls_encryption }}'
877853
backrefs: true
878854
create: true
@@ -2484,6 +2460,7 @@
24842460
when:
24852461
- rhel_08_010740
24862462
- (item.uid >= rhel8stig_interactive_uid_start | int)
2463+
- (item.uid >= rhel8stig_interactive_uid_stop | int)
24872464
tags:
24882465
- skip_ansible_lint
24892466
- RHEL-08-010740
@@ -2557,8 +2534,7 @@
25572534
file:
25582535
path: "{{ item }}"
25592536
mode: "{{ rhel8stig_local_int_perm }}"
2560-
with_items:
2561-
- "{{ rhel_08_stig_interactive_homedir_inifiles }}"
2537+
with_items: "{{ rhel_08_stig_interactive_homedir_inifiles }}"
25622538
when:
25632539
- rhel_08_010770
25642540
- rhel8stig_disruption_high
@@ -3123,7 +3099,6 @@
31233099
setype: faillog_t
31243100
state: present
31253101
register: add_faillock_secontext
3126-
when: faillock_dir.changed
31273102
31283103
- name: |
31293104
"MEDIUM | RHEL-08-020027 | RHEL 8 systems, versions 8.2 and above, must configure SELinux context type to allow the use of a non-default faillock tally directory.
@@ -3220,7 +3195,7 @@
32203195
- name: "MEDIUM | RHEL-08-020040 | PATCH | RHEL 8 must enable a user session lock until that user re-establishes access using established identification and authentication procedures for command line sessions. | Configure tmux"
32213196
lineinfile:
32223197
path: /etc/tmux.conf
3223-
regexp: '^set \-g'
3198+
regexp: '^set -g lock-command'
32243199
line: "set -g lock-command vlock"
32253200
create: true
32263201
owner: root
@@ -5938,6 +5913,28 @@
59385913
with_items:
59395914
- "{{ rhel8stig_white_list_services }}"
59405915

5916+
- name: "MEDIUM | RHEL-08-040090 | PATCH | A RHEL 8 firewall must employ a deny-all, allow-by-exception policy for allowing connections to other systems. | Target Drop | 2.10+"
5917+
firewalld:
5918+
zone: "{{ rhel8stig_custom_firewall_zone }}"
5919+
permanent: true
5920+
state: enabled
5921+
target: DROP
5922+
when: ansible_version.full is version_compare('2.10.0 | int', '>=')
5923+
5924+
- name: "MEDIUM | RHEL-08-040090 | PATCH | A RHEL 8 firewall must employ a deny-all, allow-by-exception policy for allowing connections to other systems. | Target Drop | 2.9"
5925+
block:
5926+
- name: "MEDIUM | RHEL-08-040090 | PATCH | A RHEL 8 firewall must employ a deny-all, allow-by-exception policy for allowing connections to other systems. | current setting"
5927+
shell: "firewall-cmd --list-all --zone={{ rhel8stig_custom_firewall_zone }} | grep 'target: DROP'"
5928+
changed_when: false
5929+
failed_when: false
5930+
register: rhel8stig-target_drop_set
5931+
5932+
- name: "MEDIUM | RHEL-08-040090 | PATCH | A RHEL 8 firewall must employ a deny-all, allow-by-exception policy for allowing connections to other systems. | Target Drop | 2.9"
5933+
shell: firewall-cmd --permanent --zone={{ rhel8stig_custom_firewall_zone }} --set-target=DROP
5934+
when:
5935+
- rhel8stig-target_drop_set.rc != 0
5936+
when: ansible_version.full is version_compare('2.10 | int', '<')
5937+
59415938
- name: "MEDIUM | RHEL-08-040090 | PATCH | A RHEL 8 firewall must employ a deny-all, allow-by-exception policy for allowing connections to other systems. | Reload zones"
59425939
command: firewall-cmd --reload
59435940
changed_when: rhel_08_040090_zone_reload.rc == 0

tasks/main.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,25 @@
4848
tags:
4949
- user_passwd
5050

51+
- name: "Ensure superuser for grub does not match existing user"
52+
block:
53+
- name: "Ensure superuser for grub does not match existing user | capture users"
54+
shell: cat /etc/passwd | cut -d':' -f1
55+
changed_when: false
56+
failed_when: false
57+
check_mode: false
58+
register: rhel8stig_user_list
59+
60+
- name: "Ensure superuser for grub does not match existing user"
61+
assert:
62+
that: rhel8stig_boot_superuser not in rhel8stig_user_list.stdout_lines
63+
fail_msg: "A unique name must be used for bootloader access user='{{ rhel8stig_boot_superuser }}' already exists refer to variable rhel8stig_boot_superuser"
64+
when:
65+
- rhel_08_010141 or
66+
rhel_08_010149
67+
tags:
68+
- RHEL-08-010141
69+
- RHEL-08-010149
5170

5271
- name: Setup rules if container
5372
block:

0 commit comments

Comments
 (0)