datalad/datalad-container

View on GitHub
datalad_container/adapters/docker.py

Summary

Maintainability
A
1 hr
Test Coverage

Consider possible security implications associated with subprocess module.
Open

import subprocess as sp

subprocess call - check for execution of untrusted input.
Open

    sp.check_call(cmd)

subprocess call - check for execution of untrusted input.
Open

    out = sp.check_output(
        ["docker", "images", "--all", "--quiet", "--no-trunc"])

Starting a process with a partial executable path
Open

        sp.check_call(["docker", "save", "-o", stream.name, image])

subprocess call - check for execution of untrusted input.
Open

        sp.check_call(["docker", "save", "-o", stream.name, image])

Probable insecure usage of temp file/directory.
Open

    prefix = ["docker", "run",
              # FIXME: The -v/-w settings are convenient for testing, but they
              # should be configurable.
              "-v", "{}:/tmp".format(os.getcwd()),
              "-w", "/tmp",
Severity: Minor
Found in datalad_container/adapters/docker.py by bandit

subprocess call - check for execution of untrusted input.
Open

        p = sp.Popen(cmd, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE)

Starting a process with a partial executable path
Open

    out = sp.check_output(
        ["docker", "images", "--all", "--quiet", "--no-trunc"])

Function save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def save(image, path):
    """Save and extract a docker image to a directory.

    Parameters
    ----------
Severity: Minor
Found in datalad_container/adapters/docker.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 safe_extract has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

            def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
Severity: Minor
Found in datalad_container/adapters/docker.py - About 35 mins to fix

    There are no issues that match your filters.

    Category
    Status