Commit 64bd3795 authored by Ziirish's avatar Ziirish

relocate 'engines': agent, server, celery and soon monitor

parent 0a09d51c
......@@ -115,7 +115,7 @@ def server(options=None, unknown=None):
def agent(options=None):
import trio
from burpui.agent import BUIAgent as Agent
from burpui.engines.agent import BUIAgent as Agent
from burpui.utils import lookup_file
from burpui._compat import patch_json
......@@ -176,7 +176,7 @@ def celery():
'celery',
celery_mode,
'-A',
'worker.celery'
'engines.worker.celery'
]
args += unknown
args += [x for x in options.remaining if x != '--']
......
......@@ -22,7 +22,7 @@ from functools import wraps
from .._compat import to_bytes
from ..desc import __version__, __release__, __url__, __doc__
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
from ..exceptions import BUIserverException
from ..config import config
......
......@@ -8,7 +8,7 @@
"""
from . import api
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
from ..sessions import session_manager
from ..misc.acl.meta import meta_grants
from ..utils import NOTIF_OK
......
......@@ -16,7 +16,7 @@ from .misc import History
from .custom import Resource
from .client import node_fields
from .clients import RunningBackup, ClientsReport, RunningClients
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
from ..ext.cache import cache
from ..config import config
from ..decorators import browser_cache
......
......@@ -8,7 +8,7 @@
"""
from . import api
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
from .custom import Resource
from ..exceptions import BUIserverException
......
......@@ -11,7 +11,7 @@ import os
import re
from . import api, cache_key, force_refresh
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
from .custom import fields, Resource, inputs
from ..decorators import browser_cache
from ..ext.cache import cache
......
......@@ -8,7 +8,7 @@
"""
from . import api, cache_key, force_refresh
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
from .custom import fields, Resource
from .client import ClientLabels
from ..ext.cache import cache
......
......@@ -8,7 +8,7 @@
"""
from . import api, cache_key, force_refresh
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
from .custom import fields, Resource
from ..exceptions import BUIserverException
from ..decorators import browser_cache
......
......@@ -12,7 +12,7 @@ from flask_login import current_user
from werkzeug.datastructures import MultiDict
from . import api
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
from ..ext.i18n import LANGUAGES
from .custom import Resource
......
......@@ -11,7 +11,7 @@ import select
import struct
from . import api
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
from .custom import fields, Resource, inputs
from ..exceptions import BUIserverException
......
......@@ -2,7 +2,7 @@
# This is a submodule we can also use "from ..api import api"
from . import api, cache_key, force_refresh
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
from .custom import fields, Resource
from ..ext.cache import cache
from ..decorators import browser_cache
......
......@@ -8,7 +8,7 @@
"""
from . import api
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
from ..ext.cache import cache
from .custom import Resource, inputs
from .._compat import unquote
......
......@@ -45,7 +45,7 @@ def create_app(conf=None, verbose=0, logfile=None, **kwargs):
server. Default is False
:type kwargs: dict
:returns: A :class:`burpui.server.BUIServer` object
:returns: A :class:`burpui.engines.server.BUIServer` object
"""
from flask import g, request, session, render_template
from flask_login import LoginManager
......@@ -53,7 +53,7 @@ def create_app(conf=None, verbose=0, logfile=None, **kwargs):
from flask_babel import gettext
from .utils import ReverseProxied, lookup_file, is_uuid
from .security import basic_login_from_request
from .server import BUIServer as BurpUI
from .engines.server import BUIServer as BurpUI
from .sessions import session_manager
from .ext.cache import cache
from .ext.i18n import babel, get_locale
......
......@@ -17,11 +17,11 @@ import trio
from logging.handlers import RotatingFileHandler
from .exceptions import BUIserverException
from .misc.backend.interface import BUIbackend
from ._compat import pickle, to_bytes, to_unicode
from .config import config
from .desc import __version__
from ..exceptions import BUIserverException
from ..misc.backend.interface import BUIbackend
from .._compat import pickle, to_bytes, to_unicode
from ..config import config
from ..desc import __version__
# TODO: sendfile is not yet supported by trio
# try:
......
......@@ -12,10 +12,10 @@ import re
import sys
import logging
from .misc.auth.handler import UserAuthHandler
from .misc.acl.handler import ACLloader
from .config import config
from .plugins import PluginManager
from ..misc.auth.handler import UserAuthHandler
from ..misc.acl.handler import ACLloader
from ..config import config
from ..plugins import PluginManager
from datetime import timedelta
from flask import Flask
......@@ -77,12 +77,12 @@ BUI_DEFAULTS = {
class BUIServer(Flask):
"""
The :class:`burpui.server.BUIServer` class provides the ``Burp-UI`` server.
The :class:`burpui.engines.server.BUIServer` class provides the ``Burp-UI`` server.
"""
gunicorn = False
def __init__(self):
"""The :class:`burpui.server.BUIServer` class provides the ``Burp-UI``
"""The :class:`burpui.engines.server.BUIServer` class provides the ``Burp-UI``
server.
:param app: The Flask application to launch
......@@ -109,7 +109,7 @@ class BUIServer(Flask):
return self._logger
def setup(self, conf=None, unittest=False, cli=False):
"""The :func:`burpui.server.BUIServer.setup` functions is used to setup
"""The :func:`burpui.engines.server.BUIServer.setup` functions is used to setup
the whole server by parsing the configuration file and loading the
different backends.
......@@ -414,7 +414,7 @@ class BUIServer(Flask):
module = 'burpui.misc.backend.{}'.format(backend)
# This is used for development purpose only
from .misc.backend.burp1 import Burp as BurpGeneric
from ..misc.backend.burp1 import Burp as BurpGeneric
self.client = BurpGeneric(dummy=True)
self.strict = strict
try:
......@@ -447,7 +447,7 @@ class BUIServer(Flask):
"""
if self.acl_engine and 'none' not in self.acl_engine:
# refresh acl to detect config changes
from .misc.acl.interface import BUIacl # noqa
from ..misc.acl.interface import BUIacl # noqa
acl = self.acl_handler.acl # type: BUIacl
return acl
return None
......@@ -463,7 +463,7 @@ class BUIServer(Flask):
return Flask.get_send_file_max_age(self, name)
def manual_run(self):
"""The :func:`burpui.server.BUIServer.manual_run` functions is used to
"""The :func:`burpui.engines.server.BUIServer.manual_run` functions is used to
actually launch the ``Burp-UI`` server.
.. deprecated:: 0.4.0
......
......@@ -14,7 +14,7 @@ import os
import sys
# Try to load modules from our current env first
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..'))
def init_app(conf):
......
......@@ -53,7 +53,7 @@ def create_db(myapp, cli=False, unittest=False, create=True, celery_worker=False
"""Create the SQLAlchemy instance if possible
:param myapp: Application context
:type myapp: :class:`burpui.server.BUIServer`
:type myapp: :class:`burpui.engines.server.BUIServer`
"""
if myapp.config['WITH_SQL']:
try:
......@@ -209,7 +209,7 @@ def create_websocket(myapp, websocket_server=False, celery_worker=False,
"""Create the websocket server if possible
:param myapp: Application context
:type myapp: :class:`burpui.server.BUIServer`
:type myapp: :class:`burpui.engines.server.BUIServer`
"""
if cli and not websocket_server:
return False
......@@ -275,7 +275,7 @@ def create_celery(myapp, warn=True):
"""Create the Celery app if possible
:param myapp: Application context
:type myapp: :class:`burpui.server.BUIServer`
:type myapp: :class:`burpui.engines.server.BUIServer`
"""
if myapp.config['WITH_CELERY']: # pragma: no cover
from .exceptions import BUIserverException
......
......@@ -13,7 +13,7 @@ class ACLloader(BUIaclLoader):
"""See :func:`burpui.misc.acl.interface.BUIaclLoader.__init__`
:param app: Application context
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
self.app = app
self.conf = self.app.conf
......
......@@ -15,7 +15,7 @@ class ACLloader(BUIaclLoader):
"""See :func:`burpui.misc.acl.interface.BUIaclLoader.__init__`
:param app: Application context
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
self.app = app
self.conf = self.app.conf
......
......@@ -47,7 +47,7 @@ class BUIaclLoader(object, metaclass=ABCMeta):
the loader.
:param app: Application context
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
self.app = None
if app: # pragma: no cover
......@@ -91,7 +91,7 @@ class BUIacl(object, metaclass=ABCMeta):
the ACL.
:param app: Application context
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
self.app = None
if app: # pragma: no cover
......
......@@ -18,7 +18,7 @@ class BasicLoader(BUIloader):
the configuration file.
:param app: Instance of the app we are running in
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
:param handler: Instance of handler
:type handler: :class:`burpui.misc.auth.interface.BUIhandler`
......
......@@ -20,7 +20,7 @@ class UserAuthHandler(BUIhandler):
"""See :func:`burpui.misc.auth.interface.BUIhandler.__init__`
:param app: Instance of the app we are running in
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
self.app = app
self.users = {}
......@@ -218,7 +218,7 @@ class UserHandler(BUIuser):
def __init__(self, app, backends=None, name=None, id=None):
"""
:param app: Application context
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
self.id = id
self.app = app
......
......@@ -22,7 +22,7 @@ class BUIhandler(object, metaclass=ABCMeta):
of ``Burp-UI`` users.
:param app: Instance of the app we are running in
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
priority = 0
......
......@@ -37,7 +37,7 @@ class LdapLoader(BUIloader):
connection to the LDAP server.
:param app: Instance of the app we are running in
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
self.app = app
conf = self.app.conf
......@@ -233,7 +233,7 @@ class UserHandler(BUIhandler):
handler instance
:param app: Instance of the app we are running in
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
self.ldap = LdapLoader(app, self)
self.users = {}
......
......@@ -19,7 +19,7 @@ class LocalLoader(BUIloader):
the configuration file.
:param app: Instance of the app we are running in
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
self.app = app
self.users = None
......
......@@ -30,7 +30,7 @@ class Monitor(object):
:param app: ``Burp-UI`` server instance in order to access logger
and/or some global settings
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
:param burpbin: Burp binary path
:type burpbin: str
......@@ -52,7 +52,7 @@ class Monitor(object):
"""
:param app: ``Burp-UI`` server instance in order to access logger
and/or some global settings
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
:param burpbin: Burp binary path
:type burpbin: str
......
......@@ -36,7 +36,7 @@ class Burp(BUIbackend):
:param server: ``Burp-UI`` server instance in order to access logger
and/or some global settings
:type server: :class:`burpui.server.BUIServer`
:type server: :class:`burpui.engines.server.BUIServer`
:param conf: Configuration file to use
:type conf: str
......@@ -98,7 +98,7 @@ class Burp(BUIbackend):
:param server: ``Burp-UI`` server instance in order to access logger
and/or some global settings
:type server: :class:`burpui.server.BUIServer`
:type server: :class:`burpui.engines.server.BUIServer`
:param conf: Configuration to use
:type conf: :class:`burpui.config.BUIConfig`
......
......@@ -51,7 +51,7 @@ class Burp(Burp1):
:param server: ``Burp-UI`` server instance in order to access logger
and/or some global settings
:type server: :class:`burpui.server.BUIServer`
:type server: :class:`burpui.engines.server.BUIServer`
:param conf: Configuration to use
:type conf: :class:`burpui.config.BUIConfig`
......@@ -66,7 +66,7 @@ class Burp(Burp1):
"""
:param server: ``Burp-UI`` server instance in order to access logger
and/or some global settings
:type server: :class:`burpui.server.BUIServer`
:type server: :class:`burpui.engines.server.BUIServer`
:param conf: Configuration to use
:type conf: :class:`burpui.config.BUIConfig`
......
......@@ -34,7 +34,7 @@ class BUIbackend(object, metaclass=ABCMeta):
:param server: ``Flask`` server instance in order to access logger
and/or some global settings
:type server: :class:`burpui.server.BUIServer`
:type server: :class:`burpui.engines.server.BUIServer`
:param conf: Configuration file to use
:type conf: str
......@@ -48,7 +48,7 @@ class BUIbackend(object, metaclass=ABCMeta):
def __init__(self, server=None, conf=None): # pragma: no cover
"""
:param server: Application context
:type server: :class:`burpui.server.BUIServer`
:type server: :class:`burpui.engines.server.BUIServer`
"""
self.app = server
self.zip64 = G_ZIP64
......
......@@ -156,7 +156,7 @@ class Burp(BUIbackend):
:param server: ``Burp-UI`` server instance in order to access logger
and/or some global settings
:type server: :class:`burpui.server.BUIServer`
:type server: :class:`burpui.engines.server.BUIServer`
:param conf: Configuration file to use
:type conf: str
......@@ -171,7 +171,7 @@ class Burp(BUIbackend):
def __init__(self, server=None, conf=None):
"""
:param server: Application context
:type server: :class:`burpui.server.BUIServer`
:type server: :class:`burpui.engines.server.BUIServer`
:param conf: Configuration
:type conf: :class:`burpui.config.BUIConfig`
......@@ -337,7 +337,7 @@ class NClient(BUIbackend):
the :class:`burpui.misc.backend.interface.BUIbackend` class.
:param app: The application context
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
:param host: Address of the remote agent
:type host: str
......
......@@ -11,7 +11,7 @@ import datetime
from .ext.sql import db
from flask import current_app, session
from .server import BUIServer # noqa
from .engines.server import BUIServer # noqa
app = current_app # type: BUIServer
......
......@@ -14,7 +14,7 @@ class PluginManager(object):
"""The :class:`burpui.plugins.PluginManager` class is a plugin manager.
:param app: Instance of the app we are running in
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
:param searchpath: The places to look for plugins
:type searchpath: list
......
......@@ -17,7 +17,7 @@ from flask_login import login_user, login_required, logout_user, current_user
from flask_babel import gettext as _, refresh as refresh_babel
from .desc import __url__, __doc__
from .server import BUIServer # noqa
from .engines.server import BUIServer # noqa
from .sessions import session_manager
from ._compat import quote
from .forms import LoginForm
......
......@@ -37,7 +37,7 @@ def basic_login_from_request(request, app):
:type request: :class:`flask.Request`
:param app: The application context
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
if app.auth != 'none':
if request.headers.get('X-From-UI', False):
......
......@@ -29,7 +29,7 @@ class SessionManager(object):
"""Initialize the wrapper
:param app: Application context
:type app: :class:`burpui.server.BUIServer`
:type app: :class:`burpui.engines.server.BUIServer`
"""
self.app = app
self.prefix = self.app.config.get('SESSION_KEY_PREFIX', 'session:')
......
......@@ -25,7 +25,7 @@ from burpui.config import config # noqa
from burpui.ext.async import celery # noqa
from burpui.ext.cache import cache # noqa
from burpui.sessions import session_manager # noqa
from burpui.server import BUIServer # noqa
from burpui.engines.server import BUIServer # noqa
from burpui.exceptions import BUIserverException # noqa
from burpui.api.client import ClientTreeAll # noqa
......
......@@ -10,7 +10,7 @@
from flask import current_app, request
from flask_socketio import Namespace, emit
from ..server import BUIServer # noqa
from ..engines.server import BUIServer # noqa
bui = current_app # type: BUIServer
......
......@@ -58,12 +58,11 @@ def main():
def agent(options=None):
from gevent import monkey
from burpui_agent.agent import BUIAgent as Agent
import trio
from burpui_agent.engines.agent import BUIAgent as Agent
from burpui_agent.utils import lookup_file
from burpui_agent._compat import patch_json
monkey.patch_all()
patch_json()
if not options:
......@@ -77,7 +76,7 @@ def agent(options=None):
check_config(conf)
agent = Agent(conf, options.log, options.logfile, options.debug)
agent.run()
trio.run(agent.run)
def check_config(conf):
......
../../../burpui/agent.py
\ No newline at end of file
../../../../burpui/engines/agent.py
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment