Skip to content

Commit

Permalink
Refactor build_yaml
Browse files Browse the repository at this point in the history
Clean up imports and fix small problems.
  • Loading branch information
evgenyz committed Nov 24, 2022
1 parent b7ff233 commit 3e0d2c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
11 changes: 5 additions & 6 deletions ssg/build_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


import ssg.build_remediations
from .build_cpe import CPEDoesNotExist, CPEALLogicalTest, CPEALFactRef, ProductCPEs
from .build_cpe import CPEALLogicalTest, CPEALFactRef, ProductCPEs
from .constants import (XCCDF12_NS,
OSCAP_BENCHMARK,
OSCAP_GROUP,
Expand Down Expand Up @@ -40,8 +40,7 @@
from .yaml import DocumentationNotComplete, open_and_macro_expand
from .utils import required_key, mkdir_p

from .xml import ElementTree as ET, add_xhtml_namespace, register_namespaces, parse_file
from .shims import unicode_func
from .xml import ElementTree as ET, register_namespaces, parse_file
import ssg.build_stig

from .entities.common import add_sub_element, make_items_product_specific, \
Expand Down Expand Up @@ -280,7 +279,7 @@ def process_input_dict(cls, input_contents, env_yaml, product_cpes):
return data

def represent_as_dict(self):
data = super(Benchmark, cls).represent_as_dict()
data = super(Benchmark, self).represent_as_dict()
data["rear-matter"] = data["rear_matter"]
del data["rear_matter"]

Expand Down Expand Up @@ -678,9 +677,9 @@ class Rule(XCCDFEntity, Templatable):
inherited_cpe_platform_names=lambda: set(),
bash_conditional=lambda: None,
fixes=lambda: dict(),
** XCCDFEntity.KEYS,
** Templatable.KEYS
**XCCDFEntity.KEYS
)
KEYS.update(**Templatable.KEYS)

MANDATORY_KEYS = {
"title",
Expand Down
2 changes: 1 addition & 1 deletion ssg/entities/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def get_template_vars(self, env_yaml):
# A better name is '_entity_id' (as in XCCDF Entity).
template_vars["_rule_id"] = self.id_

return make_items_product_specific(template_vars, env_yaml["product"])
return make_items_product_specific(template_vars, env_yaml["product"], allow_overwrites=True)

def get_template_backend_langs(self):
"""
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/ssg-module/data/templates/extra_ovals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ package_avahi_installed:
name: package_installed
vars:
pkgname: avahi
pkgname@ubuntu2004: avahi-daemon
pkgname@rhel8: avahi8

0 comments on commit 3e0d2c0

Please sign in to comment.