Skip to content

Commit c699736

Browse files
committed
Use motd_banner_contents variable in rule banner_etc_motd
Use motd_banner_contents variable in remediations in rule banner_etc_motd.
1 parent 36fd647 commit c699736

18 files changed

Lines changed: 35 additions & 31 deletions

File tree

controls/ccn_ol9.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ controls:
627627
- login_banner_text=cis_default
628628
- login_banner_contents=cis_default
629629
- motd_banner_text=cis_default
630+
- motd_banner_contents=cis_default
630631
- remote_login_banner_text=cis_default
631632

632633
- id: A.11.SEC-OL5

controls/cis_al2023.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ controls:
468468
rules:
469469
- banner_etc_motd
470470
- motd_banner_text=cis_banners
471+
- motd_banner_contents=cis_default
471472

472473
- id: 1.7.2
473474
title: Ensure local login warning banner is configured properly (Automated)

controls/cis_sle12.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ controls:
457457
rules:
458458
- banner_etc_motd
459459
- motd_banner_text=cis_banners
460+
- motd_banner_contents=cis_default
460461

461462
- id: 1.8.1.2
462463
title: Ensure local login warning banner is configured properly (Automated)

controls/cis_sle15.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ controls:
455455
rules:
456456
- banner_etc_motd
457457
- motd_banner_text=cis_banners
458+
- motd_banner_contents=cis_default
458459

459460
- id: 1.8.1.2
460461
title: Ensure local login warning banner is configured properly (Automated)

controls/general_sle15.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ controls:
470470
rules:
471471
- banner_etc_motd
472472
- motd_banner_text=cis_banners
473+
- motd_banner_contents=cis_default
473474

474475
- id: SLES-15-151050030
475476
title: Modify the System Login Banner

controls/general_slmicro5.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ controls:
269269
rules:
270270
- banner_etc_motd
271271
- motd_banner_text=cis_banners
272+
- motd_banner_contents=cis_default
272273

273274
- id: SLEM-5-SET-08010200
274275
title: Modify the System Login Banner

controls/std_kylinserver10.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ controls:
128128
status: automated
129129
rules:
130130
- banner_etc_motd
131-
- login_banner_text=cis_banners
131+
- motd_banner_text=cis_banners
132+
- motd_banner_contents=cis_default
132133

133134
- id: 1.15
134135
title: Ensure sshd PermitRootLogin is disabled (Automated)

controls/std_tencentos4.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ controls:
114114
rules:
115115
- banner_etc_motd
116116
- motd_banner_text=cis_banners
117+
- motd_banner_contents=cis_default
117118

118119
- id: 1.4.2
119120
title: Ensure local login warning banner is configured properly

linux_os/guide/system/accounts/accounts-banners/banner_etc_motd/ansible/shared.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# strategy = unknown
44
# complexity = low
55
# disruption = medium
6-
{{{ ansible_instantiate_variables("motd_banner_text") }}}
6+
{{{ ansible_instantiate_variables("motd_banner_contents") }}}
77

88
- name: "{{{ rule_title }}} - ensure correct banner"
99
ansible.builtin.copy:
1010
dest: /etc/motd
11-
content: '{{{ ansible_deregexify_banner_etc_issue("motd_banner_text") }}}'
11+
content: "{{ motd_banner_contents | replace('\\n', '\n') }}\n"
Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
1-
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_rhv,multi_platform_sle,multi_platform_slmicro,multi_platform_ubuntu,multi_platform_almalinux
1+
# platform = multi_platform_all
22

3-
{{{ bash_instantiate_variables("motd_banner_text") }}}
4-
5-
# Multiple regexes transform the banner regex into a usable banner
6-
# 0 - Remove anchors around the banner text
7-
{{{ bash_deregexify_banner_anchors("motd_banner_text") }}}
8-
# 1 - Keep only the first banners if there are multiple
9-
# (dod_banners contains the long and short banner)
10-
{{{ bash_deregexify_multiple_banners("motd_banner_text") }}}
11-
# 2 - Add spaces ' '. (Transforms regex for "space or newline" into a " ")
12-
{{{ bash_deregexify_banner_space("motd_banner_text") }}}
13-
# 3 - Adds newlines. (Transforms "(?:\[\\n\]+|(?:\\n)+)" into "\n")
14-
{{{ bash_deregexify_banner_newline("motd_banner_text", "\\n") }}}
15-
# 4 - Remove any leftover backslash. (From any parenthesis in the banner, for example).
16-
{{{ bash_deregexify_banner_backslash("motd_banner_text") }}}
17-
formatted=$(echo "$motd_banner_text" | fold -sw 80)
18-
19-
cat <<EOF >/etc/motd
20-
$formatted
21-
EOF
3+
motd_banner_contents=$(echo "(bash-populate motd_banner_contents)" | sed 's/\\n/\n/g')
4+
echo "$motd_banner_contents" > /etc/motd

0 commit comments

Comments
 (0)