Commit 54a117da authored by Ziirish's avatar Ziirish

fix setup-burp by enforcing burp2 backend for setup and fallback to...

fix setup-burp by enforcing burp2 backend for setup and fallback to client_version when we can't determine the server_version for the parser
parent 56464b02
Pipeline #1597 failed with stages
in 2 minutes and 58 seconds
......@@ -342,8 +342,8 @@ def setup_burp(bconfcli, bconfsrv, client, host, redis, database,
is_parallel = app.config['BACKEND'] == 'parallel' or (backend and backend == 'parallel')
if backend and app.config['BACKEND'] != backend:
app.config['BACKEND'] = backend
# enforce burp2 backend for the configuration
app.config['BACKEND'] = 'burp2'
try:
msg = app.load_modules()
......@@ -354,7 +354,7 @@ def setup_burp(bconfcli, bconfsrv, client, host, redis, database,
_die(msg, 'setup-burp')
from .misc.parser.utils import Config
from .misc.backend.utils.constant import BURP_LISTEN_OPTION
from .misc.backend.utils.constant import BURP_LISTEN_OPTION, BURP_BIND_MULTIPLE
from .app import get_redis_server
from .config import BUIConfig
import difflib
......@@ -633,7 +633,7 @@ exclude_comp=gz
confcli['cname'] = client
if confcli.get('server') != host:
confcli['server'] = host
c_status_port = confcli.get('status_port', [4972])[0]
c_status_port = confcli.get('status_port', [4972])[0] if confcli.version >= BURP_BIND_MULTIPLE else confcli.get('status_port', 4972)
if confcli.dirty:
if dry:
......@@ -710,15 +710,20 @@ exclude_comp=gz
)
status_port = confsrv.get('status_port', [4972])
do_warn = False
if 'max_status_children' not in confsrv:
info(
'We need to set the number of \'max_status_children\'. '
'Setting it to 15.'
)
confsrv['max_status_children'] = 15
elif confsrv.version < BURP_BIND_MULTIPLE:
max_status_children = confsrv.get('max_status_children')
if not max_status_children or max_status_children < 15:
confsrv['max_status_children'] = 15
do_warn = True
else:
max_status_children = confsrv.get('max_status_children', [])
do_warn = False
if not is_burp_2_2_10_plus:
for idx, value in enumerate(status_port):
if value == c_status_port:
......@@ -732,8 +737,9 @@ exclude_comp=gz
if max_status_children[-1] < 15:
confsrv['max_status_children'][-1] = 15
do_warn = True
if do_warn:
warn('We need to raise the number of \'max_status_children\'.')
if do_warn:
warn('We need to raise the number of \'max_status_children\'.')
if 'restore_client' not in confsrv:
confsrv['restore_client'] = client
......
......@@ -27,14 +27,14 @@ 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 '') >= BURP_LISTEN_OPTION:
if self.backend and (getattr(self.backend, 'server_version', None) or geattr(self.backend, 'client_version', None) 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 '') >= BURP_BIND_MULTIPLE:
elif self.backend and (getattr(self.backend, 'server_version', None) or geattr(self.backend, 'client_version', None) or '') >= BURP_BIND_MULTIPLE:
self._pair_associations = {
'port': 'max_children',
'max_children': 'port',
......@@ -48,14 +48,14 @@ 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 '') >= BURP_LISTEN_OPTION:
if self.backend and (getattr(self.backend, 'server_version', None) or geattr(self.backend, 'client_version', None) 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 '') >= BURP_BIND_MULTIPLE:
elif self.backend and (getattr(self.backend, 'server_version', None) or geattr(self.backend, 'client_version', None) or '') >= BURP_BIND_MULTIPLE:
self._pair_srv = [
'port',
'max_children',
......@@ -72,7 +72,7 @@ class Parser(Burp1):
self._multi_srv = Burp1.multi_srv + [
'label'
]
if self.backend and getattr(self.backend, 'server_version', '') >= BURP_BIND_MULTIPLE:
if self.backend and (getattr(self.backend, 'server_version', '') or geattr(self.backend, 'client_version', None) or '') >= BURP_BIND_MULTIPLE:
self._multi_srv += [
'port',
'status_port'
......@@ -83,7 +83,7 @@ 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', '') >= BURP_BIND_MULTIPLE:
if self.backend and (getattr(self.backend, 'server_version', '') or geattr(self.backend, 'client_version', None) or '') >= BURP_BIND_MULTIPLE:
for rem in ['port', 'max_children', 'status_port', 'max_status_children']:
self._integer_srv.remove(rem)
return self._integer_srv
......
......@@ -669,6 +669,12 @@ class File(dict):
self._changed = mtime != self.mtime
return self._changed
@property
def version(self):
return getattr(self.parser.backend, 'server_version', None) or \
getattr(self.parser.backend, 'client_version', None) or '' \
if self.parser.backend else ''
def _ret_data(self, raw=True):
if raw:
ret = self._raw_data
......
......@@ -230,7 +230,7 @@ case "$1" in
prog=$(which $1)
if [ -n "${prog}" ] ; then
shift 1
su -l burpui -c "$prog $@"
id burpui 2>/dev/null && su -l burpui -c "$prog $@" || "$prog $@"
else
appHelp
fi
......
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