Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,17 @@
# complexity = low
# disruption = low

{{% if product in [ 'sle16', 'slmicro6' ] %}}
{{{ ansible_copy_distro_defaults('/usr/etc/sudoers', '/etc/sudoers', rule_title=rule_title) }}}
{{{
ansible_lineinfile(
rule_title + " - Remove /usr/etc/sudoers.d include directive from /etc/sudoers",
path="/etc/sudoers",
regex='^\s*@includedir\s+/usr/etc/sudoers.d',
state="absent",
when="not ansible_check_mode"
)
}}}
{{% endif %}}

{{{ ansible_sudo_remove_config("!authenticate", "\!authenticate") }}}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
# complexity = low
# disruption = low

{{% if product in [ 'sle16', 'slmicro6' ] %}}
{{{ bash_copy_distro_defaults("/usr/etc/sudoers", "/etc/sudoers") }}}
{{{ lineinfile_absent("/etc/sudoers", "^\s*@includedir\s*/usr/etc/sudoers\.d", sed_path_separator="#", rule_id=rule_id) }}}
{{% endif %}}
{{{ bash_sudo_remove_config("!authenticate", "\!authenticate") }}}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
<criteria operator="AND">
<criterion comment="!authenticate does not exist in /etc/sudoers" test_ref="test_no_authenticate_etc_sudoers" />
<criterion comment="!authenticate does not exist in /etc/sudoers.d" test_ref="test_no_authenticate_etc_sudoers_d" />
{{% if product in [ 'sle16', 'slmicro6' ] %}}
<criterion
comment="test if configuration file /etc/sudoers exists for {{{ rule_id }}}"
test_ref="test_{{{ rule_id }}}_config_file_exists"/>
Comment thread
teacup-on-rockingchair marked this conversation as resolved.
{{% endif %}}
</criteria>
</definition>

{{% if product in [ 'sle16', 'slmicro6' ] %}}
{{{ oval_config_file_exists_test('/etc/sudoers', rule_id=rule_id) }}}
{{{ oval_config_file_exists_object('/etc/sudoers', rule_id=rule_id) }}}
{{% endif %}}
<ind:textfilecontent54_test check="all" check_existence="none_exist" comment="!authenticate does not exist in /etc/sudoers" id="test_no_authenticate_etc_sudoers" version="1">
<ind:object object_ref="object_no_authenticate_etc_sudoers" />
</ind:textfilecontent54_test>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# packages = sudo

rm -f /etc/sudoers
echo "Defaults authenticate" > /etc/sudoers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#!/bin/bash

# packages = sudo
echo "Defaults !authenticate" >> /etc/sudoers
chmod 440 /etc/sudoers

mkdir -p /etc/sudoers.d
echo "Defaults !authenticate" >> /etc/sudoers.d/sudoers
chmod 440 /etc/sudoers.d/sudoers
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# packages = sudo
echo "Defaults authenticate" > /etc/sudoers

mkdir -p /etc/sudoers.d
echo "Defaults !authenticate" >> /etc/sudoers.d/sudoers
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,17 @@
# complexity = low
# disruption = low

{{% if product in [ 'sle16', 'slmicro6' ] %}}
{{{ ansible_copy_distro_defaults('/usr/etc/sudoers', '/etc/sudoers', rule_title=rule_title) }}}
{{{
ansible_lineinfile(
rule_title + " - Remove /usr/etc/sudoers.d include directive from /etc/sudoers",
path="/etc/sudoers",
regex='^\s*@includedir\s+/usr/etc/sudoers.d',
state="absent",
when="not ansible_check_mode"
)
}}}
{{% endif %}}

{{{ ansible_sudo_remove_config("NOPASSWD", "NOPASSWD[\s]*\:") }}}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
# complexity = low
# disruption = low

{{% if product in [ 'sle16', 'slmicro6' ] %}}
{{{ bash_copy_distro_defaults("/usr/etc/sudoers", "/etc/sudoers") }}}
{{{ lineinfile_absent("/etc/sudoers", "^\s*@includedir\s*/usr/etc/sudoers\.d", sed_path_separator="#", rule_id=rule_id) }}}
{{% endif %}}
{{{ bash_sudo_remove_config("NOPASSWD", "NOPASSWD[\s]*\:") }}}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@
<criteria operator="AND">
<criterion comment="NOPASSWD is not configured in /etc/sudoers" test_ref="test_nopasswd_etc_sudoers" />
<criterion comment="NOPASSWD is not configured in /etc/sudoers.d" test_ref="test_nopasswd_etc_sudoers_d" />
{{% if product in [ 'sle16', 'slmicro6' ] %}}
<criterion
comment="test if configuration file /etc/sudoers exists for {{{ rule_id }}}"
test_ref="test_{{{ rule_id }}}_config_file_exists"/>
Comment thread
teacup-on-rockingchair marked this conversation as resolved.
{{% endif %}}
</criteria>
</definition>

{{% if product in [ 'sle16', 'slmicro6' ] %}}
{{{ oval_config_file_exists_test('/etc/sudoers', rule_id=rule_id) }}}
{{{ oval_config_file_exists_object('/etc/sudoers', rule_id=rule_id) }}}
{{% endif %}}

<ind:textfilecontent54_test check="all" check_existence="none_exist" comment="NOPASSWD does not exist /etc/sudoers" id="test_nopasswd_etc_sudoers" version="1">
<ind:object object_ref="object_nopasswd_etc_sudoers" />
</ind:textfilecontent54_test>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

# packages = sudo
rm -f /etc/sudoers
echo "%wheel ALL=(ALL) ALL" > /etc/sudoers
chmod 440 /etc/sudoers
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#!/bin/bash

# packages = sudo
echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
chmod 440 /etc/sudoers

mkdir -p /etc/sudoers.d
echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/sudoers
chmod 440 /etc/sudoers.d/sudoers
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# packages = sudo
echo "%wheel ALL=(ALL) ALL" > /etc/sudoers
chmod 440 /etc/sudoers

mkdir -p /etc/sudoers.d
echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/sudoers
chmod 440 /etc/sudoers.d/sudoers
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

# packages = sudo
echo "%wheel ALL=(ALL) NOPASSWD: /bin/systemctl, /bin/lsof, /bin/date" >> /etc/sudoers
chmod 440 /etc/sudoers

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# packages = sudo

rm -f /etc/sudoers
echo "%wheel ALL=(ALL) ALL" > /etc/sudoers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

# packages = sudo
echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
echo "Defaults !authenticate" >> /etc/sudoers
chmod 440 /etc/sudoers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,24 @@
<ind:instance datatype="int">1</ind:instance>
</ind:textfilecontent54_object>
{{% endmacro %}}

<definition class="compliance" id="{{{ rule_id }}}" version="1">
{{{ oval_metadata("Check that sudoers doesn't allow all users to run commands via sudo", rule_title=rule_title) }}}
<criteria operator="AND">
<criterion comment="Make sure that sudoers has restrictions on which users can run sudo for any target user" test_ref="test_not_all_users_can_sudo_to_users" />
<criterion comment="Make sure that sudoers has restrictions on which users can run sudo for any target group" test_ref="test_not_all_users_can_sudo_to_group" />
{{% if product in [ 'sle16', 'slmicro6' ] %}}
<criterion
comment="test if configuration file /etc/sudoers exists for {{{ rule_id }}}"
test_ref="test_{{{ rule_id }}}_config_file_exists"/>
Comment thread
teacup-on-rockingchair marked this conversation as resolved.
{{% endif %}}
</criteria>
</definition>

{{{ check_sudoers(scope='users',pattern='^\s*ALL\s+ALL\=\(ALL\)\s+ALL\s*$') }}}
{{{ check_sudoers(scope='group',pattern='^\s*ALL\s+ALL\=\(ALL\:ALL\)\s+ALL\s*') }}}

{{% if product in [ 'sle16', 'slmicro6' ] %}}
{{{ oval_config_file_exists_test('/etc/sudoers', rule_id=rule_id) }}}
{{{ oval_config_file_exists_object('/etc/sudoers', rule_id=rule_id) }}}
{{% endif %}}
</def-group>
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
register: sudoers_file_defaults
{{%- endmacro %}}

{{% if product in [ 'sle16', 'slmicro6' ] %}}
{{{ ansible_copy_distro_defaults('/usr/etc/sudoers', '/etc/sudoers', rule_title=rule_title) }}}
{{{
ansible_lineinfile(
rule_title + " - Remove /usr/etc/sudoers.d include directive from /etc/sudoers",
path="/etc/sudoers",
regex='^\s*@includedir\s+/usr/etc/sudoers.d',
state="absent",
when="not ansible_check_mode"
)
}}}
{{% endif %}}

{{{- delete_line_in_sudoers_d("Defaults targetpw") }}}
{{{- delete_line_in_sudoers_d("Defaults rootpw") }}}
{{{- delete_line_in_sudoers_d("Defaults runaspw") }}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ if grep -x '^{{{line}}}$' /etc/sudoers.d/*; then
fi
{{%- endmacro %}}

{{% if product in [ 'sle16', 'slmicro6'] %}}
{{{ bash_copy_distro_defaults("/usr/etc/sudoers", "/etc/sudoers") }}}
{{{ lineinfile_absent("/etc/sudoers", "^\s*@includedir\s*/usr/etc/sudoers\.d", sed_path_separator="#", rule_id=rule_id) }}}
{{% endif %}}

{{{- delete_line_in_sudoers_d("Defaults targetpw") }}}
{{{- delete_line_in_sudoers_d("Defaults rootpw") }}}
{{{- delete_line_in_sudoers_d("Defaults runaspw") }}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@
<criterion comment="Check Defaults targetpw is not defined in /etc/sudoers file" test_ref="test_sudoers_targetpw_not_defined" />
<criterion comment="Check Defaults rootpw is not defined in /etc/sudoers file" test_ref="test_sudoers_rootpw_not_defined" />
<criterion comment="Check Defaults runaspw is not defined in /etc/sudoers file" test_ref="test_sudoers_runaspw_not_defined" />
{{% if product in [ 'sle16', 'slmicro6' ] %}}
<criterion
comment="test if configuration file /etc/sudoers exists for {{{ rule_id }}}"
test_ref="test_{{{ rule_id }}}_config_file_exists"/>
Comment thread
teacup-on-rockingchair marked this conversation as resolved.
{{% endif %}}
</criteria>
</definition>

{{% if product in [ 'sle16', 'slmicro6' ] %}}
{{{ oval_config_file_exists_test('/etc/sudoers', rule_id=rule_id) }}}
{{{ oval_config_file_exists_object('/etc/sudoers', rule_id=rule_id) }}}
{{% endif %}}

<ind:textfilecontent54_test check="all" check_existence="at_least_one_exists" comment="Ensure invoking user's password for privilege escalation when using sudo"
id="test_sudoers_targetpw_config" version="1">
<ind:object object_ref="object_test_sudoers_targetpw_config" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,SUSE Linux Enterprise 15,multi_platform_slmicro,multi_platform_almalinux
# platform = SUSE Linux Enterprise 15,multi_platform_almalinux,multi_platform_fedora,multi_platform_ol,multi_platform_opensuse,multi_platform_rhel,multi_platform_slmicro
# packages = sudo

echo 'Defaults !targetpw' >> /etc/sudoers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,SUSE Linux Enterprise 15,multi_platform_slmicro,multi_platform_almalinux
# platform = SUSE Linux Enterprise 15,multi_platform_almalinux,multi_platform_fedora,multi_platform_ol,multi_platform_opensuse,multi_platform_rhel,multi_platform_slmicro
# packages = sudo

echo 'Defaults !targetpw' >> /etc/sudoers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = SUSE Linux Enterprise 15,multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_slmicro,multi_platform_almalinux
# platform = SUSE Linux Enterprise 15,multi_platform_fedora,multi_platform_ol,multi_platform_opensuse,multi_platform_rhel,multi_platform_slmicro,multi_platform_almalinux
# packages = sudo

echo 'Defaults !targetpw' >> /etc/sudoers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,SUSE Linux Enterprise 15,multi_platform_slmicro,multi_platform_almalinux
# platform = SUSE Linux Enterprise 15,multi_platform_almalinux,multi_platform_fedora,multi_platform_ol,multi_platform_opensuse,multi_platform_rhel,multi_platform_slmicro
# packages = sudo

echo 'Defaults !targetpw' >> /etc/sudoers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,SUSE Linux Enterprise 15,multi_platform_slmicro,multi_platform_almalinux
# platform = SUSE Linux Enterprise 15,multi_platform_almalinux,multi_platform_fedora,multi_platform_ol,multi_platform_opensuse,multi_platform_rhel,multi_platform_slmicro
# packages = sudo

echo 'Defaults !targetpw' >> /etc/sudoers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,SUSE Linux Enterprise 15,multi_platform_slmicro,multi_platform_almalinux
# platform = SUSE Linux Enterprise 15,multi_platform_almalinux,multi_platform_fedora,multi_platform_ol,multi_platform_opensuse,multi_platform_rhel,multi_platform_slmicro
# packages = sudo

touch /etc/sudoers.d/empty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,SUSE Linux Enterprise 15,multi_platform_slmicro,multi_platform_almalinux
# platform = SUSE Linux Enterprise 15,multi_platform_almalinux,multi_platform_fedora,multi_platform_ol,multi_platform_opensuse,multi_platform_rhel,multi_platform_slmicro
# packages = sudo

touch /etc/sudoers.d/empty
Expand Down
Loading