From 9ad7ac0d250ed36ba2ee3b6befb46f78cf1dbb6c Mon Sep 17 00:00:00 2001 From: Nico Tsiridis Date: Fri, 15 Nov 2024 13:59:15 -0700 Subject: [PATCH] lint udpates --- Docker | 0 modules/sfp__stor_stdout.py | 8 ++++---- modules/sfp_arin.py | 4 ++-- modules/sfp_fraudguard.py | 4 ++-- modules/sfp_github.py | 2 +- modules/sfp_riskiq.py | 4 ++-- modules/sfp_spider.py | 2 +- modules/sfp_tldsearch.py | 2 +- modules/sfp_xforce.py | 4 ++-- sfcli.py | 20 ++++++++++---------- spiderfoot/correlation.py | 4 ++-- spiderfoot/event.py | 2 +- test/requirements.txt | 4 ++-- 13 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 Docker diff --git a/Docker b/Docker new file mode 100644 index 0000000000..e69de29bb2 diff --git a/modules/sfp__stor_stdout.py b/modules/sfp__stor_stdout.py index 49d775227f..435d64210b 100644 --- a/modules/sfp__stor_stdout.py +++ b/modules/sfp__stor_stdout.py @@ -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']: diff --git a/modules/sfp_arin.py b/modules/sfp_arin.py index 81b1852ee2..60638faad4 100644 --- a/modules/sfp_arin.py +++ b/modules/sfp_arin.py @@ -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'] @@ -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'] diff --git a/modules/sfp_fraudguard.py b/modules/sfp_fraudguard.py index 39efff7828..c0cbac54ea 100644 --- a/modules/sfp_fraudguard.py +++ b/modules/sfp_fraudguard.py @@ -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 = { diff --git a/modules/sfp_github.py b/modules/sfp_github.py index 2dd606e57b..8d0403aec6 100644 --- a/modules/sfp_github.py +++ b/modules/sfp_github.py @@ -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 diff --git a/modules/sfp_riskiq.py b/modules/sfp_riskiq.py index 3cf7ce924c..8817609e24 100644 --- a/modules/sfp_riskiq.py +++ b/modules/sfp_riskiq.py @@ -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 = { diff --git a/modules/sfp_spider.py b/modules/sfp_spider.py index aa6f301226..96b55065b8 100644 --- a/modules/sfp_spider.py +++ b/modules/sfp_spider.py @@ -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) diff --git a/modules/sfp_tldsearch.py b/modules/sfp_tldsearch.py index eaec60a923..783ba75ca9 100644 --- a/modules/sfp_tldsearch.py +++ b/modules/sfp_tldsearch.py @@ -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() diff --git a/modules/sfp_xforce.py b/modules/sfp_xforce.py index 4e4aefc4a4..0ea3a0c961 100644 --- a/modules/sfp_xforce.py +++ b/modules/sfp_xforce.py @@ -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 = { diff --git a/sfcli.py b/sfcli.py index 7341ab3f1b..452d6c5e04 100755 --- a/sfcli.py +++ b/sfcli.py @@ -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 @@ -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 @@ -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])}) @@ -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": @@ -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)) diff --git a/spiderfoot/correlation.py b/spiderfoot/correlation.py index 8b812fb150..b66eaa0013 100644 --- a/spiderfoot/correlation.py +++ b/spiderfoot/correlation.py @@ -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'] @@ -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'] diff --git a/spiderfoot/event.py b/spiderfoot/event.py index 5e96d0e60e..da47caae3b 100644 --- a/spiderfoot/event.py +++ b/spiderfoot/event.py @@ -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") diff --git a/test/requirements.txt b/test/requirements.txt index 9d983a2829..2685e39d5f 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -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 @@ -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