Skip to content

Commit

Permalink
add new parametrized platform os_linux
Browse files Browse the repository at this point in the history
add associated template together with Ansible remediation.
Currently, only the OS name can be specified.
  • Loading branch information
vojtapolasek committed Dec 14, 2022
1 parent 8de4322 commit 54afd39
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
14 changes: 14 additions & 0 deletions shared/applicability/os_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "cpe:/o:{arg}"
title: "Operating System is {arg}"
check_id: platform_os_linux_{arg}
template:
name: platform_os_linux
args:
rhel:
os_name: "Red Hat Enterprise Linux"
os_id: 'rhel'
os_id_ansible: "RedHat"
fedora:
os_name: "Fedora"
os_id: 'fedora'
os_id_ansible: "Fedora"
2 changes: 2 additions & 0 deletions shared/templates/platform_os_linux/ansible.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{%- set ansible_os_release_name_cond = 'ansible_distribution == "' + OS_ID_ANSIBLE + '"' -%}}
{{{ ansible_os_release_name_cond.strip() }}}
25 changes: 25 additions & 0 deletions shared/templates/platform_os_linux/oval.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<def-group>
<definition class="inventory" id="platform_{{{ _RULE_ID }}}" version="1">
{{{ oval_metadata("The installed operating system is " + OS_NAME, affected_platforms=["multi_platform_all"]) }}}
<criteria operator="AND">
<criterion comment="The operating system installed on the system is {{{ OS_NAME }}}"
test_ref="test_os_id_is_{{{ ID }}}" />
</criteria>
</definition>

<ind:textfilecontent54_test check="all" comment="ID in os-release is {{{ OS_ID }}}" id="test_os_id_is_{{{ ID }}}" version="1">
<ind:object object_ref="obj_os_id_is_{{{ ID }}}" />
<ind:state state_ref="state_os_id_is_{{{ ID }}}" />
</ind:textfilecontent54_test>

<ind:textfilecontent54_object id="obj_os_id_is_{{{ ID }}}" version="1">
<ind:filepath>/etc/os-release</ind:filepath>
<ind:pattern operation="pattern match">^ID=[&quot;&apos;]?(\w+)[&quot;&apos;]?$</ind:pattern>
<ind:instance operation="greater than or equal" datatype="int">1</ind:instance>
</ind:textfilecontent54_object>

<ind:textfilecontent54_state id="state_os_id_is_{{{ ID }}}" version="1">
<ind:subexpression operation="pattern match">{{{ OS_ID }}}</ind:subexpression>
</ind:textfilecontent54_state>

</def-group>
3 changes: 3 additions & 0 deletions shared/templates/platform_os_linux/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
supported_languages:
- ansible
- oval

0 comments on commit 54afd39

Please sign in to comment.