Code Quality #2189

Merged
anand-skss merged 1 commits from code-quality into v0.6 2024-03-01 12:17:09 +01:00
9 changed files with 17 additions and 19 deletions

View File

@ -40,7 +40,7 @@ def generate_hash(string):
try:
# make input case insensitive
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())
# returned object is a hex string
return hash_object.hexdigest()

View File

@ -686,8 +686,7 @@ class objectProcessor(threading.Thread):
apiNotifyPath = config.safeGet(
'bitmessagesettings', 'apinotifypath')
if apiNotifyPath:
subprocess.call( # nosec B603
[apiNotifyPath, "newMessage"])
subprocess.call([apiNotifyPath, "newMessage"]) # nosec B603
# Let us now check and see whether our receiving address is
# behaving as a mailing list

View File

@ -287,7 +287,7 @@ def check_openssl():
path = ctypes.util.find_library('ssl')
if path not in paths:
paths.append(path)
except: # nosec:B110 pylint:disable=bare-except
except: # nosec:B110 # pylint:disable=bare-except
pass
openssl_version = None

View File

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

View File

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

View File

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

View File

@ -82,7 +82,7 @@ def _set_idle():
pid = win32api.GetCurrentProcessId()
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
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
pass
@ -135,7 +135,7 @@ def _doFastPoW(target, initialHash):
try:
pool.terminate()
pool.join()
except: # nosec:B110 noqa:E722 pylint:disable=bare-except
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except
pass
raise StopIteration("Interrupted")
for i in range(pool_size):
@ -297,14 +297,14 @@ def run(target, initialHash):
return _doGPUPoW(target, initialHash)
except StopIteration:
raise
except: # nosec:B110 noqa:E722 pylint:disable=bare-except
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except
pass # fallback
if bmpow:
try:
return _doCPoW(target, initialHash)
except StopIteration:
raise
except: # nosec:B110 noqa:E722 pylint:disable=bare-except
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except
pass # fallback
if paths.frozen == "macosx_app" or not paths.frozen:
# on my (Peter Surda) Windows 10, Windows Defender
@ -316,13 +316,13 @@ def run(target, initialHash):
except StopIteration:
logger.error("Fast PoW got StopIteration")
raise
except: # noqa:E722 pylint:disable=bare-except
except: # noqa:E722 # pylint:disable=bare-except
logger.error("Fast PoW got exception:", exc_info=True)
try:
return _doSafePoW(target, initialHash)
except StopIteration:
raise
except: # nosec:B110 noqa:E722 pylint:disable=bare-except
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except
pass # fallback

View File

@ -212,10 +212,9 @@ def checkSensitiveFilePermissions(filename):
# Skip known problems for non-Win32 filesystems
# without POSIX permissions.
fstype = subprocess.check_output(
'stat -f -c "%%T" %s' % (filename),
shell=True,
['/usr/bin/stat', '-f', '-c', '%T', filename],
stderr=subprocess.STDOUT
)
) # nosec B603
if 'fuseblk' in fstype:
logger.info(
'Skipping file permissions check for %s.'

View File

@ -241,7 +241,7 @@ class uPnPThread(StoppableThread):
if time.time() - lastSent > self.sendSleep and not self.routers:
try:
self.sendSearchRouter()
except: # nosec:B110 noqa:E722 pylint:disable=bare-except
except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except
pass
lastSent = time.time()
try: