Skip to content

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

spiderfoot: Use spiderfoot.__version__ for version instead of config dict (#1181)

bcoles5841672437af
diff --git a/sf.py b/sf.py
index a53270c5..ee776b88 100755
--- a/sf.py
+++ b/sf.py
@@ -31,6 +31,7 @@ from sflib import SpiderFoot
from sfscan import SpiderFootScanner
from sfwebui import SpiderFootWebUi
from spiderfoot import SpiderFootDb
+from spiderfoot import __version__
log = logging.getLogger()
log.setLevel(logging.DEBUG)
@@ -85,7 +86,6 @@ def main():
'_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
'_internettlds_cache': 72,
'_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
- '__version__': '3.3',
'__database': 'spiderfoot.db',
'__modules__': None, # List of modules. Will be set after start-up.
'_socks1type': '',
@@ -115,7 +115,7 @@ def main():
# Legacy way to run the server
args = None
- p = argparse.ArgumentParser(description='SpiderFoot 3.3: Open Source Intelligence Automation.')
+ p = argparse.ArgumentParser(description=f"SpiderFoot {__version__}: Open Source Intelligence Automation.")
p.add_argument("-d", "--debug", action='store_true', help="Enable debug output.")
p.add_argument("-l", metavar="IP:port", help="IP and port to listen on.")
p.add_argument("-m", metavar="mod1,mod2,...", type=str, help="Modules to enable.")
@@ -133,8 +133,13 @@ def main():
p.add_argument("-F", metavar="type1,type2,...", type=str, help="Show only a set of event types, comma-separated.")
p.add_argument("-x", action='store_true', help="STRICT MODE. Will only enable modules that can directly consume your target, and if -t was specified only those events will be consumed by modules. This overrides -t and -m options.")
p.add_argument("-q", action='store_true', help="Disable logging. This will also hide errors!")
+ p.add_argument("-V", "--version", action='store_true', help="Display the version of SpiderFoot and exit.")
args = p.parse_args()
+ if args.version:
+ print(f"SpiderFoot {__version__}: Open Source Intelligence Automation.")
+ sys.exit(0)
+
if args.debug:
sfConfig['_debug'] = True
log.setLevel(logging.DEBUG)
diff --git a/sfcli.py b/sfcli.py
index 400b366f..aa6205fb 100755
--- a/sfcli.py
+++ b/sfcli.py
@@ -53,7 +53,7 @@ class bcolors:
class SpiderFootCli(cmd.Cmd):
- version = "3.3"
+ version = "3.3.0"
pipecmd = None
output = None
modules = []
diff --git a/sfwebui.py b/sfwebui.py
index 595f8c6c..c1c872c9 100644
--- a/sfwebui.py
+++ b/sfwebui.py
@@ -27,6 +27,7 @@ from mako.template import Template
from secure import SecureHeaders
from spiderfoot import SpiderFootDb
+from spiderfoot import __version__
from sflib import SpiderFoot
from sfscan import SpiderFootScanner
@@ -1038,7 +1039,7 @@ class SpiderFootWebUi:
cherrypy.response.headers['Content-Type'] = "application/json; charset=utf-8"
- return json.dumps(["SUCCESS", self.config['__version__']]).encode('utf-8')
+ return json.dumps(["SUCCESS", __version__]).encode('utf-8')
ping.exposed = True
diff --git a/spiderfoot/__init__.py b/spiderfoot/__init__.py
index 46e26567..b8a0b3d6 100644
--- a/spiderfoot/__init__.py
+++ b/spiderfoot/__init__.py
@@ -2,3 +2,4 @@ from .db import SpiderFootDb
from .event import SpiderFootEvent
from .plugin import SpiderFootPlugin
from .target import SpiderFootTarget
+from spiderfoot.__version__ import __version__
diff --git a/test/conftest.py b/test/conftest.py
index 361903d4..e8dcaff4 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -13,7 +13,6 @@ def default_options(request):
'_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
'_internettlds_cache': 72,
'_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
- '__version__': '3.3',
'__database': 'spiderfoot.test.db', # note: test database file
'__modules__': None, # List of modules. Will be set after start-up.
'_socks1type': '',
diff --git a/test/integration/test_sfwebui.py b/test/integration/test_sfwebui.py
index 98447baa..cc477fa6 100644
--- a/test/integration/test_sfwebui.py
+++ b/test/integration/test_sfwebui.py
@@ -22,7 +22,6 @@ class TestSpiderFootWebUiRoutes(helper.CPWebCase):
'_internettlds': 'https://publicsuffix.org/list/effective_tld_names.dat',
'_internettlds_cache': 72,
'_genericusers': "abuse,admin,billing,compliance,devnull,dns,ftp,hostmaster,inoc,ispfeedback,ispsupport,list-request,list,maildaemon,marketing,noc,no-reply,noreply,null,peering,peering-notify,peering-request,phish,phishing,postmaster,privacy,registrar,registry,root,routing-registry,rr,sales,security,spam,support,sysadmin,tech,undisclosed-recipients,unsubscribe,usenet,uucp,webmaster,www",
- '__version__': '3.3',
'__database': 'spiderfoot.test.db', # note: test database file
'__modules__': None, # List of modules. Will be set after start-up.
'_socks1type': '',