Code Quality #2192

Merged
anand-skss merged 1 commits from code-quality into v0.6 2024-03-06 01:38:22 +01:00
11 changed files with 21 additions and 21 deletions

View File

@ -1372,7 +1372,7 @@ class singleWorker(StoppableThread):
if apiNotifyPath: if apiNotifyPath:
# There is no additional risk of remote exploitation or # There is no additional risk of remote exploitation or
# privilege escalation # privilege escalation
call([apiNotifyPath, "newMessage"]) # nosec:B603 call([apiNotifyPath, "newMessage"]) # nosec B603
def requestPubKey(self, toAddress): def requestPubKey(self, toAddress):
"""Send a getpubkey object""" """Send a getpubkey object"""

View File

@ -287,7 +287,7 @@ def check_openssl():
path = ctypes.util.find_library('ssl') path = ctypes.util.find_library('ssl')
if path not in paths: if path not in paths:
paths.append(path) paths.append(path)
except: # nosec:B110 # pylint:disable=bare-except except: # nosec B110 # pylint:disable=bare-except
pass pass
openssl_version = None openssl_version = None
@ -361,7 +361,7 @@ def check_curses():
return False return False
try: try:
subprocess.check_call(['which', 'dialog']) # nosec:B603, B607 subprocess.check_call(['which', 'dialog']) # nosec B603, B607
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
logger.error( logger.error(
'Curses requires the `dialog` command to be installed as well as' 'Curses requires the `dialog` command to be installed as well as'

View File

@ -610,7 +610,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
'Closed connection to %s because we are already' 'Closed connection to %s because we are already'
' connected to that IP.', self.destination) ' connected to that IP.', self.destination)
return False return False
except Exception: # nosec:B110 # pylint:disable=broad-exception-caught except Exception: # nosec B110 # pylint:disable=broad-exception-caught
pass pass
if not self.isOutbound: if not self.isOutbound:
# incoming from a peer we're connected to as outbound, # incoming from a peer we're connected to as outbound,

View File

@ -78,7 +78,7 @@ class InvThread(StoppableThread):
if connection == Dandelion().objectChildStem(inv[1]): if connection == Dandelion().objectChildStem(inv[1]):
# Fluff trigger by RNG # Fluff trigger by RNG
# auto-ignore if config set to 0, i.e. dandelion is off # auto-ignore if config set to 0, i.e. dandelion is off
if random.randint(1, 100) >= state.dandelion: # nosec:B311 if random.randint(1, 100) >= state.dandelion: # nosec B311
fluffs.append(inv[1]) fluffs.append(inv[1])
# send a dinv only if the stem node supports dandelion # send a dinv only if the stem node supports dandelion
elif connection.services & protocol.NODE_DANDELION > 0: elif connection.services & protocol.NODE_DANDELION > 0:

View File

@ -25,17 +25,17 @@ class BMNetworkThread(StoppableThread):
for i in BMConnectionPool().listeningSockets.values(): for i in BMConnectionPool().listeningSockets.values():
try: try:
i.close() i.close()
except: # nosec:B110 # pylint:disable=bare-except except: # nosec B110 # pylint:disable=bare-except
pass pass
for i in BMConnectionPool().outboundConnections.values(): for i in BMConnectionPool().outboundConnections.values():
try: try:
i.close() i.close()
except: # nosec:B110 # pylint:disable=bare-except except: # nosec B110 # pylint:disable=bare-except
pass pass
for i in BMConnectionPool().inboundConnections.values(): for i in BMConnectionPool().inboundConnections.values():
try: try:
i.close() i.close()
except: # nosec:B110 # pylint:disable=bare-except except: # nosec B110 # pylint:disable=bare-except
pass pass
# just in case # just in case

View File

@ -47,7 +47,7 @@ def initCL():
device_type=cl.device_type.GPU)) device_type=cl.device_type.GPU))
if platform.vendor not in vendors: if platform.vendor not in vendors:
vendors.append(platform.vendor) vendors.append(platform.vendor)
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except except: # nosec B110 # noqa:E722 # pylint:disable=bare-except
pass pass
if enabledGpus: if enabledGpus:
ctx = cl.Context(devices=enabledGpus) ctx = cl.Context(devices=enabledGpus)

View File

@ -11,14 +11,14 @@ try:
winsound.PlaySound(sound_file, winsound.SND_FILENAME) winsound.PlaySound(sound_file, winsound.SND_FILENAME)
except ImportError: except ImportError:
import os import os
import subprocess # nosec:B404 import subprocess # nosec B404
play_cmd = {} play_cmd = {}
def _subprocess(*args): def _subprocess(*args):
FNULL = open(os.devnull, 'wb') FNULL = open(os.devnull, 'wb')
subprocess.call( subprocess.call(
args, stdout=FNULL, stderr=subprocess.STDOUT, close_fds=True) # nosec:B603 args, stdout=FNULL, stderr=subprocess.STDOUT, close_fds=True) # nosec B603
def connect_plugin(sound_file): def connect_plugin(sound_file):
"""This function implements the entry point.""" """This function implements the entry point."""

View File

@ -10,7 +10,7 @@ import sys
import tempfile import tempfile
import time import time
from struct import pack, unpack from struct import pack, unpack
from subprocess import call # nosec:B404 from subprocess import call # nosec B404
import openclpow import openclpow
import paths import paths
@ -82,7 +82,7 @@ def _set_idle():
pid = win32api.GetCurrentProcessId() pid = win32api.GetCurrentProcessId()
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid) handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
win32process.SetPriorityClass(handle, win32process.IDLE_PRIORITY_CLASS) win32process.SetPriorityClass(handle, win32process.IDLE_PRIORITY_CLASS)
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except except: # nosec B110 # noqa:E722 # pylint:disable=bare-except
# Windows 64-bit # Windows 64-bit
pass pass
@ -135,7 +135,7 @@ def _doFastPoW(target, initialHash):
try: try:
pool.terminate() pool.terminate()
pool.join() pool.join()
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except except: # nosec B110 # noqa:E722 # pylint:disable=bare-except
pass pass
raise StopIteration("Interrupted") raise StopIteration("Interrupted")
for i in range(pool_size): for i in range(pool_size):
@ -298,14 +298,14 @@ def run(target, initialHash):
return _doGPUPoW(target, initialHash) return _doGPUPoW(target, initialHash)
except StopIteration: except StopIteration:
raise raise
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except except: # nosec B110 # noqa:E722 # pylint:disable=bare-except
pass # fallback pass # fallback
if bmpow: if bmpow:
try: try:
return _doCPoW(target, initialHash) return _doCPoW(target, initialHash)
except StopIteration: except StopIteration:
raise raise
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except except: # nosec B110 # noqa:E722 # pylint:disable=bare-except
pass # fallback pass # fallback
if paths.frozen == "macosx_app" or not paths.frozen: if paths.frozen == "macosx_app" or not paths.frozen:
# on my (Peter Surda) Windows 10, Windows Defender # on my (Peter Surda) Windows 10, Windows Defender
@ -323,7 +323,7 @@ def run(target, initialHash):
return _doSafePoW(target, initialHash) return _doSafePoW(target, initialHash)
except StopIteration: except StopIteration:
raise raise
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except except: # nosec B110 # noqa:E722 # pylint:disable=bare-except
pass # fallback pass # fallback

View File

@ -819,7 +819,7 @@ def loadOpenSSL():
try: try:
OpenSSL = _OpenSSL(library) OpenSSL = _OpenSSL(library)
return return
except Exception: # nosec:B110 except Exception: # nosec B110
pass pass
raise Exception( raise Exception(
"Couldn't find and load the OpenSSL library. You must install it.") "Couldn't find and load the OpenSSL library. You must install it.")

View File

@ -11,7 +11,7 @@ from __future__ import division
import hashlib import hashlib
import os import os
import stat import stat
import subprocess # nosec:B404 import subprocess # nosec B404
import sys import sys
from binascii import hexlify from binascii import hexlify

View File

@ -11,7 +11,7 @@ import time
import urllib2 import urllib2
from random import randint from random import randint
from urlparse import urlparse from urlparse import urlparse
from xml.dom.minidom import Document # nosec:B408 from xml.dom.minidom import Document # nosec B408
from defusedxml.minidom import parseString from defusedxml.minidom import parseString
import queues import queues
@ -241,7 +241,7 @@ class uPnPThread(StoppableThread):
if time.time() - lastSent > self.sendSleep and not self.routers: if time.time() - lastSent > self.sendSleep and not self.routers:
try: try:
self.sendSearchRouter() self.sendSearchRouter()
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except except: # nosec B110 # noqa:E722 # pylint:disable=bare-except
pass pass
lastSent = time.time() lastSent = time.time()
try: try: