SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
flake8: resolve flake8 violations and add flake8-bugbear
Brendan Colesc2fec83da7b1
diff --git a/modules/sfp_bitcoinabuse.py b/modules/sfp_bitcoinabuse.pyindex 0f5bd43d..526821c9 100644--- a/modules/sfp_bitcoinabuse.py+++ b/modules/sfp_bitcoinabuse.py@@ -90,7 +90,7 @@ class sfp_bitcoinabuse(SpiderFootPlugin):try:info = json.loads(res["content"])except Exception as e:- self.sf.error("Error processing JSON response from BitcoinAbuse.", False)+ self.sf.error(f"Error processing JSON response from BitcoinAbuse: {e}", False)return Nonereturn infodiff --git a/modules/sfp_googlemaps.py b/modules/sfp_googlemaps.pyindex f064d73e..a0f539cd 100644--- a/modules/sfp_googlemaps.py+++ b/modules/sfp_googlemaps.py@@ -80,7 +80,7 @@ class sfp_googlemaps(SpiderFootPlugin):})res = self.sf.fetchUrl(- "https://maps.googleapis.com/maps/api/geocode/json?{params}",+ f"https://maps.googleapis.com/maps/api/geocode/json?{params}",timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])diff --git a/modules/sfp_hostio.py b/modules/sfp_hostio.pyindex 07c00575..ac14a545 100644--- a/modules/sfp_hostio.py+++ b/modules/sfp_hostio.py@@ -81,7 +81,7 @@ class sfp_hostio(SpiderFootPlugin):def handle_error_response(self, qry, res):try:error_info = json.loads(res["content"])- except Exception as e:+ except Exception:error_info = Noneif error_info:error_message = error_info.get("error")@@ -111,7 +111,7 @@ class sfp_hostio(SpiderFootPlugin):try:info = json.loads(res["content"])except Exception as e:- self.sf.error("Error processing JSON response from Host.io.", False)+ self.sf.error(f"Error processing JSON response from Host.io: {e}", False)return Nonereturn infodiff --git a/modules/sfp_opencorporates.py b/modules/sfp_opencorporates.pyindex e34f8153..242f8c02 100644--- a/modules/sfp_opencorporates.py+++ b/modules/sfp_opencorporates.py@@ -89,7 +89,7 @@ class sfp_opencorporates(SpiderFootPlugin):})res = self.sf.fetchUrl(- "https://api.opencorporates.com/v{version}/companies/search?{params}{apiparam}",+ f"https://api.opencorporates.com/v{version}/companies/search?{params}{apiparam}",timeout=60, # High timeouts as they can sometimes take a whileuseragent=self.opts['_useragent'])diff --git a/modules/sfp_pastebin.py b/modules/sfp_pastebin.pyindex 754c4811..5533ef55 100644--- a/modules/sfp_pastebin.py+++ b/modules/sfp_pastebin.py@@ -148,11 +148,12 @@ class sfp_pastebin(SpiderFootPlugin):+ r"[^a-zA-Z\-\_0-9]", res['content'], re.IGNORECASE) is None:continue- try:- startIndex = res['content'].index(eventData)- except BaseException:- self.sf.debug("String not found in pastes content.")- continue+ # TODO: review why this is now unused+ # try:+ # startIndex = res['content'].index(eventData)+ # except BaseException:+ # self.sf.debug("String not found in pastes content.")+ # continueevt1 = SpiderFootEvent("LEAKSITE_URL", link, self.__name__, event)self.notifyListeners(evt1)diff --git a/modules/sfp_psbdmp.py b/modules/sfp_psbdmp.pyindex 60f8c0f9..cf5a7752 100644--- a/modules/sfp_psbdmp.py+++ b/modules/sfp_psbdmp.py@@ -130,11 +130,12 @@ class sfp_psbdmp(SpiderFootPlugin):) is None:continue- try:- startIndex = res['content'].index(eventData)- except BaseException:- self.sf.debug(f"{eventData} not found in pastes content.")- continue+ # TODO: review why this is now unused+ # try:+ # startIndex = res['content'].index(eventData)+ # except BaseException:+ # self.sf.debug(f"{eventData} not found in pastes content.")+ # continueevt = SpiderFootEvent("LEAKSITE_CONTENT", res['content'], self.__name__, e)self.notifyListeners(evt)diff --git a/modules/sfp_slideshare.py b/modules/sfp_slideshare.pyindex 6888eef6..7bcf3c59 100644--- a/modules/sfp_slideshare.py+++ b/modules/sfp_slideshare.py@@ -84,7 +84,7 @@ class sfp_slideshare(SpiderFootPlugin):network = eventData.split(": ")[0]url = eventData.split(": ")[1].replace("<SFURL>", "").replace("</SFURL>", "")except BaseException as e:- self.sf.error("Unable to parse SOCIAL_MEDIA: {eventData} ({e})", False)+ self.sf.error(f"Unable to parse SOCIAL_MEDIA: {eventData} ({e})", False)return Noneif not network == "SlideShare":diff --git a/requirements_test.txt b/requirements_test.txtindex 923308c9..439db59c 100644--- a/requirements_test.txt+++ b/requirements_test.txt@@ -4,4 +4,5 @@ pytest-mock==1.12.0responses==0.10.6pytest-cov==2.8.1pytest-flake8==1.0.6+flake8-bugbear==20.1.4pycodestyle==2.6.0diff --git a/setup.cfg b/setup.cfgindex 68491a68..371ee2d7 100644--- a/setup.cfg+++ b/setup.cfg@@ -1,6 +1,8 @@[flake8]flake8-max-line-length = 120-ignore = F841 E501 W503+max-complexity = 100+select = C,E,F,W,B+ignore = E501 W503 B006 B007per-file-ignores =spiderfoot/__init__.py:F401sfcli.py:W605diff --git a/sflib.py b/sflib.pyindex 73084656..7bb8d38e 100644--- a/sflib.py+++ b/sflib.py@@ -653,7 +653,7 @@ class SpiderFoot:with open(cacheFile, "r") as fp:fileContents = fp.read()return fileContents- except BaseException as e:+ except BaseException:return Nonereturn Nonediff --git a/spiderfoot/target.py b/spiderfoot/target.pyindex fbe25095..d37d3f88 100644--- a/spiderfoot/target.py+++ b/spiderfoot/target.py@@ -205,7 +205,7 @@ class SpiderFootTarget():try:if netaddr.IPAddress(value) in netaddr.IPNetwork(self.targetValue):return True- except netaddr.AddrFormatError as e:+ except netaddr.AddrFormatError:return Falsereturn Falsediff --git a/test/unit/test_spiderfoottarget.py b/test/unit/test_spiderfoottarget.pyindex 6a3fa76e..3d879dff 100644--- a/test/unit/test_spiderfoottarget.py+++ b/test/unit/test_spiderfoottarget.py@@ -24,7 +24,7 @@ class TestSpiderFootTarget(unittest.TestCase):for invalid_type in invalid_types:with self.subTest(invalid_type=invalid_type):with self.assertRaises(TypeError):- target = SpiderFootTarget(invalid_type, target_type)+ SpiderFootTarget(invalid_type, target_type)def test_init_argument_targetType_invalid_type_should_raise_TypeError(self):"""@@ -36,7 +36,7 @@ class TestSpiderFootTarget(unittest.TestCase):for invalid_type in invalid_types:with self.subTest(invalid_type=invalid_type):with self.assertRaises(TypeError):- target = SpiderFootTarget(target_value, invalid_type)+ SpiderFootTarget(target_value, invalid_type)def test_init_argument_targetType_invalid_should_raise_ValueError(self):"""