Skip to content

Commit

Permalink
Merge branch 'hotfix/4.1.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jul 23, 2021
2 parents b041e20 + 5d6cab2 commit 5e75521
Show file tree
Hide file tree
Showing 15 changed files with 251 additions and 207 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Change Log

## [4.1.9](https://github.com/TheHive-Project/TheHive/milestone/78) (2021-07-23)

**Implemented enhancements:**

- [Enhancement] Add button for index rebuilding [\#2144](https://github.com/TheHive-Project/TheHive/issues/2144)

**Fixed bugs:**

- [Bug] MISP sync delete existing observables when updating existing Alert [\#2134](https://github.com/TheHive-Project/TheHive/issues/2134)
- [Bug] Livestream emptied of audit logs after TheHive reboot [\#2135](https://github.com/TheHive-Project/TheHive/issues/2135)
- [Bug] AddTagToCase operation does not work [\#2136](https://github.com/TheHive-Project/TheHive/issues/2136)

## [4.1.8](https://github.com/TheHive-Project/TheHive/milestone/77) (2021-07-19)

**Implemented enhancements:**
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Dependencies._
import com.typesafe.sbt.packager.Keys.bashScriptDefines
import org.thp.ghcl.Milestone

val thehiveVersion = "4.1.8-1"
val thehiveVersion = "4.1.9-1"
val scala212 = "2.12.13"
val scala213 = "2.13.1"
val supportedScalaVersions = List(scala212, scala213)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ class ActionSrv @Inject() (
*/
def relatedCase(id: EntityId)(implicit graph: Graph): Option[Case with Entity] =
for {
richAction <- startTraversal.getByIds(id).richAction.getOrFail("Action").toOption
richAction <- startTraversal.getByIds(id).richAction.headOption
relatedCase <- entityHelper.parentCase(richAction.context)
} yield relatedCase

def relatedTask(id: EntityId)(implicit graph: Graph): Option[Task with Entity] =
for {
richAction <- startTraversal.getByIds(id).richAction.getOrFail("Action").toOption
richAction <- startTraversal.getByIds(id).richAction.headOption
relatedTask <- entityHelper.parentTask(richAction.context)
} yield relatedTask

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ class EntityHelper @Inject() (
*/
def parentCase(entity: Entity)(implicit graph: Graph): Option[Case with Entity] =
entity._label match {
case "Task" => taskSrv.get(entity).`case`.headOption
case "Case" => caseSrv.get(entity).headOption
case "Log" => logSrv.get(entity).`case`.headOption
case "Alert" => None
case _ => None
case "Task" => taskSrv.get(entity).`case`.headOption
case "Case" => caseSrv.get(entity).headOption
case "Observable" => observableSrv.get(entity).`case`.headOption
case "Log" => logSrv.get(entity).`case`.headOption
case "Alert" => None
case _ => None
}

/**
Expand Down
208 changes: 116 additions & 92 deletions frontend/app/scripts/controllers/admin/platform/PlatformStatusCtrl.js
Original file line number Diff line number Diff line change
@@ -1,107 +1,131 @@
(function() {
(function () {
'use strict';

angular.module('theHiveControllers').controller('PlatformStatusCtrl', function(ModalSrv, PlatformSrv, NotificationSrv, appConfig) {
var self = this;
angular.module('theHiveControllers').controller('PlatformStatusCtrl', function (ModalSrv, PlatformSrv, NotificationSrv, appConfig) {
var self = this;

self.appConfig = appConfig;
self.indexStatus = {};
self.checkStats = {};

self.loading = {
index: false,
check: false
}

this.loadIndexStatus = function() {
self.indexStatus = {};
self.loading.index = true;

PlatformSrv.getIndexStatus()
.then(function(response) {
self.indexStatus = response.data;
self.loading.index = false;
});
}
self.appConfig = appConfig;
self.indexStatus = {};
self.checkStats = {};

this.loadCheckStats = function() {
self.loading.check = true;
self.loading = {
index: false,
check: false
}

PlatformSrv.getCheckStats()
.then(function(response) {
self.checkStats = response.data;
self.loading.check = false;
})
}
this.loadIndexStatus = function () {
self.indexStatus = {};
self.loading.index = true;

this.$onInit = function() {
self.loadIndexStatus();
self.loadCheckStats();
PlatformSrv.getIndexStatus()
.then(function (response) {
self.indexStatus = response.data;
self.loading.index = false;
});
}

this.loadCheckStats = function () {
self.loading.check = true;

PlatformSrv.getCheckStats()
.then(function (response) {
self.checkStats = response.data;
self.loading.check = false;
})
}

this.$onInit = function () {
self.loadIndexStatus();
self.loadCheckStats();
};

this.exportReport = function () {
var date = new moment().format('YYYYMMDD-HH:mmZ');
var fileName = 'Platform-Status-Report-' + date + '.json';

var content = {
indexStatus: self.indexStatus,
checkStatus: self.checkStats,
schemaStatus: self.appConfig.schemaStatus
};

this.exportReport = function() {
var date = new moment().format('YYYYMMDD-HH:mmZ');
var fileName = 'Platform-Status-Report-'+date+'.json';

var content = {
indexStatus: self.indexStatus,
checkStatus: self.checkStats,
schemaStatus: self.appConfig.schemaStatus
};

// Create a blob of the data
var fileToSave = new Blob([JSON.stringify(content)], {
type: 'application/json',
name: fileName
// Create a blob of the data
var fileToSave = new Blob([JSON.stringify(content)], {
type: 'application/json',
name: fileName
});

// Save the file
saveAs(fileToSave, fileName);
}

this.reindex = function (indexName) {
var modalInstance = ModalSrv.confirm(
'Reindex',
'Are you sure you want to trigger ' + indexName + ' data reindex', {
okText: 'Yes, reindex it'
}
);

modalInstance.result
.then(function () {
PlatformSrv.runReindex(indexName);
})
.then(function (/*response*/) {
NotificationSrv.success('Reindexing of ' + indexName + ' data started sucessfully');
})
.catch(function (err) {
if (!_.isString(err)) {
NotificationSrv.error('Platform status', err.data, err.status);
}
});

// Save the file
saveAs(fileToSave, fileName);
};

this.rebuildIndex = function (indexName) {
var modalInstance = ModalSrv.confirm(
'Drop & Rebuild Index',
'Are you sure you want to delete and rebuild ' + indexName + ' data reindex. ' +
'This operation will drop your existing data index and create a new one.', {
okText: 'Yes, rebuild it',
flavor: 'danger'
}

this.reindex = function(indexName) {
var modalInstance = ModalSrv.confirm(
'Reindex',
'Are you sure you want to trigger ' + indexName + ' data reindex', {
okText: 'Yes, reindex it'
);

modalInstance.result
.then(function () {
PlatformSrv.runRebuildIndex(indexName);
})
.then(function (/*response*/) {
NotificationSrv.success('Rebuild of ' + indexName + ' data started sucessfully');
})
.catch(function (err) {
if (!_.isString(err)) {
NotificationSrv.error('Platform status', err.data, err.status);
}
);

modalInstance.result
.then(function() {
PlatformSrv.runReindex(indexName);
})
.then(function(/*response*/) {
NotificationSrv.success('Reindexing of ' + indexName + ' data started sucessfully');
})
.catch(function(err) {
if (!_.isString(err)) {
NotificationSrv.error('Platform status', err.data, err.status);
}
});
};
});
};

this.checkControl = function(checkName) {
var modalInstance = ModalSrv.confirm(
'Data health check',
'Are you sure you want to trigger ' + checkName + ' health check', {
okText: 'Yes, trigger it'
}
);

modalInstance.result
.then(function() {
PlatformSrv.runCheck(checkName);
})
.then(function(/*response*/) {
NotificationSrv.success('Data health check of ' + checkName + ' started sucessfully');
})
.catch(function(err) {
if (!_.isString(err)) {
NotificationSrv.error('Platform status', err.data, err.status);
}
});
this.checkControl = function (checkName) {
var modalInstance = ModalSrv.confirm(
'Data health check',
'Are you sure you want to trigger ' + checkName + ' health check', {
okText: 'Yes, trigger it'
}
);

modalInstance.result
.then(function () {
PlatformSrv.runCheck(checkName);
})
.then(function (/*response*/) {
NotificationSrv.success('Data health check of ' + checkName + ' started sucessfully');
})
.catch(function (err) {
if (!_.isString(err)) {
NotificationSrv.error('Platform status', err.data, err.status);
}
});
}

});
});
})();
20 changes: 12 additions & 8 deletions frontend/app/scripts/services/api/PlatformSrv.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
(function() {
(function () {
'use strict';
angular.module('theHiveServices')
.service('PlatformSrv', function($http) {
.service('PlatformSrv', function ($http) {

this.getIndexStatus = function() {
this.getIndexStatus = function () {
return $http.get('./api/v1/admin/index/status')
}

this.runReindex = function(indexName) {
return $http.get('./api/v1/admin/index/'+indexName+'/reindex');
this.runReindex = function (indexName) {
return $http.post('./api/v1/admin/index/' + indexName + '/reindex');
}

this.getCheckStats = function() {
this.runRebuildIndex = function (indexName) {
return $http.post('./api/v1/admin/index/' + indexName + '/rebuild');
}

this.getCheckStats = function () {
return $http.get('./api/v1/admin/check/stats')
}

this.runCheck = function(checkName) {
return $http.get('./api/v1/admin/check/'+checkName+'/trigger');
this.runCheck = function (checkName) {
return $http.get('./api/v1/admin/check/' + checkName + '/trigger');
}

});
Expand Down
20 changes: 12 additions & 8 deletions frontend/app/views/partials/admin/platform/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,22 @@ <h4 class="text-primary mt-m">Data index status <small class="ml-m clickable"
<div class="empty-message" ng-if="$vm.loading.index">Loading index status...</div>
<div class="flex-table" ng-show="!$vm.loading.index" ng-repeat="index in $vm.indexStatus.index">
<div class="flex-header mt-xs">
<div class="flex-col flex-2">Index: <strong>{{index.name | uppercase}}</strong></div>
<div class="flex-col flex-1"># Entities</div>
<div class="flex-col flex-w-100">
<a href class="text-primary" ng-click="$vm.reindex(index.name)"><i
class="fa fa-cog mr-xxxs"></i> Reindex</a>
<div class="flex-col flex-3">
Index: <strong>{{index.name | uppercase}}</strong>

<a href class="text-primary mh-s" ng-click="$vm.reindex(index.name)">
<i class="fa fa-cog mr-xxxs"></i> Reindex the data
</a>
<a href class="text-danger" ng-click="$vm.rebuildIndex(index.name)">
<i class="fa fa-trash mr-xxxs"></i> Drop and rebuild the index
</a>

</div>
<div class="flex-col flex-1"># Entities</div>
</div>
<div class="flex-table" ng-repeat="item in index.indices">
<div class="flex-row mt-xs">
<div class="flex-col flex-2 vertical">
<div class="flex-col flex-3 vertical">
<h4 class="media-heading text-primary">
{{item.name}}
</h4>
Expand All @@ -75,8 +81,6 @@ <h4 class="media-heading text-primary">
{{item.count}}
</span>
</div>

<div class="flex-col flex-w-100"></div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thehive",
"version": "4.1.8-1",
"version": "4.1.9-1",
"license": "AGPL-3.0",
"dependencies": {
"jquery": "^3.4.1",
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thehive",
"version": "4.1.8-1",
"version": "4.1.9-1",
"license": "AGPL-3.0",
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 5e75521

Please sign in to comment.