ComplianceAsCode/content

View on GitHub

Showing 1,039 of 1,039 total issues

Function compose_ds has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

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

        def __init__(self, env_yaml, resolved_rules_dir, templates_dir,
    Severity: Major
    Found in ssg/templates.py - About 50 mins to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      Severity: Minor
      Found in shared/templates/file_existence/template.py and 1 other location - About 50 mins to fix
      shared/templates/auditd_lineinfile/template.py on lines 0..6

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 36.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              for cpe_name in self.cpe_names:
                  plat = ET.SubElement(element, "{%s}platform" % XCCDF12_NS)
                  plat.set("idref", cpe_name)
      Severity: Minor
      Found in ssg/entities/profile_base.py and 1 other location - About 50 mins to fix
      ssg/build_yaml.py on lines 457..459

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 36.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      Severity: Minor
      Found in shared/templates/auditd_lineinfile/template.py and 1 other location - About 50 mins to fix
      shared/templates/file_existence/template.py on lines 0..6

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 36.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              for entry in self.sce_metadata['check-import']:
                  check_import = ET.SubElement(
                      sce_check, '{%s}check-import' % XCCDF12_NS)
                  check_import.set('import-name', entry)
                  check_import.text = None
      Severity: Minor
      Found in ssg/build_yaml.py and 1 other location - About 50 mins to fix
      ssg/build_yaml.py on lines 145..148

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 36.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              for cpe_name in self.product_cpe_names:
                  plat = ET.SubElement(root, "{%s}platform" % XCCDF12_NS)
                  plat.set("idref", cpe_name)
      Severity: Minor
      Found in ssg/build_yaml.py and 1 other location - About 50 mins to fix
      ssg/entities/profile_base.py on lines 135..137

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 36.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          for title, uri in ref_uri_dict.items():
              reference = ET.SubElement(benchmark_el, "{%s}reference" % XCCDF12_NS)
              reference.set("href", uri)
              reference.text = title
      Severity: Minor
      Found in ssg/build_yaml.py and 1 other location - About 50 mins to fix
      ssg/build_yaml.py on lines 1258..1262

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 36.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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 j < i:
                                  i -= 1
                              continue
      Severity: Major
      Found in ssg/ext/boolean/boolean.py - About 45 mins to fix

        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

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

            def main():
                options, args = parse_args()
            
                if options.centos:
                    mapping = ssg.constants.RHEL_CENTOS_CPE_MAPPING
            Severity: Minor
            Found in build-scripts/enable_derivatives.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_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 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

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

            def is_applicable_for_product(platform, product):
                """
                Determines if a remediation script is applicable for a given product based on the platform specifier.
            
                The function checks if the platform is either a general multi-platform specifier or matches
            Severity: Minor
            Found in ssg/utils.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 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 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

                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 TRACE_PARSE: print('ast9:', repr(ast))
                                          ast = ast[0]
                  Severity: Major
                  Found in ssg/ext/boolean/boolean.py - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language