ComplianceAsCode/content

View on GitHub

Showing 231 of 1,039 total issues

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.

    Only returns SCEs which exist.
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

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

def shorten_relevant_ref(ref_format, ref):
    match = re.match(ref_format, ref)
    if match:
        groups = []
        for refpart in match.groups():
Severity: Minor
Found in utils/tables/table_renderer.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 has_invalid_cce has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
Open

def has_invalid_cce(rule_path, rule, rule_lines):
    if 'identifiers' in rule and rule['identifiers'] is not None:
        for i_type, i_value in rule['identifiers'].items():
            if i_type[0:3] == 'cce':
                if not cce.is_cce_value_valid("CCE-" + str(i_value)):
Severity: Minor
Found in utils/fix_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

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

def fix_file_prompt(path, product_yaml, func, args):
    file_contents = open(path, 'r').read().split("\n")

    new_file_contents = _fixed_file_contents(path, file_contents, product_yaml, func)
    changes = file_contents != new_file_contents
Severity: Minor
Found in utils/fix_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

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

    def __init__(
Severity: Minor
Found in utils/oscal/cd_generator.py - About 45 mins to fix

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

    def fix_prefix_cce(file_contents, yaml_contents):
        section = 'identifiers'
    
        prefixed_identifiers = []
    
    
    Severity: Minor
    Found in utils/fix_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 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

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

      def reboot_domain(domain, domain_ip, ssh_port):
          timeout = 300           # Timeout for domain shutdown and boot.
          connection_timeout = 5  # Timeout on the socket before attempting to connect.
      
          logging.debug("Shutting down domain '{0}'".format(domain.name()))
      Severity: Minor
      Found in tests/ssg_test_suite/virt.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 fix_invalid_cce has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
      Open

      def fix_invalid_cce(file_contents, yaml_contents):
          section = 'identifiers'
      
          invalid_identifiers = []
      
      
      Severity: Minor
      Found in utils/fix_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

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

      def gather_profiles_from_datastream(path, build_dir, profiles_per_benchmark):
          input_tree = ssg.xml.ElementTree.parse(path)
          benchmarks = ssg.xccdf.get_benchmark_id_title_map(input_tree)
          if len(benchmarks) == 0:
              raise RuntimeError(
      Severity: Minor
      Found in tests/stable_profile_ids.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 _handle_parts has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
      Open

          def _handle_parts(
              self,
              control: TypeWithParts,
          ) -> None:
              """Handle parts of a control."""
      Severity: Minor
      Found in utils/oscal/cd_generator.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 map_symbolic_permissions has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
      Open

      def map_symbolic_permissions(filemode, allow_stricter_permissions):
          mode_int = int(filemode, 8)
          fields = [
              ('o', 'x'), ('o', 'w'), ('o', 'r'),
              ('g', 'x'), ('g', 'w'), ('g', 'r'),
      Severity: Minor
      Found in shared/templates/file_permissions/template.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 compare_ocils has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def compare_ocils(self, old_ocil_doc, old_ocil_id, new_ocil_doc, new_ocil_id, identifier):
      Severity: Minor
      Found in ssg/content_diff.py - About 35 mins to fix

        Function walk_rules_parallel has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def walk_rules_parallel(args, left_rules, right_rules, oval_func, remediation_func):
        Severity: Minor
        Found in ssg/rule_dir_stats.py - About 35 mins to fix

          Function find_remediation has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def find_remediation(
          Severity: Minor
          Found in build-scripts/collect_remediations.py - About 35 mins to fix

            Function load_resolve_and_validate_profiles has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

              Function build_index has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def build_index(benchmarks, input_basename, index_links, index_options,
              Severity: Minor
              Found in ssg/build_guides.py - About 35 mins to fix

                Function render_policy has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def render_policy(
                Severity: Minor
                Found in utils/render_all_policies.py - About 35 mins to fix

                  Function handle_rule_yaml has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def handle_rule_yaml(product, rule_id, rule_dir, guide_dir, env_yaml):
                  Severity: Minor
                  Found in utils/create_scap_delta_tailoring.py - About 35 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language