ComplianceAsCode/content

View on GitHub

Showing 238 of 1,093 total issues

Function get_profile_stats has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def get_profile_stats(self, profile):
"""Obtain statistics for the profile"""
 
# Holds the intermediary statistics for profile
profile_stats = {
Severity: Major
Found in ssg/build_profile.py - About 2 hrs to fix

    Function ssg_xccdf_stigid_mapping has a Cognitive Complexity of 21 (exceeds 7 allowed). Consider refactoring.
    Open

    def ssg_xccdf_stigid_mapping(ssgtree):
    xccdf_ns = ssg.xml.determine_xccdf_tree_namespace(ssgtree)
    xccdftostig_idmapping = {}
     
    for rule in ssgtree.findall(".//{%s}Rule" % xccdf_ns):
    Severity: Minor
    Found in utils/create-stig-overlay.py - About 2 hrs to fix

    Function main has a Cognitive Complexity of 21 (exceeds 7 allowed). Consider refactoring.
    Open

    def main():
    args = parse_args()
     
    product_allowlist = set(PRODUCT_ALLOWLIST)
    profile_allowlist = set(PROFILE_ALLOWLIST)
    Severity: Minor
    Found in utils/ansible_playbook_to_role.py - About 2 hrs to fix

    Function main has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def main():
    parser = argparse.ArgumentParser(
    description="Test Jinja macros that Generate OVAL")
    parser.add_argument(
    "--verbose", action="store_true", default=False,
    Severity: Major
    Found in tests/test_macros_oval.py - About 2 hrs to fix

      PlaybookToRoleConverter has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class PlaybookToRoleConverter():
      PRODUCED_FILES = ('defaults/main.yml', 'meta/main.yml', 'tasks/main.yml', 'vars/main.yml',
      'README.md')
       
      def __init__(self, local_playbook_filename):
      Severity: Minor
      Found in utils/ansible_playbook_to_role.py - About 2 hrs to fix

        GenericRunner has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class GenericRunner(object):
        def __init__(self, environment, profile, datastream, benchmark_id):
        self.environment = environment
        self.profile = profile
        self.datastream = datastream
        Severity: Minor
        Found in tests/ssg_test_suite/oscap.py - About 2 hrs to fix

          Function clusterTestFunc has a Cognitive Complexity of 20 (exceeds 7 allowed). Consider refactoring.
          Open

          def clusterTestFunc(args):
           
          print('* Testing rule %s in-cluster' % args.rule)
           
          findout = subprocess.getoutput(
          Severity: Minor
          Found in utils/add_kubernetes_rule.py - About 2 hrs to fix

          Function main has a Cognitive Complexity of 20 (exceeds 7 allowed). Consider refactoring.
          Open

          def main():
          args = parse_args()
           
          linux_products, other_products = ssg.products.get_all(args.root)
          all_products = linux_products.union(other_products)
          Severity: Minor
          Found in utils/rule_dir_json.py - About 2 hrs to fix

          File add_kubernetes_rule.py has 412 lines of code (exceeds 400 allowed). Consider refactoring.
          Open

          #!/usr/bin/python3
           
          import argparse
          import subprocess
          import sys
          Severity: Minor
          Found in utils/add_kubernetes_rule.py - About 2 hrs to fix

            Function tokenize has a Cognitive Complexity of 19 (exceeds 7 allowed). Consider refactoring.
            Open

            def tokenize(self, expr):
            """
            Return an iterable of 3-tuple describing each token given an expression
            unicode string.
             
             
            Severity: Minor
            Found in ssg/ext/boolean/boolean.py - About 2 hrs to fix

            Function get_profile_choices_for_input has a Cognitive Complexity of 19 (exceeds 7 allowed). Consider refactoring.
            Open

            def get_profile_choices_for_input(input_tree, benchmark_id, tailoring_tree):
            """
            Returns a dictionary that maps profile_ids to their respective titles.
             
            Args:
            Severity: Minor
            Found in ssg/xccdf.py - About 2 hrs to fix

            Function get_rule_to_stig_dict has a Cognitive Complexity of 19 (exceeds 7 allowed). Consider refactoring.
            Open

            def get_rule_to_stig_dict(xml: ElementTree.ElementTree, benchmark_creator: str) -> dict:
            rules = dict()
            for group in xml.findall(f'{XCCDF12}:Group', PREFIX_TO_NS):
            for sub_groups in group.findall(f'{XCCDF12}:Group', PREFIX_TO_NS):
            rules.update(get_rule_to_stig_dict(ElementTree.ElementTree(sub_groups),
            Severity: Minor
            Found in utils/compare_results.py - About 2 hrs to fix

            ContainerTestEnv has 21 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class ContainerTestEnv(TestEnv):
            def __init__(self, scanning_mode, image_name):
            super(ContainerTestEnv, self).__init__(scanning_mode)
            self._name_stem = "ssg_test"
            self.base_image = image_name
            Severity: Minor
            Found in tests/ssg_test_suite/test_env.py - About 2 hrs to fix

              TestEnv has 21 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class TestEnv(object):
              def __init__(self, scanning_mode):
              self.running_state_base = None
              self.running_state = None
               
               
              Severity: Minor
              Found in tests/ssg_test_suite/test_env.py - About 2 hrs to fix

                Function _collect_items_to_load has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
                Open

                def _collect_items_to_load(self, guide_directory):
                """
                Collects and categorizes items from the specified guide directory.
                 
                This method iterates through the items in the given directory and sorts them into
                Severity: Minor
                Found in ssg/build_yaml.py - About 2 hrs to fix

                Function add_reference_elements has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
                Open

                def add_reference_elements(element, references, ref_uri_dict):
                """
                Adds reference elements to an XML element based on provided references and their
                corresponding URIs.
                 
                 
                Severity: Minor
                Found in ssg/build_yaml.py - About 2 hrs to fix

                Function get_shell_tasks has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
                Open

                def get_shell_tasks(tasks):
                """
                Find all shell/command module tasks.
                Module can be as FQCN or just short name.
                Both forms, free form and 'cmd:' parameter, are supported.
                Severity: Minor
                Found in utils/ansible_shell_diff.py - About 2 hrs to fix

                Function walk_products has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
                Open

                def walk_products(root, all_products):
                visited_dirs = set()
                 
                all_rule_dirs = []
                product_yamls = {}
                Severity: Minor
                Found in utils/rule_dir_json.py - About 2 hrs to fix

                Function parse_args has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                def parse_args():
                parser = argparse.ArgumentParser()
                 
                common_parser = argparse.ArgumentParser(add_help=False)
                common_parser.set_defaults(test_env=None)
                Severity: Major
                Found in tests/automatus.py - About 2 hrs to fix

                  Function new_stig_overlay has a Cognitive Complexity of 17 (exceeds 7 allowed). Consider refactoring.
                  Open

                  def new_stig_overlay(xccdftree, ssgtree, outfile, quiet):
                  if not ssgtree:
                  ssg_mapping = False
                  else:
                  ssg_mapping = ssg_xccdf_stigid_mapping(ssgtree)
                  Severity: Minor
                  Found in utils/create-stig-overlay.py - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language