Code Duplication    Length = 23-25 lines in 2 locations

ssg/build_remediations.py 1 location

@@ 327-351 (lines=25) @@
324
        return our_cce
325
        return self.associated_rule.identifiers.get("cce", None)
326
327
    def get_references(self, product):
328
        if not self.associated_rule:
329
            raise RuntimeError("The Ansible snippet has no rule loaded.")
330
        # see xccdf-addremediations.xslt <- shared_constants.xslt <- shared_shorthand2xccdf.xslt
331
        # if you want to know how the map was constructed
332
        platform_id_map = {
333
            "rhel7": "DISA-STIG-RHEL-07",
334
            "rhel8": "DISA-STIG-RHEL-08",
335
        }
336
        # RHEL6 is a special case, in our content,
337
        # we have only stig IDs for RHEL6 that include the literal 'RHEL-06'
338
        stig_platform_id = platform_id_map.get(product, "DISA-STIG")
339
340
        ref_prefix_map = {
341
            "nist": "NIST-800-53",
342
            "cui": "NIST-800-171",
343
            "pcidss": "PCI-DSS",
344
            "cjis": "CJIS",
345
            "stigid@{product}".format(product=product): stig_platform_id,
346
        }
347
        result = []
348
        for ref_class, prefix in ref_prefix_map.items():
349
            refs = self._get_rule_reference(ref_class)
350
            result.extend(["{prefix}-{value}".format(prefix=prefix, value=v) for v in refs])
351
        return result
352
353
    def _get_rule_reference(self, ref_class):
354
        refs = self.associated_rule.references.get(ref_class, "")

ssg/ansible.py 1 location

@@ 130-152 (lines=23) @@
127
                break
128
        return our_cce
129
130
    def get_references(self, platform):
131
        if not self.rule:
132
            raise RuntimeError("The Ansible snippet has no rule loaded.")
133
        # see xccdf-addremediations.xslt <- shared_constants.xslt <- shared_shorthand2xccdf.xslt
134
        # if you want to know how the map was constructed
135
        platform_id_map = {
136
            "rhel6": "RHEL-06",
137
            "rhel7": "RHEL-07",
138
            "rhel8": "RHEL-08",
139
        }
140
        stig_platform_id = "DISA-STIG-{id}".format(id=platform_id_map.get(platform, None))
141
        ref_prefix_map = {
142
            "nist": "NIST-800-53",
143
            "cui": "NIST-800-171",
144
            "pcidss": "PCI-DSS",
145
            "cjis": "CJIS",
146
            "stigid@{platform}".format(platform=platform): stig_platform_id
147
        }
148
        result = []
149
        for ref_class, prefix in ref_prefix_map.items():
150
            refs = self._get_rule_reference(ref_class)
151
            result.extend(["{prefix}-{value}".format(prefix=prefix, value=v) for v in refs])
152
        return result
153
154
    def _get_rule_reference(self, ref_class):
155
        refs = self.rule.references.get(ref_class, "")