Fix flake8 E721

This commit is contained in:
Sean Whalen
2023-09-05 18:12:50 -04:00
parent 31db7d2301
commit 8b5834b00d
5 changed files with 12 additions and 12 deletions
+4 -4
View File
@@ -144,7 +144,7 @@ def _parse_report_record(record, ip_db_path=None, offline=False,
else:
auth_results = new_record["auth_results"].copy()
if type(auth_results["dkim"]) != list:
if not isinstance(auth_results["dkim"], list):
auth_results["dkim"] = [auth_results["dkim"]]
for result in auth_results["dkim"]:
if "domain" in result and result["domain"] is not None:
@@ -159,7 +159,7 @@ def _parse_report_record(record, ip_db_path=None, offline=False,
new_result["result"] = "none"
new_record["auth_results"]["dkim"].append(new_result)
if type(auth_results["spf"]) != list:
if not isinstance(auth_results["spf"], list):
auth_results["spf"] = [auth_results["spf"]]
for result in auth_results["spf"]:
new_result = OrderedDict([("domain", result["domain"])])
@@ -282,7 +282,7 @@ def parse_aggregate_report_xml(xml, ip_db_path=None, offline=False,
new_report_metadata["begin_date"] = date_range["begin"]
new_report_metadata["end_date"] = date_range["end"]
if "error" in report["report_metadata"]:
if type(report["report_metadata"]["error"]) != list:
if not isinstance(report["report_metadata"]["error"], list):
errors = [report["report_metadata"]["error"]]
else:
errors = report["report_metadata"]["error"]
@@ -824,7 +824,7 @@ def parse_report_email(input_, offline=False, ip_db_path=None,
for part in msg.walk():
content_type = part.get_content_type()
payload = part.get_payload()
if type(payload) != list:
if not isinstance(payload, list):
payload = [payload]
payload = payload[0].__str__()
if content_type == "message/feedback-report":
+1 -1
View File
@@ -181,7 +181,7 @@ def set_hosts(hosts, use_ssl=False, ssl_cert_path=None,
password (str): The password to use for authentication
timeout (float): Timeout in seconds
"""
if type(hosts) != list:
if not isinstance(hosts, list):
hosts = [hosts]
conn_params = {
"hosts": hosts,
+3 -3
View File
@@ -96,8 +96,8 @@ class KafkaClient(object):
aggregate_topic (str): The name of the Kafka topic
"""
if (type(aggregate_reports) == dict or
type(aggregate_reports) == OrderedDict):
if (isinstance(aggregate_reports, dict) or
isinstance(aggregate_reports, OrderedDict)):
aggregate_reports = [aggregate_reports]
if len(aggregate_reports) < 1:
@@ -141,7 +141,7 @@ class KafkaClient(object):
forensic_topic (str): The name of the Kafka topic
"""
if type(forensic_reports) == dict:
if isinstance(forensic_reports, dict):
forensic_reports = [forensic_reports]
if len(forensic_reports) < 1:
+2 -2
View File
@@ -64,7 +64,7 @@ class HECClient(object):
"""
logger.debug("Saving aggregate reports to Splunk")
if type(aggregate_reports) == dict:
if isinstance(aggregate_reports, dict):
aggregate_reports = [aggregate_reports]
if len(aggregate_reports) < 1:
@@ -130,7 +130,7 @@ class HECClient(object):
to save in Splunk
"""
logger.debug("Saving forensic reports to Splunk")
if type(forensic_reports) == dict:
if isinstance(forensic_reports, dict):
forensic_reports = [forensic_reports]
if len(forensic_reports) < 1:
+2 -2
View File
@@ -409,7 +409,7 @@ def is_outlook_msg(content):
Returns:
bool: A flag that indicates if the file is an Outlook MSG file
"""
return type(content) == bytes and content.startswith(
return isinstance(content, bytes) and content.startswith(
b"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1")
@@ -459,7 +459,7 @@ def parse_email(data, strip_attachment_payloads=False):
dict: Parsed email data
"""
if type(data) == bytes:
if isinstance(data, bytes):
if is_outlook_msg(data):
data = convert_outlook_msg(data)
data = data.decode("utf-8", errors="replace")