ComplianceAsCode/content

View on GitHub
tests/ssg_test_suite/test_env.py

Summary

Maintainability
F
4 days
Test Coverage

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

    ContainerTestEnv has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ContainerTestEnv(TestEnv):
        def __init__(self, scanning_mode, image_name):
            super(ContainerTestEnv, self).__init__(scanning_mode)
            self._name_stem = "ssg_test"
            self.base_image = image_name
    Severity: Minor
    Found in tests/ssg_test_suite/test_env.py - About 2 hrs to fix

      TestEnv has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class TestEnv(object):
          def __init__(self, scanning_mode):
              self.running_state_base = None
              self.running_state = None
      
      
      Severity: Minor
      Found in tests/ssg_test_suite/test_env.py - About 2 hrs to fix

        Remove this commented out code.
        Open

                # self.domain.shutdown()

        Programmers should not comment out code as it bloats programs and reduces readability.

        Unused code should be deleted and can be retrieved from source control history if required.

        See

        • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
        • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
        • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
        • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

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

                try:
                    podman_output = subprocess.check_output(podman_cmd, stderr=subprocess.STDOUT)
                except subprocess.CalledProcessError as e:
                    msg = "Command '{0}' returned {1}:\n{2}".format(
                        " ".join(e.cmd), e.returncode, e.output.decode("utf-8"))
        Severity: Major
        Found in tests/ssg_test_suite/test_env.py and 2 other locations - About 3 hrs to fix
        tests/ssg_test_suite/test_env.py on lines 540..545
        tests/ssg_test_suite/test_env.py on lines 568..573

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

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

                try:
                    podman_output = subprocess.check_output(podman_cmd, stderr=subprocess.STDOUT)
                except subprocess.CalledProcessError as e:
                    msg = "Command '{0}' returned {1}:\n{2}".format(
                        " ".join(e.cmd), e.returncode, e.output.decode("utf-8"))
        Severity: Major
        Found in tests/ssg_test_suite/test_env.py and 2 other locations - About 3 hrs to fix
        tests/ssg_test_suite/test_env.py on lines 554..559
        tests/ssg_test_suite/test_env.py on lines 568..573

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

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

                try:
                    podman_output = subprocess.check_output(podman_cmd, stderr=subprocess.STDOUT)
                except subprocess.CalledProcessError as e:
                    msg = "Command '{0}' returned {1}:\n{2}".format(
                        " ".join(e.cmd), e.returncode, e.output.decode("utf-8"))
        Severity: Major
        Found in tests/ssg_test_suite/test_env.py and 2 other locations - About 3 hrs to fix
        tests/ssg_test_suite/test_env.py on lines 540..545
        tests/ssg_test_suite/test_env.py on lines 554..559

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

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

                    try:
                        subprocess.check_output(podman_cmd, stderr=subprocess.STDOUT)
                    except subprocess.CalledProcessError as e:
                        msg = "Command '{0}' returned {1}:\n{2}".format(
                            " ".join(e.cmd), e.returncode, e.output.decode("utf-8"))
        Severity: Major
        Found in tests/ssg_test_suite/test_env.py and 3 other locations - About 3 hrs to fix
        tests/ssg_test_suite/test_env.py on lines 521..526
        tests/ssg_test_suite/test_env.py on lines 598..603
        tests/ssg_test_suite/test_env.py on lines 607..612

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

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

                try:
                    subprocess.check_output(podman_cmd, stderr=subprocess.STDOUT)
                except subprocess.CalledProcessError as e:
                    msg = "Command '{0}' returned {1}:\n{2}".format(
                        " ".join(e.cmd), e.returncode, e.output.decode("utf-8"))
        Severity: Major
        Found in tests/ssg_test_suite/test_env.py and 3 other locations - About 3 hrs to fix
        tests/ssg_test_suite/test_env.py on lines 591..596
        tests/ssg_test_suite/test_env.py on lines 598..603
        tests/ssg_test_suite/test_env.py on lines 607..612

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

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

                    try:
                        subprocess.check_output(podman_cmd, stderr=subprocess.STDOUT)
                    except subprocess.CalledProcessError as e:
                        msg = "Command '{0}' returned {1}:\n{2}".format(
                            " ".join(e.cmd), e.returncode, e.output.decode("utf-8"))
        Severity: Major
        Found in tests/ssg_test_suite/test_env.py and 3 other locations - About 3 hrs to fix
        tests/ssg_test_suite/test_env.py on lines 521..526
        tests/ssg_test_suite/test_env.py on lines 591..596
        tests/ssg_test_suite/test_env.py on lines 607..612

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

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

                try:
                    subprocess.check_output(podman_cmd, stderr=subprocess.STDOUT)
                except subprocess.CalledProcessError as e:
                    msg = "Command '{0}' returned {1}:\n{2}".format(
                        " ".join(e.cmd), e.returncode, e.output.decode("utf-8"))
        Severity: Major
        Found in tests/ssg_test_suite/test_env.py and 3 other locations - About 3 hrs to fix
        tests/ssg_test_suite/test_env.py on lines 521..526
        tests/ssg_test_suite/test_env.py on lines 591..596
        tests/ssg_test_suite/test_env.py on lines 598..603

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

        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

            def scp_download_file(self, source, destination, log_file, error_msg=None):
                scp_src = "root@{ip}:{source}".format(ip=self.domain_ip, source=source)
                return self.scp_transfer_file(scp_src, destination, log_file, error_msg)
        Severity: Major
        Found in tests/ssg_test_suite/test_env.py and 1 other location - About 1 hr to fix
        tests/ssg_test_suite/test_env.py on lines 147..149

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

        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

            def scp_upload_file(self, source, destination, log_file, error_msg=None):
                scp_dest = "root@{ip}:{dest}".format(ip=self.domain_ip, dest=destination)
                return self.scp_transfer_file(source, scp_dest, log_file, error_msg)
        Severity: Major
        Found in tests/ssg_test_suite/test_env.py and 1 other location - About 1 hr to fix
        tests/ssg_test_suite/test_env.py on lines 143..145

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

        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

            def offline_scan(self, args, verbose_path):
                command_list = self._local_oscap_check_base_arguments() + args
        
                return common.run_cmd_local(command_list, verbose_path)
        Severity: Minor
        Found in tests/ssg_test_suite/test_env.py and 1 other location - About 35 mins to fix
        tests/ssg_test_suite/test_env.py on lines 310..313

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

        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

            def offline_scan(self, args, verbose_path):
                command_list = self._local_oscap_check_base_arguments() + args
        
                return common.run_cmd_local(command_list, verbose_path)
        Severity: Minor
        Found in tests/ssg_test_suite/test_env.py and 1 other location - About 35 mins to fix
        tests/ssg_test_suite/test_env.py on lines 425..428

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

        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

        Continuation line under-indented for visual indent
        Open

                            #   "--privileged",
        Severity: Minor
        Found in tests/ssg_test_suite/test_env.py by pep8

        Continuation lines indentation.

        Continuation lines should align wrapped elements either vertically
        using Python's implicit line joining inside parentheses, brackets
        and braces, or using a hanging indent.
        
        When using a hanging indent these considerations should be applied:
        - there should be no arguments on the first line, and
        - further indentation should be used to clearly distinguish itself
          as a continuation line.
        
        Okay: a = (\n)
        E123: a = (\n    )
        
        Okay: a = (\n    42)
        E121: a = (\n   42)
        E122: a = (\n42)
        E123: a = (\n    42\n    )
        E124: a = (24,\n     42\n)
        E125: if (\n    b):\n    pass
        E126: a = (\n        42)
        E127: a = (24,\n      42)
        E128: a = (24,\n    42)
        E129: if (a or\n    b):\n    pass
        E131: a = (\n    42\n 24)

        There are no issues that match your filters.

        Category
        Status