SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
sflib: Remove exception argument from error() function
Brendan Colesfc44629a705b
diff --git a/sflib.py b/sflib.pyindex 80615e28..dc5e7eae 100644--- a/sflib.py+++ b/sflib.py@@ -420,12 +420,11 @@ class SpiderFoot:return self.dbh.scanLogEvent(self.scanId, level, message, component)- def error(self, message, exception=False):- """Print an error message and optionally also raise an exception.+ def error(self, message):+ """Print and log an error messageArgs:message (str): error message- exception (bool): also raise an exception"""if not self.opts['__logging']:@@ -956,7 +955,7 @@ class SpiderFoot:"""if not url:- self.error("Invalid URL: %s" % url, False)+ self.error("Invalid URL: %s" % url)return NonefinalBits = list()@@ -994,7 +993,7 @@ class SpiderFoot:"""if not url:- self.error("Invalid URL: %s" % url, False)+ self.error("Invalid URL: %s" % url)return Nonebits = url.split('/')@@ -1024,7 +1023,7 @@ class SpiderFoot:"""if not url:- self.error("Invalid URL: %s" % url, False)+ self.error("Invalid URL: %s" % url)return Noneif '://' in url:@@ -1048,7 +1047,7 @@ class SpiderFoot:"""if not url:- self.error(f"Invalid URL: {url}", False)+ self.error(f"Invalid URL: {url}")return Nonebaseurl = self.urlBaseUrl(url)@@ -1072,7 +1071,7 @@ class SpiderFoot:"""if not domain:- self.error(f"Invalid domain: {domain}", False)+ self.error(f"Invalid domain: {domain}")return None# Strip off the TLD@@ -1101,7 +1100,7 @@ class SpiderFoot:"""if not domainList:- self.error("Invalid domain list: %s" % domainList, False)+ self.error("Invalid domain list: %s" % domainList)return set()keywords = list()@@ -1406,7 +1405,7 @@ class SpiderFoot:"""if not isinstance(data, dict):- self.error("Data is not a dict", False)+ self.error("Data is not a dict")return {}def get_children(needle, haystack):@@ -1516,7 +1515,7 @@ class SpiderFoot:addrs = list()if not hostname:- self.error("Unable to resolve %s (Invalid hostname)" % hostname, False)+ self.error("Unable to resolve %s (Invalid hostname)" % hostname)return addrstry:@@ -2202,7 +2201,7 @@ class SpiderFoot:"""if not rawcert:- self.error(f"Invalid certificate: {rawcert}", False)+ self.error(f"Invalid certificate: {rawcert}")return Noneret = dict()@@ -2237,7 +2236,7 @@ class SpiderFoot:if ret['expiry'] <= now:ret['expired'] = Trueexcept BaseException as e:- self.error(f"Error processing date in certificate: {e}", False)+ self.error(f"Error processing date in certificate: {e}")ret['certerror'] = Truereturn ret@@ -2294,7 +2293,7 @@ class SpiderFoot:if not found:ret['mismatch'] = Trueexcept BaseException as e:- self.error("Error processing certificate: " + str(e), False)+ self.error("Error processing certificate: " + str(e))ret['certerror'] = Truereturn ret@@ -2369,7 +2368,7 @@ class SpiderFoot:if lnk.has_attr(tags[t]):urlsRel.append(lnk[tags[t]])except BaseException as e:- self.error("Error parsing with BeautifulSoup: " + str(e), False)+ self.error("Error parsing with BeautifulSoup: " + str(e))return returnLinks# Loop through all the URLs/links found@@ -2723,8 +2722,8 @@ class SpiderFoot:if not noLog:# TODO: why another except block?try:- self.error(f"Unexpected exception ({e}) occurred fetching URL: {url}", False)- self.error(traceback.format_exc(), False)+ self.error(f"Unexpected exception ({e}) occurred fetching URL: {url}")+ self.error(traceback.format_exc())except BaseException as f:# TODO: why is this exception ignored?self.debug(f"Ignoring exception: {f}")diff --git a/test/unit/test_spiderfoot.py b/test/unit/test_spiderfoot.pyindex 4338d96f..c2f5ec5a 100644--- a/test/unit/test_spiderfoot.py+++ b/test/unit/test_spiderfoot.py@@ -188,11 +188,11 @@ class TestSpiderFoot(unittest.TestCase):def test_error(self):"""- Test error(self, error, exception=False)+ Test error(self, error):"""sf = SpiderFoot(self.default_options)- sf.error(None, exception=False)+ sf.error(None)self.assertEqual('TBD', 'TBD')def test_fatal_should_exit(self):