Commit be7999a4 authored by Benjamin "Ziirish" SANS's avatar Benjamin "Ziirish" SANS

continue removing python 2 specifics

parent 8cf2f017
......@@ -270,7 +270,7 @@ class BUIAgent(BUIbackend, BUIlogging):
import hashlib
from base64 import b64decode
pickles = to_bytes(j['args'])
key = u'{}{}'.format(self.password, j['func'])
key = '{}{}'.format(self.password, j['func'])
key = to_bytes(key)
bytes_pickles = pickles
digest = hmac.new(key, bytes_pickles, hashlib.sha1).hexdigest()
......
......@@ -183,7 +183,7 @@ class BUIConfig(dict):
:param exception: Exception object
:type exception: :class:`configobj.ConfigObjError`
"""
message = u'\n'
message = '\n'
for error in exception.errors:
message += error.message + '\n'
......
......@@ -28,18 +28,6 @@ from ..._compat import unquote, to_unicode, to_bytes
from shlex import quote
G_BURPPORT = 4972
G_BURPHOST = u'::1'
G_BURPBIN = u'/usr/sbin/burp'
G_STRIPBIN = u'/usr/sbin/vss_strip'
G_BURPCONFCLI = u''
G_BURPCONFSRV = u'/etc/burp/burp-server.conf'
G_TMPDIR = u'/tmp/bui'
G_ZIP64 = False
G_INCLUDES = [u'/etc/burp']
G_ENFORCE = False
G_REVOKE = True
class Burp(BUIbackend):
"""The :class:`burpui.misc.backend.burp1.Burp` class provides a consistent
......@@ -889,13 +877,13 @@ class Burp(BUIbackend):
return None, 'Wrong call'
if os.path.isdir(tmpdir):
shutil.rmtree(tmpdir)
full_reg = u''
full_reg = ''
def _escape(s):
return re.sub(r"[(){}\[\].*?|^$\\+-]", r"\\\g<0>", s)
for restore in flist['restore']:
reg = u''
reg = ''
if restore['folder'] and restore['key'] != '/':
reg += '^' + _escape(restore['key']) + '/|'
else:
......
......@@ -185,9 +185,9 @@ class Burp(Burp1):
bufsize=0
)
if not self._proc_is_alive():
details = u''
details = ''
if verbose:
details = u':\n'
details = ':\n'
out, _ = self.proc.communicate()
details += to_unicode(out)
raise OSError('Unable to spawn burp process{}'.format(details))
......@@ -278,7 +278,7 @@ class Burp(Burp1):
def _read_proc_stdout(self, timeout):
"""reads the burp process stdout and returns a document or None"""
doc = u''
doc = ''
jso = None
while True:
try:
......@@ -292,7 +292,7 @@ class Burp(Burp1):
# if the string is a valid json and looks like a logline, we
# simply ignore it
if jso and self._is_ignored(jso):
doc = u''
doc = ''
continue
elif jso:
break
......@@ -915,7 +915,7 @@ class Burp(Burp1):
if not name or not backup:
return ret
if not root:
top = u''
top = ''
else:
top = to_unicode(root)
......
......@@ -16,16 +16,16 @@ from abc import ABCMeta, abstractmethod
from six import with_metaclass
G_BURPPORT = 4972
G_BURPHOST = u'::1'
G_BURPBIN = u'/usr/sbin/burp'
G_STRIPBIN = u'/usr/sbin/vss_strip'
G_STRIPBIN2 = u'/usr/bin/vss_strip'
G_BURPCONFCLI = u'/etc/burp/burp.conf'
G_BURPCONFSRV = u'/etc/burp/burp-server.conf'
G_TMPDIR = u'/tmp/bui'
G_BURPHOST = '::1'
G_BURPBIN = '/usr/sbin/burp'
G_STRIPBIN = '/usr/sbin/vss_strip'
G_STRIPBIN2 = '/usr/bin/vss_strip'
G_BURPCONFCLI = '/etc/burp/burp.conf'
G_BURPCONFSRV = '/etc/burp/burp-server.conf'
G_TMPDIR = '/tmp/bui'
G_TIMEOUT = 15
G_ZIP64 = False
G_INCLUDES = [u'/etc/burp']
G_INCLUDES = ['/etc/burp']
G_ENFORCE = False
G_REVOKE = True
......
......@@ -543,7 +543,7 @@ class NClient(BUIbackend):
if vers and vers >= AGENT_VERSION_CAST:
# convert the data to our custom ImmutableMultiDict
data = ImmutableMultiDict(data.to_dict(False))
key = u'{}{}'.format(self.password, 'store_conf_srv')
key = '{}{}'.format(self.password, 'store_conf_srv')
key = to_bytes(key)
pickles = to_unicode(b64encode(pickle.dumps({'data': data, 'conf': conf}, 2)))
bytes_pickles = to_bytes(pickles)
......
......@@ -395,15 +395,15 @@ class Parser(Doc):
See :func:`burpui.misc.parser.interface.BUIparser.read_client_conf`
"""
res = {
u'common': [],
u'boolean': [],
u'integer': [],
u'multi': [],
u'includes': [],
u'includes_ext': [],
u'templates': [],
u'hierarchy': [],
u'raw': None,
'common': [],
'boolean': [],
'integer': [],
'multi': [],
'includes': [],
'includes_ext': [],
'templates': [],
'hierarchy': [],
'raw': None,
}
if not client and not conf:
return res
......@@ -426,18 +426,18 @@ class Parser(Doc):
return self.filescache[mconf]['dict']
res2 = {}
res2[u'common'] = parsed.string
res2[u'boolean'] = parsed.boolean
res2[u'integer'] = parsed.integer
res2[u'multi'] = parsed.multi
res2[u'templates'] = parsed.template
res2[u'includes'] = [
res2['common'] = parsed.string
res2['boolean'] = parsed.boolean
res2['integer'] = parsed.integer
res2['multi'] = parsed.multi
res2['templates'] = parsed.template
res2['includes'] = [
x
for x in parsed.flatten('include', False).keys()
]
res2[u'includes_ext'] = parsed.include
res2[u'hierarchy'] = config.tree
res2[u'raw'] = str(parsed)
res2['includes_ext'] = parsed.include
res2['hierarchy'] = config.tree
res2['raw'] = str(parsed)
res.update(res2)
self.filescache[mconf] = {
......@@ -452,15 +452,15 @@ class Parser(Doc):
"""
mconf = None
res = {
u'common': [],
u'boolean': [],
u'integer': [],
u'multi': [],
u'pair': [],
u'includes': [],
u'includes_ext': [],
u'hierarchy': [],
u'raw': None,
'common': [],
'boolean': [],
'integer': [],
'multi': [],
'pair': [],
'includes': [],
'includes_ext': [],
'hierarchy': [],
'raw': None,
}
if not conf:
mconf = self.conf
......@@ -474,18 +474,18 @@ class Parser(Doc):
return self.filescache[mconf]['dict']
res2 = {}
res2[u'common'] = parsed.string
res2[u'boolean'] = parsed.boolean
res2[u'integer'] = parsed.integer
res2[u'multi'] = parsed.multi
res2[u'pair'] = parsed.pair
res2[u'includes'] = [
res2['common'] = parsed.string
res2['boolean'] = parsed.boolean
res2['integer'] = parsed.integer
res2['multi'] = parsed.multi
res2['pair'] = parsed.pair
res2['includes'] = [
x
for x in parsed.flatten('include', False).keys()
]
res2[u'includes_ext'] = parsed.include
res2[u'hierarchy'] = self.server_conf.tree
res2[u'raw'] = str(parsed)
res2['includes_ext'] = parsed.include
res2['hierarchy'] = self.server_conf.tree
res2['raw'] = str(parsed)
res.update(res2)
self.filescache[mconf] = {
......
This diff is collapsed.
This diff is collapsed.
......@@ -400,11 +400,11 @@ class OptionMulti(Option):
def dump(self, start=0, strict=True):
"""Return the option representation to store in configuration file"""
ret = u''
ret = ''
if start > len(self.value):
return ret
res = [self.dump_index(i, strict) for i in range(start, len(self.value))]
ret = u'\n'.join(res)
ret = '\n'.join(res)
return ret.rstrip('\n')
def dump_index(self, index, strict=True):
......@@ -506,7 +506,7 @@ class OptionPair(Option, dict):
def dump(self, start=0, strict=True):
"""Return the option representation to store in configuration file"""
ret = u''
ret = ''
try:
self_length = len(self.value[self.name])
except KeyError:
......@@ -533,7 +533,7 @@ class OptionPair(Option, dict):
except KeyError:
length = -1
if index >= length:
return u''
return ''
return self.value.get(name).dump_index(index, strict)
def parse(self, key=None):
......@@ -792,7 +792,7 @@ class File(dict):
return getattr(self.parser, '{}_{}'.format(typ, self.mode), [])
def _type_for_option(self, opt):
if opt == u'.':
if opt == '.':
return 'include'
for typ in ['boolean', 'integer', 'multi', 'string', 'pair']:
......@@ -870,7 +870,7 @@ class File(dict):
else:
opt = self.options.get(key)
opt.append(key, value)
elif key == u'.':
elif key == '.':
key = value
if self._parsing_templates:
opt = OptionTpl(self.parser, key, value)
......@@ -893,7 +893,7 @@ class File(dict):
def __repr__(self):
self._refresh_types()
ret = u''
ret = ''
for key, opts in iteritems(self.types):
ret += '{} =>\n'.format(key)
for key2, opt in iteritems(opts):
......@@ -903,7 +903,7 @@ class File(dict):
return ret.rstrip('\n')
def __str__(self):
ret = u''
ret = ''
for key, val in iteritems(self.options):
if key in self.associations:
continue
......@@ -1058,9 +1058,9 @@ class File(dict):
key = res.group(1)
reset = res.group(2)
val = res.group(3)
if key == u'compression':
if key == 'compression':
val = val.replace('zlib', 'gzip')
elif key == u'ssl_compression':
elif key == 'ssl_compression':
val = val.replace('gzip', 'zlib')
self[key] = val
if key in self:
......@@ -1652,7 +1652,7 @@ class Config(File):
def __repr__(self):
self._refresh()
ret = u''
ret = ''
for key, fil in iteritems(self.files):
ret += '>' * 5 + key + '<' * 5 + '\n'
ret += repr(fil) + '\n'
......
#!/bin/bash
PYTHON=$(which python)
VERSION=$($PYTHON -V 2>&1 | cut -d' ' -f2)
echo "test requirements"
......@@ -16,48 +15,16 @@ pip install -r requirements.txt
pip install wheel
echo "building dist"
#[ "$(sed 's/\([[:digit:]]*\)\..*$/\1/' <<<$VERSION)" -eq 2 ] && {
$PYTHON setup.py sdist bdist_wheel bdist_egg
mkdir meta
cd pkgs
for pkg in *
do
cd $pkg
$PYTHON setup.py sdist bdist_wheel bdist_egg
mkdir meta
cd pkgs
for pkg in *
do
cd $pkg
$PYTHON setup.py sdist bdist_wheel bdist_egg
find dist -exec cp "{}" ../../meta/ \;
cd ..
done
find dist -exec cp "{}" ../../meta/ \;
cd ..
#} || {
# $PYTHON setup.py bdist_egg
# mkdir meta
# cd pkgs
# for pkg in *
# do
# [ -f "$pkg" ] && continue
# cd $pkg
# $PYTHON setup.py bdist_egg
# find dist -exec cp "{}" ../../meta/ \;
# cd ..
# done
# cd ..
#}
# Not useful anymore since we are using artifacts
#echo "publishing build"
#cd dist
#tgz=$(ls -1rt burp-ui*.tar.gz | tail -1)
#egg=$(ls -1rt burp_ui*.egg | tail -1)
#whl=$(ls -1rt burp_ui*.whl | tail -1)
#cd ..
#cp -vf dist/burp-ui*.tar.gz /pub/ 2>/dev/null
#cp -vf dist/burp_ui*.egg /pub/ 2>/dev/null
#cp -vf dist/burp_ui*.whl /pub/ 2>/dev/null
#
#cd /pub
##rm burp-ui.dev.tar.gz burp_ui-dev-py${VERSION}.egg burp_ui-dev-py2.py3-none-any.whl 2>/dev/null
#[ -n "$tgz" ] && ln -sf $tgz burp-ui.dev.tar.gz
#[ -n "$egg" ] && ln -sf $egg burp_ui-dev-py${VERSION}.egg
#[ -n "$whl" ] && ln -sf $whl burp_ui-dev-py2.py3-none-any.whl
done
cd ..
exit 0
[tox]
envlist = py{27,34,36}
envlist = py{36}
[testenv]
commands = nosetests --with-coverage --cover-package=burpui tests/test_burpui.py
......
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