Skip to content

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

sflib: Ensure checkForStop() returns false when no scan ID is set

Brendan Colese242af5433e1
diff --git a/sfdb.py b/sfdb.py
index dfbd57d7..b92303c9 100644
--- a/sfdb.py
+++ b/sfdb.py
@@ -1115,7 +1115,7 @@ class SpiderFootDb:
if not sfEvent.data:
raise ValueError("sfEvent.data is empty")
- if not isinstance(sfEvent.sourceEventhash, str):
+ if not isinstance(sfEvent.sourceEventHash, str):
raise TypeError("sfEvent.sourceEventHash is %s; expected str()" % type(sfEvent.sourceEventHash))
if not sfEvent.sourceEventHash:
diff --git a/sflib.py b/sflib.py
index 23068b36..0f0d730f 100644
--- a/sflib.py
+++ b/sflib.py
@@ -2594,11 +2594,17 @@ class SpiderFootPlugin(object):
Returns:
bool
"""
+ if not self.__scanId__:
+ return False
scanstatus = self.__sfdb__.scanInstanceGet(self.__scanId__)
- if scanstatus != None:
- if scanstatus[5] == "ABORT-REQUESTED":
- return True
+
+ if not scanstatus:
+ return False
+
+ if scanstatus[5] == "ABORT-REQUESTED":
+ return True
+
return False
def watchedEvents(self):
diff --git a/test/unit/test_spiderfootplugin.py b/test/unit/test_spiderfootplugin.py
index 18dd2c0b..00d505ea 100644
--- a/test/unit/test_spiderfootplugin.py
+++ b/test/unit/test_spiderfootplugin.py
@@ -251,6 +251,7 @@ class TestSpiderFootPlugin(unittest.TestCase):
return [None, None, None, None, None, status]
sfp.__sfdb__ = DatabaseStub()
+ sfp.__scanId__ = 'example scan id'
# pseudo-parameterized test
for status, expectedReturnValue in [("RUNNING", False), ("ABORT-REQUESTED", True)]: