SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
flake8: Resolve various SIM and R violations (#1306)
bcoles21cfa91f8e79
diff --git a/modules/sfp_abstractapi.py b/modules/sfp_abstractapi.pyindex 41f811ca..17974733 100644--- a/modules/sfp_abstractapi.py+++ b/modules/sfp_abstractapi.py@@ -75,45 +75,44 @@ class sfp_abstractapi(SpiderFootPlugin):def parseApiResponse(self, res):if not res:- return+ return Noneif res['code'] == '429':self.sf.error("You are being rate-limited by AbstractAPI.")- return+ return Noneif res['code'] == '401':self.sf.error("Unauthorized. Invalid AbstractAPI API key.")self.errorState = True- return+ return Noneif res['code'] == '422':self.sf.error("Usage quota reached. Insufficient API credit.")self.errorState = True- return+ return Noneif res['code'] == '500' or res['code'] == '503':self.sf.error("Abstract API service is unavailable")self.errorState = True- return+ return Noneif res['code'] == '204':self.sf.debug("No response data for target")- return+ return Noneif res['code'] != '200':self.sf.error(f"Unexpected reply from AbstractAPI: {res['code']}")- return+ return Noneif res['content'] is None:- return+ return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return- return data+ return Nonedef queryCompanyEnrichment(self, qry):"""Enrich domain with company information.@@ -127,7 +126,7 @@ class sfp_abstractapi(SpiderFootPlugin):api_key = self.opts['companyenrichment_api_key']if not api_key:- return+ return Noneparams = urllib.parse.urlencode({'api_key': api_key,@@ -143,7 +142,7 @@ class sfp_abstractapi(SpiderFootPlugin):if not res:self.sf.debug("No response from AbstractAPI Company Enrichment API endpoint")- return+ return Nonereturn self.parseApiResponse(res)@@ -175,7 +174,7 @@ class sfp_abstractapi(SpiderFootPlugin):if not res:self.sf.debug("No response from AbstractAPI Phone Validation API endpoint")- return+ return Nonereturn self.parseApiResponse(res)@@ -207,7 +206,7 @@ class sfp_abstractapi(SpiderFootPlugin):if not res:self.sf.debug("No response from AbstractAPI Phone Validation API endpoint")- return+ return Nonereturn self.parseApiResponse(res)@@ -314,7 +313,7 @@ class sfp_abstractapi(SpiderFootPlugin):e = SpiderFootEvent("GEOINFO", geoinfo, self.__name__, event)self.notifyListeners(e)- elif eventName == "IP_ADDRESS" or eventName == "IPV6_ADDRESS":+ elif eventName in ['IP_ADDRESS', 'IPV6_ADDRESS']:if self.opts["ipgeolocation_api_key"] == "":self.sf.info(f"No API key set for IP Geolocation API endpoint. Ignoring {eventData}"diff --git a/modules/sfp_alienvault.py b/modules/sfp_alienvault.pyindex 6138329a..d9c716ea 100644--- a/modules/sfp_alienvault.py+++ b/modules/sfp_alienvault.py@@ -136,23 +136,22 @@ class sfp_alienvault(SpiderFootPlugin):if res['code'] == '429':self.sf.error("You are being rate-limited by AienVault OTX")self.errorState = True- return+ return Noneif res['code'] == "403":self.sf.error("AlienVault OTX API key seems to have been rejected or you have exceeded usage limits for the month.")self.errorState = True- return+ return Noneif res['content'] is None or res['code'] == "404":- return+ return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.error(f"Error processing JSON response from AlienVault OTX: {e}")- return- return data+ return Nonedef queryReputation(self, qry):if ":" in qry:@@ -327,7 +326,7 @@ class sfp_alienvault(SpiderFootPlugin):qrylist.append(eventData)# For IP Addresses, do the additional passive DNS lookup- if eventName == "IP_ADDRESS" or eventName == "IPV6_ADDRESS":+ if eventName in ['IP_ADDRESS', 'IPV6_ADDRESS']:ret = self.queryPassiveDns(eventData)if ret is None:@@ -379,7 +378,7 @@ class sfp_alienvault(SpiderFootPlugin):if self.errorState:return- if eventName == 'IP_ADDRESS' or eventName == 'IPV6_ADDRESS' or eventName.startswith('NETBLOCK_'):+ if eventName in ['IP_ADDRESS', 'IPV6_ADDRESS'] or eventName.startswith('NETBLOCK_'):evtType = 'MALICIOUS_IPADDR'elif eventName == "AFFILIATE_IPADDR":evtType = 'MALICIOUS_AFFILIATE_IPADDR'diff --git a/modules/sfp_apility.py b/modules/sfp_apility.pyindex 27c88cc1..f65d816c 100644--- a/modules/sfp_apility.py+++ b/modules/sfp_apility.py@@ -167,12 +167,11 @@ class sfp_apility(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_arin.py b/modules/sfp_arin.pyindex d91f67c6..5928b669 100644--- a/modules/sfp_arin.py+++ b/modules/sfp_arin.py@@ -110,15 +110,15 @@ class sfp_arin(SpiderFootPlugin):return Nonetry:- j = json.loads(res['content'])- evt = SpiderFootEvent("RAW_RIR_DATA", res['content'], self.__name__,- self.currentEventSrc)- self.notifyListeners(evt)- return j+ data = json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")return None+ evt = SpiderFootEvent("RAW_RIR_DATA", str(data), self.__name__, self.currentEventSrc)+ self.notifyListeners(evt)+ return data+# Handle events sent to this moduledef handleEvent(self, event):eventName = event.eventTypediff --git a/modules/sfp_bgpview.py b/modules/sfp_bgpview.pyindex 251fc3b3..cad3741f 100644--- a/modules/sfp_bgpview.py+++ b/modules/sfp_bgpview.py@@ -76,7 +76,7 @@ class sfp_bgpview(SpiderFootPlugin):self.sf.debug(f"Error processing JSON response from BGPView: {e}")return None- if not json_data.get('status') == 'ok':+ if json_data.get('status') != 'ok':self.sf.debug("No results found for ASN " + qry)return None@@ -104,7 +104,7 @@ class sfp_bgpview(SpiderFootPlugin):self.sf.debug(f"Error processing JSON response from BGPView: {e}")return None- if not json_data.get('status') == 'ok':+ if json_data.get('status') != 'ok':self.sf.debug("No results found for IP address " + qry)return None@@ -132,7 +132,7 @@ class sfp_bgpview(SpiderFootPlugin):self.sf.debug(f"Error processing JSON response from BGPView: {e}")return None- if not json_data.get('status') == 'ok':+ if json_data.get('status') != 'ok':self.sf.debug("No results found for netblock " + qry)return Nonediff --git a/modules/sfp_bitcoinabuse.py b/modules/sfp_bitcoinabuse.pyindex ae254875..627c0e7d 100644--- a/modules/sfp_bitcoinabuse.py+++ b/modules/sfp_bitcoinabuse.py@@ -86,12 +86,11 @@ class sfp_bitcoinabuse(SpiderFootPlugin):return Nonetry:- info = json.loads(res["content"])+ return json.loads(res["content"])except Exception as e:self.sf.error(f"Error processing JSON response from BitcoinAbuse: {e}")- return None- return info+ return Nonedef handleEvent(self, event):eventName = event.eventTypediff --git a/modules/sfp_bitcoinwhoswho.py b/modules/sfp_bitcoinwhoswho.pyindex 199b8442..78ed4e71 100644--- a/modules/sfp_bitcoinwhoswho.py+++ b/modules/sfp_bitcoinwhoswho.py@@ -84,12 +84,11 @@ class sfp_bitcoinwhoswho(SpiderFootPlugin):return Nonetry:- info = json.loads(res["content"])+ return json.loads(res["content"])except Exception as e:self.sf.error(f"Error processing JSON response from {self.meta['name']}: {e}")- return None- return info+ return Nonedef emit(self, etype, data, pevent, notify=True):evt = SpiderFootEvent(etype, data, self.__name__, pevent)diff --git a/modules/sfp_certspotter.py b/modules/sfp_certspotter.pyindex fa5af1fe..60467e95 100644--- a/modules/sfp_certspotter.py+++ b/modules/sfp_certspotter.py@@ -119,25 +119,24 @@ class sfp_certspotter(SpiderFootPlugin):if res['content'] is None:self.sf.debug('No response from CertSpotter API')- return+ return Noneif res['code'] == '429':self.sf.error("You are being rate-limited by CertSpotter")self.errorState = True- return+ return Noneif res['code'] != '200':self.sf.error(f"Unexpected HTTP response code {res['code']} from CertSpotter")self.errorState = True- return+ return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return- return data+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_citadel.py b/modules/sfp_citadel.pyindex 590662a1..68321e06 100644--- a/modules/sfp_citadel.py+++ b/modules/sfp_citadel.py@@ -114,12 +114,11 @@ class sfp_citadel(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_clearbit.py b/modules/sfp_clearbit.pyindex c0ee2d54..783e89d6 100644--- a/modules/sfp_clearbit.py+++ b/modules/sfp_clearbit.py@@ -86,8 +86,6 @@ class sfp_clearbit(SpiderFootPlugin):"AFFILIATE_INTERNET_NAME", "EMAILADDR", "EMAILADDR_GENERIC"]def query(self, t):- ret = None-api_key = self.opts['api_key']if type(api_key) == str:api_key = api_key.encode('utf-8')@@ -105,12 +103,11 @@ class sfp_clearbit(SpiderFootPlugin):return Nonetry:- ret = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.error(f"Error processing JSON response from clearbit.io: {e}")- return None- return ret+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_cloudflaredns.py b/modules/sfp_cloudflaredns.pyindex 4c39907a..bbc030eb 100644--- a/modules/sfp_cloudflaredns.py+++ b/modules/sfp_cloudflaredns.py@@ -73,19 +73,18 @@ class sfp_cloudflaredns(SpiderFootPlugin):try:addrs = res.resolve(qaddr)- self.sf.debug("Addresses returned: " + str(addrs))+ self.sf.debug(f"Addresses returned: {addrs}")except Exception:self.sf.debug(f"Unable to resolve {qaddr}")return False- if addrs:- a = self.sf.normalizeDNS(addrs)- if "0.0.0.0" in a:- return False- else:- return True+ if not addrs:+ return False++ if "0.0.0.0" in self.sf.normalizeDNS(addrs):+ return False- return False+ return True# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_cybercrimetracker.py b/modules/sfp_cybercrimetracker.pyindex 8daca8b0..1ec65ea0 100644--- a/modules/sfp_cybercrimetracker.py+++ b/modules/sfp_cybercrimetracker.py@@ -104,12 +104,12 @@ class sfp_cybercrimetracker(SpiderFootPlugin):if res['code'] != "200":self.sf.error(f"Unexpected HTTP response code {res['code']} from cybercrime-tracker.net.")self.errorState = True- return+ return Noneif res['content'] is None:self.sf.error("Received no content from cybercrime-tracker.net")self.errorState = True- return+ return Noneself.sf.cachePut("cybercrime-tracker", res['content'])diff --git a/modules/sfp_darksearch.py b/modules/sfp_darksearch.pyindex b354b7d7..a662ca1c 100644--- a/modules/sfp_darksearch.py+++ b/modules/sfp_darksearch.py@@ -93,12 +93,11 @@ class sfp_darksearch(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return Nonedef handleEvent(self, event):eventName = event.eventTypediff --git a/modules/sfp_dnsgrep.py b/modules/sfp_dnsgrep.pyindex 96f21151..7b6b218b 100644--- a/modules/sfp_dnsgrep.py+++ b/modules/sfp_dnsgrep.py@@ -100,12 +100,11 @@ class sfp_dnsgrep(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.error(f"Error processing JSON response from DNSGrep: {e}")- return None- return data+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_emailcrawlr.py b/modules/sfp_emailcrawlr.pyindex 9e502a59..49b33d15 100644--- a/modules/sfp_emailcrawlr.py+++ b/modules/sfp_emailcrawlr.py@@ -136,12 +136,11 @@ class sfp_emailcrawlr(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_emailrep.py b/modules/sfp_emailrep.pyindex 67ffaa0d..cdeb96a6 100644--- a/modules/sfp_emailrep.py+++ b/modules/sfp_emailrep.py@@ -113,12 +113,11 @@ class sfp_emailrep(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return Nonedef handleEvent(self, event):eventName = event.eventTypediff --git a/modules/sfp_flickr.py b/modules/sfp_flickr.pyindex e183556b..9191896d 100644--- a/modules/sfp_flickr.py+++ b/modules/sfp_flickr.py@@ -127,13 +127,11 @@ class sfp_flickr(SpiderFootPlugin):time.sleep(self.opts['pause'])try:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")return None- return data-# Handle events sent to this moduledef handleEvent(self, event):eventName = event.eventTypediff --git a/modules/sfp_fraudguard.py b/modules/sfp_fraudguard.pyindex 33f567cb..4c91f66e 100644--- a/modules/sfp_fraudguard.py+++ b/modules/sfp_fraudguard.py@@ -119,12 +119,11 @@ class sfp_fraudguard(SpiderFootPlugin):return Nonetry:- info = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.error(f"Error processing JSON response from Fraudguard.io: {e}")- return None- return info+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_github.py b/modules/sfp_github.pyindex 2f9de896..d4d0c078 100644--- a/modules/sfp_github.py+++ b/modules/sfp_github.py@@ -66,29 +66,30 @@ class sfp_github(SpiderFootPlugin):# Build up repo info for use as an eventdef buildRepoInfo(self, item):- repo_info = None-# Get repos matching the name- if item.get('name') is None:+ name = item.get('name')+ if name is None:self.sf.debug("Incomplete Github information found (name).")return None- if item.get('html_url') is None:+ html_url = item.get('html_url')+ if html_url is None:self.sf.debug("Incomplete Github information found (url).")return None- if item.get('description') is None:+ description = item.get('description')+ if description is None:self.sf.debug("Incomplete Github information found (description).")return None- repo_info = "Name: " + item['name'] + "\n" + "URL: " + item['html_url'] + \- "\n" + "Description: " + item['description']-- return repo_info+ return "\n".join(f"Name: {name}", f"URL: {html_url}", f"Description: {description}")def handleEvent(self, event):eventName = event.eventTypeeventData = event.data+ srcModuleName = event.module++ self.sf.debug(f"Received event, {eventName}, from {srcModuleName}")if eventData in self.results:self.sf.debug(f"Already did a search for {eventData}, skipping.")@@ -105,7 +106,7 @@ class sfp_github(SpiderFootPlugin):self.sf.error(f"Unable to parse SOCIAL_MEDIA: {eventData} ({e})")return None- if not network == "Github":+ if network != "Github":self.sf.debug(f"Skipping social network profile, {url}, as not a GitHub profile")return Nonediff --git a/modules/sfp_grep_app.py b/modules/sfp_grep_app.pyindex db137253..50469643 100644--- a/modules/sfp_grep_app.py+++ b/modules/sfp_grep_app.py@@ -88,12 +88,11 @@ class sfp_grep_app(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return Nonedef handleEvent(self, event):eventName = event.eventType@@ -101,7 +100,7 @@ class sfp_grep_app(SpiderFootPlugin):eventData = event.dataif eventData in self.results:- return None+ returnself.results[eventData] = True@@ -109,7 +108,7 @@ class sfp_grep_app(SpiderFootPlugin):if srcModuleName == 'sfp_grep_app':self.sf.debug("Ignoring " + eventData + ", from self.")- return None+ returnhosts = list()page = 1@@ -117,25 +116,25 @@ class sfp_grep_app(SpiderFootPlugin):pages = self.opts['max_pages']while page <= pages:if self.checkForStop():- return None+ returnif self.errorState:- return None+ returnres = self.query(eventData, page)if res is None:- return None+ returnfacets = res.get('facets')if facets is None:- return None+ returncount = facets.get('count')if count is None:- return None+ returnlast_page = math.ceil(count / per_page)@@ -151,12 +150,12 @@ class sfp_grep_app(SpiderFootPlugin):hits = res.get('hits')if hits is None:- return None+ returndata = hits.get('hits')if data is None:- return None+ returnfor result in data:if result is None:@@ -220,10 +219,10 @@ class sfp_grep_app(SpiderFootPlugin):for host in set(hosts):if self.checkForStop():- return None+ returnif self.errorState:- return None+ returnif self.opts['dns_resolve'] and not self.sf.resolveHost(host):self.sf.debug(f"Host {host} could not be resolved")diff --git a/modules/sfp_greynoise.py b/modules/sfp_greynoise.pyindex f124965f..d6e81d36 100644--- a/modules/sfp_greynoise.py+++ b/modules/sfp_greynoise.py@@ -113,12 +113,11 @@ class sfp_greynoise(SpiderFootPlugin):return Nonetry:- info = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.error(f"Error processing JSON response from Greynoise: {e}")- return None- return info+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_haveibeenpwned.py b/modules/sfp_haveibeenpwned.pyindex 281c036f..f0c892a9 100644--- a/modules/sfp_haveibeenpwned.py+++ b/modules/sfp_haveibeenpwned.py@@ -78,7 +78,6 @@ class sfp_haveibeenpwned(SpiderFootPlugin):return ["EMAILADDR_COMPROMISED", "PHONE_NUMBER_COMPROMISED", "LEAKSITE_CONTENT", "LEAKSITE_URL"]def query(self, qry):- ret = Noneif self.opts['api_key']:version = "3"else:@@ -114,16 +113,13 @@ class sfp_haveibeenpwned(SpiderFootPlugin):return Nonetry:- ret = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.error(f"Error processing JSON response from HaveIBeenPwned?: {e}")- return None- return ret+ return Nonedef queryPaste(self, qry):- ret = None-url = f"https://haveibeenpwned.com/api/v3/pasteaccount/{qry}"headers = {'Accept': "application/json",@@ -155,12 +151,11 @@ class sfp_haveibeenpwned(SpiderFootPlugin):return Nonetry:- ret = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.error(f"Error processing JSON response from HaveIBeenPwned?: {e}")- return None- return ret+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_honeypot.py b/modules/sfp_honeypot.pyindex 16838995..f1cbdfb4 100644--- a/modules/sfp_honeypot.py+++ b/modules/sfp_honeypot.py@@ -128,10 +128,9 @@ class sfp_honeypot(SpiderFootPlugin):if int(bits[3]) == 0 and self.opts['searchengine']:return None- text = "Honeypotproject ({0}): " + self.statuses[bits[3]] + \+ return "Honeypotproject ({0}): " + self.statuses[bits[3]] + \"\nLast Activity: " + bits[1] + " days ago" + \"\nThreat Level: " + bits[2]- return textdef queryAddr(self, qaddr, parentEvent):eventName = parentEvent.eventTypediff --git a/modules/sfp_hostio.py b/modules/sfp_hostio.pyindex 3868b2d6..d8887e4b 100644--- a/modules/sfp_hostio.py+++ b/modules/sfp_hostio.py@@ -109,12 +109,11 @@ class sfp_hostio(SpiderFootPlugin):return Nonetry:- info = json.loads(res["content"])+ return json.loads(res["content"])except Exception as e:self.sf.error(f"Error processing JSON response from Host.io: {e}")- return None- return info+ return Nonedef handleEvent(self, event):eventName = event.eventType@@ -122,7 +121,7 @@ class sfp_hostio(SpiderFootPlugin):eventData = event.dataif self.errorState:- return None+ returnself.sf.debug(f"Received event, {eventName}, from {srcModuleName}")@@ -131,17 +130,18 @@ class sfp_hostio(SpiderFootPlugin):f"You enabled {self.__class__.__name__} but did not set an API key!")self.errorState = True- return None+ returnif eventData in self.results:self.sf.debug(f"Skipping {eventData} as already mapped.")- return None+ return+self.results[eventData] = Truedata = self.query(event.data)if not data:self.sf.error(f"No data received for {event.data}")- return None+ returnfound = Falseipinfo = data.get("ipinfo")diff --git a/modules/sfp_hunter.py b/modules/sfp_hunter.pyindex acad524f..48c89b1b 100644--- a/modules/sfp_hunter.py+++ b/modules/sfp_hunter.py@@ -90,8 +90,6 @@ class sfp_hunter(SpiderFootPlugin):"limit": str(limit)}- ret = None-url = f"https://api.hunter.io/v2/domain-search?{urllib.parse.urlencode(params)}"res = self.sf.fetchUrl(url, timeout=self.opts['_fetchtimeout'], useragent="SpiderFoot")@@ -103,12 +101,11 @@ class sfp_hunter(SpiderFootPlugin):return Nonetry:- ret = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.error(f"Error processing JSON response from hunter.io: {e}")- return None- return ret+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_hybrid_analysis.py b/modules/sfp_hybrid_analysis.pyindex 36b0c155..6f5c9dc1 100644--- a/modules/sfp_hybrid_analysis.py+++ b/modules/sfp_hybrid_analysis.py@@ -194,12 +194,11 @@ class sfp_hybrid_analysis(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return Nonedef handleEvent(self, event):eventName = event.eventTypediff --git a/modules/sfp_iknowwhatyoudownload.py b/modules/sfp_iknowwhatyoudownload.pyindex e1152737..5e489f39 100644--- a/modules/sfp_iknowwhatyoudownload.py+++ b/modules/sfp_iknowwhatyoudownload.py@@ -74,15 +74,11 @@ class sfp_iknowwhatyoudownload(SpiderFootPlugin):# What events is this module interested in for inputdef watchedEvents(self):- ret = ["IP_ADDRESS"]-- return ret+ return ["IP_ADDRESS"]# What events this module producesdef producedEvents(self):- ret = ["MALICIOUS_IPADDR"]-- return ret+ return ["MALICIOUS_IPADDR"]def query(self, qry):ret = None@@ -116,7 +112,7 @@ class sfp_iknowwhatyoudownload(SpiderFootPlugin):if not len(ret['contents']):return None- retdata = "<SFURL>https://iknowwhatyoudownload.com/en/peer/?ip=" + qry + "</SFURL>\n"+ retdata = f"<SFURL>https://iknowwhatyoudownload.com/en/peer/?ip={qry}</SFURL>\n"for d in ret['contents']:retdata += d['torrent']['name'] + " (" + d.get("endDate", "Date unknown") + ")\n"diff --git a/modules/sfp_instagram.py b/modules/sfp_instagram.pyindex cff5a002..c58c1336 100644--- a/modules/sfp_instagram.py+++ b/modules/sfp_instagram.py@@ -65,12 +65,11 @@ class sfp_instagram(SpiderFootPlugin):return Nonetry:- data = json.loads(json_data[0])+ return json.loads(json_data[0])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return Nonedef handleEvent(self, event):eventName = event.eventType@@ -92,7 +91,7 @@ class sfp_instagram(SpiderFootPlugin):self.sf.error(f"Unable to parse SOCIAL_MEDIA: {eventData} ({e})")return None- if not network == 'Instagram':+ if network != 'Instagram':self.sf.debug(f"Skipping social network profile, {url}, as not an Instagram profile")return Nonediff --git a/modules/sfp_ipinfo.py b/modules/sfp_ipinfo.pyindex 17691c0d..1f1d49e2 100644--- a/modules/sfp_ipinfo.py+++ b/modules/sfp_ipinfo.py@@ -93,12 +93,11 @@ class sfp_ipinfo(SpiderFootPlugin):return Nonetry:- result = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return result+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_ipqualityscore.py b/modules/sfp_ipqualityscore.pyindex 6175001a..f89196ed 100644--- a/modules/sfp_ipqualityscore.py+++ b/modules/sfp_ipqualityscore.py@@ -107,7 +107,7 @@ class sfp_ipqualityscore(SpiderFootPlugin):queryString = f"https://ipqualityscore.com/api/json/phone/{self.opts['api_key']}/{qry}?strictness={self.opts['strictness']}"elif eventName == "EMAILADDR":queryString = f"https://ipqualityscore.com/api/json/email/{self.opts['api_key']}/{qry}?strictness={self.opts['strictness']}"- elif eventName == "IP_ADDRESS" or eventName == "DOMAIN_NAME":+ elif eventName in ['IP_ADDRESS', 'DOMAIN_NAME']:queryString = f"https://ipqualityscore.com/api/json/ip/{self.opts['api_key']}/{qry}?strictness={self.opts['strictness']}"res = self.sf.fetchUrl(@@ -220,7 +220,7 @@ class sfp_ipqualityscore(SpiderFootPlugin):evt = SpiderFootEvent("EMAILADDR_COMPROMISED", f"{eventData} [Unknown]", self.__name__, event)self.notifyListeners(evt)- elif eventName == "IP_ADDRESS" or eventName == "DOMAIN_NAME":+ elif eventName in ['IP_ADDRESS', 'DOMAIN_NAME']:if malicious:maliciousDesc += f" - FRAUD SCORE: {fraudScore}\n - BOT STATUS: {botStatus}\n - RECENT ABUSE: {recentAbuse}\n - ABUSE VELOCITY: {data.get('abuse_velocity')}\n - VPN: {data.get('vpn')}\n - ACTIVE VPN: {data.get('active_vpn')}\n - TOR: {data.get('tor')}\n - ACTIVE TOR: {data.get('active_tor')}"diff --git a/modules/sfp_ipregistry.py b/modules/sfp_ipregistry.pyindex 3286b2e5..9cb6e672 100644--- a/modules/sfp_ipregistry.py+++ b/modules/sfp_ipregistry.py@@ -80,14 +80,13 @@ class sfp_ipregistry(SpiderFootPlugin):return Nonetry:- info = json.loads(res["content"])+ return json.loads(res["content"])except Exception as e:self.sf.error(f"Error processing JSON response from {self.meta['name']}: {e}")- return None- return info+ return Nonedef emit(self, etype, data, pevent):evt = SpiderFootEvent(etype, data, self.__name__, pevent)diff --git a/modules/sfp_jsonwhoiscom.py b/modules/sfp_jsonwhoiscom.pyindex 8815b319..8d34bc8f 100644--- a/modules/sfp_jsonwhoiscom.py+++ b/modules/sfp_jsonwhoiscom.py@@ -140,12 +140,11 @@ class sfp_jsonwhoiscom(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_junkfiles.py b/modules/sfp_junkfiles.pyindex 9a8a0350..8681561b 100644--- a/modules/sfp_junkfiles.py+++ b/modules/sfp_junkfiles.py@@ -87,7 +87,6 @@ class sfp_junkfiles(SpiderFootPlugin):eventName = event.eventTypesrcModuleName = event.moduleeventData = event.data- host = self.sf.urlBaseUrl(eventData)self.sf.debug(f"Received event, {eventName}, from {srcModuleName}")@@ -96,6 +95,8 @@ class sfp_junkfiles(SpiderFootPlugin):self.results[eventData] = True+ host = self.sf.urlBaseUrl(eventData)+if host in self.skiphosts:self.sf.debug("Skipping " + host + " because it doesn't return 404s.")return None@@ -115,11 +116,12 @@ class sfp_junkfiles(SpiderFootPlugin):self.sf.debug("Trying " + x + " against " + eventData)fetch = bits[0] + "." + x- if fetch not in self.results:- self.results[fetch] = True- else:+ if fetch in self.results:self.sf.debug("Skipping, already fetched.")continue++ self.results[fetch] = True+res = self.sf.fetchUrl(fetch, headOnly=True,timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'],@@ -138,8 +140,8 @@ class sfp_junkfiles(SpiderFootPlugin):base = self.sf.urlBaseDir(eventData)if not base or base in self.bases:return None- else:- self.bases[base] = True++ self.bases[base] = True# http://www/blah/abc.html -> try http://www/blah/[files]for f in self.opts['files']:@@ -152,11 +154,12 @@ class sfp_junkfiles(SpiderFootPlugin):self.sf.debug("Trying " + f + " against " + eventData)fetch = base + f- if fetch not in self.results:- self.results[fetch] = True- else:+ if fetch in self.results:self.sf.debug("Skipping, already fetched.")continue++ self.results[fetch] = True+res = self.sf.fetchUrl(fetch, headOnly=True,timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'],@@ -172,8 +175,8 @@ class sfp_junkfiles(SpiderFootPlugin):self.notifyListeners(evt)# don't do anything with the root directory of a site- self.sf.debug("Base: " + base + ", event: " + eventData)- if base == eventData + "/" or base == eventData:+ self.sf.debug(f"Base: {base}, event: {eventData}")+ if base in [eventData, eventData + "/"]:return None# http://www/blah/abc.html -> try http://www/blah.[dirs]@@ -191,11 +194,12 @@ class sfp_junkfiles(SpiderFootPlugin):self.sf.debug("Trying " + dirfile + " against " + eventData)fetch = base[0:len(base) - 1] + "." + dirfile- if fetch not in self.results:- self.results[fetch] = True- else:+ if fetch in self.results:self.sf.debug("Skipping, already fetched.")continue++ self.results[fetch] = True+res = self.sf.fetchUrl(fetch, headOnly=True,timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'],diff --git a/modules/sfp_keybase.py b/modules/sfp_keybase.pyindex 7f285928..81096c1a 100644--- a/modules/sfp_keybase.py+++ b/modules/sfp_keybase.py@@ -89,7 +89,7 @@ class sfp_keybase(SpiderFootPlugin):# In this case, it will always be 200 if keybase is queried# The actual response codes are stored in status tag of the response- if not res['code'] == '200':+ if res['code'] != '200':return Nonecontent = json.loads(res['content'])@@ -103,7 +103,7 @@ class sfp_keybase(SpiderFootPlugin):return Nonetry:- if not int(code) == 0:+ if int(code) != 0:return Noneexcept Exception:self.sf.error("Invalid code returned as response")@@ -180,7 +180,7 @@ class sfp_keybase(SpiderFootPlugin):# Failsafe to prevent reporting any wrongly received dataif basics:responseUserName = basics.get('username')- if not userName == responseUserName:+ if userName != responseUserName:self.sf.error("Username does not match received response, skipping")return Nonediff --git a/modules/sfp_leakix.py b/modules/sfp_leakix.pyindex bc9344e3..086437fb 100644--- a/modules/sfp_leakix.py+++ b/modules/sfp_leakix.py@@ -121,12 +121,11 @@ class sfp_leakix(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_maltiverse.py b/modules/sfp_maltiverse.pyindex 55599f4c..9a491987 100644--- a/modules/sfp_maltiverse.py+++ b/modules/sfp_maltiverse.py@@ -105,7 +105,7 @@ class sfp_maltiverse(SpiderFootPlugin):self.sf.error("API endpoint not found")return None- if not res['code'] == "200":+ if res['code'] != "200":self.sf.debug("No information found from Maltiverse for IP Address")return Nonediff --git a/modules/sfp_metadefender.py b/modules/sfp_metadefender.pyindex 7d82587b..343a8be1 100644--- a/modules/sfp_metadefender.py+++ b/modules/sfp_metadefender.py@@ -131,12 +131,11 @@ class sfp_metadefender(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_openbugbounty.py b/modules/sfp_openbugbounty.pyindex e1507182..edd09a5c 100644--- a/modules/sfp_openbugbounty.py+++ b/modules/sfp_openbugbounty.py@@ -69,9 +69,7 @@ class sfp_openbugbounty(SpiderFootPlugin):# What events this module producesdef producedEvents(self):- ret = ["VULNERABILITY"]-- return ret+ return ["VULNERABILITY"]# Query XSSposed.orgdef queryOBB(self, qry):diff --git a/modules/sfp_opencorporates.py b/modules/sfp_opencorporates.pyindex df96021e..c77bea00 100644--- a/modules/sfp_opencorporates.py+++ b/modules/sfp_opencorporates.py@@ -86,7 +86,7 @@ class sfp_opencorporates(SpiderFootPlugin):version = '0.4'apiparam = ""- if not self.opts['api_key'] == "":+ if self.opts['api_key']:apiparam = "&api_token=" + self.opts['api_key']params = urllib.parse.urlencode({@@ -124,7 +124,7 @@ class sfp_opencorporates(SpiderFootPlugin):def retrieveCompanyDetails(self, jurisdiction_code, company_number):url = f"https://api.opencorporates.com/companies/{jurisdiction_code}/{company_number}"- if not self.opts['api_key'] == "":+ if self.opts['api_key']:url += "?api_token=" + self.opts['api_key']res = self.sf.fetchUrl(@@ -230,7 +230,7 @@ class sfp_opencorporates(SpiderFootPlugin):continue# Check for match- if not eventData.lower() == company.get('name').lower():+ if eventData.lower() != company.get('name').lower():continue# Extract company details from search resultsdiff --git a/modules/sfp_openphish.py b/modules/sfp_openphish.pyindex 0c18b5c0..2ded40d6 100644--- a/modules/sfp_openphish.py+++ b/modules/sfp_openphish.py@@ -135,7 +135,7 @@ class sfp_openphish(SpiderFootPlugin):# Note: URL parsing and validation with sf.validHost() is too slow to use hereurl = line.strip().lower()- if not len(url.split("/")) >= 3:+ if len(url.split("/")) < 3:continuehost = url.split("/")[2]if not host:diff --git a/modules/sfp_openstreetmap.py b/modules/sfp_openstreetmap.pyindex fdb38496..ca2fdb27 100644--- a/modules/sfp_openstreetmap.py+++ b/modules/sfp_openstreetmap.py@@ -83,12 +83,11 @@ class sfp_openstreetmap(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_phishstats.py b/modules/sfp_phishstats.pyindex 0a5034c9..9e56d82d 100644--- a/modules/sfp_phishstats.py+++ b/modules/sfp_phishstats.py@@ -106,7 +106,7 @@ class sfp_phishstats(SpiderFootPlugin):useragent=self.opts['_useragent'])- if not res['code'] == "200":+ if res['code'] != "200":self.sf.debug("No information found from Phishstats for IP Address")return Nonediff --git a/modules/sfp_phishtank.py b/modules/sfp_phishtank.pyindex b3f03524..d4dd37bc 100644--- a/modules/sfp_phishtank.py+++ b/modules/sfp_phishtank.py@@ -134,7 +134,7 @@ class sfp_phishtank(SpiderFootPlugin):phish_id = line.strip().split(",")[0]url = str(line.strip().split(",")[1]).lower()# Note: URL parsing and validation with sf.validHost() is too slow to use here- if not len(url.split("/")) >= 3:+ if len(url.split("/")) < 3:continuehost = url.split("/")[2]if not host:diff --git a/modules/sfp_projectdiscovery.py b/modules/sfp_projectdiscovery.pyindex 73b66c96..07c008d7 100644--- a/modules/sfp_projectdiscovery.py+++ b/modules/sfp_projectdiscovery.py@@ -84,14 +84,13 @@ class sfp_projectdiscovery(SpiderFootPlugin):return Nonetry:- info = json.loads(res["content"])+ return json.loads(res["content"])except json.JSONDecodeError as e:self.sf.error(f"Error processing JSON response from Chaos projectdiscovery: {e}")- return None- return info+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_pulsedive.py b/modules/sfp_pulsedive.pyindex b1c06f76..d0b45b19 100644--- a/modules/sfp_pulsedive.py+++ b/modules/sfp_pulsedive.py@@ -121,12 +121,11 @@ class sfp_pulsedive(SpiderFootPlugin):return Nonetry:- info = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.error(f"Error processing JSON response from Pulsedive: {e}")- return None- return info+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_punkspider.py b/modules/sfp_punkspider.pyindex 64ee8fe8..2258612e 100644--- a/modules/sfp_punkspider.py+++ b/modules/sfp_punkspider.py@@ -61,12 +61,9 @@ class sfp_punkspider(SpiderFootPlugin):# What events this module producesdef producedEvents(self):- ret = ["VULNERABILITY"]-- return ret+ return ["VULNERABILITY"]def query(self, qry):- ret = Noneqryhash = hashlib.md5(qry.encode('utf-8', errors='replace').lower()).hexdigest() # noqa: DUO130url = f"https://api.punkspider.org/api/partial-hash/{qryhash}"@@ -76,11 +73,11 @@ class sfp_punkspider(SpiderFootPlugin):return Nonetry:- ret = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.error(f"Error processing response from PunkSpider: {e}")- return None- return ret++ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_reversewhois.py b/modules/sfp_reversewhois.pyindex 5140dc75..fff81f1f 100644--- a/modules/sfp_reversewhois.py+++ b/modules/sfp_reversewhois.py@@ -11,6 +11,7 @@# -------------------------------------------------------------------------------import re+from bs4 import BeautifulSoupfrom spiderfoot import SpiderFootEvent, SpiderFootPlugindiff --git a/modules/sfp_ripe.py b/modules/sfp_ripe.pyindex 88af0d2d..c77a4ea2 100644--- a/modules/sfp_ripe.py+++ b/modules/sfp_ripe.py@@ -256,15 +256,17 @@ class sfp_ripe(SpiderFootPlugin):def ownsAs(self, asn):# Determine whether the AS is owned by our targetownerinfo = self.asOwnerInfo(asn)- owned = False-- if ownerinfo is not None:- for k in list(ownerinfo.keys()):- items = ownerinfo[k]- for item in items:- if self.findName(item.lower()):- owned = True- return owned++ if not ownerinfo:+ return False++ for k in list(ownerinfo.keys()):+ items = ownerinfo[k]+ for item in items:+ if self.findName(item.lower()):+ return True++ return False# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_scylla.py b/modules/sfp_scylla.pyindex 1307c5b9..c2262d07 100644--- a/modules/sfp_scylla.py+++ b/modules/sfp_scylla.py@@ -84,7 +84,7 @@ class sfp_scylla(SpiderFootPlugin):headers = {'Accept': 'application/json'}- res = self.sf.fetchUrl('https://scylla.so/search?' + urllib.parse.urlencode(params),+ res = self.sf.fetchUrl(f"https://scylla.so/search?{urllib.parse.urlencode(params)}",headers=headers,timeout=15,useragent=self.opts['_useragent'],@@ -103,12 +103,11 @@ class sfp_scylla(SpiderFootPlugin):return Nonetry:- data = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.debug(f"Error processing JSON response: {e}")- return None- return data+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_seon.py b/modules/sfp_seon.pyindex e443fcaf..58e4b81c 100644--- a/modules/sfp_seon.py+++ b/modules/sfp_seon.py@@ -96,7 +96,7 @@ class sfp_seon(SpiderFootPlugin):]def query(self, qry, eventName):- if eventName == "IP_ADDRESS" or eventName == "IPV6_ADDRESS":+ if eventName in ['IP_ADDRESS', 'IPV6_ADDRESS']:queryString = f"https://api.seon.io/SeonRestService/ip-api/v1.0/{qry}"elif eventName == "EMAILADDR":queryString = f"https://api.seon.io/SeonRestService/email-api/v2.0/{qry}"@@ -152,7 +152,7 @@ class sfp_seon(SpiderFootPlugin):self.results[eventData] = TruedataFound = False- if eventName == "IP_ADDRESS" or eventName == "IPV6_ADDRESS":+ if eventName in ['IP_ADDRESS', 'IPV6_ADDRESS']:data = self.query(eventData, eventName)if data is None:return Nonediff --git a/modules/sfp_slideshare.py b/modules/sfp_slideshare.pyindex 87f814fb..b4861985 100644--- a/modules/sfp_slideshare.py+++ b/modules/sfp_slideshare.py@@ -87,7 +87,7 @@ class sfp_slideshare(SpiderFootPlugin):self.sf.error(f"Unable to parse SOCIAL_MEDIA: {eventData} ({e})")return None- if not network == "SlideShare":+ if network != "SlideShare":self.sf.debug(f"Skipping social network profile, {url}, as not a SlideShare profile")return Nonediff --git a/modules/sfp_snov.py b/modules/sfp_snov.pyindex 3b7b7987..a7875e93 100644--- a/modules/sfp_snov.py+++ b/modules/sfp_snov.py@@ -99,7 +99,7 @@ class sfp_snov(SpiderFootPlugin):useragent=self.opts['_useragent'])- if not res['code'] == '200':+ if res['code'] != '200':self.sf.error("No access token received from snov.io for the provided Client ID and/or Client Secret")self.errorState = Truereturn None@@ -138,7 +138,7 @@ class sfp_snov(SpiderFootPlugin):timeout=30,useragent=self.opts['_useragent'])- if not res['code'] == '200':+ if res['code'] != '200':self.sf.debug("Could not fetch email addresses")return Nonediff --git a/modules/sfp_spur.py b/modules/sfp_spur.pyindex 7b6877c6..d20083f9 100644--- a/modules/sfp_spur.py+++ b/modules/sfp_spur.py@@ -125,7 +125,7 @@ class sfp_spur(SpiderFootPlugin):self.sf.debug("IP Address not found.")return None- if not code == '200':+ if code != '200':self.sf.error("Unable to fetch data from spur.us")return Nonediff --git a/modules/sfp_spyonweb.py b/modules/sfp_spyonweb.pyindex dd444f93..d9e9d66a 100644--- a/modules/sfp_spyonweb.py+++ b/modules/sfp_spyonweb.py@@ -110,7 +110,7 @@ class sfp_spyonweb(SpiderFootPlugin):status = data.get('status')- if not status == 'found':+ if status != 'found':self.sf.debug("No results found for " + qry)return Nonediff --git a/modules/sfp_subdomain_takeover.py b/modules/sfp_subdomain_takeover.pyindex 4dc2fe9b..c9341bbe 100644--- a/modules/sfp_subdomain_takeover.py+++ b/modules/sfp_subdomain_takeover.py@@ -103,7 +103,7 @@ class sfp_subdomain_takeover(SpiderFootPlugin):continuefor cname in cnames:- if not cname.lower() in eventData.lower():+ if cname.lower() not in eventData.lower():continuefor proto in ["https", "http"]:@@ -134,7 +134,7 @@ class sfp_subdomain_takeover(SpiderFootPlugin):continuefor cname in cnames:- if not cname.lower() in eventData.lower():+ if cname.lower() not in eventData.lower():continueself.sf.info(f"{eventData} appears to be vulnerable to takeover on {service}")evt = SpiderFootEvent("AFFILIATE_INTERNET_NAME_HIJACKABLE", eventData, self.__name__, event)diff --git a/modules/sfp_threatcrowd.py b/modules/sfp_threatcrowd.pyindex 69a6cc23..84a4c7f9 100644--- a/modules/sfp_threatcrowd.py+++ b/modules/sfp_threatcrowd.py@@ -90,7 +90,6 @@ class sfp_threatcrowd(SpiderFootPlugin):"MALICIOUS_SUBNET", "MALICIOUS_EMAILADDR"]def query(self, qry):- ret = Noneurl = Noneif self.sf.validIP(qry):@@ -105,17 +104,16 @@ class sfp_threatcrowd(SpiderFootPlugin):res = self.sf.fetchUrl(url, timeout=self.opts['_fetchtimeout'], useragent="SpiderFoot")if res['content'] is None:- self.sf.info("No ThreatCrowd info found for " + qry)+ self.sf.info(f"No ThreatCrowd info found for {qry}")return Nonetry:- ret = json.loads(res['content'])+ return json.loads(res['content'])except Exception as e:self.sf.error(f"Error processing JSON response from ThreatCrowd: {e}")self.errorState = True- return None- return ret+ return None# Handle events sent to this moduledef handleEvent(self, event):diff --git a/modules/sfp_trashpanda.py b/modules/sfp_trashpanda.pyindex 89708136..a466c8dc 100644--- a/modules/sfp_trashpanda.py+++ b/modules/sfp_trashpanda.py@@ -86,7 +86,7 @@ class sfp_trashpanda(SpiderFootPlugin):auth = base64.b64encode(secret.encode('utf-8')).decode('utf-8')queryString = ""- if eventName == "DOMAIN_NAME" or eventName == "INTERNET_NAME":+ if eventName in ['DOMAIN_NAME', 'INTERNET_NAME']:queryString = f"http://api.got-hacked.wtf:5580/domain?v={qry}&s=zpg"elif eventName == "EMAILADDR":queryString = f"http://api.got-hacked.wtf:5580/email?v={qry}&s=zpg"diff --git a/modules/sfp_twilio.py b/modules/sfp_twilio.pyindex 07544e00..a61b5521 100644--- a/modules/sfp_twilio.py+++ b/modules/sfp_twilio.py@@ -105,7 +105,7 @@ class sfp_twilio(SpiderFootPlugin):self.sf.error("Service unavailable.")return None- if not res['code'] == '200':+ if res['code'] != '200':self.sf.error("Could not fetch data.")return Nonediff --git a/modules/sfp_twitter.py b/modules/sfp_twitter.pyindex 87da9714..31ee8797 100644--- a/modules/sfp_twitter.py+++ b/modules/sfp_twitter.py@@ -79,8 +79,8 @@ class sfp_twitter(SpiderFootPlugin):self.sf.error(f"Unable to parse SOCIAL_MEDIA: {eventData} ({e})")return- if not network == "Twitter":- self.sf.debug("Skipping social network profile, " + url + ", as not a Twitter profile")+ if network != "Twitter":+ self.sf.debug(f"Skipping social network profile, {url}, as not a Twitter profile")returnres = self.sf.fetchUrl(url, timeout=self.opts['_fetchtimeout'],@@ -89,7 +89,7 @@ class sfp_twitter(SpiderFootPlugin):if res['content'] is None:return- if not res['code'] == "200":+ if res['code'] != "200":self.sf.debug(url + " is not a valid Twitter profile")returndiff --git a/modules/sfp_vxvault.py b/modules/sfp_vxvault.pyindex e95d4e20..ecac6f39 100644--- a/modules/sfp_vxvault.py+++ b/modules/sfp_vxvault.py@@ -139,7 +139,7 @@ class sfp_vxvault(SpiderFootPlugin):# Note: URL parsing and validation with sf.validHost() is too slow to use hereurl = line.strip().lower()- if not len(url.split("/")) >= 3:+ if len(url.split("/")) < 3:continuehost = url.split("/")[2]if not host:diff --git a/modules/sfp_zetalytics.py b/modules/sfp_zetalytics.pyindex e6fdee38..1ba521ff 100644--- a/modules/sfp_zetalytics.py+++ b/modules/sfp_zetalytics.py@@ -71,17 +71,20 @@ class sfp_zetalytics(SpiderFootPlugin):def verify_emit_internet_name(self, hostname, pevent):if f"INTERNET_NAME:{hostname}" in self.results:return False+if not self.getTarget().matches(hostname):return False+if self.opts["verify"] and not self.sf.resolveHost(hostname):self.sf.debug(f"Host {hostname} could not be resolved")self.emit("INTERNET_NAME_UNRESOLVED", hostname, pevent)return True- else:- self.emit("INTERNET_NAME", hostname, pevent)- if self.sf.isDomain(hostname, self.opts["_internettlds"]):- self.emit("DOMAIN_NAME", hostname, pevent)- return True++ self.emit("INTERNET_NAME", hostname, pevent)+ if self.sf.isDomain(hostname, self.opts["_internettlds"]):+ self.emit("DOMAIN_NAME", hostname, pevent)++ return Truedef request(self, path, params):params = {**params, "token": self.opts["api_key"]}@@ -115,16 +118,21 @@ class sfp_zetalytics(SpiderFootPlugin):return self.request("/email_address", {"q": email_address})def generate_subdomains_events(self, data, pevent):+ if not isinstance(data, dict):+ return False++ results = data.get("results", [])+ if not isinstance(results, list):+ return False+events_generated = False- if isinstance(data, dict):- results = data.get("results", [])- if isinstance(results, list):- for r in results:- qname = r.get("qname")- if not isinstance(qname, str):- continue- if self.verify_emit_internet_name(qname, pevent):- events_generated = True+ for r in results:+ qname = r.get("qname")+ if not isinstance(qname, str):+ continue+ if self.verify_emit_internet_name(qname, pevent):+ events_generated = True+return events_generateddef generate_hostname_events(self, data, pevent):@@ -175,7 +183,7 @@ class sfp_zetalytics(SpiderFootPlugin):returnif self.checkForStop():- return None+ returnself.sf.debug(f"Received event, {eventName}, from {srcModuleName}")diff --git a/setup.cfg b/setup.cfgindex 62a94beb..4013220e 100644--- a/setup.cfg+++ b/setup.cfg@@ -3,22 +3,26 @@ flake8-max-line-length = 120max-line-length = 120max-complexity = 80select = C,E,F,W,I,B,DUO,D,R,A,S,Q0,SIM,SFS-ignore = E501 W503 B006 E800 B9 SFS301 SF01 Q000 SIM+# Note: B9 and SIM tests should be reviewed and fixed instead of ignored+ignore = E501 W503 B006 E800 B9 SFS301 SF01 Q000 SIM102 SIM110 SIM111 SIM113 SIM115 SIM118+# Note: most of these should be fixed instead of ignoredper-file-ignores =spiderfoot/event.py:A,Dspiderfoot/plugin.py:I,D- spiderfoot/db.py:A,D,SFS101+ spiderfoot/db.py:A,D,SFS101,SIM106sf.py:I,D,SFS101,SFS201sflib.py:I,D,SFS101sfwebui.py:A,I,D,SFS101,Q003- sfscan.py:I,D- modules/*:R,I,D+ sfscan.py:I,D,SIM105,SIM109+ modules/*:I,D,R501,R502modules/sfp__stor_stdout.py:D,SFS201modules/sfp_bitcoin.py:D,SFS101+ modules/sfp_reversewhois.py:D,R504+ modules/sfp_zetalytics.py:D,R504spiderfoot/*:I,Dspiderfoot/__init__.py:I,D,F401sfcli.py:D- test/*:I,D+ test/*:I,D,SIM117docs/conf.py:A,D[darglint]diff --git a/sfcli.py b/sfcli.pyindex 200d7bb1..cfe65c60 100755--- a/sfcli.py+++ b/sfcli.py@@ -502,7 +502,7 @@ class SpiderFootCli(cmd.Cmd):if re.match(p, r.strip()):newout += r + "\n"- if pipecmd == "str" or pipecmd == "grep":+ if pipecmd in ['str', 'grep']:for r in out.split("\n"):if pipeargs.lower() in r.strip().lower():newout += r + "\n"@@ -1171,11 +1171,8 @@ class SpiderFootCli(cmd.Cmd):output = list()for k in ks:c = self.ownopts[k]- if type(c) == bool:- if c:- c = "True"- else:- c = "False"+ if isinstance(c, bool):+ c = str(c)if not cfg:output.append({'opt': k, 'val': c})diff --git a/test/unit/test_spiderfoot.py b/test/unit/test_spiderfoot.pyindex 8dc197a6..a010fea4 100644--- a/test/unit/test_spiderfoot.py+++ b/test/unit/test_spiderfoot.py@@ -38,9 +38,8 @@ class TestSpiderFoot(unittest.TestCase):"""invalid_types = [None, "", list(), int()]for invalid_type in invalid_types:- with self.subTest(invalid_type=invalid_type):- with self.assertRaises(TypeError):- SpiderFoot(invalid_type)+ with self.subTest(invalid_type=invalid_type), self.assertRaises(TypeError):+ SpiderFoot(invalid_type)def test_init_argument_options_with_empty_dict(self):"""@@ -85,6 +84,17 @@ class TestSpiderFoot(unittest.TestCase):self.assertIsInstance(opt_data, str)self.assertEqual(test_string, opt_data)+ def test_optValueToData_argument_val_filename_should_return_file_contents_as_string(self):+ """+ Test optValueToData(self, val)+ """+ sf = SpiderFoot(self.default_options)++ test_string = "@VERSION"+ opt_data = sf.optValueToData(test_string)+ self.assertIsInstance(opt_data, str)+ self.assertTrue(opt_data.startswith("SpiderFoot"))+def test_optValueToData_argument_val_invalid_type_should_return_None(self):"""Test optValueToData(self, val)@@ -1137,9 +1147,8 @@ class TestSpiderFoot(unittest.TestCase):invalid_types = [None, "", list()]for invalid_type in invalid_types:- with self.subTest(invalid_type=invalid_type):- with self.assertRaises(TypeError):- sf.sslDerToPem(invalid_type)+ with self.subTest(invalid_type=invalid_type), self.assertRaises(TypeError):+ sf.sslDerToPem(invalid_type)def test_parse_cert_should_return_a_dict(self):"""