ComplianceAsCode/content

View on GitHub

Showing 229 of 962 total issues

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

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        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

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        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

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

          def _get_implied_properties(existing_properties):
              result = existing_properties.copy()
              if "pkg_manager" in existing_properties:
                  pkg_manager = existing_properties["pkg_manager"]
                  if "pkg_system" not in existing_properties:
          Severity: Minor
          Found in ssg/products.py - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          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

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          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.
              """
          
              # Ideally oscap would have a command line to do this, but as of now it
          Severity: Minor
          Found in ssg/xccdf.py - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          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 add_reference_elements has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
              Open

              def add_reference_elements(element, references, ref_uri_dict):
                  for ref_type, ref_vals in references.items():
                      for ref_val in ref_vals:
                          # This assumes that a single srg key may have items from multiple SRG types
                          if ref_type == 'srg':
              Severity: Minor
              Found in ssg/build_yaml.py - About 2 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              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

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              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):
                      for dir_item in sorted(os.listdir(guide_directory)):
                          dir_item_path = os.path.join(guide_directory, dir_item)
                          _, extension = os.path.splitext(dir_item)
              
              
              Severity: Minor
              Found in ssg/build_yaml.py - About 2 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              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

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              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

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                def handle_remediations(product_list, product_yamls, rule_obj):
                    rule_dir = rule_obj['dir']
                
                    rule_remediations = {}
                    r_products = defaultdict(set)
                Severity: Minor
                Found in utils/rule_dir_json.py - About 1 hr to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                def preprocess(data, lang):
                    data["zero_comparison_operation"] = data.get("zero_comparison_operation", None)
                
                    if "greater" in data["operation"]:
                        if data["zero_comparison_operation"]:
                Severity: Minor
                Found in shared/templates/accounts_password/template.py - About 1 hr to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Severity
                Category
                Status
                Source
                Language