Verified Commit 4d73ae8a authored by Benjamin "Ziirish" SANS's avatar Benjamin "Ziirish" SANS
Browse files

fix: allow to provide a burp-server version in case we cannot determine it automatically #333

parent 48aed7aa
Pipeline #1776 passed with stages
in 19 minutes and 52 seconds
......@@ -327,10 +327,12 @@ def compile_translation():
help='Number of burp-client processes to spawn in the monitor')
@click.option('-B', '--backend', default=None,
help='Switch to another backend', type=click.Choice(['burp2', 'parallel']))
@click.option('-a', '--assume-version', 'assume', default=None,
help='If we cannot determine server version use this one')
@click.option('-n', '--dry', is_flag=True,
help='Dry mode. Do not edit the files but display changes')
def setup_burp(bconfcli, bconfsrv, client, listen, host, redis, database,
plugins, monitor, mbind, concurrency, pool, backend, dry):
plugins, monitor, mbind, concurrency, pool, backend, assume, dry):
"""Setup burp client for burp-ui."""
if app.config['BACKEND'] not in ['burp2', 'parallel'] and not backend:
err("Sorry, you can only setup the 'burp2' and the 'parallel' backends")
......@@ -391,7 +393,7 @@ def setup_burp(bconfcli, bconfsrv, client, listen, host, redis, database,
monconf.options.filename = temp
parser = app.client.get_parser()
server_version = app.client.get_server_version()
server_version = app.client.get_server_version() or assume
orig = source = None
conf_orig = []
if dry:
......@@ -652,7 +654,7 @@ exclude_comp=gz
with open(dest_bconfcli, 'w') as confcli:
confcli.write(clitpl)
parser = app.client.get_parser()
parser = app.client.get_parser(assume)
confcli = Config(dest_bconfcli, parser, 'srv')
confcli.set_default(dest_bconfcli)
......
......@@ -1085,9 +1085,11 @@ class Burp(BUIbackend):
except AttributeError:
return default
def get_parser(self, agent=None):
def get_parser(self, assume_version=None, agent=None):
"""See :func:`burpui.misc.backend.interface.BUIbackend.get_parser`"""
if self.parser:
if assume_version:
self.parser._assume_server_version = assume_version
return self.parser
raise BUIserverException('Missing parser')
......
......@@ -28,6 +28,9 @@ class Parser(Doc):
"""
pver = 1
_assume_server_version = ''
_assume_client_version = ''
def __init__(self, backend=None):
"""
:param backend: Backend context
......
......@@ -27,14 +27,16 @@ class Parser(Burp1):
@property
def pair_associations(self):
if self._pair_associations is None:
if self.backend and (getattr(self.backend, 'server_version', None) or getattr(self.backend, 'client_version', None) or '') >= BURP_LISTEN_OPTION:
if self.backend and (getattr(self.backend, 'server_version', self._assume_server_version) or
getattr(self.backend, 'client_version', self._assume_client_version) or '') >= BURP_LISTEN_OPTION:
self._pair_associations = {
'listen': 'max_children',
'max_children': 'listen',
'listen_status': 'max_status_children',
'max_status_children': 'listen_status',
}
elif self.backend and (getattr(self.backend, 'server_version', None) or getattr(self.backend, 'client_version', None) or '') >= BURP_BIND_MULTIPLE:
elif self.backend and (getattr(self.backend, 'server_version', self._assume_server_version) or
getattr(self.backend, 'client_version', self._assume_client_version) or '') >= BURP_BIND_MULTIPLE:
self._pair_associations = {
'port': 'max_children',
'max_children': 'port',
......@@ -48,14 +50,16 @@ class Parser(Burp1):
@property
def pair_srv(self):
if self._pair_srv is None:
if self.backend and (getattr(self.backend, 'server_version', None) or getattr(self.backend, 'client_version', None) or '') >= BURP_LISTEN_OPTION:
if self.backend and (getattr(self.backend, 'server_version', self._assume_server_version) or
getattr(self.backend, 'client_version', self._assume_client_version) or '') >= BURP_LISTEN_OPTION:
self._pair_srv = [
'listen',
'max_children',
'listen_status',
'max_status_children',
]
elif self.backend and (getattr(self.backend, 'server_version', None) or getattr(self.backend, 'client_version', None) or '') >= BURP_BIND_MULTIPLE:
elif self.backend and (getattr(self.backend, 'server_version', self._assume_server_version) or
getattr(self.backend, 'client_version', self._assume_client_version) or '') >= BURP_BIND_MULTIPLE:
self._pair_srv = [
'port',
'max_children',
......@@ -72,7 +76,8 @@ class Parser(Burp1):
self._multi_srv = Burp1.multi_srv + [
'label'
]
if self.backend and (getattr(self.backend, 'server_version', '') or getattr(self.backend, 'client_version', None) or '') >= BURP_BIND_MULTIPLE:
if self.backend and (getattr(self.backend, 'server_version', self._assume_server_version) or
getattr(self.backend, 'client_version', self._assume_client_version) or '') >= BURP_BIND_MULTIPLE:
self._multi_srv += [
'port',
'status_port'
......@@ -83,7 +88,8 @@ class Parser(Burp1):
def integer_srv(self):
if self._integer_srv is None:
self._integer_srv = Burp1.integer_srv
if self.backend and (getattr(self.backend, 'server_version', '') or getattr(self.backend, 'client_version', None) or '') >= BURP_BIND_MULTIPLE:
if self.backend and (getattr(self.backend, 'server_version', self._assume_server_version) or
getattr(self.backend, 'client_version', self._assume_client_version) or '') >= BURP_BIND_MULTIPLE:
for rem in ['port', 'max_children', 'status_port', 'max_status_children']:
self._integer_srv.remove(rem)
return self._integer_srv
......
......@@ -19,6 +19,7 @@ BURP_CLIENT_CONFIG=${BURP_CLIENT_CONFIG:-/tmp/burp.conf}
BURP_SERVER_CONFIG=${BURP_SERVER_CONFIG:-/etc/burp/burp-server.conf}
BURP_SERVER_ADDR=${BURP_SERVER_ADDR:-burp-server}
BURP_RESTORE_LISTEN_ADDR=${BURP_RESTORE_LISTEN_ADDR:-0.0.0.0:5971}
BURP_VERSION=${BURP_VERSION:-2.2.18}
REDIS_SERVER=${REDIS_SERVER:-redis:6379}
DATABASE_URL=${DATABASE_URL:-postgresql://burpui:burpui@pgsql/burpuidb}
GUNICORN_WORKERS=${GUNICORN_WORKERS:-$(getconf _NPROCESSORS_ONLN)}
......@@ -71,7 +72,7 @@ appStart () {
LOGFILE=$(doas burpui mktemp)
echo "Setting up burp & burp-ui:"
COMMAND="bui-manage -c $BURPUI_CONFIG setup-burp --burp-conf-cli $BURP_CLIENT_CONFIG --burp-conf-serv $BURP_SERVER_CONFIG --host $BURP_SERVER_ADDR --client $BURPUI_CLIENT_NAME --redis $REDIS_SERVER --database $DATABASE_URL --plugins $BURPUI_PLUGINS --monitor $BURPUI_MONITOR_CONFIG --monitor-listen $BURPUI_MONITOR_LISTEN --concurrency $ASYNC_CONCURRENCY --pool-size $ASYNC_POOL_SIZE --backend $BURPUI_BACKEND --listen $BURP_RESTORE_LISTEN_ADDR"
COMMAND="bui-manage -c $BURPUI_CONFIG setup-burp --burp-conf-cli $BURP_CLIENT_CONFIG --burp-conf-serv $BURP_SERVER_CONFIG --host $BURP_SERVER_ADDR --client $BURPUI_CLIENT_NAME --redis $REDIS_SERVER --database $DATABASE_URL --assume-version $BURP_VERSION --plugins $BURPUI_PLUGINS --monitor $BURPUI_MONITOR_CONFIG --monitor-listen $BURPUI_MONITOR_LISTEN --concurrency $ASYNC_CONCURRENCY --pool-size $ASYNC_POOL_SIZE --backend $BURPUI_BACKEND --listen $BURP_RESTORE_LISTEN_ADDR"
echo $COMMAND
set +e
doas burpui "$COMMAND 2>&1 | tee $LOGFILE"
......
......@@ -13,6 +13,7 @@ services:
# - MYSQL_PASSWORD=burpui
# - MYSQL_DATABASE=burpuidb
# - MYSQL_RANDOM_ROOT_PASSWORD=yes
# - TZ=Europe/Paris
## Additionally, you may want to persist data
## volumes:
## - /var/lib/buistore/mariadb:/var/lib/mysql
......@@ -22,6 +23,8 @@ services:
image: registry.ziirish.me/ziirish/burp-ui/pgsql:10
environment:
- POSTGRES_PASSWORD=password
# - TZ=Europe/Paris
# - PGTZ=Europe/Paris
## Additionally, you may want to persist data
## volumes:
## - /var/lib/buistore/pgsql/10/data:/var/lib/postgresql/data
......@@ -33,9 +36,9 @@ services:
- 0.0.0.0:4971:4971
- 0.0.0.0:4972:4972
volumes:
- /etc/burp
- /var/spool/burp
- /var/lib/burp
- /etc/burp:/etc/burp
- /var/spool/burp:/var/spool/burp
- /var/lib/burp:/var/lib/burp
# Additionally, you can override some default settings
# environment:
# - BURP_UID=5337
......
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