Skip to content

Commit

Permalink
Merge pull request #242 from jan-cerny/class
Browse files Browse the repository at this point in the history
Remove OVAL definition class information
  • Loading branch information
evgenyz authored Jul 29, 2024
2 parents dffe2fe + a94cb99 commit 60dc569
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@
</div></div>
</td>
</tr>
<tr role="row">
<th class="pf-m-fit-content" role="rowheader" scope="row"><b>Class:</b></th>
<td role="cell">
<div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item">
<p class="pf-c-table__text">{{ rule.oval_definition.definition_class }}</p></div></div>
</td>
</tr>
<tr role="row">
<th class="pf-m-fit-content" role="rowheader" scope="row"><b>Title:</b></th>
<td role="cell">
Expand All @@ -33,13 +26,6 @@
<p class="pf-c-table__text">{{ rule.oval_definition.description }}</p></div></div>
</td>
</tr>
<tr role="row">
<th class="pf-m-fit-content" role="rowheader" scope="row"><b>Class explained:</b></th>
<td role="cell">
<div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item">
<p class="pf-c-table__text">{{ rule.oval_definition.get_oval_class_description() }}</p></div></div>
</td>
</tr>
<tr role="row">
<th class="pf-m-fit-content" role="rowheader" scope="row"><b>Version:</b></th>
<td role="cell">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,10 @@
"version",
]

OVAL_CLASS_DESCRIPTION = {
"compliance": (
"Compliance class describes OVAL Definitions that check to see if a system's state is "
'compliant with a specific policy. An evaluation result of "true", for this class of OVAL '
"Definitions, indicates that a system is compliant with the stated policy."
),
"vulnerability": (
"Vulnerability class describes OVAL Definitions that check to see if the system is in a "
'vulnerable state. An evaluation result of "true", for this class of OVAL Definitions, '
"indicates that the system is in a vulnerable state."
),
"inventory": (
"Inventory class describes OVAL Definitions that check to see if a piece of software is "
'installed on a system. An evaluation result of "true", for this class of OVAL '
"Definitions, indicates that the specified software is installed on the system."
),
"patch": (
"Patch class describes OVAL Definitions that check to see if a patch should be installed "
'on a system. An evaluation result of "true", for this class of OVAL Definitions, '
"indicates that the specified patch should be installed on the system."
),
}


@dataclass
class OvalDefinition:
definition_id: str
definition_class: str
title: str
description: str = ""
version: str = ""
Expand All @@ -51,6 +27,3 @@ class OvalDefinition:

def as_dict(self):
return asdict(self)

def get_oval_class_description(self):
return OVAL_CLASS_DESCRIPTION[self.definition_class]
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ def _get_references(self, definition):
references.append(OvalReference(ref.get("source"), ref.get("ref_id")))
return references

def parse_oval_definition(self, definition_id, definition_class, definition):
def parse_oval_definition(self, definition_id, definition):
oval_definition_dict = {
"definition_id": definition_id,
"definition_class": definition_class,
"title": definition.find('.//oval-definitions:title', NAMESPACES).text,
"description": definition.find('.//oval-definitions:description', NAMESPACES).text,
"version": definition.get("version"),
Expand All @@ -48,10 +47,8 @@ def _get_oval_definitions(self, oval):
dict_of_criteria = {}
for definition in self.oval_definitions[oval]:
definition_id = definition.get("id")
definition_class = definition.get("class")
oval_definition = self.parse_oval_definition(
definition_id,
definition_class,
definition
)
criteria = definition.find('.//oval-definitions:criteria', NAMESPACES)
Expand Down
1 change: 0 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def get_dummy_cpe_oval_definition():
dummy_oval_definition = OvalDefinition(
definition_id="dummy_oval_def",
title="dummy OVAL definition",
definition_class="compliance",
oval_tree=OVAL_TREE_TRUE,
)
return {
Expand Down

0 comments on commit 60dc569

Please sign in to comment.