From 4d5e0651f552ed2d51b0f7be8512c6b1d874d519 Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Thu, 11 Feb 2021 07:09:57 +0100 Subject: [PATCH] #1766 Update pattern admin page to include more details in pattern modal --- .../admin/attack/AttackPatternListCtrl.js | 12 +- .../scripts/services/api/AttackPatternSrv.js | 29 +++- .../app/views/partials/admin/attack/list.html | 14 +- .../app/views/partials/admin/attack/view.html | 137 +++++++++++++----- 4 files changed, 143 insertions(+), 49 deletions(-) diff --git a/frontend/app/scripts/controllers/admin/attack/AttackPatternListCtrl.js b/frontend/app/scripts/controllers/admin/attack/AttackPatternListCtrl.js index 2c91a1bdd3..80604099a3 100644 --- a/frontend/app/scripts/controllers/admin/attack/AttackPatternListCtrl.js +++ b/frontend/app/scripts/controllers/admin/attack/AttackPatternListCtrl.js @@ -31,7 +31,7 @@ operations: [ {'_name': 'listPattern'} ], - extraData: ['enabled'], + extraData: ['enabled', 'parent'], onUpdate: function() { self.loading = false; } @@ -137,6 +137,16 @@ this.cancel = function () { $uibModalInstance.dismiss('cancel'); }; + + this.$onInit = function() { + if (this.pattern.extraData.parent) { + this.pattern.isSubTechnique = true; + this.pattern.parentId = this.pattern.extraData.parent.patternId; + this.pattern.parentName = this.pattern.extraData.parent.name; + } else { + this.pattern.isSubTechnique = false; + } + }; } function AttackPatternImportCtrl($uibModalInstance, AttackPatternSrv, NotificationSrv, appConfig) { diff --git a/frontend/app/scripts/services/api/AttackPatternSrv.js b/frontend/app/scripts/services/api/AttackPatternSrv.js index 1979cfde9c..138e91ac25 100644 --- a/frontend/app/scripts/services/api/AttackPatternSrv.js +++ b/frontend/app/scripts/services/api/AttackPatternSrv.js @@ -2,7 +2,7 @@ (function() { 'use strict'; angular.module('theHiveServices') - .service('AttackPatternSrv', function($http, QuerySrv) { + .service('AttackPatternSrv', function($http, $q, QuerySrv) { var baseUrl = './api/v1/pattern'; this.list = function() { @@ -14,10 +14,29 @@ }; this.get = function(id) { - return $http.get(baseUrl + '/' + id) - .then(function(response){ - return response.data; - }); + + var defer = $q.defer(); + + QuerySrv.call('v1', [{ + '_name': 'getPattern', + 'idOrName': id + }], { + name:'get-attach-pattern-' + id, + page: { + from: 0, + to: 1, + extraData: [ + "parent", + "children" + ] + } + }).then(function(response) { + defer.resolve(response[0]); + }).catch(function(err){ + defer.reject(err); + }); + + return defer.promise; }; this.import = function(post) { diff --git a/frontend/app/views/partials/admin/attack/list.html b/frontend/app/views/partials/admin/attack/list.html index 02ed890326..95f5f16bdd 100644 --- a/frontend/app/views/partials/admin/attack/list.html +++ b/frontend/app/views/partials/admin/attack/list.html @@ -56,8 +56,12 @@

List of ATT&CK patterns

{{::pattern.name}} - - - {{::pattern.parent}} + - + + {{::pattern.extraData.parent.patternId}} + + +
@@ -73,13 +77,13 @@

List of ATT&CK patterns

- + - +
diff --git a/frontend/app/views/partials/admin/attack/view.html b/frontend/app/views/partials/admin/attack/view.html index 7a8250dd18..9539e30e6d 100644 --- a/frontend/app/views/partials/admin/attack/view.html +++ b/frontend/app/views/partials/admin/attack/view.html @@ -1,62 +1,128 @@
- -