Skip to content

Commit

Permalink
convert sshd_set_idle_timeout partially to templated rule
Browse files Browse the repository at this point in the history
The OVAL is kept because there is a special condition where ClientAliveInterval is expected to be 0.
  • Loading branch information
vojtapolasek committed Aug 14, 2024
1 parent 24fbff3 commit 7fc1dd6
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 124 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
<extend_definition comment="rpm package openssh-server installed"
definition_ref="package_openssh-server_installed" />
{{% endif %}}
<criteria comment="ClientAliveInterval is configured correctly" operator="OR">
<criteria comment="ClientAliveInterval is configured correctly" operator="AND">
<criterion comment="Check ClientAliveInterval in /etc/ssh/sshd_config"
test_ref="test_sshd_idle_timeout" />
{{%- if sshd_distributed_config == "true" %}}
<criterion comment="Check ClientAliveInterval in /etc/ssh/sshd_config.d/"
test_ref="test_sshd_idle_timeout_config_dir" />
{{%- endif %}}
<criterion comment="the configuration exists" test_ref="test_clientaliveinterval_present" />
</criteria>
{{%- if product not in ["ol8", "ol9", "rhel8", "rhel9"] %}}
<extend_definition comment="The SSH ClientAliveCountMax is set to zero" definition_ref="sshd_set_keepalive" />
Expand All @@ -40,7 +41,7 @@
</criteria>
</definition>

<ind:textfilecontent54_test check="all" check_existence="all_exist"
<ind:textfilecontent54_test check="all" check_existence="any_exist"
comment="timeout is configured" id="test_sshd_idle_timeout" version="1">
<ind:object object_ref="object_sshd_idle_timeout" />
<ind:state state_ref="state_timeout_value_upper_bound" />
Expand All @@ -50,11 +51,11 @@
<ind:textfilecontent54_object id="object_sshd_idle_timeout" version="2">
<ind:filepath>/etc/ssh/sshd_config</ind:filepath>
<ind:pattern operation="pattern match">^[\s]*(?i)ClientAliveInterval[\s]+(\d+)[\s]*(?:#.*)?$</ind:pattern>
<ind:instance datatype="int">1</ind:instance>
<ind:instance operation="greater than or equal" datatype="int">1</ind:instance>
</ind:textfilecontent54_object>

{{%- if sshd_distributed_config == "true" %}}
<ind:textfilecontent54_test check="all" check_existence="all_exist"
<ind:textfilecontent54_test check="all" check_existence="any_exist"
comment="timeout is configured in config directory" id="test_sshd_idle_timeout_config_dir" version="1">
<ind:object object_ref="object_sshd_idle_timeout_config_dir" />
<ind:state state_ref="state_timeout_value_upper_bound" />
Expand All @@ -80,6 +81,22 @@
<ind:subexpression datatype="int" operation="greater than">0</ind:subexpression>
</ind:textfilecontent54_state>

<ind:textfilecontent54_test id="test_clientaliveinterval_present" version="1"
check="all" check_existence="at_least_one_exists"
comment="Verify that the value of ClientAliveInterval is present">
<ind:object object_ref="obj_collection_obj_sshd_set_idle_timeout" />
</ind:textfilecontent54_test>

<ind:textfilecontent54_object comment="All confs collection" id="obj_collection_obj_sshd_set_idle_timeout" version="1">
<set>
<object_reference>object_sshd_idle_timeout</object_reference>
{{% if sshd_distributed_config == "true" %}}
<object_reference>object_sshd_idle_timeout_config_dir</object_reference>
{{% endif %}}
</set>
</ind:textfilecontent54_object>


<external_variable comment="timeout value" datatype="int"
id="sshd_idle_timeout_value" version="1" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,13 @@ warnings:
<li>Remote processes on the remote machine generates output. As the output has to be transferred over the network to the client, the timeout is reset every time such transfer happens.</li>
<li>Any <tt>scp</tt> or <tt>sftp</tt> activity by the same user to the host resets the timeout.</li>
</ul>
template:
name: sshd_lineinfile
vars:
parameter: ClientAliveInterval
xccdf_variable: sshd_idle_timeout_value
datatype: int
backends:
oval: "off"

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 7fc1dd6

Please sign in to comment.