ComplianceAsCode/content

View on GitHub

Showing 229 of 962 total issues

File test_env.py has 482 lines of code (exceeds 400 allowed). Consider refactoring.
Open

from __future__ import print_function

import contextlib
import json
import logging
Severity: Minor
Found in tests/ssg_test_suite/test_env.py - About 4 hrs to fix

    Function get_profile_stats has a Cognitive Complexity of 28 (exceeds 7 allowed). Consider refactoring.
    Open

        def get_profile_stats(self, profile):
            """Obtain statistics for the profile"""
    
            # Holds the intermediary statistics for profile
            profile_stats = {
    Severity: Minor
    Found in ssg/build_profile.py - About 3 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 remove_idents has a Cognitive Complexity of 28 (exceeds 7 allowed). Consider refactoring.
    Open

    def remove_idents(tree_root, namespace, prod="RHEL"):
        """
        Remove product identifiers from rules in XML tree
        """
    
    
    Severity: Minor
    Found in ssg/build_derivatives.py - About 3 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

    Rule has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Rule(XCCDFEntity, Templatable):
        """Represents XCCDF Rule
        """
        KEYS = dict(
            description=lambda: "",
    Severity: Minor
    Found in ssg/build_yaml.py - About 3 hrs to fix

      File build_remediations.py has 469 lines of code (exceeds 400 allowed). Consider refactoring.
      Open

      from __future__ import absolute_import
      from __future__ import print_function
      
      import sys
      import os
      Severity: Minor
      Found in ssg/build_remediations.py - About 3 hrs to fix

        File controls.py has 468 lines of code (exceeds 400 allowed). Consider refactoring.
        Open

        import collections
        import os
        import copy
        from glob import glob
        
        
        Severity: Minor
        Found in ssg/controls.py - About 3 hrs to fix

          Function translate has a Cognitive Complexity of 27 (exceeds 7 allowed). Consider refactoring.
          Open

              def translate(self, tree, store_defname=False):
                  for element in tree.iter():
                      idname = element.get("id")
                      if idname:
                          # store the old name if requested (for OVAL definitions)
          Severity: Minor
          Found in ssg/id_translate.py - About 3 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 sort_section_keys has a Cognitive Complexity of 27 (exceeds 7 allowed). Consider refactoring.
          Open

          def sort_section_keys(file_path, file_contents, sections, sort_func=None):
              """
              Sort subkeys in a YAML file's section.
              """
          
          
          Severity: Minor
          Found in ssg/rule_yaml.py - About 3 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 createPlatformRuleFunc has a Cognitive Complexity of 26 (exceeds 7 allowed). Consider refactoring.
          Open

          def createPlatformRuleFunc(args):
              url = args.url
              retries = 0
              namespace_flag = ''
              if args.namespace is not None:
          Severity: Minor
          Found in utils/add_kubernetes_rule.py - About 3 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

          Benchmark has 27 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Benchmark(XCCDFEntity):
              """Represents XCCDF Benchmark
              """
              KEYS = dict(
                  status=lambda: "",
          Severity: Minor
          Found in ssg/build_yaml.py - About 3 hrs to fix

            RuleChecker has 27 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class RuleChecker(oscap.Checker):
                """
                Rule checks generally work like this -
                for every profile that supports that rule:
            
            
            Severity: Minor
            Found in tests/ssg_test_suite/rule.py - About 3 hrs to fix

              Function move_patches_up_to_date_to_source_data_stream_component has a Cognitive Complexity of 23 (exceeds 7 allowed). Consider refactoring.
              Open

              def move_patches_up_to_date_to_source_data_stream_component(datastreamtree):
                  ds_checklists = datastreamtree.find(
                      ".//{%s}checklists" % datastream_namespace)
                  checklists_component_ref = ds_checklists.find(
                      "{%s}component-ref" % datastream_namespace)
              Severity: Minor
              Found in build-scripts/compose_ds.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 has_duplicated_subkeys has a Cognitive Complexity of 23 (exceeds 7 allowed). Consider refactoring.
              Open

              def has_duplicated_subkeys(file_path, file_contents, sections):
                  """
                  Checks whether a section has duplicated keys. Note that these are silently
                  eaten by the YAML parser we use.
                  """
              Severity: Minor
              Found in ssg/rule_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_rules_parallel has a Cognitive Complexity of 23 (exceeds 7 allowed). Consider refactoring.
              Open

              def walk_rules_parallel(args, left_rules, right_rules, oval_func, remediation_func):
                  """
                  Walks two sets of known_rules (left_rules and right_rules) with identical
                  keys and returns left_only, right_only, and common_only output from
                  _walk_rule. If the outputted data for a rule when called on left_rules and
              Severity: Minor
              Found in ssg/rule_dir_stats.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 determine_ip has a Cognitive Complexity of 23 (exceeds 7 allowed). Consider refactoring.
              Open

              def determine_ip(domain):
                  GUEST_AGENT_XML = ("<channel type='unix'>"
                                     "  <source mode='bind'/>"
                                     "  <target type='virtio'"
                                     "          name='org.qemu.guest_agent.0'"
              Severity: Minor
              Found in tests/ssg_test_suite/virt.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 constants.py has 434 lines of code (exceeds 400 allowed). Consider refactoring.
              Open

              from __future__ import absolute_import
              from __future__ import print_function
              
              import os.path
              import os
              Severity: Minor
              Found in ssg/constants.py - About 2 hrs to fix

                File automatus.py has 434 lines of code (exceeds 400 allowed). Consider refactoring.
                Open

                #!/usr/bin/python3
                from __future__ import print_function
                
                import argparse
                import contextlib
                Severity: Minor
                Found in tests/automatus.py - About 2 hrs to fix

                  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 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

                    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 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

                    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