mirror of
https://github.com/aljazceru/cowrie.git
synced 2025-12-17 14:04:28 +01:00
Improve handling of ImportErrors to notify users that they need to install new dependencies (#389)
* Improve handling of ImportErrors to notify users that they need to install new dependencies Also added missing dependency to requirements.txt * Mention installing dependencies in virtualenv if used * Move requirements used only by output modules to a separate file * Using a virtualenv is now the only officially supported method * Handle ImportErrors when loading output plugins so different install instructions can be given * Cleanup requirements-output.txt
This commit is contained in:
committed by
Michel Oosterhof
parent
ccbd05746e
commit
24c251b405
20
requirements-output.txt
Normal file
20
requirements-output.txt
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# csirtg
|
||||||
|
csirtgsdk>=0.0.0a6 # Specify version because pip won't install pre-release versions by default
|
||||||
|
|
||||||
|
# dshield
|
||||||
|
requests
|
||||||
|
|
||||||
|
# elasticsearch
|
||||||
|
pyes
|
||||||
|
|
||||||
|
# mysql
|
||||||
|
MySQL-python
|
||||||
|
|
||||||
|
# rethinkdblog
|
||||||
|
rethinkdb
|
||||||
|
|
||||||
|
# slack
|
||||||
|
slackclient
|
||||||
|
|
||||||
|
# splunklegacy
|
||||||
|
splunk-sdk
|
||||||
@@ -7,4 +7,3 @@ service_identity
|
|||||||
pycrypto
|
pycrypto
|
||||||
python-dateutil
|
python-dateutil
|
||||||
tftpy
|
tftpy
|
||||||
csirtgsdk
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ FIXME: This module contains ...
|
|||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from zope.interface import implementer
|
from zope.interface import implementer, provider
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -42,6 +42,7 @@ from twisted.plugin import IPlugin
|
|||||||
from twisted.application.service import IServiceMaker
|
from twisted.application.service import IServiceMaker
|
||||||
from twisted.application import internet, service
|
from twisted.application import internet, service
|
||||||
from twisted.cred import portal
|
from twisted.cred import portal
|
||||||
|
from twisted.logger import ILogObserver, globalLogPublisher
|
||||||
|
|
||||||
from cowrie.core.config import readConfigFile
|
from cowrie.core.config import readConfigFile
|
||||||
from cowrie import core
|
from cowrie import core
|
||||||
@@ -61,6 +62,16 @@ class Options(usage.Options):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@provider(ILogObserver)
|
||||||
|
def importFailureObserver(event):
|
||||||
|
if 'failure' in event and event['failure'].type is ImportError:
|
||||||
|
log.err("ERROR: %s. Please run `pip install -U -r requirements.txt` "
|
||||||
|
"from Cowrie's install directory and virtualenv to install "
|
||||||
|
"the new dependency" % event['failure'].value.message)
|
||||||
|
|
||||||
|
|
||||||
|
globalLogPublisher.addObserver(importFailureObserver)
|
||||||
|
|
||||||
|
|
||||||
@implementer(IServiceMaker, IPlugin)
|
@implementer(IServiceMaker, IPlugin)
|
||||||
class CowrieServiceMaker(object):
|
class CowrieServiceMaker(object):
|
||||||
@@ -132,7 +143,10 @@ class CowrieServiceMaker(object):
|
|||||||
log.addObserver(output.emit)
|
log.addObserver(output.emit)
|
||||||
self.output_plugins.append(output)
|
self.output_plugins.append(output)
|
||||||
log.msg("Loaded output engine: {}".format(engine))
|
log.msg("Loaded output engine: {}".format(engine))
|
||||||
except:
|
except ImportError as e:
|
||||||
|
log.err("Failed to load output engine: {} due to ImportError: {}".format(engine, e))
|
||||||
|
log.msg("Please install the dependencies for {} listed in requirements-output.txt".format(engine))
|
||||||
|
except Exception:
|
||||||
log.err()
|
log.err()
|
||||||
log.msg("Failed to load output engine: {}".format(engine))
|
log.msg("Failed to load output engine: {}".format(engine))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user