Code Quality #2189
|
@ -40,7 +40,7 @@ def generate_hash(string):
|
||||||
try:
|
try:
|
||||||
# make input case insensitive
|
# make input case insensitive
|
||||||
string = str.lower(string)
|
string = str.lower(string)
|
||||||
hash_object = hashlib.md5(str.encode(string)) # nosec B303, B324
|
hash_object = hashlib.md5(str.encode(string)) # nosec B324, B303
|
||||||
print(hash_object.hexdigest())
|
print(hash_object.hexdigest())
|
||||||
# returned object is a hex string
|
# returned object is a hex string
|
||||||
return hash_object.hexdigest()
|
return hash_object.hexdigest()
|
||||||
|
|
|
@ -686,8 +686,7 @@ class objectProcessor(threading.Thread):
|
||||||
apiNotifyPath = config.safeGet(
|
apiNotifyPath = config.safeGet(
|
||||||
'bitmessagesettings', 'apinotifypath')
|
'bitmessagesettings', 'apinotifypath')
|
||||||
if apiNotifyPath:
|
if apiNotifyPath:
|
||||||
subprocess.call( # nosec B603
|
subprocess.call([apiNotifyPath, "newMessage"]) # nosec B603
|
||||||
[apiNotifyPath, "newMessage"])
|
|
||||||
|
|
||||||
# Let us now check and see whether our receiving address is
|
# Let us now check and see whether our receiving address is
|
||||||
# behaving as a mailing list
|
# behaving as a mailing list
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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):
|
||||||
|
@ -297,14 +297,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
|
||||||
|
@ -316,13 +316,13 @@ def run(target, initialHash):
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
logger.error("Fast PoW got StopIteration")
|
logger.error("Fast PoW got StopIteration")
|
||||||
raise
|
raise
|
||||||
except: # noqa:E722 pylint:disable=bare-except
|
except: # noqa:E722 # pylint:disable=bare-except
|
||||||
logger.error("Fast PoW got exception:", exc_info=True)
|
logger.error("Fast PoW got exception:", exc_info=True)
|
||||||
try:
|
try:
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -212,10 +212,9 @@ def checkSensitiveFilePermissions(filename):
|
||||||
# Skip known problems for non-Win32 filesystems
|
# Skip known problems for non-Win32 filesystems
|
||||||
# without POSIX permissions.
|
# without POSIX permissions.
|
||||||
fstype = subprocess.check_output(
|
fstype = subprocess.check_output(
|
||||||
'stat -f -c "%%T" %s' % (filename),
|
['/usr/bin/stat', '-f', '-c', '%T', filename],
|
||||||
shell=True,
|
|
||||||
stderr=subprocess.STDOUT
|
stderr=subprocess.STDOUT
|
||||||
)
|
) # nosec B603
|
||||||
if 'fuseblk' in fstype:
|
if 'fuseblk' in fstype:
|
||||||
logger.info(
|
logger.info(
|
||||||
'Skipping file permissions check for %s.'
|
'Skipping file permissions check for %s.'
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Reference in New Issue
Block a user