Skip to content

Commit

Permalink
#609 Add responder menu in observables list and details page
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jul 12, 2018
1 parent 7c36185 commit 0291aeb
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 79 deletions.
28 changes: 27 additions & 1 deletion ui/app/scripts/controllers/case/CaseListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
angular.module('theHiveControllers')
.controller('CaseListCtrl', CaseListCtrl);

function CaseListCtrl($scope, $q, $state, $window, CasesUISrv, StreamStatSrv, PSearchSrv, EntitySrv, UserInfoSrv, TagSrv, UserSrv, AuthenticationSrv, CaseResolutionStatus, Severity, Tlp) {
function CaseListCtrl($scope, $q, $state, $window, CasesUISrv, StreamStatSrv, PSearchSrv, EntitySrv, UserInfoSrv, TagSrv, UserSrv, AuthenticationSrv, CaseResolutionStatus, NotificationSrv, Severity, Tlp, CortexSrv) {
var self = this;

this.openEntity = EntitySrv.open;
this.getUserInfo = UserInfoSrv;
this.CaseResolutionStatus = CaseResolutionStatus;
this.caseResponders = null;

this.uiSrv = CasesUISrv;
this.uiSrv.initContext('list');
Expand Down Expand Up @@ -219,5 +220,30 @@
this.uiSrv.setSort(sort);
};

this.getCaseResponders = function(caseId, force) {
if(!force && this.caseResponders !== null) {
return;
}

this.caseResponders = null;
CortexSrv.getResponders('case', caseId)
.then(function(responders) {
self.caseResponders = responders;
})
.catch(function(err) {
NotificationSrv.error('CaseList', response.data, response.status);
})
};

this.runResponder = function(responderId, caze) {
CortexSrv.runResponder(responderId, 'case', _.pick(caze, 'id', 'tlp', 'pap'))
.then(function(response) {
NotificationSrv.log(['Responder', response.data.responderName, 'started successfully on case', caze.title].join(' '), 'success');
})
.catch(function(response) {
NotificationSrv.error('CaseList', response.data, response.status);
});
};

}
})();
6 changes: 3 additions & 3 deletions ui/app/scripts/controllers/case/CaseMainCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@
$scope.runResponder = function(responderId) {
CortexSrv.runResponder(responderId, 'case', _.pick($scope.caze, 'id', 'tlp', 'pap'))
.then(function(response) {
console.log(response);
NotificationSrv.log(['Responder', response.data.responderName, 'started successfully on case', $scope.caze.title].join(' '), 'success');
})
.catch(function(err) {
console.log(err);
.catch(function(response) {
NotificationSrv.error('caseDetails', response.data, response.status);
});
};

Expand Down
29 changes: 28 additions & 1 deletion ui/app/scripts/controllers/case/CaseObservablesCtrl.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
(function () {
'use strict';
angular.module('theHiveControllers').controller('CaseObservablesCtrl',
function ($scope, $q, $state, $stateParams, $uibModal, StreamSrv, CaseTabsSrv, PSearchSrv, CaseArtifactSrv, NotificationSrv, AnalyzerSrv, CortexSrv, ObservablesUISrv, VersionSrv, Tlp) {
function ($scope, $q, $state, $stateParams, $filter, $uibModal, StreamSrv, CaseTabsSrv, PSearchSrv, CaseArtifactSrv, NotificationSrv, AnalyzerSrv, CortexSrv, ObservablesUISrv, VersionSrv, Tlp) {

CaseTabsSrv.activateTab($state.current.data.tab);

$scope.analysisEnabled = VersionSrv.hasCortex();
$scope.uiSrv = ObservablesUISrv;
$scope.caseId = $stateParams.caseId;
$scope.showText = false;
$scope.obsResponders = null;

$scope.uiSrv.initContext($scope.caseId);
$scope.searchForm = {
Expand Down Expand Up @@ -685,6 +686,32 @@
NotificationSrv.error('Unable to fetch the analysis report');
})
}

$scope.getObsResponders = function(observableId, force) {
if(!force && $scope.obsResponders !== null) {
return;
}

$scope.obsResponders = null;
CortexSrv.getResponders('case_artifact', observableId)
.then(function(responders) {
$scope.obsResponders = responders;
})
.catch(function(err) {
NotificationSrv.error('observablesList', response.data, response.status);
})
};

$scope.runResponder = function(responderId, artifact) {
CortexSrv.runResponder(responderId, 'case_artifact', _.pick(artifact, 'id'))
.then(function(response) {
var data = '['+$filter('fang')(artifact.name || artifact.attachment.name)+']';
NotificationSrv.log(['Responder', response.data.responderName, 'started successfully on observable', data].join(' '), 'success');
})
.catch(function(response) {
NotificationSrv.error('observablesList', response.data, response.status);
});
};
}
)
.controller('JobReportModalCtrl', function($uibModalInstance, report, observable) {
Expand Down
29 changes: 28 additions & 1 deletion ui/app/scripts/controllers/case/CaseObservablesItemCtrl.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
(function () {
'use strict';
angular.module('theHiveControllers').controller('CaseObservablesItemCtrl',
function ($scope, $state, $stateParams, $q, $timeout, $document, CaseTabsSrv, CaseArtifactSrv, CortexSrv, PSearchSrv, AnalyzerSrv, NotificationSrv, VersionSrv, appConfig) {
function ($scope, $state, $stateParams, $q, $filter, $timeout, $document, CaseTabsSrv, CaseArtifactSrv, CortexSrv, PSearchSrv, AnalyzerSrv, NotificationSrv, VersionSrv, appConfig) {
var observableId = $stateParams.itemId,
observableName = 'observable-' + observableId;

$scope.caseId = $stateParams.caseId;
$scope.report = null;
$scope.obsResponders = null;
$scope.analyzers = {};
$scope.analyzerJobs = {};
$scope.jobs = {};
Expand Down Expand Up @@ -218,6 +219,32 @@
});
};

$scope.getObsResponders = function(observableId, force) {
if(!force && $scope.obsResponders !== null) {
return;
}

$scope.obsResponders = null;
CortexSrv.getResponders('case_artifact', observableId)
.then(function(responders) {
$scope.obsResponders = responders;
})
.catch(function(err) {
NotificationSrv.error('observablesList', response.data, response.status);
})
};

$scope.runResponder = function(responderId, artifact) {
CortexSrv.runResponder(responderId, 'case_artifact', _.pick(artifact, 'id'))
.then(function(response) {
var data = '['+$filter('fang')(artifact.name || artifact.attachment.name)+']';
NotificationSrv.log(['Responder', response.data.responderName, 'started successfully on observable', data].join(' '), 'success');
})
.catch(function(response) {
NotificationSrv.error('observablesList', response.data, response.status);
});
};

}
);

Expand Down
6 changes: 3 additions & 3 deletions ui/app/scripts/controllers/case/CaseTasksCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@
$scope.runResponder = function(responderId, task) {
CortexSrv.runResponder(responderId, 'case_task', _.pick(task, 'id'))
.then(function(response) {
console.log(response);
NotificationSrv.log(['Responder', response.data.responderName, 'started successfully on task', task.title].join(' '), 'success');
})
.catch(function(err) {
console.log(err);
.catch(function(response) {
NotificationSrv.error('taskList', response.data, response.status);
});
};
}
Expand Down
6 changes: 3 additions & 3 deletions ui/app/scripts/controllers/case/CaseTasksItemCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@
$scope.runResponder = function(responderId) {
CortexSrv.runResponder(responderId, 'case_task', _.pick($scope.task, 'id'))
.then(function(response) {
console.log(response);
NotificationSrv.log(['Responder', response.data.responderName, 'started successfully on task', $scope.task.title].join(' '), 'success');
})
.catch(function(err) {
console.log(err);
.catch(function(response) {
NotificationSrv.error('taskDetails', response.data, response.status);
});
};

Expand Down
23 changes: 23 additions & 0 deletions ui/app/views/partials/case/case.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ <h3 class="box-title">List of cases ({{$vm.list.total || 0}} of {{$vm.caseStats.
<th style="width: 100px;">Observables</th>
<th style="width: 60px;">Assignee</th>
<th style="width: 120px;">Date</th>
<th style="width: 40px;" ng-if="appConfig.connectors.cortex.enabled">Actions</th>
</tr>
</thead>

Expand Down Expand Up @@ -112,6 +113,28 @@ <h3 class="box-title">List of cases ({{$vm.list.total || 0}} of {{$vm.caseStats.
<span uib-tooltip="{{currentCase.startDate | showDate}}" tooltip-popup-delay="500" tooltip-placement="bottom">{{currentCase.startDate | shortDate}}</span>
</a>
</td>
<td ng-if="appConfig.connectors.cortex.enabled">
<span class="ml-xs" uib-dropdown>
<a href class="text-primary noline nowrap" ng-click="$vm.getCaseResponders(currentCase.id, true)" uib-dropdown-toggle>
<i class="text-primary fa fa-cog"></i>
<!-- Responders
<i class="text-primary fa fa-angle-down"></i> -->
</a>
<ul class="dropdown-menu align-right" uib-dropdown-menu>
<li ng-if="$vm.caseResponders && $vm.caseResponders.length === 0">
<a href ng-click="$vm.getCaseResponders(currentCase.id, true)">
<strong><i class="fa fa-refresh mr-xxs"></i> No responders available</strong>
</a>
</li>
<li ng-repeat="responder in $vm.caseResponders">
<a href ng-click="$vm.runResponder(responder.id, currentCase)">
<strong>{{responder.name}}</strong>
<br>
<small>{{responder.description}}</small></a>
</li>
</ul>
</span>
</td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="row">
<div class="col-md-12">
<h3 class="pv-xxs pr-xxs text-primary">
<h4 class="pv-xxs pr-xxs text-primary">
Analysis
<span class="pull-right" ng-if="analysisEnabled">
<small><a href class="text-primary" ng-click="runAll()">Run all</a></small>
</span>
</h3>
</h4>
<table class="table table-striped">
<thead>
<th>Analyzer</th>
Expand Down Expand Up @@ -90,14 +90,14 @@ <h3 class="pv-xxs pr-xxs text-primary">

<div class="row observable-report" ng-if="report">
<div class="col-md-12">
<h3 class="pad10 text-primary">
<h4 class="pad10 text-primary">
Report <small>for {{report.template}} analysis of {{(report.endDate || report.startDate) | showDate}}</small>
<span class="pull-right">
<small><a href class="text-primary" ng-click="showRaw = !showRaw">{{showRaw ? 'Hide': 'Show'}} Raw Report</a></small>
<small class="mh-xxxs">|</small>
<small><a href class="text-primary" ng-click="showArtifacts = !showArtifacts">{{showArtifacts ? 'Hide': 'Show'}} observables ({{report.content.artifacts.length}})</a></small>
</span>
</h3>
</h4>
<div ng-if="showArtifacts" class="">
<div class="panel panel-info">
<div class="panel-heading">
Expand Down
Loading

0 comments on commit 0291aeb

Please sign in to comment.