ruff: auto-run flake8-comprehensions (C4)
parent
3c4d9cc4bb
commit
dcc724118f
|
@ -42,7 +42,7 @@ def neo4j_local_admins(context, driver):
|
|||
except Exception as e:
|
||||
context.log.fail(f"Could not pull admins: {e}")
|
||||
return None
|
||||
results = [record for record in admins.data()]
|
||||
results = list(admins.data())
|
||||
return results
|
||||
|
||||
|
||||
|
@ -105,7 +105,7 @@ def process_creds(context, connection, credentials_data, dbconnection, cursor, d
|
|||
session = driver.session()
|
||||
session.run('MATCH (u) WHERE (u.name = "' + username + '") SET u.owned=True RETURN u,u.name,u.owned')
|
||||
path_to_da = session.run("MATCH p=shortestPath((n)-[*1..]->(m)) WHERE n.owned=true AND m.name=~ '.*DOMAIN ADMINS.*' RETURN p")
|
||||
paths = [record for record in path_to_da.data()]
|
||||
paths = list(path_to_da.data())
|
||||
|
||||
for path in paths:
|
||||
if path:
|
||||
|
|
|
@ -197,7 +197,7 @@ class DRIVER_INFO_2_BLOB(Structure):
|
|||
class DRIVER_INFO_2_ARRAY(Structure):
|
||||
def __init__(self, data=None, pcReturned=None):
|
||||
Structure.__init__(self, data=data)
|
||||
self["drivers"] = list()
|
||||
self["drivers"] = []
|
||||
remaining = data
|
||||
if data is not None:
|
||||
for _ in range(pcReturned):
|
||||
|
|
|
@ -49,7 +49,7 @@ def get_list_from_option(opt):
|
|||
"""Takes a comma-separated string and converts it to a list of lowercase strings.
|
||||
It filters out empty strings from the input before converting.
|
||||
"""
|
||||
return list(map(lambda o: o.lower(), filter(bool, opt.split(","))))
|
||||
return [o.lower() for o in filter(bool, opt.split(","))]
|
||||
|
||||
|
||||
class SMBSpiderPlus:
|
||||
|
@ -70,14 +70,14 @@ class SMBSpiderPlus:
|
|||
self.logger = logger
|
||||
self.results = {}
|
||||
self.stats = {
|
||||
"shares": list(),
|
||||
"shares_readable": list(),
|
||||
"shares_writable": list(),
|
||||
"shares": [],
|
||||
"shares_readable": [],
|
||||
"shares_writable": [],
|
||||
"num_shares_filtered": 0,
|
||||
"num_folders": 0,
|
||||
"num_folders_filtered": 0,
|
||||
"num_files": 0,
|
||||
"file_sizes": list(),
|
||||
"file_sizes": [],
|
||||
"file_exts": set(),
|
||||
"num_get_success": 0,
|
||||
"num_get_fail": 0,
|
||||
|
|
|
@ -73,7 +73,7 @@ class NXCModule:
|
|||
tmp_uuid = str(entry["tower"]["Floors"][0])
|
||||
if (tmp_uuid in endpoints) is not True:
|
||||
endpoints[tmp_uuid] = {}
|
||||
endpoints[tmp_uuid]["Bindings"] = list()
|
||||
endpoints[tmp_uuid]["Bindings"] = []
|
||||
if uuid.uuidtup_to_bin(uuid.string_to_uuidtup(tmp_uuid))[:18] in epm.KNOWN_UUIDS:
|
||||
endpoints[tmp_uuid]["EXE"] = epm.KNOWN_UUIDS[uuid.uuidtup_to_bin(uuid.string_to_uuidtup(tmp_uuid))[:18]]
|
||||
else:
|
||||
|
|
|
@ -377,7 +377,7 @@ class DatabaseNavigator(cmd.Cmd):
|
|||
rows.append(row)
|
||||
|
||||
if line[1].lower() == "simple":
|
||||
simple_rows = list((row[0], row[1], row[2], row[3], row[5]) for row in rows)
|
||||
simple_rows = [(row[0], row[1], row[2], row[3], row[5]) for row in rows]
|
||||
write_csv(filename, csv_header_simple, simple_rows)
|
||||
elif line[1].lower() == "detailed":
|
||||
write_csv(filename, csv_header_detailed, rows)
|
||||
|
|
|
@ -194,7 +194,7 @@ class KerberosAttacks:
|
|||
|
||||
req_body = seq_set(as_req, "req-body")
|
||||
|
||||
opts = list()
|
||||
opts = []
|
||||
opts.append(constants.KDCOptions.forwardable.value)
|
||||
opts.append(constants.KDCOptions.renewable.value)
|
||||
opts.append(constants.KDCOptions.proxiable.value)
|
||||
|
|
|
@ -1303,7 +1303,7 @@ class smb(connection):
|
|||
if sids_to_check == 0:
|
||||
break
|
||||
|
||||
sids = list()
|
||||
sids = []
|
||||
for i in range(so_far, so_far + sids_to_check):
|
||||
sids.append(f"{domain_sid}-{i:d}")
|
||||
try:
|
||||
|
|
|
@ -914,7 +914,7 @@ class database:
|
|||
q = select(self.ConfChecksTable).filter(self.ConfChecksTable.c.name == name)
|
||||
select_results = self.conn.execute(q).all()
|
||||
context = locals()
|
||||
new_row = dict((column, context[column]) for column in ("name", "description"))
|
||||
new_row = {column: context[column] for column in ("name", "description")}
|
||||
updated_ids = self.insert_data(self.ConfChecksTable, select_results, **new_row)
|
||||
|
||||
if updated_ids:
|
||||
|
@ -926,7 +926,7 @@ class database:
|
|||
q = select(self.ConfChecksResultsTable).filter(self.ConfChecksResultsTable.c.host_id == host_id, self.ConfChecksResultsTable.c.check_id == check_id)
|
||||
select_results = self.conn.execute(q).all()
|
||||
context = locals()
|
||||
new_row = dict((column, context[column]) for column in ("host_id", "check_id", "secure", "reasons"))
|
||||
new_row = {column: context[column] for column in ("host_id", "check_id", "secure", "reasons")}
|
||||
updated_ids = self.insert_data(self.ConfChecksResultsTable, select_results, **new_row)
|
||||
|
||||
if updated_ids:
|
||||
|
|
|
@ -369,7 +369,7 @@ class navigator(DatabaseNavigator):
|
|||
columns_to_display = list(valid_columns.values())
|
||||
else:
|
||||
requested_columns = line.split(" ")
|
||||
columns_to_display = list(valid_columns[column.lower()] for column in requested_columns if column.lower() in valid_columns)
|
||||
columns_to_display = [valid_columns[column.lower()] for column in requested_columns if column.lower() in valid_columns]
|
||||
|
||||
results = self.db.get_check_results()
|
||||
self.display_wcc_results(results, columns_to_display)
|
||||
|
|
|
@ -168,7 +168,7 @@ class FirefoxTriage:
|
|||
return "", "", ""
|
||||
|
||||
def get_users(self):
|
||||
users = list()
|
||||
users = []
|
||||
|
||||
users_dir_path = "Users\\*"
|
||||
directories = self.conn.listPath(shareName=self.share, path=ntpath.normpath(users_dir_path))
|
||||
|
|
|
@ -79,8 +79,8 @@ build-backend = "poetry.core.masonry.api"
|
|||
[tool.ruff]
|
||||
# Ruff doesn't enable pycodestyle warnings (`W`) or
|
||||
# McCabe complexity (`C901`) by default.
|
||||
# Other options: pep8-naming (N), flake8-annotations (ANN), flake8-blind-except (BLE)
|
||||
select = ["E", "F", "D", "UP", "YTT", "ASYNC", "B", "A"]
|
||||
# Other options: pep8-naming (N), flake8-annotations (ANN), flake8-blind-except (BLE), flake8-commas (COM)
|
||||
select = ["E", "F", "D", "UP", "YTT", "ASYNC", "B", "A", "C4"]
|
||||
ignore = [ "E501", "F405", "F841", "D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107", "D203", "D204", "D205", "D212", "D213", "D400", "D401", "D415", "D417", "D419"]
|
||||
|
||||
# Allow autofix for all enabled rules (when `--fix`) is provided.
|
||||
|
|
Loading…
Reference in New Issue