From d8fd5730dddedee96d67852422a424d7b77f75a4 Mon Sep 17 00:00:00 2001 From: ziirish Date: Thu, 9 Jun 2016 23:42:51 +0200 Subject: [PATCH] fix tests --- burpui/misc/parser/burp1.py | 4 ++-- burpui/misc/parser/interface.py | 14 ++++++++++++++ burpui/misc/parser/openssl.py | 17 ++++++++--------- burpui/misc/parser/utils.py | 9 +++++---- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/burpui/misc/parser/burp1.py b/burpui/misc/parser/burp1.py index df28bf7c..5269a694 100644 --- a/burpui/misc/parser/burp1.py +++ b/burpui/misc/parser/burp1.py @@ -735,9 +735,9 @@ class Parser(Doc): if 'restore' not in flist: raise BUIserverException('Wrong call') - full_reg = ur'' + full_reg = r'' for rest in flist['restore']: - reg = ur'' + reg = r'' if rest['folder'] and rest['key'] != '/': reg += '^' + re.escape(rest['key']) + '/|' else: diff --git a/burpui/misc/parser/interface.py b/burpui/misc/parser/interface.py index 87de2911..3b33158c 100644 --- a/burpui/misc/parser/interface.py +++ b/burpui/misc/parser/interface.py @@ -188,6 +188,20 @@ class BUIparser(object): "Sorry, the current Parser does not implement this method!" ) # pragma: no cover + @abstractmethod + def is_client_revoked(self, client=None): + """:func:`burpui.misc.parser.interface.BUIparser.is_client_revoked` is + used to check if a given client has it's certificate revoked or not. + + :param client: The name of the client to check + :type client: str + + :returns: True or False + """ + raise NotImplementedError( + "Sorry, the current Parser does not implement this method!" + ) # pragma: no cover + @abstractmethod def remove_client(self, client=None, delcert=False, revoke=False): """:func:`burpui.misc.parser.interface.BUIparser.remove_client` is used diff --git a/burpui/misc/parser/openssl.py b/burpui/misc/parser/openssl.py index ae9cca82..0253b874 100644 --- a/burpui/misc/parser/openssl.py +++ b/burpui/misc/parser/openssl.py @@ -37,7 +37,7 @@ class OSSLAuth(object): self._load_crl() def _load_crl(self): - crl_path = self.ossl_conf.get_crl_path(self.name) + crl_path = self._get_crl_path() try: with open(crl_path) as crl: self.crl = crypto.load_crl( @@ -53,6 +53,13 @@ class OSSLAuth(object): os.path.join(self.ossl_conf.values.get('CA_DIR'), client) ) + def _get_crl_path(self): + """Returns the CRL path of a given CA""" + path = self.ossl_conf.values.get('CA_DIR') + if not path: + return '' + return '{}/CA_{}.crl'.format(path, self.name) + def check_client_revoked(self, client): """Check whether the given client certificate has been revoked :param client: Client name @@ -164,14 +171,6 @@ class OSSLConf(object): self._parse() return self.conf - def get_crl_path(self, ca_name): - """Returns the CRL path of a given CA""" - self._parse() - path = self.conf.get('CA_DIR') - if not path: - return None - return '{}/CA_{}.crl'.format(path, ca_name) - def _read(self): """Read the file if possible""" ret = [] diff --git a/burpui/misc/parser/utils.py b/burpui/misc/parser/utils.py index 429cef04..c97e0377 100644 --- a/burpui/misc/parser/utils.py +++ b/burpui/misc/parser/utils.py @@ -409,10 +409,11 @@ class Config(File): def set_default(self, path): self.default = path self.name = path - if not self.parser: - self.parser = self.get_default().parser - if not self.mode: - self.mode = self.get_default().mode + default = self.get_default() + if not self.parser and default: + self.parser = getattr(self.get_default(), 'parser') + if not self.mode and default: + self.mode = getattr(self.get_default(), 'mode') def get_default(self, exc=False): if self.default: