Skip to content

Commit

Permalink
#1766 Update pattern admin page to include more details in pattern modal
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Feb 11, 2021
1 parent bb1fa57 commit 4d5e065
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
operations: [
{'_name': 'listPattern'}
],
extraData: ['enabled'],
extraData: ['enabled', 'parent'],
onUpdate: function() {
self.loading = false;
}
Expand Down Expand Up @@ -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) {
Expand Down
29 changes: 24 additions & 5 deletions frontend/app/scripts/services/api/AttackPatternSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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) {
Expand Down
14 changes: 9 additions & 5 deletions frontend/app/views/partials/admin/attack/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ <h3 class="box-title">List of ATT&CK patterns</h3>
</td>
<td>{{::pattern.name}}</td>
<td>
<span ng-if="!pattern.parent">-</span>
<a ng-if="::pattern.parent" href ng-click="$vm.show(pattern.parent)">{{::pattern.parent}}</a>
<span ng-if="!pattern.extraData.parent">-</span>
<span ng-if="::pattern.extraData.parent">
<a href ng-click="$vm.show(pattern.extraData.parent.patternId)" class="mr-xxs">{{::pattern.extraData.parent.patternId}}</a>
<a href ng-click="$vm.addFilterValue('parent', pattern.extraData.parent.patternId)"><i class="fa fa-filter"></i></a>
</span>

</td>
<td>
<div ng-repeat="tactic in ::pattern.tactics" class="mb-xxs">
Expand All @@ -73,13 +77,13 @@ <h3 class="box-title">List of ATT&CK patterns</h3>
<i class="text-primary fa fa-external-link"></i>
</a>

<a class="btn btn-icon btn-clear" href ng-click="$vm.show(pattern)" uib-tooltip="Edit pattern">
<a class="btn btn-icon btn-clear" href ng-click="$vm.show(pattern.patternId)" uib-tooltip="Show pattern">
<i class="text-primary fa fa-search"></i>
</a>

<!--
<a class="btn btn-icon btn-clear" href ng-click="$vm.remove(pattern)" uib-tooltip="Delete pattern">
<i class="text-danger fa fa-trash"></i>
</a>
</a> -->
</div>

</td>
Expand Down
137 changes: 99 additions & 38 deletions frontend/app/views/partials/admin/attack/view.html
Original file line number Diff line number Diff line change
@@ -1,62 +1,128 @@
<form class="form">

<div class="modal-header bg-primary">
<h3 class="modal-title">{{::$modal.pattern.parent ? 'Sub-technique' : 'Technique'}}: {{::$modal.pattern.name}}
<small class="ml-xxxs">(Version: {{::$modal.pattern.version}})</small>
<div class="modal-header" ng-class="{'bg-primary': !!!modal.pattern.revoked, 'bg-danger': !!modal.pattern.revoked}">
<h3 class="modal-title">{{$modal.pattern.isSubTechnique ? ($modal.pattern.parentName + ': ') : ''}}{{::$modal.pattern.name}}
<small class="text-white ml-xxxs">(Version: {{::$modal.pattern.version}})</small>
</h3>
</div>

<div class="modal-body">
<div class="row">
<div class="col-sm-6">
<div class="col-sm-4">
<div class="form-group">
<label>{{::$modal.pattern.parent ? 'Sub-technique' : 'Technique'}} Name</label>
<label>{{::$modal.pattern.isSubTechnique ? 'Sub-technique' : 'Technique'}} Name</label>
<div>{{::$modal.pattern.name}}</div>
</div>
</div>
<div class="col-sm-6" ng-if="::$modal.pattern.parent">
<div class="col-sm-4" ng-if="::$modal.pattern.isSubTechnique">
<div class="form-group">
<label>Sub-Technique of</label>
<div>{{::$modal.pattern.parent || '-'}}</div>
<div>{{::$modal.pattern.parentName || '-'}}</div>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>URL</label>
<div>
<a href="{{::$modal.pattern.url}}" target="_blank">
{{::$modal.pattern.url}}<i class="fa fa-external-link ml-xxxs"></i>
</a>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col-sm-6">
<div class="col-sm-4">
<div class="form-group">
<label>Tactics</label>
<div ng-if="::$modal.pattern.tactics.length === 0">
<em class="text-muted">None</em>
</div>
<div ng-repeat="tactic in ::$modal.pattern.tactics" class="mb-xxs">
<span class="label label-lg label-default">{{tactic}}</span>
<span class="label label-default">{{tactic}}</span>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="col-sm-4">
<div class="form-group">
<label>Data Sources</label>
<div ng-if="::$modal.pattern.dataSources.length === 0">
<em class="text-muted">None</em>
</div>
<div ng-repeat="ds in ::$modal.pattern.dataSources" class="mb-xxs">
<span class="label label-lg label-default">{{ds}}</span>
<span class="label label-default">{{ds}}</span>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Platforms</label>
<div ng-if="::$modal.pattern.platforms.length === 0">
<em class="text-muted">None</em>
</div>
<div ng-repeat="platform in ::$modal.pattern.platforms" class="mb-xxs">
<span class="label label-default">{{platform}}</span>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col-sm-6">
<div class="col-sm-4">
<div class="form-group">
<label>URL</label>
<div>
<a href="{{::$modal.pattern.url}}" target="_blank">
{{::$modal.pattern.url}}<i class="fa fa-external-link ml-xxxs"></i>
</a>
<label>Defense Bypassed</label>
<div ng-if="::$modal.pattern.defenseBypassed.length === 0">
<em class="text-muted">None</em>
</div>
<div ng-repeat="defense in ::$modal.pattern.defenseBypassed" class="mb-xxs">
<span class="label label-default">{{defense}}</span>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="col-sm-4">
<div class="form-group">
<label>Platforms</label>
<div ng-repeat="platform in ::$modal.pattern.platforms" class="mb-xxs">
<span class="label label-lg label-default">{{platform}}</span>
<label>Permissions Required</label>
<div ng-if="::$modal.pattern.permissionsRequired.length === 0">
<em class="text-muted">None</em>
</div>
<div ng-repeat="perm in ::$modal.pattern.permissionsRequired" class="mb-xxs">
<span class="label label-default">{{perm}}</span>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>System Requirements</label>
<div ng-if="::$modal.pattern.systemRequirements.length === 0">
<em class="text-muted">None</em>
</div>
<div ng-repeat="req in ::$modal.pattern.systemRequirements" class="mb-xxs">
<span class="label label-default">{{req}}</span>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col-sm-4">
<div class="form-group">
<label>Remote Support</label>
<div>{{!!$modal.pattern.remoteSupport}}</div>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Capec ID</label>
<div>{{::$modal.pattern.capecId || '-'}}</div>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Capec URL</label>
<div>
<a href="{{::$modal.pattern.capecUrl}}" target="_blank">
{{::$modal.pattern.capecUrl}}<i class="fa fa-external-link ml-xxxs"></i>
</a>
</div>
</div>
</div>
Expand All @@ -67,32 +133,27 @@ <h3 class="modal-title">{{::$modal.pattern.parent ? 'Sub-technique' : 'Technique
<div>{{::$modal.pattern.description}}</div>
</div>

<div class="row">
<div class="row" ng-if="!$modal.pattern.isSubTechnique">
<div class="col-sm-12">
<table class="table table-striped">
<thead>
<tr>
<th class="pl-0" width="200">Tag</th>
<th>Predicate</th>
<th>Value</th>
<th width="100">Color</th>
<th width="10"></th>
<th class="pl-0" width="200">ID</th>
<th>Name</th>
<th>Tactics</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="tag in $modal.taxonomy.tags">
<tr ng-repeat="p in $modal.pattern.extraData.children">
<td>
<span class="label">
<tag value="tag"></tag>
</span>
{{::p.patternId}}
<a class="ml-xxs" href="{{::p.url}}" target="_blank">
<i class="text-primary fa fa-external-link"></i>
</a>
</td>
<td>{{::tag.predicate}}</td>
<td>{{::tag.value || '-'}}</td>
<td>{{::tag.colour}}</td>
<td>{{::p.name}}</td>
<td>
<span ng-if="::tag.description" uib-tooltip="{{::tag.description}}" tooltip-placement="left">
<i class="fa fa-question-circle"></i>
</span>
<span ng-repeat="tactic in p.tactics" class="label label-default mr-xxxs mb-xxxs">{{tactic}}</span>
</td>
</tr>
</tbody>
Expand Down

0 comments on commit 4d5e065

Please sign in to comment.