Skip to content

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

Move SpiderFootDb into spiderfoot module

Brendan Coles19dff46fd633
diff --git a/sf.py b/sf.py
index a0c1ba2c..4c52dbb8 100755
--- a/sf.py
+++ b/sf.py
@@ -31,7 +31,7 @@ from logging import handlers
import cherrypy
from cherrypy.lib import auth_digest
-from sfdb import SpiderFootDb
+from spiderfoot import SpiderFootDb
from sflib import SpiderFoot
from sfscan import SpiderFootScanner
from sfwebui import SpiderFootWebUi
diff --git a/sfscan.py b/sfscan.py
index a990959a..98cfe149 100644
--- a/sfscan.py
+++ b/sfscan.py
@@ -17,9 +17,8 @@ from copy import deepcopy
import dns.resolver
-from sfdb import SpiderFootDb
from sflib import SpiderFoot
-from spiderfoot import SpiderFootEvent, SpiderFootPlugin, SpiderFootTarget
+from spiderfoot import SpiderFootDb, SpiderFootEvent, SpiderFootPlugin, SpiderFootTarget
class SpiderFootScanner():
diff --git a/sfwebui.py b/sfwebui.py
index f7e6149b..a01b3c38 100644
--- a/sfwebui.py
+++ b/sfwebui.py
@@ -26,7 +26,7 @@ from mako.lookup import TemplateLookup
from mako.template import Template
from secure import SecureHeaders
-from sfdb import SpiderFootDb
+from spiderfoot import SpiderFootDb
from sflib import SpiderFoot
from sfscan import SpiderFootScanner
@@ -432,20 +432,19 @@ class SpiderFootWebUi:
if not info:
return self.error("Invalid scan ID.")
- scanconfig = dbh.scanConfigGet(id)
scanname = info[0]
scantarget = info[1]
- targetType = None
- if len(scanconfig) == 0:
- return self.error("Something went wrong internally.")
+ scanconfig = dbh.scanConfigGet(id)
+ if not scanconfig:
+ return self.error(f"Error loading config from scan: {id}")
modlist = scanconfig['_modulesenabled'].split(',')
if "sfp__stor_stdout" in modlist:
modlist.remove("sfp__stor_stdout")
targetType = sf.targetType(scantarget)
- if targetType is None:
+ if not targetType:
# It must then be a name, as a re-run scan should always have a clean
# target. Put quotes around the target value and try to determine the
# target type again.
diff --git a/spiderfoot/__init__.py b/spiderfoot/__init__.py
index 4ae91a95..46e26567 100644
--- a/spiderfoot/__init__.py
+++ b/spiderfoot/__init__.py
@@ -1,3 +1,4 @@
+from .db import SpiderFootDb
from .event import SpiderFootEvent
from .plugin import SpiderFootPlugin
from .target import SpiderFootTarget
diff --git a/sfdb.py b/spiderfoot/db.py
similarity index 99%
rename from sfdb.py
rename to spiderfoot/db.py
index 7e747986..d73e7484 100644
--- a/sfdb.py
+++ b/spiderfoot/db.py
@@ -16,7 +16,6 @@ import threading
import time
from sflib import SpiderFoot
-from spiderfoot import SpiderFootEvent
class SpiderFootDb:
@@ -1106,6 +1105,7 @@ class SpiderFootDb:
ValueError: arg value was invalid
IOError: database I/O failed
"""
+ from spiderfoot import SpiderFootEvent
if not isinstance(instanceId, str):
raise TypeError(f"instanceId is {type(instanceId)}; expected str()")
diff --git a/test/unit/test_spiderfootdb.py b/test/unit/test_spiderfootdb.py
index 8a5fac66..35c821f1 100644
--- a/test/unit/test_spiderfootdb.py
+++ b/test/unit/test_spiderfootdb.py
@@ -1,7 +1,7 @@
# test_spiderfootdb.py
import unittest
-from sfdb import SpiderFootDb, SpiderFootEvent
+from spiderfoot import SpiderFootDb, SpiderFootEvent
class TestSpiderFootDb(unittest.TestCase):
diff --git a/test/unit/test_spiderfootplugin.py b/test/unit/test_spiderfootplugin.py
index 8065c357..e2ad86f1 100644
--- a/test/unit/test_spiderfootplugin.py
+++ b/test/unit/test_spiderfootplugin.py
@@ -1,8 +1,7 @@
# test_spiderfootplugin.py
import unittest
-from sfdb import SpiderFootDb, SpiderFootEvent
-from spiderfoot import SpiderFootPlugin, SpiderFootTarget
+from spiderfoot import SpiderFootDb, SpiderFootEvent, SpiderFootPlugin, SpiderFootTarget
class TestSpiderFootPlugin(unittest.TestCase):