ComplianceAsCode/content

View on GitHub

Showing 1,039 of 1,039 total issues

Avoid too many return statements within this function.
Open

                        return self.__class__(*args).simplify()
Severity: Major
Found in ssg/ext/boolean/boolean.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return current_status
    Severity: Major
    Found in utils/compare_results.py - About 30 mins to fix

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

          def initial(self):
              self.command_options += ['--results-arf', self.arf_path]
              return super(AnsibleRuleRunner, self).initial()
      Severity: Major
      Found in tests/ssg_test_suite/oscap.py and 3 other locations - About 30 mins to fix
      tests/ssg_test_suite/oscap.py on lines 599..601
      tests/ssg_test_suite/oscap.py on lines 615..617
      tests/ssg_test_suite/oscap.py on lines 639..641

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

      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

      Avoid too many return statements within this function.
      Open

                      return False
      Severity: Major
      Found in tests/ssg_test_suite/rule.py - About 30 mins to fix

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

                obj = "'%s'" % self.obj if isinstance(self.obj, basestring) else repr(self.obj)
        Severity: Minor
        Found in ssg/ext/boolean/boolean.py and 1 other location - About 30 mins to fix
        ssg/ext/boolean/boolean.py on lines 923..923

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

        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 4 locations. Consider refactoring.
        Open

            def initial(self):
                self.command_options += ['--results-arf', self.arf_path]
                return super(BashRuleRunner, self).initial()
        Severity: Major
        Found in tests/ssg_test_suite/oscap.py and 3 other locations - About 30 mins to fix
        tests/ssg_test_suite/oscap.py on lines 599..601
        tests/ssg_test_suite/oscap.py on lines 615..617
        tests/ssg_test_suite/oscap.py on lines 653..655

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

        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

        Avoid too many return statements within this function.
        Open

                        return self._final_scan_went_ok(runner, rule_id)
        Severity: Major
        Found in tests/ssg_test_suite/rule.py - About 30 mins to fix

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

              def initial(self):
                  self.command_options += ['--results-arf', self.arf_path]
                  return super(AnsibleProfileRunner, self).initial()
          Severity: Major
          Found in tests/ssg_test_suite/oscap.py and 3 other locations - About 30 mins to fix
          tests/ssg_test_suite/oscap.py on lines 615..617
          tests/ssg_test_suite/oscap.py on lines 639..641
          tests/ssg_test_suite/oscap.py on lines 653..655

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

          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

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

              if not get_file_remote(test_env, verbose_path, LogHelper.LOG_DIR,
                                     '/' + formatting['output_file']):
                  return False
          Severity: Minor
          Found in tests/ssg_test_suite/oscap.py and 1 other location - About 30 mins to fix
          tests/ssg_test_suite/oscap.py on lines 140..142

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

          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 4 locations. Consider refactoring.
          Open

              def initial(self):
                  self.command_options += ['--results-arf', self.arf_path]
                  return super(BashProfileRunner, self).initial()
          Severity: Major
          Found in tests/ssg_test_suite/oscap.py and 3 other locations - About 30 mins to fix
          tests/ssg_test_suite/oscap.py on lines 599..601
          tests/ssg_test_suite/oscap.py on lines 639..641
          tests/ssg_test_suite/oscap.py on lines 653..655

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

          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

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

                  obj = "'%s'" % self.obj if isinstance(self.obj, basestring) else repr(self.obj)
          Severity: Minor
          Found in ssg/ext/boolean/boolean.py and 1 other location - About 30 mins to fix
          ssg/ext/boolean/boolean.py on lines 934..934

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

          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

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

              if not get_file_remote(test_env, verbose_path, LogHelper.LOG_DIR,
                                     '/' + formatting['output_file']):
                  return False
          Severity: Minor
          Found in tests/ssg_test_suite/oscap.py and 1 other location - About 30 mins to fix
          tests/ssg_test_suite/oscap.py on lines 189..191

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

          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

              if '<' in start_line[1:]:
                  raise ValueError("Malformed OVAL file: line with starting affected "
                                   "tag contains other elements: line:%s\n%s\n\n" %
                                   (start_line, oval_contents))
          Severity: Minor
          Found in ssg/oval.py and 1 other location - About 30 mins to fix
          ssg/oval.py on lines 153..156

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

          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

              if '<' in end_line[1:]:
                  raise ValueError("Malformed OVAL file: line with ending affected "
                                   "tag contains other elements: line:%s\n%s\n\n" %
                                   (end_line, oval_contents))
          Severity: Minor
          Found in ssg/oval.py and 1 other location - About 30 mins to fix
          ssg/oval.py on lines 138..141

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

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

          def get_ovalfiles(checks):
              global exit_value
              # Iterate over all checks, grab the OVAL files referenced within
              ovalfiles = set()
              for check in checks:
          Severity: Minor
          Found in build-scripts/verify_references.py - About 25 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 a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
          Open

              def __init__(self, rule, cis_ns):
                  self.id = rule.get("id")
                  self.oval = rule.find('./{%s}check[@system="%s"]' % (XCCDF12_NS, oval_ns))
                  self.sce = rule.find('./{%s}check[@system="%s"]' % (XCCDF12_NS, sce_ns))
                  self.bash_fix = rule.find('./{%s}fix[@system="%s"]' % (XCCDF12_NS, bash_rem_system))
          Severity: Minor
          Found in ssg/build_profile.py - About 25 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 main has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
          Open

          def main():
              args = parse_args()
          
              input_path, input_basename, path_base, output_dir = \
                  ssg.build_guides.get_path_args(args)
          Severity: Minor
          Found in build-scripts/build_all_guides.py - About 25 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_data_from_snippet has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
          Open

              def get_data_from_snippet(self, snippet_yaml, variables, refinements):
                  """
                  Extracts and resolves tasks and variables from Ansible snippet.
                  """
                  xccdf_var_pattern = re.compile(r"\(xccdf-var\s+(\S+)\)")
          Severity: Minor
          Found in ssg/playbook_builder.py - About 25 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 product_names_remediation has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
          Open

          def product_names_remediation(rule_obj, r_type):
              """
              Checks the consistency between the scope of platforms and the product names of the
              remediations of a given type for a rule object.
          
          
          Severity: Minor
          Found in ssg/rule_dir_stats.py - About 25 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 main has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
          Open

          def main():
              args = parse_args()
              product_yaml = os.path.join(args.ssg_root, "products", args.product, "product.yml")
              if args.input_dir:
                  input_dir = args.input_dir
          Severity: Minor
          Found in build-scripts/build_rule_playbooks.py - About 25 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