Skip to content

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

sfwebui: validate provided scan id

Brendan Colesa4b285298505
diff --git a/sfwebui.py b/sfwebui.py
index 5417b319..b1eb230a 100644
--- a/sfwebui.py
+++ b/sfwebui.py
@@ -384,6 +384,10 @@ class SpiderFootWebUi:
sf = SpiderFoot(cfg)
dbh = SpiderFootDb(cfg)
info = dbh.scanInstanceGet(id)
+
+ if not info:
+ return self.error("Invalid scan ID.")
+
scanconfig = dbh.scanConfigGet(id)
scanname = info[0]
scantarget = info[1]
@@ -491,6 +495,10 @@ class SpiderFootWebUi:
dbh = SpiderFootDb(self.config)
types = dbh.eventTypes()
info = dbh.scanInstanceGet(id)
+
+ if not info:
+ return self.error("Invalid scan ID.")
+
scanconfig = dbh.scanConfigGet(id)
scanname = info[0]
scantarget = info[1]
@@ -951,21 +959,22 @@ class SpiderFootWebUi:
def stopscan(self, id, cli=None):
dbh = SpiderFootDb(self.config)
scaninfo = dbh.scanInstanceGet(id)
- scanstatus = scaninfo[5]
- print(scanstatus)
- if scaninfo is None:
+
+ if not scaninfo:
if not cli:
return self.error("Invalid scan ID.")
else:
return json.dumps(["ERROR", "Invalid scan ID."])
+ scanstatus = scaninfo[5]
+ print(scanstatus)
+
if scanstatus == "ABORTED":
if not cli:
return self.error("The scan is already aborted.")
else:
return json.dumps(["ERROR", "Scan already aborted."])
-
if not scanstatus == "RUNNING":
if not cli:
return self.error("The running scan is currently in the state '" + \