File: oval.template

package info (click to toggle)
scap-security-guide 0.1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 110,644 kB
  • sloc: xml: 241,883; sh: 73,777; python: 32,527; makefile: 27
file content (93 lines) | stat: -rw-r--r-- 4,346 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<def-group>
  <definition class="compliance" id="{{{ _RULE_ID }}}"
  version="1">
    {{{ oval_metadata("The kernel " ~ CONFIG ~ " should have value " ~ (VALUE if VALUE else "according to " ~ VARIABLE), affected_platforms=["multi_platform_all"]) }}}
    <criteria operator="OR">
      <criteria operator="AND">
        <criterion comment="Check presence of build configuration of installed kernels"
        test_ref="test_kernel_{{{ CONFIG | lower }}}" />
        <criterion comment="Ensure all kernels have the config"
        test_ref="test_all_kernels_{{{ CONFIG | lower }}}_compliant" />
      </criteria>
{{% if SHOULD_CHECK_ABSENCE %}}
      <criterion comment="Check absense of build configuration of installed kernels"
      test_ref="test_kernel_{{{ CONFIG | lower }}}_absence" />
{{% endif %}}
    </criteria>
  </definition>

  <ind:textfilecontent54_test check="all"
  comment="Check /boot/config-.* files for {{{ CONFIG }}}{{{ '=' ~ VALUE if VALUE else " according to " ~ VARIABLE }}}"
  id="test_kernel_{{{ CONFIG | lower }}}" version="1">
    <ind:object object_ref="object_kernel_{{{ CONFIG | lower }}}" />
    <ind:state state_ref="state_kernel_{{{ CONFIG | lower }}}" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_kernel_{{{ CONFIG | lower }}}" version="1">
    <ind:filepath operation="pattern match">^/boot/config-.*$</ind:filepath>
    <ind:pattern operation="pattern match">^{{{ CONFIG }}}="?(.*?)"?$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>

{{%- if VARIABLE %}}
  <ind:textfilecontent54_state id="state_kernel_{{{ CONFIG | lower }}}" version="1">
    <ind:subexpression operation="equals" datatype="string" var_ref="var_kernel_{{{ CONFIG | lower }}}"/>
  </ind:textfilecontent54_state>
{{% else %}}
  <ind:textfilecontent54_state id="state_kernel_{{{ CONFIG | lower }}}" version="1">
    <ind:subexpression operation="equals" datatype="string">{{{ VALUE }}}</ind:subexpression>
  </ind:textfilecontent54_state>
{{% endif %}}

{{% if SHOULD_CHECK_ABSENCE %}}
  <ind:textfilecontent54_test check="all" check_existence="none_exist"
  comment="Check /boot/config-.* files for absence of {{{ CONFIG }}}"
  id="test_kernel_{{{ CONFIG | lower }}}_absence" version="1">
    <ind:object object_ref="object_kernel_{{{ CONFIG | lower }}}" />
  </ind:textfilecontent54_test>
{{% endif %}}

  <ind:variable_test check="all" check_existence="all_exist"
  comment="Check if all installed kernels are compliant"
  id="test_all_kernels_{{{ CONFIG | lower }}}_compliant" version="1">
    <ind:object object_ref="object_var_kernel_{{{ CONFIG | lower }}}_count" />
    <ind:state state_ref="state_var_kernel_{{{ CONFIG | lower }}}" />
  </ind:variable_test>

  <ind:variable_object id="object_var_kernel_{{{ CONFIG | lower }}}_count" version="1">
    <ind:var_ref>local_var_{{{ CONFIG | lower }}}_count_kernels_installed</ind:var_ref>
  </ind:variable_object>

  <ind:variable_state id="state_var_kernel_{{{ CONFIG | lower }}}" version="1">
    <ind:value operation="equals" datatype="int"
    var_ref="local_var_{{{ CONFIG | lower }}}_count_compliant_configs" />
  </ind:variable_state>

  <local_variable comment="Count number of kernels installed" datatype="int"
  id="local_var_{{{ CONFIG | lower }}}_count_kernels_installed" version="1">
    <count>
      <unique>
        <object_component object_ref="object_kernel_{{{ CONFIG | lower }}}_files"
        item_field="filepath" />
      </unique>
    </count>
  </local_variable>

  <local_variable comment="Count number of configs found" datatype="int"
  id="local_var_{{{ CONFIG | lower }}}_count_compliant_configs" version="1">
    <count>
      <unique>
        <object_component object_ref="object_kernel_{{{ CONFIG | lower }}}"
        item_field="filepath" />
      </unique>
    </count>
  </local_variable>

  <unix:file_object comment="Collect the kernel config files" id="object_kernel_{{{ CONFIG | lower }}}_files" version="1">
      <unix:path>/boot</unix:path>
      <unix:filename operation="pattern match">^config-.*$</unix:filename>
  </unix:file_object>
{{%- if VARIABLE %}}
  <external_variable comment="Value for kernel {{{ CONFIG }}} setting" datatype="string" id="var_kernel_{{{ CONFIG | lower }}}" version="1" />
{{%- endif %}}
</def-group>