Skip to content

Commit

Permalink
lint udpates
Browse files Browse the repository at this point in the history
  • Loading branch information
nctsiridis committed Nov 15, 2024
1 parent 49de524 commit 9ad7ac0
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 30 deletions.
Empty file added Docker
Empty file.
8 changes: 4 additions & 4 deletions modules/sfp__stor_stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ def watchedEvents(self):

def output(self, event):
d = self.opts['_csvdelim']
if type(event.data) in [list, dict]:
if isinstance(event.data, (list, dict)):
data = str(event.data)
else:
data = event.data

if type(data) != str:
if not isinstance(data, str):
data = str(event.data)

if type(event.sourceEvent.data) in [list, dict]:
if isinstance(event.sourceEvent.data, (list, dict)):
srcdata = str(event.sourceEvent.data)
else:
srcdata = event.sourceEvent.data

if type(srcdata) != str:
if not isinstance(srcdata, str):
srcdata = str(event.sourceEvent.data)

if self.opts['_stripnewline']:
Expand Down
4 changes: 2 additions & 2 deletions modules/sfp_arin.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def handleEvent(self, event):
if "pocRef" in ret['pocs']:
ref = list()
# Might be a list or a dictionary
if type(ret['pocs']['pocRef']) == dict:
if isinstance(ret['pocs']['pocRef'], dict):
ref = [ret['pocs']['pocRef']]
else:
ref = ret['pocs']['pocRef']
Expand All @@ -169,7 +169,7 @@ def handleEvent(self, event):
if "pocRef" in ret['pocs']:
ref = list()
# Might be a list or a dictionary
if type(ret['pocs']['pocRef']) == dict:
if isinstance(ret['pocs']['pocRef'], dict):
ref = [ret['pocs']['pocRef']]
else:
ref = ret['pocs']['pocRef']
Expand Down
4 changes: 2 additions & 2 deletions modules/sfp_fraudguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ def query(self, qry):

fraudguard_url = "https://api.fraudguard.io/ip/" + qry
api_key_account = self.opts['fraudguard_api_key_account']
if type(api_key_account) == str:
if isinstance(api_key_account, str):
api_key_account = api_key_account.encode('utf-8')
api_key_password = self.opts['fraudguard_api_key_password']
if type(api_key_password) == str:
if isinstance(api_key_password, str):
api_key_password = api_key_password.encode('utf-8')
token = base64.b64encode(api_key_account + ':'.encode('utf-8') + api_key_password)
headers = {
Expand Down
2 changes: 1 addition & 1 deletion modules/sfp_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def handleEvent(self, event):
continue

for item in repret:
if type(item) != dict:
if not isinstance(item, dict):
self.debug("Encountered an unexpected or empty response from Github.")
continue

Expand Down
4 changes: 2 additions & 2 deletions modules/sfp_riskiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ def query(self, qry, qtype, opts=dict()):
post = '{"field": "email", "query": "' + qry + '"}'

api_key_login = self.opts['api_key_login']
if type(api_key_login) == str:
if isinstance(api_key_login, str):
api_key_login = api_key_login.encode('utf-8')
api_key_password = self.opts['api_key_password']
if type(api_key_password) == str:
if isinstance(api_key_password, str):
api_key_password = api_key_password.encode('utf-8')
cred = base64.b64encode(api_key_login + ":".encode('utf-8') + api_key_password)
headers = {
Expand Down
2 changes: 1 addition & 1 deletion modules/sfp_spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def linkNotify(self, url: str, parentEvent=None):
else:
utype = "LINKED_URL_EXTERNAL"

if type(url) != str:
if not isinstance(url, str):
url = str(url, "utf-8", errors='replace')
event = SpiderFootEvent(utype, url, self.__name__, parentEvent)
self.notifyListeners(event)
Expand Down
2 changes: 1 addition & 1 deletion modules/sfp_tldsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def handleEvent(self, event):
# Look through all TLDs for the existence of this target keyword
targetList = list()
for tld in self.opts['_internettlds']:
if type(tld) != str:
if not isinstance(tld, str):
tld = str(tld.strip(), errors='ignore')
else:
tld = tld.strip()
Expand Down
4 changes: 2 additions & 2 deletions modules/sfp_xforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ def query(self, qry, querytype):
xforce_url = "https://api.xforce.ibmcloud.com"

api_key = self.opts['xforce_api_key']
if type(api_key) == str:
if isinstance(api_key, str):
api_key = api_key.encode('utf-8')
api_key_password = self.opts['xforce_api_key_password']
if type(api_key_password) == str:
if isinstance(api_key_password, str):
api_key_password = api_key_password.encode('utf-8')
token = base64.b64encode(api_key + ":".encode('utf-8') + api_key_password)
headers = {
Expand Down
20 changes: 10 additions & 10 deletions sfcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def pretty(self, data, titlemap=None):
out = list()
# Get the column titles
maxsize = dict()
if type(data[0]) == dict:
if isinstance(data[0], dict):
cols = list(data[0].keys())
else:
# for lists, use the index numbers as titles
Expand All @@ -250,12 +250,12 @@ def pretty(self, data, titlemap=None):
# Find the maximum column sizes
for r in data:
for i, c in enumerate(r):
if type(r) == list:
if isinstance(r, list):
# we have list index
cn = str(i)
if type(c) == int:
if isinstance(c, int):
v = str(c)
if type(c) == str:
if isinstance(c, str):
v = c
else:
# we have a dict key
Expand Down Expand Up @@ -1246,7 +1246,7 @@ def do_set(self, line):
self.dprint(f"{k} = {c}", plain=True)

for k in sorted(serverconfig.keys()):
if type(serverconfig[k]) == list:
if isinstance(serverconfig[k], list):
serverconfig[k] = ','.join(serverconfig[k])
if not cfg:
output.append({'opt': k, 'val': str(serverconfig[k])})
Expand All @@ -1270,7 +1270,7 @@ def do_set(self, line):
for k in serverconfig:
if k == cfg:
serverconfig[k] = val
if type(val) == str:
if isinstance(val, str):
if val.lower() == "true":
serverconfig[k] = "1"
if val.lower() == "false":
Expand All @@ -1284,18 +1284,18 @@ def do_set(self, line):
# Sanitize the data before sending it to the server
for k in serverconfig:
optstr = ":".join(k.split(".")[1:])
if type(serverconfig[k]) == bool:
if isinstance(serverconfig[k], bool):
if serverconfig[k]:
confdata[optstr] = "1"
else:
confdata[optstr] = "0"
if type(serverconfig[k]) == list:
if isinstance(serverconfig[k], list):
# If set by the user, it must already be a
# string, not a list
confdata[optstr] = ','.join(serverconfig[k])
if type(serverconfig[k]) == int:
if isinstance(serverconfig[k], int):
confdata[optstr] = str(serverconfig[k])
if type(serverconfig[k]) == str:
if isinstance(serverconfig[k], str):
confdata[optstr] = serverconfig[k]

self.ddprint(str(confdata))
Expand Down
4 changes: 2 additions & 2 deletions spiderfoot/correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def build_db_criteria(self, matchrule: dict) -> dict:
criterias['eventType'] = list()

if matchrule['method'] == 'regex':
if type(matchrule['value']) != list:
if not isinstance(matchrule['value'], list):
regexps = [matchrule['value']]
else:
regexps = matchrule['value']
Expand All @@ -176,7 +176,7 @@ def build_db_criteria(self, matchrule: dict) -> dict:
criterias['eventType'].append(t[1])

if matchrule['method'] == 'exact':
if type(matchrule['value']) != list:
if not isinstance(matchrule['value'], list):
matches = [matchrule['value']]
else:
matches = matchrule['value']
Expand Down
2 changes: 1 addition & 1 deletion spiderfoot/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def module(self, module: str) -> None:
ValueError: module value was invalid
"""
if not isinstance(module, str):
raise TypeError(f"module is {type(module )}; expected str()")
raise TypeError(f"module is {type(module)}; expected str()")

if not module and self.eventType != "ROOT":
raise ValueError("module is empty")
Expand Down
4 changes: 2 additions & 2 deletions test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-r ../requirements.txt
darglint==1.8.1
dlint==0.14.0
flake8==5.0.4
flake8==7.1.1
flake8-annotations==2.9.1
flake8-blind-except==0.2.1
flake8-bugbear==23.2.13
Expand All @@ -14,5 +14,5 @@ pytest==7.2.1
pytest-cov==4.0.0
pytest-mock==3.10.0
pytest-xdist==3.2.0
pycodestyle==2.9.0
pycodestyle==2.12.1
responses==0.22.0

0 comments on commit 9ad7ac0

Please sign in to comment.