

def __init__(self, server=None, conf=None):
    global g_burpbin, g_stripbin, g_burpconfcli, g_burpconfsrv, g_tmpdir, g_timeout, BURP_MINIMAL_VERSION
    self.proc = None
    self.app = None
    self.client_version = None
    self.server_version = None
    self.zip64 = False
    self.logger = logging.getLogger('burp-ui')
    if server:
        if hasattr(server, 'zip64'):
            self.zip64 = server.zip64
    self.burpbin = g_burpbin
    self.stripbin = g_stripbin
    self.burpconfcli = g_burpconfcli
    self.burpconfsrv = g_burpconfsrv
    self.defaults = {
        'burpbin': g_burpbin,
        'stripbin': g_stripbin,
        'bconfcli': g_burpconfcli,
        'bconfsrv': g_burpconfsrv,
        'timeout': g_timeout,
        'tmpdir': g_tmpdir,
    }
    self.running = []
    version = ''
    if conf:
        config = ConfigParser.ConfigParser(self.defaults)
        with codecs.open(conf, 'r', 'utf-8') as fp:
            config.readfp(fp)
            try:
                bbin = self._safe_config_get(config.get, 'burpbin', sect='Burp2')
                strip = self._safe_config_get(config.get, 'stripbin', sect='Burp2')
                confcli = self._safe_config_get(config.get, 'bconfcli', sect='Burp2')
                confsrv = self._safe_config_get(confsrv.get, 'bconfsrv', sect='Burp2')
                self.timeout = self._safe_config_get(config.getint, 'timeout', sect='Burp2', cast=int)
                tmpdir = self._safe_config_get(config.get, 'tmpdir')
                if (tmpdir and os.path.exists(tmpdir) and (not os.path.isdir(tmpdir))):
                    self._logger('warning', "'%s' is not a directory", tmpdir)
                    tmpdir = g_tmpdir
                if (confcli and (not os.path.isfile(confcli))):
                    self._logger('warning', "The file '%s' does not exist", confcli)
                    confcli = g_burpconfcli
                if (confsrv and (not os.path.isfile(confsrv))):
                    self._logger('warning', "The file '%s' does not exist", confsrv)
                    confsrv = g_burpconfsrv
                if (strip and (not strip.startswith('/'))):
                    self._logger('warning', "Please provide an absolute path for the 'stripbin' option. Fallback to '%s'", g_stripbin)
                    strip = g_stripbin
                elif (strip and (not re.match('^\\S+$', strip))):
                    self._logger('warning', "Incorrect value for the 'stripbin' option. Fallback to '%s'", g_stripbin)
                    strip = g_stripbin
                elif (strip and ((not os.path.isfile(strip)) or (not os.access(strip, os.X_OK)))):
                    self._logger('warning', "'%s' does not exist or is not executable. Fallback to '%s'", strip, g_stripbin)
                    strip = g_stripbin
                if (strip and ((not os.path.isfile(strip)) or (not os.access(strip, os.X_OK)))):
                    self._logger('error', "Ooops, '%s' not found or is not executable", strip)
                    strip = None
                if (bbin and (not bbin.startswith('/'))):
                    self._logger('warning', "Please provide an absolute path for the 'burpbin' option. Fallback to '%s'", g_burpbin)
                    bbin = g_burpbin
                elif (bbin and (not re.match('^\\S+$', bbin))):
                    self._logger('warning', "Incorrect value for the 'burpbin' option. Fallback to '%s'", g_burpbin)
                    bbin = g_burpbin
                elif (bbin and ((not os.path.isfile(bbin)) or (not os.access(bbin, os.X_OK)))):
                    self._logger('warning', "'%s' does not exist or is not executable. Fallback to '%s'", bbin, g_burpbin)
                    bbin = g_burpbin
                if (bbin and ((not os.path.isfile(bbin)) or (not os.access(bbin, os.X_OK)))):
                    self._logger('critical', "Ooops, '%s' not found or is not executable", bbin)
                    raise Exception('This backend *CAN NOT* work without a burp binary')
                self.tmpdir = tmpdir
                self.burpbin = bbin
                self.stripbin = strip
                self.burpconfcli = confcli
                self.burpconfsrv = confsrv
            except ConfigParser.NoOptionError as e:
                self._logger('error', str(e))
            except ConfigParser.NoSectionError as e:
                self._logger('warning', str(e))
    try:
        cmd = [self.burpbin, '-v']
        version = subprocess.check_output(cmd, universal_newlines=True).rstrip()
        if (version < BURP_MINIMAL_VERSION):
            raise Exception('Your burp version ({}) does not fit the minimal requirements: {}'.format(version, BURP_MINIMAL_VERSION))
    except subprocess.CalledProcessError as e:
        raise Exception('Unable to determine your burp version: {}'.format(str(e)))
    self.client_version = version.replace('burp-', '')
    self.parser = Parser(self.burpconfsrv)
    self._logger('info', 'burp binary: {}'.format(self.burpbin))
    self._logger('info', 'strip binary: {}'.format(self.stripbin))
    self._logger('info', 'burp conf cli: {}'.format(self.burpconfcli))
    self._logger('info', 'burp conf srv: {}'.format(self.burpconfsrv))
    self._logger('info', 'command timeout: {}'.format(self.timeout))
    self._logger('info', 'burp version: {}'.format(self.client_version))
    try:
        self.status()
    except BUIserverException:
        pass

dataset/ETHPy150Open ziirish/burp-ui/burpui/misc/backend/burp2.py Burp.__init__/VarMisuse@272/419 `config`->`confsrv`