Skip to content

Commit

Permalink
#130 Display Cortex and Misp connectors' statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Oct 26, 2017
1 parent fb24edc commit 1ecfd93
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 12 deletions.
2 changes: 2 additions & 0 deletions ui/app/scripts/controllers/AboutCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
angular.module('theHiveControllers').controller('AboutCtrl',
function($rootScope, $scope, $uibModalInstance, VersionSrv, NotificationSrv) {
VersionSrv.get().then(function(response) {
console.log(response);
$scope.version = response.versions;
$scope.connectors = response.connectors;
}, function(data, status) {
NotificationSrv.error('AboutCtrl', data, status);
});
Expand Down
10 changes: 6 additions & 4 deletions ui/app/scripts/controllers/case/CaseObservablesItemCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$scope.artifact = {};
$scope.artifact.tlp = $scope.artifact.tlp || -1;
$scope.analysisEnabled = VersionSrv.hasCortex();
$scope.cortexServers = $scope.analysisEnabled && appConfig.connectors.cortex.servers;
$scope.protectDownloadsWith = appConfig.config.protectDownloadsWith;

$scope.editorOptions = {
Expand Down Expand Up @@ -80,7 +81,7 @@

_.each(_.keys($scope.analyzers).sort(), function(analyzerId) {
$scope.analyzerJobs[analyzerId] = [];
});
});

angular.forEach($scope.jobs.values, function (job) {
if (job.analyzerId in $scope.analyzerJobs) {
Expand Down Expand Up @@ -180,11 +181,12 @@
});
};

$scope.runAnalyzer = function (analyzerId) {
$scope.runAnalyzer = function (analyzerId, serverId) {
var artifactName = $scope.artifact.data || $scope.artifact.attachment.name;

CortexSrv.getServers([analyzerId])
.then(function (serverId) {
var promise = serverId ? $q.resolve(serverId) : CortexSrv.getServers([analyzerId])

promise.then(function (serverId) {
return $scope._runAnalyzer(serverId, analyzerId, $scope.artifact.id);
})
.then(function () {
Expand Down
20 changes: 19 additions & 1 deletion ui/app/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,20 @@ footer.main-footer {

footer .footer-logo {
height: 40px;
border-radius: 50%;
}

footer .footer-logo.logo-ok{
background-color: #00a65a;
}
footer .footer-logo.logo-error{
background-color: #dd4b39;
}
footer .footer-logo.logo-error{
background-color: #dd4b39;
}
footer .footer-logo.logo-warning{
background-color: #f39c12;
}

report:empty {
Expand All @@ -515,5 +529,9 @@ span.action-button {

table tr td.task-actions span.action-button {
width: 60px;
display: inline-block;
display: inline-block;
}

.misp-export .status-label {
display: block;
}
4 changes: 2 additions & 2 deletions ui/app/views/components/app-container.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
and in tooltip the list of appConfig.connectors.cortex.server (property name, status and version)
-->
<span ng-if="appConfig.connectors.cortex.enabled" uib-tooltip="Cortex integration enabled">
<img class="footer-logo" src="images/cortex-logo.svg"/>
<img class="footer-logo logo-{{appConfig.connectors.cortex.status | lowercase}}" src="images/cortex-logo.svg"/>
</span>
<!--
show appConfig.connectors.misp.status (OK, WARNING or ERROR)
and in tooltip the list of appConfig.connectors.misp.server (property name, status and version)
-->
<span ng-if="appConfig.connectors.misp.enabled" uib-tooltip="MISP integration enabled">
<img class="footer-logo" src="images/misp-logo.svg"/>
<img class="footer-logo logo-{{appConfig.connectors.misp.status | lowercase}}" src="images/misp-logo.svg"/>
</span>
</div>
<div>
Expand Down
11 changes: 11 additions & 0 deletions ui/app/views/partials/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
<div class="col-md-6"><strong class="pull-right">{{module}}</strong></div>
<div class="col-md-6">{{ver}}</div>
</div>

<div class="row mt-xs" ng-repeat="(key, connector) in connectors" ng-if="connector.enabled">
<div class="col-md-6"><strong class="pull-right">{{key | uppercase}}</strong></div>
<div class="col-md-6">
<div ng-repeat="server in connector.servers">
<span>{{server.version || 'Unknown version'}}</span> -
<strong>{{server.name}}</strong>
(<strong ng-class="{'OK': 'text-success', 'ERROR': 'text-danger'}[server.status]">{{server.status}}</strong>)
</div>
</div>
</div>
<div class="row mt-s">
<div class="col-md-12 text-center">
Copyright (C) 2014-2017 Thomas Franco, Saâd Kadhi, Jérôme Leonard
Expand Down
17 changes: 13 additions & 4 deletions ui/app/views/partials/misp/case.export.confirm.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
<div class="modal-header bg-primary">
<h3 class="modal-title">MISP Export</h3>
</div>
<div class="modal-body">
<div class="modal-body misp-export">
<div ng-if="dialog.mode !== 'error'">
<p>
You are about to export the case <strong>{{dialog.caze.title}}</strong> to one of the following MISP servers:
</p>

<table class="mt-m table table-striped valigned">
<tbody class="pv-xs" ng-repeat="server in dialog.servers"> <!-- TODO Nabil -->
<tbody class="pv-xs" ng-repeat="server in dialog.servers">
<tr>
<td><h4>{{server}}</h4></td>
<td width="100">
<h4>
<span class="mr-xs status-label label" ng-class="{
'OK': 'label-success',
'ERROR': 'label-danger'}[server.status]">{{server.status}}</span>
</h4>
</td>
<td>
<h4>{{server.name}}</h4>
</td>
<td width="150">
<button class="btn btn-block pull-right"
ng-class="{'btn-primary': dialog.existingExports[server], 'btn-warning': !dialog.existingExports[server]}"
ng-click="dialog.export(server)"
ng-disabled="dialog.loading">{{dialog.existingExports[server] ? 'Update' : 'Export'}}</button>
ng-disabled="dialog.loading || server.status === 'ERROR'">{{dialog.existingExports[server] ? 'Update' : 'Export'}}</button>
</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,33 @@ <h3 class="pv-xxs pr-xxs text-primary">
<td ng-if="analysisEnabled">
<span class="btn btn-xs" ng-class="{true: 'btn-warning', false: 'btn-danger'}[jobs.length > 0]"
ng-click="runAnalyzer(analyzerId)"
ng-if="analyzer.active">
ng-if="analyzer.cortexIds.length === 1 && analyzer.active">
<i class="glyphicon" ng-class="{true: 'glyphicon-repeat', false: 'glyphicon-fire'}[jobs.length > 0]"></i>
</span>

<div class="btn-group" ng-if="analyzer.cortexIds.length > 1 && analyzer.active" uib-dropdown>
<button type="button" class="btn btn-xs dropdown-toggle"
ng-class="{true: 'btn-warning', false: 'btn-danger'}[jobs.length > 0]"
uib-dropdown-toggle>
<span class="mr-xxxs">
<i class="glyphicon" ng-class="{true: 'glyphicon-repeat', false: 'glyphicon-fire'}[jobs.length > 0]"></i>
</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu>
<li ng-repeat="srv in cortexServers">
<a href ng-click="runAnalyzer(analyzerId, srv.name)" ng-disabled="srv.status === 'ERROR'">
<div>
<strong>{{srv.name}}</strong>
</div>
<div>
<strong ng-class="{'OK': 'text-success', 'ERROR': 'text-danger'}[srv.status]">Status: {{srv.status}}</strong>
</div>
</a>
</li>
</ul>
</div>

</td>
</tr>
</tbody>
Expand Down

0 comments on commit 1ecfd93

Please sign in to comment.