Skip to content

Commit

Permalink
Merge pull request #6402 from matejak/abort_missing_extending_defs
Browse files Browse the repository at this point in the history
Abort the build if an OVAL is not included due to extend_definition
  • Loading branch information
jan-cerny committed Apr 8, 2021
2 parents 69515a6 + c7b6094 commit 2bebe03
Show file tree
Hide file tree
Showing 31 changed files with 62 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
documentation_complete: true

prodtype: debian10,debian9,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,ubuntu1604,ubuntu1804,ubuntu2004,wrlinux1019,wrlinux8

title: 'Install the OpenSSH Server Package'

description: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
documentation_complete: true

prodtype: debian10,debian9,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,ubuntu1604,ubuntu1804,ubuntu2004,wrlinux1019,wrlinux8

title: 'Remove the OpenSSH Server Package'

description: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: ol7,ol8,rhel7,rhel8,rhv4
prodtype: ol7,ol8,rhel7,rhel8,rhv4,wrlinux1019

title: 'Enable SSH Server firewalld Firewall Exception'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
documentation_complete: true

prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Ensure auditd Collects File Deletion Events by User'

description: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
documentation_complete: true

prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Ensure auditd Collects Unauthorized Access Attempts to Files (unsuccessful)'

description: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Record Unsuccessful Access Attempts to Files - creat'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Record Unsuccessful Access Attempts to Files - ftruncate'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Record Unsuccessful Access Attempts to Files - open'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Record Unsuccessful Access Attempts to Files - open_by_handle_at'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Record Unsuccessful Access Attempts to Files - openat'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Record Unsuccessful Access Attempts to Files - truncate'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
documentation_complete: true

prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Ensure auditd Collects Information on Kernel Module Loading and Unloading'

description: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Ensure auditd Collects Information on Kernel Module Unloading - delete_module'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Ensure auditd Collects Information on Kernel Module Loading and Unloading - finit_module'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Ensure auditd Collects Information on Kernel Module Loading - init_module'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
documentation_complete: true

prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Record Attempts to Alter Logon and Logout Events'

description: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Record Attempts to Alter Logon and Logout Events - faillock'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Record Attempts to Alter Logon and Logout Events - lastlog'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Record Attempts to Alter Logon and Logout Events - tallylog'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Disable IPv6 Networking Support Automatic Loading'

description: |-
Expand Down
3 changes: 2 additions & 1 deletion linux_os/guide/system/selinux/selinux_state/rule.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
# This rule is applicable even to non-selinux platforms, as the selinux_state is leveraged
# by rules that deal with technologies that conflict with SELinux

title: 'Ensure SELinux State is Enforcing'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15
prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux8,wrlinux1019

title: 'The Installed Operating System Is FIPS 140-2 Certified'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,sle12,sle15,rhv4

title: 'Harden SSHD Crypto Policy'

description: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
documentation_complete: true

prodtype: fedora,ol7,ol8,rhcos4,rhel7,rhel8,rhv4,sle12,sle15

title: 'Install the Host Intrusion Prevention System (HIPS) Module'

description: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: rhcos4,ol7,rhel7
prodtype: rhcos4,ol7,rhel7,wrlinux1019

title: 'Install the dracut-fips-aesni Package'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: rhcos4,ol7,rhel7
prodtype: rhcos4,ol7,rhel7,wrlinux1019

title: 'Install the dracut-fips Package'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
documentation_complete: true

prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Build and Test AIDE Database'

description: |-
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
documentation_complete: true

prodtype: fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019
prodtype: debian9,debian10,fedora,rhcos4,ol7,ol8,rhel7,rhel8,rhv4,sle12,sle15,wrlinux1019

title: 'Install AIDE'

Expand Down
1 change: 1 addition & 0 deletions shared/checks/oval/sysctl_kernel_ipv6_disable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>Kernel Runtime Parameter IPv6 Check</title>
<affected family="unix">
<platform>multi_platform_debian</platform>
<platform>multi_platform_example</platform>
<platform>multi_platform_fedora</platform>
<platform>multi_platform_opensuse</platform>
<platform>multi_platform_ol</platform>
Expand Down
38 changes: 29 additions & 9 deletions ssg/build_renumber.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import
from __future__ import print_function
import sys
import collections


from .constants import oval_namespace, XCCDF11_NS, cce_uri, ocil_cs, ocil_namespace
Expand Down Expand Up @@ -139,8 +140,14 @@ def _link_oval_tree(self):
indexed_oval_defs = map_elements_to_their_ids(
self.tree, ".//{0}".format(self._get_checkid_string()))

drop_oval_checks_extending_non_existing_checks(
self.tree, self.oval_groups, indexed_oval_defs)
defs_miss = get_oval_checks_extending_non_existing_checks(self.tree, indexed_oval_defs)
if defs_miss:
msg = ["Following extending definitions are missing:"]
for missing, broken in transpose_dict_with_sets(defs_miss).items():
broken = [b.get("id") for b in broken]
msg.append("\t'{missing}' needed by: {broken}"
.format(missing=missing, broken=broken))
raise RuntimeError("\n".join(msg))

self._add_cce_id_refs_to_oval_checks(xccdf_to_cce_id_mapping)

Expand Down Expand Up @@ -316,20 +323,33 @@ def get_nonexisting_check_definition_extends(definition, indexed_oval_defs):
return None


def drop_oval_checks_extending_non_existing_checks(ovaltree, oval_groups, indexed_oval_defs):
def get_oval_checks_extending_non_existing_checks(ovaltree, indexed_oval_defs):
# Incomplete OVAL checks are as useful as non existing checks
# Here we check if all extend_definition refs from a definition exists in local OVAL file
definitions = ovaltree.find(".//{%s}definitions" % oval_ns)
defstoremove = set()
definitions_misses = collections.defaultdict(set)
for definition in definitions:
nonexisting_ref = get_nonexisting_check_definition_extends(definition, indexed_oval_defs)
if nonexisting_ref is not None:
print("WARNING: OVAL definition '{0}' extends non-existing '{1}', "
"removing it from OVAL definitions."
.format(definition.get("id"), nonexisting_ref),
file=sys.stderr)
defstoremove.add(definition)
definitions_misses[definition].add(nonexisting_ref)

return definitions_misses


def transpose_dict_with_sets(dict_in):
"""
Given a mapping X: key -> set of values, produce a mapping Y of the same type, where
for every combination of a, b for which a in X[b], the following holds: b in Y[a].
"""
result = collections.defaultdict(set)
for key, values in dict_in.items():
for val in values:
result[val].add(key)
return result


def drop_oval_definitions(ovaltree, defstoremove, oval_groups, indexed_oval_defs):
definitions = ovaltree.find(".//{%s}definitions" % oval_ns)
for definition in defstoremove:
del oval_groups["definitions"][definition.get("id")]
del indexed_oval_defs[definition.get("id")]
Expand Down
2 changes: 1 addition & 1 deletion ssg/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
'sle': 'SUSE Linux Enterprise',
'vsel': 'McAfee VirusScan Enterprise for Linux',
'wrlinux': 'WRLinux',
'example': 'Example Linux Content',
'example': 'Example',
'ol': 'Oracle Linux',
'ocp': 'Red Hat OpenShift Container Platform',
'rhcos': 'Red Hat Enterprise Linux CoreOS',
Expand Down

0 comments on commit 2bebe03

Please sign in to comment.