Skip to content

Commit

Permalink
Merge branch 'hotfix/4.1.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jun 14, 2021
2 parents 4777b29 + 35a58b6 commit 7d6d55d
Show file tree
Hide file tree
Showing 25 changed files with 337 additions and 96 deletions.
28 changes: 14 additions & 14 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@ steps:
commands:
- sbt -Duser.home=$PWD test:compile

# Save external libraries in cache
- name: save-cache
image: drillster/drone-volume-cache
settings:
rebuild: true
backend: "filesystem"
mount:
- .sbt
- .ivy2
- .cache
- frontend/node_modules
- frontend/bower_components
volumes: [{name: cache, path: /cache}]

# Build packages
- name: build-packages
image: thehiveproject/drone-scala-node
Expand Down Expand Up @@ -71,6 +57,20 @@ steps:
when:
event: [tag]

# Save external libraries in cache
- name: save-cache
image: drillster/drone-volume-cache
settings:
rebuild: true
backend: "filesystem"
mount:
- .sbt
- .ivy2
- .cache
- frontend/node_modules
- frontend/bower_components
volumes: [{name: cache, path: /cache}]

# Send packages using scp
- name: send packages
image: appleboy/drone-scp
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Change Log

## [4.1.6](https://github.com/TheHive-Project/TheHive/milestone/75) (2021-06-14)

**Implemented enhancements:**

- [Feature Request] Add API to repair database [\#2081](https://github.com/TheHive-Project/TheHive/issues/2081)

**Fixed bugs:**

- [Bug] Editing case template tasks incorrectly removes tasks [\#1926](https://github.com/TheHive-Project/TheHive/issues/1926)
- [Bug] When creating cases from alerts via API, the same case number gets assigned to multiple distinct cases [\#1970](https://github.com/TheHive-Project/TheHive/issues/1970)
- [Bug] src:MISP-ORG missing on MISP alerts [\#2058](https://github.com/TheHive-Project/TheHive/issues/2058)
- [Bug] Analyzer reports dissapear in 4.1.5 (observable already exists error) [\#2059](https://github.com/TheHive-Project/TheHive/issues/2059)
- [Bug] CaseNumber Conflict [\#2061](https://github.com/TheHive-Project/TheHive/issues/2061)
- [Bug] Alert tags glitch after previewing alert [\#2062](https://github.com/TheHive-Project/TheHive/issues/2062)
- [Bug] Case Template content mixed across organisations [\#2068](https://github.com/TheHive-Project/TheHive/issues/2068)
- [Bug] /api/v1/<user.ID>/key returns 401/403 if user hasn't key [\#2069](https://github.com/TheHive-Project/TheHive/issues/2069)
- [Bug] When API call returns failure, actual response depends on authentication methods [\#2070](https://github.com/TheHive-Project/TheHive/issues/2070)
- [Bug] Deleting observables doesn't produce audit log [\#2076](https://github.com/TheHive-Project/TheHive/issues/2076)

## [4.1.5](https://github.com/TheHive-Project/TheHive/milestone/74) (2021-06-03)

**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.5-1"
val thehiveVersion = "4.1.6-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
@@ -1,7 +1,7 @@
package org.thp.thehive.connector.cortex.controllers.v0

import com.google.inject.name.Named
import org.thp.scalligraph.EntityIdOrName
import org.thp.scalligraph.{EntityIdOrName, NotFoundError}
import org.thp.scalligraph.controllers.{Entrypoint, FFile, FieldsParser}
import org.thp.scalligraph.models.{Database, Entity, UMapping}
import org.thp.scalligraph.query._
Expand Down Expand Up @@ -37,6 +37,9 @@ class AnalyzerTemplateCtrl @Inject() (
analyzerTemplateSrv
.getOrFail(EntityIdOrName(id))
.map(report => Results.Ok(report.content))
.recover {
case _: NotFoundError => Results.NotFound(s"AnalyzerTemplate $id not found")
}
}

def importTemplates: Action[AnyContent] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ class JobSrv @Inject() (
Future
.fromTry {
db.tryTransaction { implicit graph =>
for {
origObs <- get(job).observable.getOrFail("Observable")
obs <- observableSrv.create(artifact.toObservable(job._id, origObs.organisationIds), artifact.data.get)
_ <- addObservable(job, obs.observable)
} yield ()
get(job).observable.getOrFail("Observable").map { origObs =>
observableSrv
.create(artifact.toObservable(job._id, origObs.organisationIds), artifact.data.get)
.foreach(obs => addObservable(job, obs.observable))
}
}
}
}
Expand Down Expand Up @@ -336,7 +336,7 @@ object JobOps {
_.reportObservables
.project(
_.by(_.richObservable)
.by(_.similar.filter(_.`case`.observables.out[ObservableJob].where(P.eq[String](thisJob.name)))._id.fold)
.by(_.similar.where(_.`case`.observables.out[ObservableJob].v[Job].isStep(P.eq[String](thisJob.name)))._id.fold)
)
.fold
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(function() {
(function () {
'use strict';

angular.module('theHiveComponents')
.component('orgCaseTemplateList', {
controller: function($uibModal, $scope, $q, CaseTemplateSrv, PaginatedQuerySrv, FilteringSrv, UserSrv, NotificationSrv, ModalUtilsSrv) {
controller: function ($uibModal, $scope, $q, CaseTemplateSrv, PaginatedQuerySrv, FilteringSrv, UserSrv, NotificationSrv, ModalUtilsSrv) {
var self = this;

self.task = '';
Expand All @@ -13,7 +13,7 @@
self.getUserInfo = UserSrv.getCache;


this.$onInit = function() {
this.$onInit = function () {
self.filtering = new FilteringSrv('caseTemplate', 'caseTemplate.list', {
version: 'v1',
defaults: {
Expand All @@ -26,7 +26,7 @@
});

self.filtering.initContext(self.organisation.name)
.then(function() {
.then(function () {
self.load();

$scope.$watch('$vm.list.pageSize', function (newValue) {
Expand All @@ -35,7 +35,7 @@
});
};

this.load = function() {
this.load = function () {

self.list = new PaginatedQuerySrv({
name: 'organisation-case-templates',
Expand All @@ -46,15 +46,15 @@
pageSize: self.filtering.context.pageSize,
filter: this.filtering.buildQuery(),
operations: [{
'_name': 'getOrganisation',
'idOrName': self.organisation.name
},
{
'_name': 'caseTemplates'
}
'_name': 'getOrganisation',
'idOrName': self.organisation.name
},
{
'_name': 'caseTemplates'
}
],
onFailure: function(err) {
if(err && err.status === 400) {
onFailure: function (err) {
if (err && err.status === 400) {
self.filtering.resetContext();
self.load();
}
Expand Down Expand Up @@ -90,36 +90,36 @@
this.search();
};

this.filterBy = function(field, value) {
this.filterBy = function (field, value) {
self.filtering.clearFilters()
.then(function(){
.then(function () {
self.addFilterValue(field, value);
});
};

this.sortBy = function(sort) {
this.sortBy = function (sort) {
self.list.sort = sort;
self.list.update();
self.filtering.setSort(sort);
};

this.sortByField = function(field) {
this.sortByField = function (field) {
var context = this.filtering.context;
var currentSort = Array.isArray(context.sort) ? context.sort[0] : context.sort;
var sort = null;

if(currentSort.substr(1) !== field) {
if (currentSort.substr(1) !== field) {
sort = ['+' + field];
} else {
sort = [(currentSort === '+' + field) ? '-'+field : '+'+field];
sort = [(currentSort === '+' + field) ? '-' + field : '+' + field];
}

self.list.sort = sort;
self.list.update();
self.filtering.setSort(sort);
};

this.newTemplate = function() {
this.newTemplate = function () {
self.showTemplate({
name: '',
titlePrefix: '',
Expand All @@ -133,12 +133,12 @@
});
};

this.showTemplate = function(template) {
this.showTemplate = function (template) {

var promise = template._id ? CaseTemplateSrv.get(template._id) : $q.resolve(template);

promise
.then(function(response) {
.then(function (response) {
var modalInstance = $uibModal.open({
animation: true,
keyboard: false,
Expand All @@ -148,43 +148,49 @@
controllerAs: '$vm',
size: 'max',
resolve: {
template: function() {
return response;
template: function () {
var tmpl = angular.copy(response);

if (tmpl.tasks && tmpl.tasks.length > 0) {
tmpl.tasks = _.sortBy(tmpl.tasks, 'order');
}

return tmpl;
},
fields: function() {
fields: function () {
return self.fields;
}
}
});

return modalInstance.result;
})
.then(function() {
.then(function () {
self.load();
})
.catch(function(err) {
if(err && !_.isString(err)) {
.catch(function (err) {
if (err && !_.isString(err)) {
NotificationSrv.error('Case Template Admin', err.data, err.status);
}
})
}

self.createTemplate = function(template) {
self.createTemplate = function (template) {
return CaseTemplateSrv.create(template).then(
function(/*response*/) {
function (/*response*/) {
self.load();

$scope.$emit('templates:refresh');

NotificationSrv.log('The template [' + template.name + '] has been successfully created', 'success');
},
function(response) {
function (response) {
NotificationSrv.error('TemplateCtrl', response.data, response.status);
}
);
};

self.importTemplate = function() {
self.importTemplate = function () {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'views/components/org/case-template/import.html',
Expand All @@ -194,10 +200,10 @@
});

modalInstance.result
.then(function(template) {
.then(function (template) {
return self.createTemplate(template);
})
.catch(function(err) {
.catch(function (err) {
if (err && err.status) {
NotificationSrv.error('TemplateCtrl', err.data, err.status);
}
Expand All @@ -221,7 +227,7 @@

self.exportTemplate = function (template) {
CaseTemplateSrv.get(template._id)
.then(function(response) {
.then(function (response) {
var fileName = 'Case-Template__' + response.name.replace(/\s/gi, '_') + '.json';

// Create a blob of the data
Expand Down
4 changes: 3 additions & 1 deletion frontend/app/scripts/controllers/alert/AlertListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@
controllerAs: 'dialog',
size: 'max',
resolve: {
event: event,
event: function () {
return angular.copy(event);
},
templates: function () {
return CaseTemplateSrv.list();
},
Expand Down
11 changes: 7 additions & 4 deletions frontend/app/views/components/org/case-template/tasks.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
No tasks have been specified. <a href class="mr-xxxs" ng-click="$vm.addTask()">Add a task</a>
</div>
<div ng-if="$vm.template.tasks.length !== 0" ui-sortable="$vm.sortableOptions" ng-model="$vm.template.tasks">
<div class="task-item" ng-init="isCollapsed=true" ng-repeat="t in $vm.template.tasks | orderBy:'order' track by $index">
<div class="task-item" ng-init="isCollapsed=true"
ng-repeat="t in $vm.template.tasks | orderBy:'order' track by $index">
<div class="panel-heading">
<span class="drag-handle text-primary clickable mr-xxs">
<i class="fa fa-bars"></i>
Expand All @@ -22,14 +23,16 @@
</a>
</span>
<span class="hpad5">[{{t.group || 'default'}}] {{t.title}}</span>
<span class="mr-xxs" ng-if="t.owner">(Assigned to <em><user-info value="t.owner" field="name"></user-info></em>)</span>
<span class="mr-xxs" ng-if="t.owner">(Assigned to <em>
<user-info value="t.owner" field="name"></user-info>
</em>)</span>

<span class="pull-right">
<a class="text-default" href ng-click="$vm.editTask(t)">
<i class="fa fa-pencil"></i>&nbsp;Edit</a>
<span class="hpad5"></span>
<a class="text-danger" href ng-click="$vm.removeTask(t)">
<i class="fa fa-trash"></i>&nbsp;Delete</a>
<a class="text-danger" href ng-click="$vm.removeTask(t)">
<i class="fa fa-trash"></i>&nbsp;Delete</a>
</span>
</div>
<div class="panel-body" ng-hide="isCollapsed">
Expand Down
Loading

0 comments on commit 7d6d55d

Please sign in to comment.