Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified 'ensure_rsyslog_log_file_conf' OVAL to allow user/groupnames #11226

Merged
merged 1 commit into from
Oct 26, 2023
Merged
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 @@ -79,9 +79,9 @@ template:
name: rsyslog_logfiles_attributes_modify
vars:
attribute: groupowner
value: 0
value@debian10: 4
value@debian11: 4
value@ubuntu1604: 4
value@ubuntu2004: 4
value@ubuntu2204: 4
value: root
value@debian10: adm
value@debian11: adm
value@ubuntu1604: adm
value@ubuntu2004: adm
value@ubuntu2204: adm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ template:
name: rsyslog_logfiles_attributes_modify
vars:
attribute: owner
value: 0
value@ubuntu2004: 104
value@ubuntu2204: 104
value: root
value@ubuntu2004: syslog
value@ubuntu2204: syslog
53 changes: 51 additions & 2 deletions shared/templates/rsyslog_logfiles_attributes_modify/oval.template
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,61 @@
var_ref="var_{{{ _RULE_ID }}}_log_files_paths"/>
</unix:file_object>

{{% if ATTRIBUTE == "groupowner" %}}
{{% if VALUE is number %}}
<!-- store groupowner GID in variable -->
<constant_variable id="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_gid" datatype="int" version="1" comment="GID of {{{ ATTRIBUTE }}}"><value>{{{ VALUE }}}</value></constant_variable>

{{% else %}}
<!-- get groupowner GID from name -->
<ind:textfilecontent54_object id="obj_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_gid" version="1" comment="GID of group {{{ VALUE }}}">
{{# Copied from file_groupowner template, assuming logic is still valid #}}
{{%- if product in ["rhcos4","ocp4"] %}}
<ind:filepath>/usr/lib/group</ind:filepath>
{{%- else %}}
<ind:filepath>/etc/group</ind:filepath>
{{%- endif %}}
<ind:pattern operation="pattern match">^{{{ VALUE }}}:\w+:(\w+):.*</ind:pattern>
<ind:instance datatype="int" operation="equals">1</ind:instance>
</ind:textfilecontent54_object>

<local_variable id="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_gid" datatype="int" version="1"
comment="GID of group {{{ VALUE }}}">
<object_component item_field="subexpression" object_ref="obj_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_gid"/>
</local_variable>
{{% endif %}}

{{% elif ATTRIBUTE == "owner" %}}
{{% if VALUE is number %}}
<!-- store owner UID in variable -->
<constant_variable id="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_uid" datatype="int" version="1" comment="UID of {{{ ATTRIBUTE }}}"><value>{{{ VALUE }}}</value></constant_variable>

{{% else %}}
<!-- get owner UID from name -->
<ind:textfilecontent54_object id="obj_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_uid" version="1" comment="UID of user {{{ VALUE }}}">
{{# Assuming same logic as above applies to users #}}
{{%- if product in ["rhcos4","ocp4"] %}}
<ind:filepath>/usr/lib/passwd</ind:filepath>
{{%- else %}}
<ind:filepath>/etc/passwd</ind:filepath>
{{%- endif %}}
<ind:pattern operation="pattern match">^{{{ VALUE }}}:\w+:(\w+):.*</ind:pattern>
<ind:instance datatype="int" operation="equals">1</ind:instance>
</ind:textfilecontent54_object>

<local_variable id="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_uid" datatype="int" version="1"
comment="UID of user {{{ VALUE }}}">
<object_component item_field="subexpression" object_ref="obj_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_uid"/>
</local_variable>
{{% endif %}}
{{% endif %}}

<unix:file_state id="state_{{{ _RULE_ID }}}" version="1">
<unix:type operation="equals">regular</unix:type>
{{% if ATTRIBUTE == "groupowner" %}}
<unix:group_id datatype="int">{{{ VALUE }}}</unix:group_id>
<unix:group_id datatype="int" var_ref="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_gid"></unix:group_id>
{{% elif ATTRIBUTE == "owner" %}}
<unix:user_id datatype="int">{{{ VALUE }}}</unix:user_id>
<unix:user_id datatype="int" var_ref="var_{{{ _RULE_ID }}}_{{{ ATTRIBUTE }}}_uid"></unix:user_id>
{{% else %}}
{{{ STATEMODE | indent(4) }}}
{{% endif %}}
Expand Down
Loading