SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
PEP 8 – Comparison to 'None' Part 2
Gormogonfad8a49b6853
diff --git a/modules/sfp_googlesearch.py b/modules/sfp_googlesearch.pyindex e75743b3..2b3dbd93 100644--- a/modules/sfp_googlesearch.py+++ b/modules/sfp_googlesearch.py@@ -65,7 +65,7 @@ class sfp_googlesearch(SpiderFootPlugin):pages = self.sf.googleIterate("site:" + eventData,dict(limit=self.opts['pages'], useragent=self.opts['_useragent'],timeout=self.opts['_fetchtimeout']))- if pages == None:+ if pages is None:self.sf.info("No results returned from Google.")return Nonediff --git a/modules/sfp_honeypot.py b/modules/sfp_honeypot.pyindex 2b9726bd..fd12ce7c 100644--- a/modules/sfp_honeypot.py+++ b/modules/sfp_honeypot.py@@ -116,12 +116,12 @@ class sfp_honeypot(SpiderFootPlugin):text = Nonefor addr in addrs:text = self.reportIP(addr)- if text == None:+ if text is None:continueelse:break- if text != None:+ if text is not None:if eventName == "AFFILIATE_IPADDR":e = "BLACKLISTED_AFFILIATE_IPADDR"if eventName == "IP_ADDRESS":diff --git a/modules/sfp_intfiles.py b/modules/sfp_intfiles.pyindex 80659b9b..53dd15da 100644--- a/modules/sfp_intfiles.py+++ b/modules/sfp_intfiles.py@@ -108,7 +108,7 @@ class sfp_intfiles(SpiderFootPlugin):useragent=self.opts['_useragent'],timeout=self.opts['_fetchtimeout']))- if pages == None:+ if pages is None:self.sf.info("No results returned from " + self.opts['searchengine'] + \" for " + fileExt + " files.")continuediff --git a/modules/sfp_ir.py b/modules/sfp_ir.pyindex d67c7181..4f56d17c 100644--- a/modules/sfp_ir.py+++ b/modules/sfp_ir.py@@ -56,7 +56,7 @@ class sfp_ir(SpiderFootPlugin):else:res = self.sf.fetchUrl(url, timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if res['content'] != None:+ if res['content'] is not None:self.memCache[url] = resevt = SpiderFootEvent("RAW_RIR_DATA", res['content'], self.__name__,self.currentEventSrc)@@ -68,7 +68,7 @@ class sfp_ir(SpiderFootPlugin):prefix = Noneres = self.fetchRir("https://stat.ripe.net/data/network-info/data.json?resource=" + ipaddr)- if res['content'] == None:+ if res['content'] is None:self.sf.debug("No Netblock info found/available for " + ipaddr + " at RIPE.")return None@@ -79,7 +79,7 @@ class sfp_ir(SpiderFootPlugin):return Noneprefix = j["data"]["prefix"]- if prefix == None:+ if prefix is None:self.sf.debug("Could not identify network prefix.")return None@@ -90,7 +90,7 @@ class sfp_ir(SpiderFootPlugin):asn = Noneres = self.fetchRir("https://stat.ripe.net/data/whois/data.json?resource=" + prefix)- if res['content'] == None:+ if res['content'] is None:self.sf.debug("No AS info found/available for prefix: " + prefix + " at RIPE.")return None@@ -116,7 +116,7 @@ class sfp_ir(SpiderFootPlugin):ownerinfo = dict()res = self.fetchRir("https://stat.ripe.net/data/whois/data.json?resource=" + asn)- if res['content'] == None:+ if res['content'] is None:self.sf.debug("No info found/available for ASN: " + asn + " at RIPE.")return None@@ -147,7 +147,7 @@ class sfp_ir(SpiderFootPlugin):netblocks = list()res = self.fetchRir("https://stat.ripe.net/data/announced-prefixes/data.json?resource=AS" + asn)- if res['content'] == None:+ if res['content'] is None:self.sf.debug("No netblocks info found/available for AS" + asn + " at RIPE.")return None@@ -169,7 +169,7 @@ class sfp_ir(SpiderFootPlugin):neighbours = list()res = self.fetchRir("https://stat.ripe.net/data/asn-neighbours/data.json?resource=AS" + asn)- if res['content'] == None:+ if res['content'] is None:self.sf.debug("No neighbour info found/available for AS" + asn + " at RIPE.")return None@@ -192,7 +192,7 @@ class sfp_ir(SpiderFootPlugin):if self.getTarget().getValue() in string:return True- if self.keywords == None:+ if self.keywords is None:self.keywords = self.sf.domainKeywords(self.getTarget().getNames(),self.opts['_internettlds'])@@ -215,7 +215,7 @@ class sfp_ir(SpiderFootPlugin):for kw in keywordList:self.sf.debug("Looking for keyword: " + kw)for r in rx:- if re.match(r.format(kw), string, re.IGNORECASE) != None:+ if re.match(r.format(kw), string, re.IGNORECASE) is not None:return Truereturn False@@ -226,7 +226,7 @@ class sfp_ir(SpiderFootPlugin):ownerinfo = self.asOwnerInfo(asn)owned = False- if ownerinfo != None:+ if ownerinfo is not None:for k in ownerinfo.keys():items = ownerinfo[k]for item in items:@@ -253,7 +253,7 @@ class sfp_ir(SpiderFootPlugin):# BGP AS Owner/Member -> BGP AS Peersif eventName.startswith("BGP_AS_"):neighs = self.asNeighbours(eventData)- if neighs == None:+ if neighs is None:self.sf.debug("No neighbors found to AS " + eventData)return None@@ -263,7 +263,7 @@ class sfp_ir(SpiderFootPlugin):ownerinfo = self.asOwnerInfo(nasn)ownertext = ''- if ownerinfo != None:+ if ownerinfo is not None:for k, v in ownerinfo.iteritems():ownertext = ownertext + k + ": " + ', '.join(v) + "\n"@@ -280,7 +280,7 @@ class sfp_ir(SpiderFootPlugin):# Find all the netblocks owned by this ASself.nbreported[eventData] = Truenetblocks = self.asNetblocks(eventData)- if netblocks != None:+ if netblocks is not None:for netblock in netblocks:if self.results.has_key(netblock):continue@@ -296,7 +296,7 @@ class sfp_ir(SpiderFootPlugin):if eventName.startswith("NETBLOCK_"):# Get the BGP AS the netblock is a part ofasn = self.netblockAs(eventData)- if asn == None:+ if asn is None:self.sf.debug("Could not identify BGP AS for " + eventData)return None@@ -313,13 +313,13 @@ class sfp_ir(SpiderFootPlugin):if eventName == "IP_ADDRESS":# Get the Netblock the IP is a part ofprefix = self.ipNetblock(eventData)- if prefix == None:+ if prefix is None:self.sf.debug("Could not identify network prefix for " + eventData)return None# Get the BGP AS the netblock is a part ofasn = self.netblockAs(prefix)- if asn == None:+ if asn is None:self.sf.debug("Could not identify BGP AS for " + prefix)return Nonediff --git a/modules/sfp_junkfiles.py b/modules/sfp_junkfiles.pyindex fd917baa..35cbbbd4 100644--- a/modules/sfp_junkfiles.py+++ b/modules/sfp_junkfiles.py@@ -85,7 +85,7 @@ class sfp_junkfiles(SpiderFootPlugin):res = self.sf.fetchUrl(fetch,timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if res['content'] != None and res['code'] != "404":+ if res['content'] is not None and res['code'] != "404":evt = SpiderFootEvent("JUNK_FILE", fetch,self.__name__, event)self.notifyListeners(evt)@@ -104,7 +104,7 @@ class sfp_junkfiles(SpiderFootPlugin):res = self.sf.fetchUrl(fetch,timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if res['content'] != None and res['code'] != "404":+ if res['content'] is not None and res['code'] != "404":evt = SpiderFootEvent("JUNK_FILE", fetch,self.__name__, event)self.notifyListeners(evt)@@ -125,7 +125,7 @@ class sfp_junkfiles(SpiderFootPlugin):res = self.sf.fetchUrl(fetch,timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if res['content'] != None and res['code'] != "404":+ if res['content'] is not None and res['code'] != "404":evt = SpiderFootEvent("JUNK_FILE", fetch,self.__name__, event)self.notifyListeners(evt)@@ -141,7 +141,7 @@ class sfp_junkfiles(SpiderFootPlugin):res = self.sf.fetchUrl(fetch,timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if res['content'] != None and res['code'] != "404":+ if res['content'] is not None and res['code'] != "404":evt = SpiderFootEvent("JUNK_FILE", fetch,self.__name__, event)self.notifyListeners(evt)diff --git a/modules/sfp_malcheck.py b/modules/sfp_malcheck.pyindex 5aa37858..f4692713 100644--- a/modules/sfp_malcheck.py+++ b/modules/sfp_malcheck.py@@ -327,7 +327,7 @@ class sfp_malcheck(SpiderFootPlugin):if id == cid and malchecks[check]['type'] == "query":url = unicode(malchecks[check]['url'])res = self.sf.fetchUrl(url.format(target), useragent=self.opts['_useragent'])- if res['content'] == None:+ if res['content'] is None:self.sf.error("Unable to fetch " + url.format(target), False)return Noneif self.contentMalicious(res['content'],@@ -350,9 +350,9 @@ class sfp_malcheck(SpiderFootPlugin):data = dict()url = malchecks[check]['url']data['content'] = self.sf.cacheGet("sfmal_" + cid, self.opts['aaacacheperiod'])- if data['content'] == None:+ if data['content'] is None:data = self.sf.fetchUrl(url, useragent=self.opts['_useragent'])- if data['content'] == None:+ if data['content'] is None:self.sf.error("Unable to fetch " + url, False)return Noneelse:@@ -484,7 +484,7 @@ class sfp_malcheck(SpiderFootPlugin):return None# Notify other modules of what you've found- if url != None:+ if url is not None:text = check + " [" + eventData + "]\n" + "<SFURL>" + url + "</SFURL>"evt = SpiderFootEvent(evtType, text, self.__name__, event)self.notifyListeners(evt)diff --git a/modules/sfp_pastebin.py b/modules/sfp_pastebin.pyindex e2cae527..62d07a80 100644--- a/modules/sfp_pastebin.py+++ b/modules/sfp_pastebin.py@@ -63,7 +63,7 @@ class sfp_pastebin(SpiderFootPlugin):dict(limit=self.opts['pages'],useragent=self.opts['_useragent'], timeout=self.opts['_fetchtimeout']))- if pages == None:+ if pages is None:self.sf.info("No results returned from Google PasteBin search.")return None@@ -101,7 +101,7 @@ class sfp_pastebin(SpiderFootPlugin):res = self.sf.fetchUrl(link, timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if res['content'] == None:+ if res['content'] is None:self.sf.debug("Ignoring " + link + " as no data returned")continue@@ -111,7 +111,7 @@ class sfp_pastebin(SpiderFootPlugin):# Sometimes pastebin search results false positivesif re.search("[^a-zA-Z\-\_0-9]" + re.escape(eventData) + \- "[^a-zA-Z\-\_0-9]", res['content'], re.IGNORECASE) == None:+ "[^a-zA-Z\-\_0-9]", res['content'], re.IGNORECASE) is None:continuetry:diff --git a/modules/sfp_pgp.py b/modules/sfp_pgp.pyindex 1d1d2360..70ed7584 100644--- a/modules/sfp_pgp.py+++ b/modules/sfp_pgp.py@@ -70,7 +70,7 @@ class sfp_pgp(SpiderFootPlugin):res = self.sf.fetchUrl(self.opts['keyserver_search'] + eventData,timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if res['content'] != None:+ if res['content'] is not None:pat = re.compile("([a-zA-Z\.0-9_\-]+@[a-zA-Z\.0-9\-]+\.[a-zA-Z\.0-9\-]+)")matches = re.findall(pat, res['content'])for match in matches:@@ -92,7 +92,7 @@ class sfp_pgp(SpiderFootPlugin):res = self.sf.fetchUrl(self.opts['keyserver_fetch'] + eventData,timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if res['content'] != None:+ if res['content'] is not None:pat = re.compile("(-----BEGIN.*END.*BLOCK-----)", re.MULTILINE|re.DOTALL)matches = re.findall(pat, res['content'])for match in matches:diff --git a/modules/sfp_sharedip.py b/modules/sfp_sharedip.pyindex 8be1aa92..2d817d0a 100644--- a/modules/sfp_sharedip.py+++ b/modules/sfp_sharedip.py@@ -90,7 +90,7 @@ class sfp_sharedip(SpiderFootPlugin):# Robtexif self.opts['source'].lower() == "robtex":res = self.sf.fetchUrl("https://www.robtex.com/shared/" + eventData + ".html")- if res['content'] == None:+ if res['content'] is None:self.sf.error("Unable to fetch robtex content.", False)return None@@ -129,7 +129,7 @@ class sfp_sharedip(SpiderFootPlugin):results = self.sf.bingIterate("ip:" + eventData, dict(limit=self.opts['pages'],useragent=self.opts['_useragent'], timeout=self.opts['_fetchtimeout']))myres = list()- if results == None:+ if results is None:self.sf.info("No data returned from Bing.")return Nonediff --git a/modules/sfp_shodan.py b/modules/sfp_shodan.pyindex e1bf34f8..4df8e4f9 100644--- a/modules/sfp_shodan.py+++ b/modules/sfp_shodan.py@@ -56,7 +56,7 @@ class sfp_shodan(SpiderFootPlugin):res = self.sf.fetchUrl("https://api.shodan.io/shodan/host/" + qry + \"?key=" + self.opts['apikey'],timeout=self.opts['_fetchtimeout'], useragent="SpiderFoot")- if res['content'] == None:+ if res['content'] is None:self.sf.info("No SHODAN info found for " + qry)return None@@ -104,19 +104,19 @@ class sfp_shodan(SpiderFootPlugin):for addr in qrylist:rec = self.query(addr)- if rec == None:+ if rec is None:continueif self.checkForStop():return None- if rec.get('os') != None:+ if rec.get('os') is not None:# Notify other modules of what you've foundevt = SpiderFootEvent("OPERATING_SYSTEM", rec.get('os') + \" (" + addr +")", self.__name__, event)self.notifyListeners(evt)- if rec.get('devtype') != None:+ if rec.get('devtype') is not None:# Notify other modules of what you've foundevt = SpiderFootEvent("DEVICE_TYPE", rec.get('devtype') + \" (" + addr +")", self.__name__, event)@@ -128,14 +128,14 @@ class sfp_shodan(SpiderFootPlugin):port = str(r.get('port'))banner = r.get('banner')- if port != None:+ if port is not None:# Notify other modules of what you've foundcp = addr + ":" + portevt = SpiderFootEvent("TCP_PORT_OPEN", cp,self.__name__, event)self.notifyListeners(evt)- if banner != None:+ if banner is not None:# Notify other modules of what you've foundevt = SpiderFootEvent("TCP_PORT_OPEN_BANNER", banner,self.__name__, event)diff --git a/modules/sfp_similar.py b/modules/sfp_similar.pyindex c2e53221..606be9d3 100644--- a/modules/sfp_similar.py+++ b/modules/sfp_similar.py@@ -102,7 +102,7 @@ class sfp_similar(SpiderFootPlugin):whois = self.sf.fetchUrl(fetchPage, timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if whois['content'] == None:+ if whois['content'] is None:return None# Extract the similar domains out of the whois content@@ -134,7 +134,7 @@ class sfp_similar(SpiderFootPlugin):domtool = self.sf.fetchUrl(fetchPage, timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if domtool['content'] == None:+ if domtool['content'] is None:return None# Extract the similar domains out of the domain tools content@@ -169,7 +169,7 @@ class sfp_similar(SpiderFootPlugin):namedrop = self.sf.fetchUrl(fetchPage, timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if namedrop['content'] == None:+ if namedrop['content'] is None:return None# Extract the similar domains out of the namedropper content@@ -199,7 +199,7 @@ class sfp_similar(SpiderFootPlugin):pageContent = self.sf.fetchUrl('http://' + result,timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])- if pageContent['content'] != None:+ if pageContent['content'] is not None:evt = SpiderFootEvent("SIMILARDOMAIN", result, self.__name__, source)self.notifyListeners(evt)else:diff --git a/modules/sfp_social.py b/modules/sfp_social.pyindex 092b44fc..7c8e6480 100644--- a/modules/sfp_social.py+++ b/modules/sfp_social.py@@ -75,7 +75,7 @@ class sfp_social(SpiderFootPlugin):for regexpGrp in regexps.keys():for regex in regexps[regexpGrp]:bits = re.match(regex, eventData, re.IGNORECASE)- if bits != None:+ if bits is not None:self.sf.info("Matched " + regexpGrp + " in " + eventData)evt = SpiderFootEvent("SOCIAL_MEDIA", regexpGrp + ": " + \bits.group(1), self.__name__, event)diff --git a/modules/sfp_socialprofiles.py b/modules/sfp_socialprofiles.pyindex 05431ada..6cd09be7 100644--- a/modules/sfp_socialprofiles.py+++ b/modules/sfp_socialprofiles.py@@ -84,7 +84,7 @@ class sfp_socialprofiles(SpiderFootPlugin):else:self.results.append(eventData)- if self.keywords == None:+ if self.keywords is None:self.keywords = self.sf.domainKeywords(self.getTarget().getNames(),self.opts['_internettlds'])@@ -108,7 +108,7 @@ class sfp_socialprofiles(SpiderFootPlugin):useragent=self.opts['_useragent'],timeout=self.opts['_fetchtimeout']))- if results == None:+ if results is None:self.sf.info("No data returned from " + self.opts['method'] + ".")return None@@ -130,7 +130,7 @@ class sfp_socialprofiles(SpiderFootPlugin):matches = re.findall(searchDom, res, re.IGNORECASE)- if matches != None:+ if matches is not None:for match in matches:if match in instances:continue@@ -146,7 +146,7 @@ class sfp_socialprofiles(SpiderFootPlugin):pres = self.sf.fetchUrl(match, timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if pres['content'] == None:+ if pres['content'] is None:continueelse:found = Falsediff --git a/modules/sfp_spider.py b/modules/sfp_spider.pyindex 00fca648..b7a8c0cf 100644--- a/modules/sfp_spider.py+++ b/modules/sfp_spider.py@@ -86,7 +86,7 @@ class sfp_spider(SpiderFootPlugin):self.fetchedPages[url] = True# Track cookies a site has sent, then send the back in subsquent requests- if self.opts['usecookies'] and fetched['headers'] != None:+ if self.opts['usecookies'] and fetched['headers'] is not None:if fetched['headers'].get('Set-Cookie'):self.siteCookies[site] = fetched['headers'].get('Set-Cookie')self.sf.debug("Saving cookies for " + site + ": " + str(self.siteCookies[site]))@@ -97,7 +97,7 @@ class sfp_spider(SpiderFootPlugin):# Notify modules about the content obtainedself.contentNotify(url, fetched, self.urlEvents[url])- if fetched['realurl'] != None and fetched['realurl'] != url:+ if fetched['realurl'] is not None and fetched['realurl'] != url:self.sf.debug("Redirect of " + url + " to " + fetched['realurl'])# Store the content for the redirect so that it isn't fetched againself.fetchedPages[fetched['realurl']] = True@@ -109,7 +109,7 @@ class sfp_spider(SpiderFootPlugin):# Extract links from the contentlinks = self.sf.parseLinks(url, fetched['content'], self.getTarget().getNames())- if links == None or len(links) == 0:+ if links is None or len(links) == 0:self.sf.info("No links found at " + url)return None@@ -235,7 +235,7 @@ class sfp_spider(SpiderFootPlugin):for prefix in self.opts['start']:res = self.sf.fetchUrl(prefix + eventData, timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])- if res['content'] != None:+ if res['content'] is not None:spiderTarget = prefix + eventDataevt = SpiderFootEvent("LINKED_URL_INTERNAL", spiderTarget,self.__name__, event)@@ -244,7 +244,7 @@ class sfp_spider(SpiderFootPlugin):else:spiderTarget = eventData- if spiderTarget == None:+ if spiderTarget is None:return Noneself.sf.info("Initiating spider of " + spiderTarget)@@ -265,7 +265,7 @@ class sfp_spider(SpiderFootPlugin):if self.opts['robotsonly'] and not self.robotsRules.has_key(targetBase):robotsTxt = self.sf.fetchUrl(targetBase + '/robots.txt',timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])- if robotsTxt['content'] != None:+ if robotsTxt['content'] is not None:self.sf.debug('robots.txt contents: ' + robotsTxt['content'])self.robotsRules[targetBase] = self.sf.parseRobotsTxt(robotsTxt['content'])else:@@ -278,7 +278,7 @@ class sfp_spider(SpiderFootPlugin):links = self.processUrl(startingPoint) # fetch first page# No links from the first fetch means we've got a problem- if links == None:+ if links is None:self.sf.error("No links found on the first fetch!", exception=False)return@@ -302,7 +302,7 @@ class sfp_spider(SpiderFootPlugin):self.sf.debug("Fetching fresh content from: " + link)time.sleep(self.opts['pause'])freshLinks = self.processUrl(link)- if freshLinks != None:+ if freshLinks is not None:links.update(freshLinks)totalFetched += 1diff --git a/modules/sfp_tldsearch.py b/modules/sfp_tldsearch.pyindex fe557001..eb469f82 100644--- a/modules/sfp_tldsearch.py+++ b/modules/sfp_tldsearch.py@@ -105,7 +105,7 @@ class sfp_tldsearch(SpiderFootPlugin):pageContent = self.sf.fetchUrl('http://' + result,timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])- if pageContent['content'] != None:+ if pageContent['content'] is not None:evt = SpiderFootEvent("SIMILARDOMAIN", result, self.__name__, source)self.notifyListeners(evt)else: