Skip to content

Commit 3cda908

Browse files
Simplify SLE16 handling in SSH rules
- sle16 OVAL is removed and test for checking main config file exist is added - tests checking /usr/etc/ssh stuff are removed and tests use sshd_main_config_file and sshd_config_dir
1 parent 8794c72 commit 3cda908

94 files changed

Lines changed: 239 additions & 1360 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

linux_os/guide/services/ssh/ssh_server/sshd_limit_user_access/oval/shared.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,31 @@
66
<def-group>
77
<definition class="compliance" id="{{{ rule_id }}}" version="1">
88
{{{ oval_metadata("One of the following parameters of the sshd configuration file is set: AllowUsers, DenyUsers, AllowGroups, DenyGroups.", rule_title=rule_title) }}}
9+
{{% if product in [ 'sle16', 'slmicro6' ] %}}
10+
<criteria operator="AND">
11+
<criterion comment="test if SSH main configuration {{{ sshd_main_config }}} exists for {{{ rule_id }}}"
12+
test_ref="test_{{{ rule_id }}}_config_file_exists"/>
13+
<criteria operator="OR">
14+
<criterion test_ref="test_allow_user_is_configured" />
15+
<criterion test_ref="test_allow_group_is_configured" />
16+
<criterion test_ref="test_deny_user_is_configured" />
17+
<criterion test_ref="test_deny_group_is_configured" />
18+
</criteria>
19+
</criteria>
20+
{{% else %}}
921
<criteria operator="OR">
1022
<criterion test_ref="test_allow_user_is_configured" />
1123
<criterion test_ref="test_allow_group_is_configured" />
1224
<criterion test_ref="test_deny_user_is_configured" />
1325
<criterion test_ref="test_deny_group_is_configured" />
1426
</criteria>
27+
{{% endif %}}
1528
</definition>
1629

30+
{{% if product in [ 'sle16', 'slmicro6' ] %}}
31+
{{{ oval_config_file_exists_test(sshd_main_config, rule_id=rule_id) }}}
32+
{{{ oval_config_file_exists_object(sshd_main_config, rule_id=rule_id) }}}
33+
{{% endif %}}
1734
<ind:textfilecontent54_test id="test_allow_user_is_configured" version="1" check="all"
1835
check_existence="only_one_exists" comment="Check if there is an AllowUsers entry">
1936
<ind:object object_ref="obj_allow_user" />

linux_os/guide/services/ssh/ssh_server/sshd_limit_user_access/oval/sle16.xml

Lines changed: 0 additions & 100 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

33
source common.sh
4-
echo "AllowGroups testgroup1 testgroup2 testgroup3" >> /etc/ssh/sshd_config
4+
echo "AllowGroups testgroup1 testgroup2 testgroup3" >> "{{{ sshd_main_config_file }}}"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
22
# platform = SUSE Linux Enterprise 16
33
source common.sh
4-
echo "AllowGroups group" >> /etc/ssh/sshd_config.d/01-complianceascode-reinforce-os-defaults.conf
4+
touch "{{{ sshd_main_config_file }}}"
5+
echo "AllowGroups group" >> "{{{ sshd_config_dir }}}/01-complianceascode-reinforce-os-defaults.conf"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# remediation = none
3+
# platform = SUSE Linux Enterprise 16
4+
source common.sh
5+
echo "AllowGroups group" >> "{{{ sshd_config_dir }}}/01-complianceascode-reinforce-os-defaults.conf"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

33
source common.sh
4-
echo "AllowUsers testuser1 testuser2 testuser3" >> /etc/ssh/sshd_config
4+
echo "AllowUsers testuser1 testuser2 testuser3" >> "{{{ sshd_main_config_file }}}"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22

33
source common.sh
4-
echo "AllowUsers testuser1 testuser2 testuser3" >> /etc/ssh/sshd_config
5-
echo "AllowGroups testgroup1 testgroup2 testgroup3" >> /etc/ssh/sshd_config
4+
echo "AllowUsers testuser1 testuser2 testuser3" >> "{{{ sshd_main_config_file }}}"
5+
echo "AllowGroups testgroup1 testgroup2 testgroup3" >> "{{{ sshd_main_config_file }}}"

linux_os/guide/services/ssh/ssh_server/sshd_limit_user_access/tests/allow_users_usr_etc_ssh_sshd_config.pass.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/bin/bash
22

3-
declare -a SSHD_PATHS=("/etc/ssh/sshd_config")
4-
{{% if product == 'sle16' %}}
5-
SSHD_PATHS+=("/usr/etc/ssh/sshd_config" /usr/etc/ssh/sshd_config.d/* /etc/ssh/sshd_config.d/*)
3+
declare -a SSHD_PATHS=("{{{ sshd_main_config_file }}}")
4+
{{% if product in [ 'sle16', 'slmicro6' ] %}}
5+
SSHD_PATHS+=("{{{ sshd_config_dir }}}/*")
66
{{% endif %}}
77
# clean up configurations
88
sed -i '/^(Allow|Deny)(Users|Groups).*/d' "${SSHD_PATHS[@]}"
99

10-
# restore to defaults for sle16
11-
{{% if product == 'sle16' %}}
12-
if [ -e "/etc/ssh/sshd_config" ] ; then
13-
rm /etc/ssh/sshd_config
10+
# restore to defaults for sle16 and slmicro6
11+
{{% if product in [ 'sle16', 'slmicro6' ] %}}
12+
if [ -e "{{{ sshd_main_config_file }}}" ] ; then
13+
rm "{{{ sshd_main_config_file }}}"
1414
fi
1515
{{% endif %}}

linux_os/guide/services/ssh/ssh_server/sshd_limit_user_access/tests/deny_group_in_usr_etc_missing.fail.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# platform = SUSE Linux Enterprise 16
44
source common.sh
55

6-
touch /etc/ssh/sshd_config
6+
touch "{{{ sshd_main_config_file }}}"
77
echo "DenyGroups testgroup" >> /usr/etc/ssh/sshd_config

0 commit comments

Comments
 (0)