From beeedf7448a7fbd39613c8c615b507e571f860be Mon Sep 17 00:00:00 2001 From: ziirish Date: Mon, 22 Jan 2018 20:16:37 +0100 Subject: [PATCH] WIP: display config hierarchy --- burpui/api/settings.py | 24 ++++++++++++++++++++++++ burpui/misc/parser/burp1.py | 4 ++++ burpui/misc/parser/interface.py | 24 ++++++++++++++++++++++++ burpui/misc/parser/utils.py | 1 + burpui/templates/js/settings.js | 2 ++ burpui/templates/layout.html | 4 ++-- burpui/templates/settings.html | 5 +++++ tests/test_burpui.py | 6 ++++-- 8 files changed, 66 insertions(+), 4 deletions(-) diff --git a/burpui/api/settings.py b/burpui/api/settings.py index a97dea51..35dc20c2 100644 --- a/burpui/api/settings.py +++ b/burpui/api/settings.py @@ -168,6 +168,30 @@ class ServerSettings(Resource): ] }, { "...": "..." } + ], + "hierarchy": [ + { + "children": [ + { + "children": [], + "dir": "/tmp/burp/conf.d", + "full": "/tmp/burp/conf.d/empty.conf", + "name": "empty.conf", + "parent": "/tmp/burp/burp-server.conf" + }, + { + "children": [], + "dir": "/tmp/burp/conf.d", + "full": "/tmp/burp/conf.d/ipv4.conf", + "name": "ipv4.conf", + "parent": "/tmp/burp/burp-server.conf" + } + ], + "dir": "/tmp/burp", + "full": "/tmp/burp/burp-server.conf", + "name": "burp-server.conf", + "parent": null + } ] }, "server_doc": { diff --git a/burpui/misc/parser/burp1.py b/burpui/misc/parser/burp1.py index be155fc1..066cda71 100644 --- a/burpui/misc/parser/burp1.py +++ b/burpui/misc/parser/burp1.py @@ -314,6 +314,7 @@ class Parser(Doc): u'includes': [], u'includes_ext': [], u'clients': self._list_clients(), + u'hierarchy': [], } if not client and not conf: return res @@ -341,6 +342,7 @@ class Parser(Doc): for x in parsed.flatten('include', False).keys() ] res2[u'includes_ext'] = parsed.include + res2[u'hierarchy'] = config.tree res.update(res2) self.filescache[mconf] = { @@ -362,6 +364,7 @@ class Parser(Doc): u'includes': [], u'includes_ext': [], u'clients': self._list_clients(), + u'hierarchy': [], } if not conf: mconf = self.conf @@ -390,6 +393,7 @@ class Parser(Doc): for x in parsed.flatten('include', False).keys() ] res2[u'includes_ext'] = parsed.include + res2[u'hierarchy'] = self.server_conf.tree res.update(res2) self.filescache[mconf] = { diff --git a/burpui/misc/parser/interface.py b/burpui/misc/parser/interface.py index 0f650465..0c3446ca 100644 --- a/burpui/misc/parser/interface.py +++ b/burpui/misc/parser/interface.py @@ -103,6 +103,30 @@ class BUIparser(with_metaclass(ABCMeta, object)): ] }, ], + "hierarchy": [ + { + "children": [ + { + "children": [], + "dir": "/tmp/burp/conf.d", + "full": "/tmp/burp/conf.d/empty.conf", + "name": "empty.conf", + "parent": "/tmp/burp/burp-server.conf" + }, + { + "children": [], + "dir": "/tmp/burp/conf.d", + "full": "/tmp/burp/conf.d/ipv4.conf", + "name": "ipv4.conf", + "parent": "/tmp/burp/burp-server.conf" + } + ], + "dir": "/tmp/burp", + "full": "/tmp/burp/burp-server.conf", + "name": "burp-server.conf", + "parent": null + } + ] } """ raise NotImplementedError( diff --git a/burpui/misc/parser/utils.py b/burpui/misc/parser/utils.py index 7e8f12b7..b355105f 100644 --- a/burpui/misc/parser/utils.py +++ b/burpui/misc/parser/utils.py @@ -1072,6 +1072,7 @@ class Config(File): basename = os.path.basename(name) return { 'name': basename, + 'title': basename, 'full': name, 'dir': dirname, 'parent': parent, diff --git a/burpui/templates/js/settings.js b/burpui/templates/js/settings.js index e396a926..a906445f 100644 --- a/burpui/templates/js/settings.js +++ b/burpui/templates/js/settings.js @@ -108,6 +108,7 @@ app.controller('ConfigCtrl', ['$scope', '$http', '$scrollspy', function($scope, $scope.bools = []; $scope.strings = []; $scope.clients = []; + $scope.hierarchy = []; $scope.client = {}; $scope.defaults = {}; $scope.placeholders = {}; @@ -161,6 +162,7 @@ app.controller('ConfigCtrl', ['$scope', '$http', '$scrollspy', function($scope, $scope.includes = data.results.includes; $scope.includes_ori = angular.copy($scope.includes); $scope.includes_ext = data.results.includes_ext; + $scope.hierarchy = data.results.hierarchy; $scope.refreshScrollspy(); $('#waiting-container').hide(); $('#settings-panel').show(); diff --git a/burpui/templates/layout.html b/burpui/templates/layout.html index 34bfb2c0..3ff54185 100644 --- a/burpui/templates/layout.html +++ b/burpui/templates/layout.html @@ -26,7 +26,7 @@ {% endif -%} {% endif -%} - {% if tree -%} + {% if tree or settings -%} {% endif -%} {% if settings or me -%} @@ -104,7 +104,7 @@ {% endif -%} - {% if tree -%} + {% if tree or settings -%} {# -#} diff --git a/burpui/templates/settings.html b/burpui/templates/settings.html index 45910c09..80cc7a04 100644 --- a/burpui/templates/settings.html +++ b/burpui/templates/settings.html @@ -268,6 +268,11 @@
+
+ {% raw -%} + {{ hierarchy }} + {% endraw -%} +
diff --git a/tests/test_burpui.py b/tests/test_burpui.py index d826e7c2..8397d75a 100755 --- a/tests/test_burpui.py +++ b/tests/test_burpui.py @@ -140,7 +140,8 @@ class BurpuiAPITestCase(TestCase): u'multi': [], u'includes': [], u'includes_ext': [], - u'clients': [] + u'clients': [], + u'hierarchy': [{'children': [], 'dir': '/dev', 'full': '/dev/null', 'name': 'null', 'parent': None}], } ), (u'boolean', self.bui.client.get_parser_attr('boolean_srv')), @@ -166,7 +167,8 @@ class BurpuiAPITestCase(TestCase): u'multi': [], u'includes': [], u'includes_ext': [], - u'clients': [] + u'clients': [], + u'hierarchy': [], } ), (u'boolean', self.bui.client.get_parser_attr('boolean_cli')),