forked from ComplianceAsCode/content
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate_OVAL_file_permissions
40 lines (40 loc) · 1.85 KB
/
template_OVAL_file_permissions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<def-group>
<definition class="compliance" id="file_permissions{{{ FILEID }}}" version="1">
<metadata>
<title>Verify {{{ FILEPATH }}} Mode Permissions</title>
{{{- oval_affected(products) }}}
<description>This test makes sure that {{{ FILEPATH }}} has mode {{{ FILEMODE }}}.
If the target file or directory has an extended ACL, then it will fail the mode check.
</description>
</metadata>
<criteria>
<criterion comment="Check file mode of {{{ FILEPATH }}}" test_ref="test_file_permissions{{{ FILEID }}}" />
</criteria>
</definition>
{{%- if MISSING_FILE_PASS -%}}
{{# Any number of files can exist, from zero to any #}}
{{% set FILE_EXISTENCE = "any_exist" %}}
{{%- else -%}}
{{# All defined files must exist. When using regex, at least one file must match #}}
{{% set FILE_EXISTENCE = "all_exist" %}}
{{%- endif -%}}
<unix:file_test check="all" check_existence="{{{ FILE_EXISTENCE }}}" comment="Testing mode of {{{ FILEPATH }}}" id="test_file_permissions{{{ FILEID }}}" version="1">
<unix:object object_ref="object_file_permissions{{{ FILEID }}}" />
<unix:state state_ref="state_file_permissions{{{ FILEID }}}_mode_{{{ FILEMODE }}}" />
</unix:file_test>
<unix:file_state id="state_file_permissions{{{ FILEID }}}_mode_{{{ FILEMODE }}}" version="1">
{{{ STATEMODE }}}
</unix:file_state>
<unix:file_object comment="{{{ FILEPATH }}}" id="object_file_permissions{{{ FILEID }}}" version="1">
{{%- if IS_DIRECTORY -%}}
<unix:path>{{{ FILEPATH }}}</unix:path>
{{%- if FILE_REGEX -%}}
<unix:filename operation="pattern match">{{{ FILE_REGEX }}}</unix:filename>
{{%- else -%}}
<unix:filename xsi:nil="true" />
{{%- endif -%}}
{{%- else -%}}
<unix:filepath>{{{ FILEPATH }}}</unix:filepath>
{{%- endif -%}}
</unix:file_object>
</def-group>