Verified Commit e3947441 authored by Ziirish's avatar Ziirish

add: allow to delete clients data upon removal (fix #232)

parent b38e3c9d
......@@ -12,6 +12,7 @@ Current
- Add: new ``bui-monitor`` processes pool + ``async`` backend to parallelize some requests `#278 <https://git.ziirish.me/ziirish/burp-ui/issues/278>`_
- Add: new `listen` and `listen_status` options in burp-2.2.10 `#279 <https://git.ziirish.me/ziirish/burp-ui/issues/279>`_
- Add: allow to hide selected clients/servers `#282 <https://git.ziirish.me/ziirish/burp-ui/issues/282>`_
- Add: allow to delete clients data upon removal `#232 <<https://git.ziirish.me/ziirish/burp-ui/issues/232>`_
- Fix: sync pkgs requirements with burp-ui's `#300 <https://git.ziirish.me/ziirish/burp-ui/issues/300>`__
- Fix: wrong command suggestion `#296 <https://git.ziirish.me/ziirish/burp-ui/issues/296>`__
- Fix: allow templates removal `#290 <https://git.ziirish.me/ziirish/burp-ui/issues/290>`__
......
......@@ -488,6 +488,7 @@ class ClientSettings(Resource):
parser_delete.add_argument('delcert', type=inputs.boolean, help='Whether to delete the certificate or not', default=False, nullable=True)
parser_delete.add_argument('keepconf', type=inputs.boolean, help='Whether to keep the conf or not', default=False, nullable=True)
parser_delete.add_argument('template', type=inputs.boolean, help='Whether we work on a template or not', default=False, nullable=True)
parser_delete.add_argument('delete', type=inputs.boolean, help='Whether we should remove the data as well or not', default=False, nullable=True)
parser_post = ns.parser()
parser_post.add_argument('template', type=inputs.boolean, help='Whether we work on a template or not', default=False, nullable=True)
parser_get = ns.parser()
......@@ -606,6 +607,7 @@ class ClientSettings(Resource):
revoke = args.get('revoke', False)
keepconf = args.get('keepconf', False)
template = args.get('template', False)
delete = args.get('delete', False)
if not keepconf:
# clear the cache when we remove a client
......@@ -622,8 +624,8 @@ class ClientSettings(Resource):
force_scheduling_now()
parser = bui.client.get_parser(agent=server)
bui.audit.logger.info(f'deleted client configuration {client} ({conf}), delete certificate: {delcert}, revoke certificate: {revoke}, keep a backup of the configuration: {keepconf}', server=server)
return parser.remove_client(client, keepconf, delcert, revoke, template), 200
bui.audit.logger.info(f'deleted client configuration {client} ({conf}), delete certificate: {delcert}, revoke certificate: {revoke}, keep a backup of the configuration: {keepconf}, delete data: {delete}', server=server)
return parser.remove_client(client, keepconf, delcert, revoke, template, delete), 200
@ns.route('/path-expander',
......
......@@ -9,6 +9,7 @@ import re
import os
import json
import codecs
import shutil
from glob import glob
......@@ -288,7 +289,7 @@ class Parser(Doc):
self.templates_mtime = os.path.getmtime(self.templates_path)
return res
def _get_server_path(self, name=None, fil=None):
def _get_server_path(self, name=None, fil=''):
"""Returns the path of the 'server *fil*' file"""
if not name:
raise BUIserverException('Missing name')
......@@ -344,7 +345,8 @@ class Parser(Doc):
return False
return self.openssl_auth.check_client_revoked(client)
def remove_client(self, client=None, keepconf=False, delcert=False, revoke=False, template=False):
def remove_client(self, client=None, keepconf=False, delcert=False, revoke=False,
template=False, delete=False):
"""See :func:`burpui.misc.parser.interface.BUIparser.remove_client`"""
res = []
revoked = False
......@@ -352,6 +354,7 @@ class Parser(Doc):
if not client:
return [[NOTIF_ERROR, "No client provided"]]
try:
data = self._get_server_path(client)
if not keepconf:
if template:
path = os.path.join(self.templates_path, client)
......@@ -370,6 +373,8 @@ class Parser(Doc):
self._refresh_cache()
shutil.rmtree(data)
except OSError as exp:
res.append([NOTIF_ERROR, str(exp)])
......
......@@ -263,7 +263,8 @@ class BUIparser(object, metaclass=ABCMeta):
) # pragma: no cover
@abstractmethod
def remove_client(self, client=None, keepconf=False, delcert=False, revoke=False, template=False):
def remove_client(self, client=None, keepconf=False, delcert=False, revoke=False,
template=False, delete=False):
""":func:`burpui.misc.parser.interface.BUIparser.remove_client` is used
to delete a client from burp's configuration.
......@@ -282,8 +283,12 @@ class BUIparser(object, metaclass=ABCMeta):
:param template: Whether we remove a template
:type template: bool
:param delete: Whether to remove data as well
:type delete: bool
:returns: A list of notifications to return to the UI (success or
failure)
:rtype: list
"""
raise NotImplementedError(
"Sorry, the current Parser does not implement this method!"
......
......@@ -638,7 +638,7 @@ app.controller('ConfigCtrl', ['$scope', '$http', '$timeout', '$scrollspy', 'DTOp
{% if template -%}
data: { template: true }
{% else -%}
data: { delcert: $('#delcert').is(':checked'), revoke: $('#revoke').is(':checked'), keepconf: $('#keepconf').is(':checked') }
data: { delcert: $('#delcert').is(':checked'), revoke: $('#revoke').is(':checked'), keepconf: $('#keepconf').is(':checked'), delete: $('#deldata').is(':checked') }
{% endif -%}
})
.fail(buiFail)
......
......@@ -403,6 +403,7 @@
<li><label for="keepconf">{{ _('Do not remove the configuration:') }}&nbsp;</label><input type="checkbox" id="keepconf" name="keepconf"></li>
<li><label for="delcert">{{ _('Remove associated certificate:') }}&nbsp;</label><input type="checkbox" id="delcert" name="delcert"></li>
<li><label for="revoke">{{ _('Revoke associated certificate:') }}&nbsp;</label><input type="checkbox" id="revoke" name="revoke" ng-disabled="!revokeEnabled"></li>
<li><label for="deldata">{{ _('Remove associated data:') }}&nbsp;</label><input type="checkbox" id="deldata" name="delete"></li>
</ul>
{% endif -%}
</div>
......
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