ruff: add F841 back in and auto-fix

main
Marshall Hallenbeck 2023-10-15 13:31:51 -04:00
parent e043e0704e
commit e77ecd31bd
9 changed files with 11 additions and 12 deletions

View File

@ -57,7 +57,7 @@ class NXCModule:
try:
with open(handlekatz_loc, "wb") as handlekatz:
handlekatz.write(self.handlekatz_embeded)
except FileNotFoundError as e:
except FileNotFoundError:
context.log.fail(f"Handlekatz file specified '{handlekatz_loc}' does not exist!")
sys.exit(1)

View File

@ -52,7 +52,7 @@ class NXCModule:
try:
with open(file_to_upload, "wb") as impersonate:
impersonate.write(self.impersonate_embedded)
except FileNotFoundError as e:
except FileNotFoundError:
context.log.fail(f"Impersonate file specified '{file_to_upload}' does not exist!")
sys.exit(1)
else:

View File

@ -396,7 +396,7 @@ def check(ip, port=445):
raw_proto = session_setup_andx_request()
client.send(raw_proto)
tcp_response = client.recv(buffersize)
netbios = tcp_response[:4]
tcp_response[:4]
smb_header = tcp_response[4:36]
smb = SmbHeader(smb_header)
@ -404,14 +404,14 @@ def check(ip, port=445):
# Extract native OS from session setup response
session_setup_andx_response = tcp_response[36:]
native_os = session_setup_andx_response[9:].split("\x00")[0]
session_setup_andx_response[9:].split("\x00")[0]
# Send tree connect request and receive response
raw_proto = tree_connect_andx_request(ip, user_id)
client.send(raw_proto)
tcp_response = client.recv(buffersize)
netbios = tcp_response[:4]
tcp_response[:4]
smb_header = tcp_response[4:36]
smb = SmbHeader(smb_header)
@ -425,7 +425,7 @@ def check(ip, port=445):
client.send(raw_proto)
tcp_response = client.recv(buffersize)
netbios = tcp_response[:4]
tcp_response[:4]
smb_header = tcp_response[4:36]
smb = SmbHeader(smb_header)

View File

@ -54,7 +54,7 @@ class NXCModule:
try:
with open(file_to_upload, "w") as msol:
msol.write(self.msol_embedded)
except FileNotFoundError as e:
except FileNotFoundError:
context.log.fail(f"Impersonate file specified '{file_to_upload}' does not exist!")
sys.exit(1)

View File

@ -745,7 +745,7 @@ class ldap(connection):
if e.getErrorString().find("sizeLimitExceeded") >= 0:
# We should never reach this code as we use paged search now
self.logger.fail("sizeLimitExceeded exception caught, giving up and processing the data received")
resp = e.getAnswers()
e.getAnswers()
else:
self.logger.fail(e)
return False

View File

@ -130,7 +130,7 @@ class SMBEXEC:
self.logger.debug(f"Remote service {self.__serviceName} deleted.")
scmr.hRDeleteService(self.__scmr, service)
scmr.hRCloseServiceHandle(self.__scmr, service)
except Exception as e:
except Exception:
pass
self.get_output_remote()

View File

@ -227,7 +227,6 @@ class SMBSpider:
traceback.print_exc()
def get_lastm_time(self, result_obj):
lastm_time = None
with contextlib.suppress(Exception):
return strftime("%Y-%m-%d %H:%M", localtime(result_obj.get_mtime_epoch()))

View File

@ -192,7 +192,7 @@ class winrm(connection):
for url in endpoints:
try:
self.logger.debug(f"Requesting URL: {url}")
res = requests.post(url, verify=False, timeout=self.args.http_timeout)
requests.post(url, verify=False, timeout=self.args.http_timeout)
self.logger.debug("Received response code: {res.status_code}")
self.endpoint = url
if self.endpoint.startswith("https://"):

View File

@ -82,7 +82,7 @@ build-backend = "poetry.core.masonry.api"
# Other options: pep8-naming (N), flake8-annotations (ANN), flake8-blind-except (BLE), flake8-commas (COM), flake8-pyi (PYI), flake8-pytest-style (PT), flake8-unused-arguments (ARG), etc
# Should tackle flake8-use-pathlib (PTH) at some point
select = ["E", "F", "D", "UP", "YTT", "ASYNC", "B", "A", "C4", "ISC", "ICN", "PIE", "PT", "Q", "RSE", "RET", "SIM", "TID", "ERA", "FLY", "PERF"]
ignore = [ "E501", "F405", "F841", "D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107", "D203", "D204", "D205", "D212", "D213", "D400", "D401", "D415", "D417", "D419", "RET505", "RET506", "RET507", "RET508", "PERF203"]
ignore = [ "E501", "F405", "D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107", "D203", "D204", "D205", "D212", "D213", "D400", "D401", "D415", "D417", "D419", "RET505", "RET506", "RET507", "RET508", "PERF203"]
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]