ComplianceAsCode/content

View on GitHub

Showing 229 of 962 total issues

Function _get_rules_variables has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
Open

    def _get_rules_variables(self, base_dir):
        for dirpath, dirnames, filenames in os.walk(base_dir):
            dirnames.sort()
            filenames.sort()
            for filename in filenames:
Severity: Minor
Found in ssg/playbook_builder.py - About 45 mins 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_profileruleids has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
Open

def get_profileruleids(xccdftree, profile_name):
    ruleids = []

    while profile_name:
        profile = None
Severity: Minor
Found in build-scripts/verify_references.py - About 45 mins 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

Avoid deeply nested control flow statements.
Open

                    if subkey_counts[our_key] > 1:
                        print("Duplicated key " + our_key + " in " + section + " of " + file_path)
                        return True

Severity: Major
Found in ssg/rule_yaml.py - About 45 mins to fix

    Function get_all_resolved_profiles_by_id has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def get_all_resolved_profiles_by_id(
    Severity: Minor
    Found in build-scripts/compile_all.py - About 45 mins to fix

      Function compare_platforms has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
      Open

          def compare_platforms(self, old_rule, new_rule, old_benchmark, new_benchmark, identifier):
              entries = [{
                      "benchmark": old_benchmark,
                      "rule": old_rule,
                      "cpe": []
      Severity: Minor
      Found in ssg/content_diff.py - About 45 mins 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

      Avoid deeply nested control flow statements.
      Open

                              if TRACE_PARSE: print('ast10:', repr(ast))
                              break
      Severity: Major
      Found in ssg/ext/boolean/boolean.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if negated is None:
                                    negated = arg
                                else:
                                    negated = None
                                    break
        Severity: Major
        Found in ssg/ext/boolean/boolean.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if arg in target.args:
                                      pass
                                  elif narg in target.args:
                                      if remove is None:
                                          remove = narg
          Severity: Major
          Found in ssg/ext/boolean/boolean.py - About 45 mins to fix

            Function get_rule_dir_remediations has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
            Open

            def get_rule_dir_remediations(dir_path, remediation_type, product=None):
                """
                Gets a list of remediations of type remediation_type contained in a
                rule directory. If product is None, returns all such remediations.
                If product is not None, returns applicable remediations in order of
            Severity: Minor
            Found in ssg/build_remediations.py - About 45 mins 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

            Avoid deeply nested control flow statements.
            Open

                                if our_line:
                                    # Not supposed to be possible to have multiple keys
                                    # matching the same value in this file. We should've
                                    # already fixed this with fix-rules.py's duplicate_subkeys.
                                    msg = "File {0} has duplicated key {1}: {2} vs {3}"
            Severity: Major
            Found in ssg/rule_yaml.py - About 45 mins to fix

              Function which has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
              Open

              def which(program):
                  fpath, fname = os.path.split(program)
                  if fpath:
                      if os.path.isfile(fpath) and os.access(fpath, os.X_OK):
                          return program
              Severity: Minor
              Found in utils/add_kubernetes_rule.py - About 45 mins 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 compose_ds has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def compose_ds(
              Severity: Minor
              Found in build-scripts/compose_ds.py - About 45 mins to fix

                Function get_rule_dir_sces has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
                Open

                def get_rule_dir_sces(dir_path, product=None):
                    """
                    Get a list of SCEs contained in a rule directory. If product is None,
                    returns all SCEs. If product is not None, returns applicable SCEs in
                    order of priority:
                Severity: Minor
                Found in ssg/rules.py - About 45 mins 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

                Avoid deeply nested control flow statements.
                Open

                                    if not ref.text.startswith("SRG-"):
                                        rhid.append(ref.text)
                                    else:
                                        srgs.append(ref.text)
                            for id in rhid:
                Severity: Major
                Found in utils/create-stig-overlay.py - About 45 mins to fix

                  Function create_tailoring has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
                  Open

                  def create_tailoring(args):
                      benchmark_root = ET.parse(args.manual).getroot()
                      known_rules = get_implemented_stigs(args.product, args.root, args.build_config_yaml,
                                                          args.reference, args.json, args.resolved_rules_dir,
                                                          args.build_root)
                  Severity: Minor
                  Found in utils/create_scap_delta_tailoring.py - About 45 mins 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(self, product_yaml_path, input_dir, output_dir, rules_dir, profiles_dir,
                  Severity: Minor
                  Found in ssg/playbook_builder.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if nonempty_line and file_contents[line_num][0] != ' ':
                                            break
                                        line_num += 1
                    Severity: Major
                    Found in ssg/rule_yaml.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if TRACE_PARSE: print('ast9:', repr(ast))
                                              ast = ast[0]
                      Severity: Major
                      Found in ssg/ext/boolean/boolean.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if len(file_contents[line_num]) > 0 and file_contents[line_num][0] != ' ':
                                                break
                                            line_num += 1
                        Severity: Major
                        Found in utils/fix_rules.py - About 45 mins to fix

                          Function add_platform_to_benchmark has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
                          Open

                          def add_platform_to_benchmark(root, cpe_regex):
                              benchmark_query = ".//ds:component/xccdf-1.2:Benchmark"
                              benchmarks = root.findall(benchmark_query, PREFIX_TO_NS)
                              if not benchmarks:
                                  msg = (
                          Severity: Minor
                          Found in tests/ssg_test_suite/xml_operations.py - About 45 mins 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