avocado-framework/avocado

View on GitHub
selftests/functional/test_output.py

Summary

Maintainability
D
2 days
Test Coverage

Using xml.dom.minidom.parse to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.dom.minidom.parse with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
Open

        minidom.parse(tmpfile)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Using xml.dom.minidom.parse to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.dom.minidom.parse with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
Open

        minidom.parse(tmpfile)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Use of insecure and deprecated function (mktemp).
Open

        tmpfile = tempfile.mktemp(dir=self.tmpdir.name)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Using xml.dom.minidom.parseString to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.dom.minidom.parseString with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
Open

        minidom.parseString(result.stdout_text)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Use of insecure and deprecated function (mktemp).
Open

        tmpfile2 = tempfile.mktemp(dir=self.tmpdir.name)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Function call with shell=True parameter identified, possible security issue.
Open

        result = process.run(cmd_line, ignore_status=True, shell=True)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Use of insecure and deprecated function (mktemp).
Open

        tmpfile = tempfile.mktemp(dir=self.tmpdir.name)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Use of insecure and deprecated function (mktemp).
Open

        redirected_output_path = tempfile.mktemp(dir=self.tmpdir.name)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Use of insecure and deprecated function (mktemp).
Open

        tmpfile = tempfile.mktemp(dir=self.tmpdir.name)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Function call with shell=True parameter identified, possible security issue.
Open

        result = process.run(cmd_line, shell=True, ignore_status=True,
                             env={"LC_ALL": "C"})
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Use of insecure and deprecated function (mktemp).
Open

        tmpfile = tempfile.mktemp(dir=self.tmpdir.name)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Using minidom to parse untrusted XML data is known to be vulnerable to XML attacks. Replace minidom with the equivalent defusedxml package, or make sure defusedxml.defuse_stdlib() is called.
Open

from xml.dom import minidom

Using xml.dom.minidom.parse to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.dom.minidom.parse with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
Open

            minidom.parse(xunit_output_path)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

Starting a process with a partial executable path
Open

    return os.system("perl -e 'use TAP::Parser;'") != 0

Starting a process with a shell: Seems safe, but may be changed in the future, consider rewriting without shell
Open

    return os.system("perl -e 'use TAP::Parser;'") != 0

Use of insecure and deprecated function (mktemp).
Open

        tmpfile = tempfile.mktemp(dir=self.tmpdir.name)
Severity: Minor
Found in selftests/functional/test_output.py by bandit

File test_output.py has 548 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import os
import re
import shlex
import tempfile
Severity: Major
Found in selftests/functional/test_output.py - About 1 day to fix

    Function _check_output has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _check_output(self, path, exps):
            i = 0
            end = len(exps)
            with open(path, 'rb') as output_file:
                output_file_content = output_file.read()
    Severity: Minor
    Found in selftests/functional/test_output.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

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

        @unittest.skipIf(perl_tap_parser_uncapable(),
                         "Uncapable of using Perl TAP::Parser library")
        def test_tap_parser(self):
            with script.TemporaryScript(
                    "tap_parser.pl",
    Severity: Major
    Found in selftests/functional/test_output.py and 1 other location - About 2 hrs to fix
    selftests/functional/test_output.py on lines 594..601

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

    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

        @unittest.skipIf(perl_tap_parser_uncapable(),
                         "Uncapable of using Perl TAP::Parser library")
        def test_tap_parser_failfast(self):
            with script.TemporaryScript(
                    "tap_parser.pl",
    Severity: Major
    Found in selftests/functional/test_output.py and 1 other location - About 2 hrs to fix
    selftests/functional/test_output.py on lines 585..592

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

    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

            with open(tmpfile, 'r') as fp:
                json_results = json.load(fp)
                debug_log = json_results['debuglog']
                self.check_output_files(debug_log)
    Severity: Major
    Found in selftests/functional/test_output.py and 1 other location - About 1 hr to fix
    selftests/functional/test_output.py on lines 485..488

    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

            with open(tmpfile2, 'r') as fp:
                json_results = json.load(fp)
                debug_log = json_results['debuglog']
                self.check_output_files(debug_log)
    Severity: Major
    Found in selftests/functional/test_output.py and 1 other location - About 1 hr to fix
    selftests/functional/test_output.py on lines 463..466

    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

            with open(os.path.join(testdir, "stdout"), 'rb') as stdout_file:
                expected = b"top_print\n\ntop_stdout\ninit_print\n\ninit_stdout\ntest_print\n\ntest_stdout\n"
                self.assertEqual(expected, stdout_file.read())
    Severity: Major
    Found in selftests/functional/test_output.py and 1 other location - About 1 hr to fix
    selftests/functional/test_output.py on lines 278..280

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

    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

            with open(os.path.join(testdir, "stderr"), 'rb') as stderr_file:
                expected = b"top_stderr\ninit_stderr\ntest_stderr\n"
                self.assertEqual(expected, stderr_file.read())
    Severity: Major
    Found in selftests/functional/test_output.py and 1 other location - About 1 hr to fix
    selftests/functional/test_output.py on lines 275..277

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

    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

    There are no issues that match your filters.

    Category
    Status