File: state.py

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 (32 lines) | stat: -rw-r--r-- 961 bytes parent folder | download
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
from ...constants import STR_TO_BOOL
from ..general import (
    OVALEntity,
    load_property_and_notes_of_oval_entity,
    required_attribute,
)


def load_state(oval_state_xml_el):
    state_property, notes = load_property_and_notes_of_oval_entity(oval_state_xml_el)

    state = State(
        oval_state_xml_el.tag,
        required_attribute(oval_state_xml_el, "id"),
        state_property,
    )
    state.version = required_attribute(oval_state_xml_el, "version")
    state.comment = oval_state_xml_el.get("comment", "")
    state.deprecated = STR_TO_BOOL.get(oval_state_xml_el.get("deprecated", ""), False)
    state.notes = notes
    state.operator = oval_state_xml_el.get("operator", "AND")
    return state


class State(OVALEntity):
    operator = "AND"

    def get_xml_element(self):
        return super(State, self).get_xml_element(operator=self.operator)

    def get_variable_references(self):
        return self._get_references("var_ref")