Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

flake8: Resolve various SIM and R violations (#1306)

bcoles21cfa91f8e79
diff --git a/modules/sfp_abstractapi.py b/modules/sfp_abstractapi.py
index 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 None
if res['code'] == '429':
self.sf.error("You are being rate-limited by AbstractAPI.")
- return
+ return None
if res['code'] == '401':
self.sf.error("Unauthorized. Invalid AbstractAPI API key.")
self.errorState = True
- return
+ return None
if res['code'] == '422':
self.sf.error("Usage quota reached. Insufficient API credit.")
self.errorState = True
- return
+ return None
if res['code'] == '500' or res['code'] == '503':
self.sf.error("Abstract API service is unavailable")
self.errorState = True
- return
+ return None
if res['code'] == '204':
self.sf.debug("No response data for target")
- return
+ return None
if res['code'] != '200':
self.sf.error(f"Unexpected reply from AbstractAPI: {res['code']}")
- return
+ return None
if res['content'] is None:
- return
+ return None
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
- return data
+ return None
def 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 None
params = 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 None
return 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 None
return 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 None
return 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.py
index 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 None
if 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 None
if res['content'] is None or res['code'] == "404":
- return
+ return None
try:
- 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 None
def 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.py
index 27c88cc1..f65d816c 100644
--- a/modules/sfp_apility.py
+++ b/modules/sfp_apility.py
@@ -167,12 +167,11 @@ class sfp_apility(SpiderFootPlugin):
return None
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
+ return None
# Handle events sent to this module
def handleEvent(self, event):
diff --git a/modules/sfp_arin.py b/modules/sfp_arin.py
index d91f67c6..5928b669 100644
--- a/modules/sfp_arin.py
+++ b/modules/sfp_arin.py
@@ -110,15 +110,15 @@ class sfp_arin(SpiderFootPlugin):
return None
try:
- 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 module
def handleEvent(self, event):
eventName = event.eventType
diff --git a/modules/sfp_bgpview.py b/modules/sfp_bgpview.py
index 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 None
diff --git a/modules/sfp_bitcoinabuse.py b/modules/sfp_bitcoinabuse.py
index ae254875..627c0e7d 100644
--- a/modules/sfp_bitcoinabuse.py
+++ b/modules/sfp_bitcoinabuse.py
@@ -86,12 +86,11 @@ class sfp_bitcoinabuse(SpiderFootPlugin):
return None
try:
- 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 None
def handleEvent(self, event):
eventName = event.eventType
diff --git a/modules/sfp_bitcoinwhoswho.py b/modules/sfp_bitcoinwhoswho.py
index 199b8442..78ed4e71 100644
--- a/modules/sfp_bitcoinwhoswho.py
+++ b/modules/sfp_bitcoinwhoswho.py
@@ -84,12 +84,11 @@ class sfp_bitcoinwhoswho(SpiderFootPlugin):
return None
try:
- 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 None
def 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.py
index 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 None
if res['code'] == '429':
self.sf.error("You are being rate-limited by CertSpotter")
self.errorState = True
- return
+ return None
if res['code'] != '200':
self.sf.error(f"Unexpected HTTP response code {res['code']} from CertSpotter")
self.errorState = True
- return
+ return None
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
- return data
+ return None
# Handle events sent to this module
def handleEvent(self, event):
diff --git a/modules/sfp_citadel.py b/modules/sfp_citadel.py
index 590662a1..68321e06 100644
--- a/modules/sfp_citadel.py
+++ b/modules/sfp_citadel.py
@@ -114,12 +114,11 @@ class sfp_citadel(SpiderFootPlugin):
return None
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
+ return None
# Handle events sent to this module
def handleEvent(self, event):
diff --git a/modules/sfp_clearbit.py b/modules/sfp_clearbit.py
index 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 None
try:
- 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_cloudflaredns.py b/modules/sfp_cloudflaredns.py
index 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_cybercrimetracker.py b/modules/sfp_cybercrimetracker.py
index 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 None
if res['content'] is None:
self.sf.error("Received no content from cybercrime-tracker.net")
self.errorState = True
- return
+ return None
self.sf.cachePut("cybercrime-tracker", res['content'])
diff --git a/modules/sfp_darksearch.py b/modules/sfp_darksearch.py
index b354b7d7..a662ca1c 100644
--- a/modules/sfp_darksearch.py
+++ b/modules/sfp_darksearch.py
@@ -93,12 +93,11 @@ class sfp_darksearch(SpiderFootPlugin):
return None
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
+ return None
def handleEvent(self, event):
eventName = event.eventType
diff --git a/modules/sfp_dnsgrep.py b/modules/sfp_dnsgrep.py
index 96f21151..7b6b218b 100644
--- a/modules/sfp_dnsgrep.py
+++ b/modules/sfp_dnsgrep.py
@@ -100,12 +100,11 @@ class sfp_dnsgrep(SpiderFootPlugin):
return None
try:
- 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_emailcrawlr.py b/modules/sfp_emailcrawlr.py
index 9e502a59..49b33d15 100644
--- a/modules/sfp_emailcrawlr.py
+++ b/modules/sfp_emailcrawlr.py
@@ -136,12 +136,11 @@ class sfp_emailcrawlr(SpiderFootPlugin):
return None
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
+ return None
# Handle events sent to this module
def handleEvent(self, event):
diff --git a/modules/sfp_emailrep.py b/modules/sfp_emailrep.py
index 67ffaa0d..cdeb96a6 100644
--- a/modules/sfp_emailrep.py
+++ b/modules/sfp_emailrep.py
@@ -113,12 +113,11 @@ class sfp_emailrep(SpiderFootPlugin):
return None
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
+ return None
def handleEvent(self, event):
eventName = event.eventType
diff --git a/modules/sfp_flickr.py b/modules/sfp_flickr.py
index 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 module
def handleEvent(self, event):
eventName = event.eventType
diff --git a/modules/sfp_fraudguard.py b/modules/sfp_fraudguard.py
index 33f567cb..4c91f66e 100644
--- a/modules/sfp_fraudguard.py
+++ b/modules/sfp_fraudguard.py
@@ -119,12 +119,11 @@ class sfp_fraudguard(SpiderFootPlugin):
return None
try:
- 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_github.py b/modules/sfp_github.py
index 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 event
def 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.eventType
eventData = 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 None
diff --git a/modules/sfp_grep_app.py b/modules/sfp_grep_app.py
index 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 None
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
+ return None
def handleEvent(self, event):
eventName = event.eventType
@@ -101,7 +100,7 @@ class sfp_grep_app(SpiderFootPlugin):
eventData = event.data
if eventData in self.results:
- return None
+ return
self.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
+ return
hosts = 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
+ return
if self.errorState:
- return None
+ return
res = self.query(eventData, page)
if res is None:
- return None
+ return
facets = res.get('facets')
if facets is None:
- return None
+ return
count = facets.get('count')
if count is None:
- return None
+ return
last_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
+ return
data = hits.get('hits')
if data is None:
- return None
+ return
for 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
+ return
if self.errorState:
- return None
+ return
if 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.py
index f124965f..d6e81d36 100644
--- a/modules/sfp_greynoise.py
+++ b/modules/sfp_greynoise.py
@@ -113,12 +113,11 @@ class sfp_greynoise(SpiderFootPlugin):
return None
try:
- 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_haveibeenpwned.py b/modules/sfp_haveibeenpwned.py
index 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 = None
if self.opts['api_key']:
version = "3"
else:
@@ -114,16 +113,13 @@ class sfp_haveibeenpwned(SpiderFootPlugin):
return None
try:
- 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
def 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 None
try:
- 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_honeypot.py b/modules/sfp_honeypot.py
index 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 text
def queryAddr(self, qaddr, parentEvent):
eventName = parentEvent.eventType
diff --git a/modules/sfp_hostio.py b/modules/sfp_hostio.py
index 3868b2d6..d8887e4b 100644
--- a/modules/sfp_hostio.py
+++ b/modules/sfp_hostio.py
@@ -109,12 +109,11 @@ class sfp_hostio(SpiderFootPlugin):
return None
try:
- 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 None
def handleEvent(self, event):
eventName = event.eventType
@@ -122,7 +121,7 @@ class sfp_hostio(SpiderFootPlugin):
eventData = event.data
if self.errorState:
- return None
+ return
self.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
+ return
if eventData in self.results:
self.sf.debug(f"Skipping {eventData} as already mapped.")
- return None
+ return
+
self.results[eventData] = True
data = self.query(event.data)
if not data:
self.sf.error(f"No data received for {event.data}")
- return None
+ return
found = False
ipinfo = data.get("ipinfo")
diff --git a/modules/sfp_hunter.py b/modules/sfp_hunter.py
index 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 None
try:
- 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_hybrid_analysis.py b/modules/sfp_hybrid_analysis.py
index 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 None
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
+ return None
def handleEvent(self, event):
eventName = event.eventType
diff --git a/modules/sfp_iknowwhatyoudownload.py b/modules/sfp_iknowwhatyoudownload.py
index 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 input
def watchedEvents(self):
- ret = ["IP_ADDRESS"]
-
- return ret
+ return ["IP_ADDRESS"]
# What events this module produces
def 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.py
index cff5a002..c58c1336 100644
--- a/modules/sfp_instagram.py
+++ b/modules/sfp_instagram.py
@@ -65,12 +65,11 @@ class sfp_instagram(SpiderFootPlugin):
return None
try:
- 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 None
def 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 None
diff --git a/modules/sfp_ipinfo.py b/modules/sfp_ipinfo.py
index 17691c0d..1f1d49e2 100644
--- a/modules/sfp_ipinfo.py
+++ b/modules/sfp_ipinfo.py
@@ -93,12 +93,11 @@ class sfp_ipinfo(SpiderFootPlugin):
return None
try:
- 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_ipqualityscore.py b/modules/sfp_ipqualityscore.py
index 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.py
index 3286b2e5..9cb6e672 100644
--- a/modules/sfp_ipregistry.py
+++ b/modules/sfp_ipregistry.py
@@ -80,14 +80,13 @@ class sfp_ipregistry(SpiderFootPlugin):
return None
try:
- 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 None
def emit(self, etype, data, pevent):
evt = SpiderFootEvent(etype, data, self.__name__, pevent)
diff --git a/modules/sfp_jsonwhoiscom.py b/modules/sfp_jsonwhoiscom.py
index 8815b319..8d34bc8f 100644
--- a/modules/sfp_jsonwhoiscom.py
+++ b/modules/sfp_jsonwhoiscom.py
@@ -140,12 +140,11 @@ class sfp_jsonwhoiscom(SpiderFootPlugin):
return None
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
+ return None
# Handle events sent to this module
def handleEvent(self, event):
diff --git a/modules/sfp_junkfiles.py b/modules/sfp_junkfiles.py
index 9a8a0350..8681561b 100644
--- a/modules/sfp_junkfiles.py
+++ b/modules/sfp_junkfiles.py
@@ -87,7 +87,6 @@ class sfp_junkfiles(SpiderFootPlugin):
eventName = event.eventType
srcModuleName = event.module
eventData = 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.py
index 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 None
content = json.loads(res['content'])
@@ -103,7 +103,7 @@ class sfp_keybase(SpiderFootPlugin):
return None
try:
- if not int(code) == 0:
+ if int(code) != 0:
return None
except Exception:
self.sf.error("Invalid code returned as response")
@@ -180,7 +180,7 @@ class sfp_keybase(SpiderFootPlugin):
# Failsafe to prevent reporting any wrongly received data
if basics:
responseUserName = basics.get('username')
- if not userName == responseUserName:
+ if userName != responseUserName:
self.sf.error("Username does not match received response, skipping")
return None
diff --git a/modules/sfp_leakix.py b/modules/sfp_leakix.py
index bc9344e3..086437fb 100644
--- a/modules/sfp_leakix.py
+++ b/modules/sfp_leakix.py
@@ -121,12 +121,11 @@ class sfp_leakix(SpiderFootPlugin):
return None
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
+ return None
# Handle events sent to this module
def handleEvent(self, event):
diff --git a/modules/sfp_maltiverse.py b/modules/sfp_maltiverse.py
index 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 None
diff --git a/modules/sfp_metadefender.py b/modules/sfp_metadefender.py
index 7d82587b..343a8be1 100644
--- a/modules/sfp_metadefender.py
+++ b/modules/sfp_metadefender.py
@@ -131,12 +131,11 @@ class sfp_metadefender(SpiderFootPlugin):
return None
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
+ return None
# Handle events sent to this module
def handleEvent(self, event):
diff --git a/modules/sfp_openbugbounty.py b/modules/sfp_openbugbounty.py
index 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 produces
def producedEvents(self):
- ret = ["VULNERABILITY"]
-
- return ret
+ return ["VULNERABILITY"]
# Query XSSposed.org
def queryOBB(self, qry):
diff --git a/modules/sfp_opencorporates.py b/modules/sfp_opencorporates.py
index 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 results
diff --git a/modules/sfp_openphish.py b/modules/sfp_openphish.py
index 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 here
url = line.strip().lower()
- if not len(url.split("/")) >= 3:
+ if len(url.split("/")) < 3:
continue
host = url.split("/")[2]
if not host:
diff --git a/modules/sfp_openstreetmap.py b/modules/sfp_openstreetmap.py
index fdb38496..ca2fdb27 100644
--- a/modules/sfp_openstreetmap.py
+++ b/modules/sfp_openstreetmap.py
@@ -83,12 +83,11 @@ class sfp_openstreetmap(SpiderFootPlugin):
return None
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
+ return None
# Handle events sent to this module
def handleEvent(self, event):
diff --git a/modules/sfp_phishstats.py b/modules/sfp_phishstats.py
index 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 None
diff --git a/modules/sfp_phishtank.py b/modules/sfp_phishtank.py
index 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:
continue
host = url.split("/")[2]
if not host:
diff --git a/modules/sfp_projectdiscovery.py b/modules/sfp_projectdiscovery.py
index 73b66c96..07c008d7 100644
--- a/modules/sfp_projectdiscovery.py
+++ b/modules/sfp_projectdiscovery.py
@@ -84,14 +84,13 @@ class sfp_projectdiscovery(SpiderFootPlugin):
return None
try:
- 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_pulsedive.py b/modules/sfp_pulsedive.py
index b1c06f76..d0b45b19 100644
--- a/modules/sfp_pulsedive.py
+++ b/modules/sfp_pulsedive.py
@@ -121,12 +121,11 @@ class sfp_pulsedive(SpiderFootPlugin):
return None
try:
- 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_punkspider.py b/modules/sfp_punkspider.py
index 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 produces
def producedEvents(self):
- ret = ["VULNERABILITY"]
-
- return ret
+ return ["VULNERABILITY"]
def query(self, qry):
- ret = None
qryhash = hashlib.md5(qry.encode('utf-8', errors='replace').lower()).hexdigest() # noqa: DUO130
url = f"https://api.punkspider.org/api/partial-hash/{qryhash}"
@@ -76,11 +73,11 @@ class sfp_punkspider(SpiderFootPlugin):
return None
try:
- 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_reversewhois.py b/modules/sfp_reversewhois.py
index 5140dc75..fff81f1f 100644
--- a/modules/sfp_reversewhois.py
+++ b/modules/sfp_reversewhois.py
@@ -11,6 +11,7 @@
# -------------------------------------------------------------------------------
import re
+
from bs4 import BeautifulSoup
from spiderfoot import SpiderFootEvent, SpiderFootPlugin
diff --git a/modules/sfp_ripe.py b/modules/sfp_ripe.py
index 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 target
ownerinfo = 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_scylla.py b/modules/sfp_scylla.py
index 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 None
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
+ return None
# Handle events sent to this module
def handleEvent(self, event):
diff --git a/modules/sfp_seon.py b/modules/sfp_seon.py
index 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] = True
dataFound = 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 None
diff --git a/modules/sfp_slideshare.py b/modules/sfp_slideshare.py
index 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 None
diff --git a/modules/sfp_snov.py b/modules/sfp_snov.py
index 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 = True
return 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 None
diff --git a/modules/sfp_spur.py b/modules/sfp_spur.py
index 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 None
diff --git a/modules/sfp_spyonweb.py b/modules/sfp_spyonweb.py
index 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 None
diff --git a/modules/sfp_subdomain_takeover.py b/modules/sfp_subdomain_takeover.py
index 4dc2fe9b..c9341bbe 100644
--- a/modules/sfp_subdomain_takeover.py
+++ b/modules/sfp_subdomain_takeover.py
@@ -103,7 +103,7 @@ class sfp_subdomain_takeover(SpiderFootPlugin):
continue
for cname in cnames:
- if not cname.lower() in eventData.lower():
+ if cname.lower() not in eventData.lower():
continue
for proto in ["https", "http"]:
@@ -134,7 +134,7 @@ class sfp_subdomain_takeover(SpiderFootPlugin):
continue
for cname in cnames:
- if not cname.lower() in eventData.lower():
+ if cname.lower() not in eventData.lower():
continue
self.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.py
index 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 = None
url = None
if 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 None
try:
- 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 module
def handleEvent(self, event):
diff --git a/modules/sfp_trashpanda.py b/modules/sfp_trashpanda.py
index 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.py
index 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 None
diff --git a/modules/sfp_twitter.py b/modules/sfp_twitter.py
index 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")
return
res = 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")
return
diff --git a/modules/sfp_vxvault.py b/modules/sfp_vxvault.py
index 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 here
url = line.strip().lower()
- if not len(url.split("/")) >= 3:
+ if len(url.split("/")) < 3:
continue
host = url.split("/")[2]
if not host:
diff --git a/modules/sfp_zetalytics.py b/modules/sfp_zetalytics.py
index 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 True
def 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_generated
def generate_hostname_events(self, data, pevent):
@@ -175,7 +183,7 @@ class sfp_zetalytics(SpiderFootPlugin):
return
if self.checkForStop():
- return None
+ return
self.sf.debug(f"Received event, {eventName}, from {srcModuleName}")
diff --git a/setup.cfg b/setup.cfg
index 62a94beb..4013220e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -3,22 +3,26 @@ flake8-max-line-length = 120
max-line-length = 120
max-complexity = 80
select = 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 ignored
per-file-ignores =
spiderfoot/event.py:A,D
spiderfoot/plugin.py:I,D
- spiderfoot/db.py:A,D,SFS101
+ spiderfoot/db.py:A,D,SFS101,SIM106
sf.py:I,D,SFS101,SFS201
sflib.py:I,D,SFS101
sfwebui.py:A,I,D,SFS101,Q003
- sfscan.py:I,D
- modules/*:R,I,D
+ sfscan.py:I,D,SIM105,SIM109
+ modules/*:I,D,R501,R502
modules/sfp__stor_stdout.py:D,SFS201
modules/sfp_bitcoin.py:D,SFS101
+ modules/sfp_reversewhois.py:D,R504
+ modules/sfp_zetalytics.py:D,R504
spiderfoot/*:I,D
spiderfoot/__init__.py:I,D,F401
sfcli.py:D
- test/*:I,D
+ test/*:I,D,SIM117
docs/conf.py:A,D
[darglint]
diff --git a/sfcli.py b/sfcli.py
index 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.py
index 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):
"""