Starting a process with a partial executable path Open
call(["docker", "start", "compose_bitcoind_1"])
- Exclude checks
Consider possible security implications associated with call module. Open
from subprocess import call, run, PIPE, STDOUT, DEVNULL
- Exclude checks
Starting a process with a partial executable path Open
tar = run(["tar", "xf", snapshot_path])
- Exclude checks
Starting a process with a partial executable path Open
call(["docker", "exec", "compose_bitcoind_1", "bitcoin-cli", "stop"])
- Exclude checks
Starting a process with a partial executable path Open
openssl_location = run(
["which", "openssl"], stdout=DEVNULL, stderr=DEVNULL
- Exclude checks
subprocess call - check for execution of untrusted input. Open
openssl = run(
["openssl", "dgst", "-sha256", snapshot_path],
stdout=PIPE,
stderr=PIPE,
- Exclude checks
Possible hardcoded password: '' Open
def generate_rpcauth(username, password=""):
"""Generate bitcoind rpcauth string from username and optional password"""
if not password:
password = rpcauth.generate_password()
salt = rpcauth.generate_salt(16)
- Exclude checks
subprocess call - check for execution of untrusted input. Open
shasum = run(
["sha256sum", snapshot_path], stdout=PIPE, stderr=PIPE
- Exclude checks
subprocess call - check for execution of untrusted input. Open
call(["docker", "start", "compose_bitcoind_1"])
- Exclude checks
subprocess call - check for execution of untrusted input. Open
call(["docker", "exec", "compose_bitcoind_1", "bitcoin-cli", "stop"])
- Exclude checks
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code. Open
assert IOError("Corrupt snapshot file")
- Exclude checks
Starting a process with a partial executable path Open
shasum = run(
["sha256sum", snapshot_path], stdout=PIPE, stderr=PIPE
- Exclude checks
Chmod setting a permissive mask 0o755 on file (NOT PARSED). Open
os.chmod(os.path.join(path, directory), 0o755)
- Exclude checks
Starting a process with a partial executable path Open
openssl = run(
["openssl", "dgst", "-sha256", snapshot_path],
stdout=PIPE,
stderr=PIPE,
- Exclude checks
subprocess call - check for execution of untrusted input. Open
openssl_location = run(
["which", "openssl"], stdout=DEVNULL, stderr=DEVNULL
- Exclude checks
subprocess call - check for execution of untrusted input. Open
tar = run(["tar", "xf", snapshot_path])
- Exclude checks
subprocess call - check for execution of untrusted input. Open
download = run(
["axel", "--quiet", "--no-clobber", url],
stdout=PIPE,
stderr=STDOUT,
- Exclude checks
Starting a process with a partial executable path Open
download = run(
["axel", "--quiet", "--no-clobber", url],
stdout=PIPE,
stderr=STDOUT,
- Exclude checks
Function fastsync
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
def fastsync():
"""
Download blocks and chainstate snapshot
:return bool: success status
- Read upRead up
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
Cyclomatic complexity is too high in function set_kv. (8) Open
def set_kv(key, value, config_path):
"""
Set key to value in path
kv pairs are separated by "="
- Read upRead up
- Exclude checks
Cyclomatic Complexity
Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.
Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:
Construct | Effect on CC | Reasoning |
---|---|---|
if | +1 | An if statement is a single decision. |
elif | +1 | The elif statement adds another decision. |
else | +0 | The else statement does not cause a new decision. The decision is at the if. |
for | +1 | There is a decision at the start of the loop. |
while | +1 | There is a decision at the while statement. |
except | +1 | Each except branch adds a new conditional path of execution. |
finally | +0 | The finally block is unconditionally executed. |
with | +1 | The with statement roughly corresponds to a try/except block (see PEP 343 for details). |
assert | +1 | The assert statement internally roughly equals a conditional statement. |
Comprehension | +1 | A list/set/dict comprehension of generator expression is equivalent to a for loop. |
Boolean Operator | +1 | Every boolean operator (and, or) adds a decision point. |
File bitcoind.py
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
bitcoind related functionality
"""
from subprocess import call, run, PIPE, STDOUT, DEVNULL
import os
Cyclomatic complexity is too high in function fastsync. (7) Open
def fastsync():
"""
Download blocks and chainstate snapshot
:return bool: success status
- Read upRead up
- Exclude checks
Cyclomatic Complexity
Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.
Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:
Construct | Effect on CC | Reasoning |
---|---|---|
if | +1 | An if statement is a single decision. |
elif | +1 | The elif statement adds another decision. |
else | +0 | The else statement does not cause a new decision. The decision is at the if. |
for | +1 | There is a decision at the start of the loop. |
while | +1 | There is a decision at the while statement. |
except | +1 | Each except branch adds a new conditional path of execution. |
finally | +0 | The finally block is unconditionally executed. |
with | +1 | The with statement roughly corresponds to a try/except block (see PEP 343 for details). |
assert | +1 | The assert statement internally roughly equals a conditional statement. |
Comprehension | +1 | A list/set/dict comprehension of generator expression is equivalent to a for loop. |
Boolean Operator | +1 | Every boolean operator (and, or) adds a decision point. |
Function set_kv
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def set_kv(key, value, config_path):
"""
Set key to value in path
kv pairs are separated by "="
- Read upRead up
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 check
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check():
"""Check bitcoind filesystem structure"""
bitcoind_dir = "/media/archive/archive/bitcoin"
bitcoind_dir_exists = pathlib.Path(bitcoind_dir).is_dir()
- Read upRead up
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
Refactor this function to reduce its Cognitive Complexity from 54 to the 15 allowed. Open
def fastsync():
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.