fix: py3 tests

This commit is contained in:
ziirish 2015-10-20 18:32:04 +02:00
parent 66cbc15f44
commit 2bacf30dca
4 changed files with 18 additions and 11 deletions

View file

@ -4,7 +4,8 @@ import sys
import os
from argparse import ArgumentParser
sys.path.append('{0}/..'.format(os.path.join(os.path.dirname(os.path.realpath(__file__)))))
# Try to load modules from our current env first
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
def parse_args(mode=True, name=None):
@ -14,10 +15,10 @@ def parse_args(mode=True, name=None):
parser.add_argument('-v', '--verbose', dest='log', help='increase output verbosity (e.g., -vv is more than -v)', action='count')
parser.add_argument('-d', '--debug', dest='log', help='alias for -v', action='count') # alias for -v
parser.add_argument('-V', '--version', dest='version', help='print version and exit', action='store_true')
parser.add_argument('-c', '--config', dest='config', help='configuration file', metavar='CONFIG')
parser.add_argument('-l', '--logfile', dest='logfile', help='output logs in defined file', metavar='FILE')
parser.add_argument('-c', '--config', dest='config', help='configuration file', metavar='<CONFIG>')
parser.add_argument('-l', '--logfile', dest='logfile', help='output logs in defined file', metavar='<FILE>')
if mode:
parser.add_argument('-m', '--mode', dest='mode', help='application mode (server or agent)', metavar='MODE')
parser.add_argument('-m', '--mode', dest='mode', help='application mode (server or agent)', metavar='<agent|server>')
options = parser.parse_args()

View file

@ -101,6 +101,7 @@ class BUIAgent(BUIlogging, Dummy):
module = 'burpui.misc.backend.burp{0}'.format(self.vers)
try:
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
mod = __import__(module, fromlist=['Burp'])
Client = mod.Burp
self.backend = Client(conf=conf)

View file

@ -13,6 +13,7 @@ import re
import sys
from flask.ext.restful import Api
from importlib import import_module
class ApiWrapper(Api):
@ -32,8 +33,8 @@ class ApiWrapper(Api):
if (os.path.isfile(os.path.join(__path__[0], f)) and
ext == '.py' and
name not in ['__init__', '.', '..']):
mod = name
__import__(mod, globals=globals())
mod = '.'+name
import_module(mod, 'burpui.api')
api = ApiWrapper()

View file

@ -13,8 +13,8 @@ except ImportError:
import configparser as ConfigParser
import traceback
import sys
import os
from .misc.backend.burp1 import Burp as BurpGeneric
g_port = '5000'
g_bind = '::'
@ -79,7 +79,8 @@ class BUIServer:
self.auth = self._safe_config_get(config.get, 'auth')
if self.auth and self.auth.lower() != 'none':
try:
import os
# Try to load submodules from our current environment
# first
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
mod = __import__(
'burpui.misc.auth.{0}'.format(self.auth.lower()),
@ -100,7 +101,8 @@ class BUIServer:
if self.acl_engine and self.acl_engine.lower() != 'none':
try:
import os
# Try to load submodules from our current environment
# first
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
mod = __import__(
'burpui.misc.acl.{0}'.format(self.acl_engine.lower()),
@ -109,7 +111,7 @@ class BUIServer:
ACLloader = mod.ACLloader
self.acl_handler = ACLloader(self.app, self.standalone)
# for development purpose only
from burpui.misc.acl.interface import BUIacl
from .misc.acl.interface import BUIacl
self.acl = BUIacl
self.acl = self.acl_handler.acl
except Exception as e:
@ -143,9 +145,11 @@ class BUIServer:
else:
module = 'burpui.misc.backend.multi'
# This instanciation is used for development purpose only
from .misc.backend.burp1 import Burp as BurpGeneric
self.cli = BurpGeneric(dummy=True)
try:
import os
# Try to load submodules from our current environment
# first
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
mod = __import__(module, fromlist=['Burp'])
Client = mod.Burp