mirror of
https://github.com/ziirish/burp-ui.git
synced 2026-05-15 14:16:08 -06:00
demo: ensure the monitor is ready before initializing the agent
This commit is contained in:
parent
06db950c17
commit
8a3f50aed5
6 changed files with 51 additions and 5 deletions
|
|
@ -74,7 +74,7 @@ class BurpHandler(BUIbackend):
|
|||
if 'alive' not in stats or not stats['alive']:
|
||||
raise BUIserverException('Cannot talk to burp server')
|
||||
except Exception as exc:
|
||||
self.logger.error('Failed loading backend {}: {}'.format(self.backend, str(exc)), exc_info=exc, stack_info=True)
|
||||
self.logger.error('Failed loading backend {}: {}'.format(self.backend_name, str(exc)), exc_info=exc, stack_info=True)
|
||||
sys.exit(2)
|
||||
|
||||
def __getattribute__(self, name):
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
import re
|
||||
import json
|
||||
import ssl
|
||||
import time
|
||||
import trio
|
||||
import struct
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ BUI_DEFAULTS = {
|
|||
'password': 'password123456',
|
||||
'timeout': 15,
|
||||
'concurrency': 2,
|
||||
'init_wait': 15,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -183,6 +185,9 @@ class Burp(Burp2):
|
|||
_server_version = None
|
||||
_batch_list_supported = None
|
||||
|
||||
_ready = False
|
||||
parser = None
|
||||
|
||||
def __init__(self, server=None, conf=None):
|
||||
"""
|
||||
:param server: ``Burp-UI`` server instance in order to access logger
|
||||
|
|
@ -196,9 +201,8 @@ class Burp(Burp2):
|
|||
BUIbackend.__init__(self, server, conf)
|
||||
|
||||
self.conf = conf
|
||||
self.concurrency = conf.safe_get('concurrency', 'integer', section='Parallel', defaults=BUI_DEFAULTS)
|
||||
|
||||
self.parser = Parser(self)
|
||||
self.concurrency = conf.safe_get('concurrency', 'integer', 'Parallel', BUI_DEFAULTS)
|
||||
self.init_wait = conf.safe_get('init_wait', 'integer', 'Parallel', BUI_DEFAULTS)
|
||||
|
||||
self.logger.info('burp conf cli: {}'.format(self.burpconfcli))
|
||||
self.logger.info('burp conf srv: {}'.format(self.burpconfsrv))
|
||||
|
|
@ -209,6 +213,29 @@ class Burp(Burp2):
|
|||
self.logger.info('enforce: {}'.format(self.enforce))
|
||||
self.logger.info('revoke: {}'.format(self.revoke))
|
||||
self.logger.info('concurrency: {}'.format(self.concurrency))
|
||||
self.logger.info('init_wait: {}'.format(self.init_wait))
|
||||
|
||||
if self.init_wait:
|
||||
exc = None
|
||||
init_mon = Parallel(conf)
|
||||
for _ in range(self.init_wait):
|
||||
try:
|
||||
self.logger.warning('monitor not ready, waiting for it...')
|
||||
trio.run(init_mon.conn)
|
||||
if init_mon.connected:
|
||||
break
|
||||
except BUIserverException as eee:
|
||||
exc = eee
|
||||
time.sleep(1)
|
||||
else:
|
||||
self.logger.error('monitor not ready, giving up!')
|
||||
raise exc
|
||||
del init_mon
|
||||
self.init_all()
|
||||
|
||||
def init_all(self):
|
||||
self._ready = True
|
||||
self.parser = Parser(self)
|
||||
|
||||
@property
|
||||
def client_version(self):
|
||||
|
|
@ -243,6 +270,8 @@ class Burp(Burp2):
|
|||
return await async_client.status(query, timeout, cache)
|
||||
except OSError as exc:
|
||||
raise BUIserverException(str(exc))
|
||||
if not self._ready:
|
||||
self.init_all()
|
||||
|
||||
async def _async_request(self, func, *args, **kwargs):
|
||||
async_client = Parallel(self.conf)
|
||||
|
|
@ -250,6 +279,8 @@ class Burp(Burp2):
|
|||
return await async_client.request(func, *args, **kwargs)
|
||||
except OSError as exc:
|
||||
raise BUIserverException(str(exc))
|
||||
if not self._ready:
|
||||
self.init_all()
|
||||
|
||||
@usetriorun
|
||||
def status(self, query='c:\n', timeout=None, cache=True, agent=None):
|
||||
|
|
@ -795,7 +826,7 @@ class AsyncBurp(Burp):
|
|||
def statistics(self, agent=None):
|
||||
return Burp.statistics(self)
|
||||
|
||||
# this method must not be async
|
||||
# this method must not be async!
|
||||
@implement
|
||||
def get_parser(self, agent=None):
|
||||
"""See :func:`burpui.misc.backend.interface.BUIbackend.get_parser`"""
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ appStart () {
|
|||
echo "Starting bui-monitor..."
|
||||
supervisorctl start buimonitor >/dev/null
|
||||
|
||||
# wait for the monitor to be up and running
|
||||
sleep 10
|
||||
|
||||
echo "Starting bui-agent..."
|
||||
supervisorctl start buiagent >/dev/null
|
||||
|
||||
|
|
|
|||
|
|
@ -404,6 +404,10 @@ Once this backend is enabled, you have to configure the ``[Parallel]`` section.
|
|||
# number of operations to process concurrently
|
||||
# the value should not exceed the pool size you set in the bui-monitor.cfg file
|
||||
concurrency = 2
|
||||
# time to wait at startup, mainly used by the bui-agent
|
||||
# the bui-monitor must be started before your agent, but since it needs to
|
||||
# initialize its workers first you may need to wait a bit for it to be available
|
||||
init_wait = 15
|
||||
|
||||
|
||||
To configure your monitor pool, please refer to the `bui-monitor`_ page.
|
||||
|
|
|
|||
|
|
@ -78,3 +78,7 @@ ssl = true
|
|||
# number of operations to process concurrently
|
||||
# the value should not exceed the pool size you set in the bui-monitor.cfg file
|
||||
concurrency = 2
|
||||
# time to wait at startup
|
||||
# the bui-monitor must be started before your agent, but since it needs to
|
||||
# initialize its workers first you may need to wait a bit for it to be available
|
||||
init_wait = 15
|
||||
|
|
|
|||
|
|
@ -203,6 +203,10 @@ ssl = true
|
|||
# number of operations to process concurrently
|
||||
# the value should not exceed the pool size you set in the bui-monitor.cfg file
|
||||
concurrency = 2
|
||||
# time to wait at startup, mainly used by the bui-agent
|
||||
# the bui-monitor must be started before your agent, but since it needs to
|
||||
# initialize its workers first you may need to wait a bit for it to be available
|
||||
init_wait = 15
|
||||
|
||||
# Basic audit backend options
|
||||
[BASIC:AUDIT]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue