@@ -1033,9 +1033,10 @@ Generates the :code:`<affected>` tag for OVAL check using correct product platfo
10331033:type datatype: str
10341034
10351035#}}
1036- {{%- macro sshd_oval_check(parameter, value, missing_parameter_pass, config_is_distributed, xccdf_variable="", datatype="", rule_id=None, rule_title=None) -%}}
1036+ {{%- macro sshd_oval_check(parameter, value, missing_parameter_pass, config_is_distributed, runtime_check="false", xccdf_variable="", datatype="", rule_id=None, rule_title=None) -%}}
10371037{{%- set sshd_config_path = "/etc/ssh/sshd_config" %}}
10381038{{%- set sshd_config_dir = "/etc/ssh/sshd_config.d" -%}}
1039+ {{%- set sshd_runtime_path = "/etc/compliance-operator/runtime/sshd_effective_config" -%}}
10391040{{%- if xccdf_variable -%}}
10401041{{%- set description = "Ensure '" ~ parameter ~ "' is configured with value configured in " ~ xccdf_variable ~ " variable in " ~ sshd_config_path %}}
10411042{{%- else -%}}
@@ -1081,6 +1082,12 @@ Generates the :code:`<affected>` tag for OVAL check using correct product platfo
10811082 {{{- oval_line_in_file_criterion("sshd_config included", parameter, id_stem=rule_id ~ "_sshd_included_files", avoid_conflicting=true, rule_id=rule_id) | indent(10)}}}
10821083 {{% endif %}}
10831084 </criteria >
1085+ {{%- if runtime_check == "true" %}}
1086+ <criteria comment =" runtime configuration is correct" operator =" OR" >
1087+ <criterion comment =" runtime config file does not exist" test_ref =" test_runtime_config_absent_{{{ rule_id }}}" />
1088+ <criterion comment =" runtime config matches expected value" test_ref =" test_runtime_{{{ parameter }}}_{{{ rule_id }}}" />
1089+ </criteria >
1090+ {{%- endif %}}
10841091 {{%- if not missing_parameter_pass %}}
10851092 <criterion comment =" the configuration exists" test_ref =" test_{{{ parameter }}}_present_{{{ rule_id }}}" />
10861093 {{% endif %}}
@@ -1162,6 +1169,49 @@ Generates the :code:`<affected>` tag for OVAL check using correct product platfo
11621169 </ind:textfilecontent54 _test >
11631170
11641171 {{% endif %}}
1172+
1173+ {{%- if runtime_check == "true" %}}
1174+ <!-- Runtime configuration checks -->
1175+ <ind:textfilecontent54 _test id =" test_runtime_config_absent_{{{ rule_id }}}" version =" 1"
1176+ check =" none satisfy" check_existence =" none_exist"
1177+ comment =" Check if runtime config file exists" >
1178+ <ind:object object_ref =" obj_runtime_config_file_{{{ rule_id }}}" />
1179+ </ind:textfilecontent54 _test >
1180+
1181+ <ind:textfilecontent54 _object id =" obj_runtime_config_file_{{{ rule_id }}}" version =" 1" >
1182+ <ind:filepath >{{{ sshd_runtime_path }}}</ind:filepath >
1183+ <ind:pattern operation =" pattern match" >.*</ind:pattern >
1184+ <ind:instance datatype =" int" >1</ind:instance >
1185+ </ind:textfilecontent54 _object >
1186+
1187+ <ind:textfilecontent54 _test id =" test_runtime_{{{ parameter }}}_{{{ rule_id }}}" version =" 1"
1188+ check =" all" check_existence =" at_least_one_exists"
1189+ comment =" Check runtime {{{ parameter }}} value" >
1190+ <ind:object object_ref =" obj_runtime_{{{ parameter }}}_{{{ rule_id }}}" />
1191+ {{%- if xccdf_variable -%}}
1192+ <ind:state state_ref =" state_runtime_{{{ parameter }}}_{{{ rule_id }}}_xccdf" />
1193+ {{%- else -%}}
1194+ <ind:state state_ref =" state_runtime_{{{ parameter }}}_{{{ rule_id }}}" />
1195+ {{%- endif -%}}
1196+ </ind:textfilecontent54 _test >
1197+
1198+ <ind:textfilecontent54 _object id =" obj_runtime_{{{ parameter }}}_{{{ rule_id }}}" version =" 1" >
1199+ <ind:filepath >{{{ sshd_runtime_path }}}</ind:filepath >
1200+ <ind:pattern operation =" pattern match" >^[\s]*{{{ parameter | lower }}}[\s]+(.*)$</ind:pattern >
1201+ <ind:instance datatype =" int" >1</ind:instance >
1202+ </ind:textfilecontent54 _object >
1203+
1204+ {{%- if xccdf_variable -%}}
1205+ <ind:textfilecontent54 _state id =" state_runtime_{{{ parameter }}}_{{{ rule_id }}}_xccdf" version =" 1" >
1206+ <ind:subexpression operation =" equals" datatype =" {{{ datatype }}}" var_ref =" {{{ xccdf_variable }}}" />
1207+ </ind:textfilecontent54 _state >
1208+ {{%- else -%}}
1209+ <ind:textfilecontent54 _state id =" state_runtime_{{{ parameter }}}_{{{ rule_id }}}" version =" 1" >
1210+ <ind:subexpression operation =" {{{ 'pattern match' if datatype == 'string' else 'equals' }}}" datatype =" {{{ datatype }}}" >{{{ value }}}</ind:subexpression >
1211+ </ind:textfilecontent54 _state >
1212+ {{%- endif -%}}
1213+ {{%- endif %}}
1214+
11651215</def-group >
11661216{{%- endmacro %}}
11671217
0 commit comments