From 18820ca4c3ddd8b31b2ef48d82ec41616eb64d18 Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Sun, 3 May 2020 19:40:54 +0200 Subject: [PATCH] #1242 Check that cortex is available before calling related APIs --- .../controllers/case/CaseDetailsCtrl.js | 50 +++++++++-------- .../case/CaseObservablesItemCtrl.js | 55 ++++++++++--------- .../controllers/case/CaseTasksItemCtrl.js | 49 +++++++++-------- .../observables/details/analysers.html | 7 ++- 4 files changed, 89 insertions(+), 72 deletions(-) diff --git a/frontend/app/scripts/controllers/case/CaseDetailsCtrl.js b/frontend/app/scripts/controllers/case/CaseDetailsCtrl.js index a3d97755fe..49ea55cc3b 100644 --- a/frontend/app/scripts/controllers/case/CaseDetailsCtrl.js +++ b/frontend/app/scripts/controllers/case/CaseDetailsCtrl.js @@ -40,30 +40,34 @@ nparent: 1 }); - $scope.actions = PSearchSrv(null, 'connector/cortex/action', { - scope: $scope, - streamObjectType: 'action', - filter: { - _and: [ - { - _not: { - status: 'Deleted' + + var connectors = $scope.appConfig.connectors; + if(connectors.cortex && connectors.cortex.enabled) { + $scope.actions = PSearchSrv(null, 'connector/cortex/action', { + scope: $scope, + streamObjectType: 'action', + filter: { + _and: [ + { + _not: { + status: 'Deleted' + } + }, { + objectType: 'case' + }, { + objectId: $scope.caseId } - }, { - objectType: 'case' - }, { - objectId: $scope.caseId - } - ] - }, - sort: ['-startDate'], - pageSize: 100, - guard: function(updates) { - return _.find(updates, function(item) { - return (item.base.object.objectType === 'case') && (item.base.object.objectId === $scope.caseId); - }) !== undefined; - } - }); + ] + }, + sort: ['-startDate'], + pageSize: 100, + guard: function(updates) { + return _.find(updates, function(item) { + return (item.base.object.objectType === 'case') && (item.base.object.objectId === $scope.caseId); + }) !== undefined; + } + }); + } $scope.openAttachment = function(attachment) { $state.go('app.case.tasks-item', { diff --git a/frontend/app/scripts/controllers/case/CaseObservablesItemCtrl.js b/frontend/app/scripts/controllers/case/CaseObservablesItemCtrl.js index 870b3912f3..637d8ffedb 100644 --- a/frontend/app/scripts/controllers/case/CaseObservablesItemCtrl.js +++ b/frontend/app/scripts/controllers/case/CaseObservablesItemCtrl.js @@ -10,7 +10,7 @@ $scope.obsResponders = null; $scope.analyzers = {}; $scope.analyzerJobs = {}; - $scope.jobs = {}; + //$scope.jobs = {}; $scope.state = { 'editing': false, 'isCollapsed': false, @@ -61,33 +61,38 @@ $scope.analyzers = []; }) .finally(function () { - $scope.jobs = CortexSrv.list($scope, $scope.caseId, observableId, $scope.onJobsChange); + if($scope.analysisEnabled) { + $scope.jobs = CortexSrv.list($scope, $scope.caseId, observableId, $scope.onJobsChange); + } }); - $scope.actions = PSearchSrv(null, 'connector/cortex/action', { - scope: $scope, - streamObjectType: 'action', - filter: { - _and: [ - { - _not: { - status: 'Deleted' + var connectors = $scope.appConfig.connectors; + if(connectors.cortex && connectors.cortex.enabled) { + $scope.actions = PSearchSrv(null, 'connector/cortex/action', { + scope: $scope, + streamObjectType: 'action', + filter: { + _and: [ + { + _not: { + status: 'Deleted' + } + }, { + objectType: 'case_artifact' + }, { + objectId: artifact.id } - }, { - objectType: 'case_artifact' - }, { - objectId: artifact.id - } - ] - }, - sort: ['-startDate'], - pageSize: 100, - guard: function(updates) { - return _.find(updates, function(item) { - return (item.base.object.objectType === 'case_artifact') && (item.base.object.objectId === artifact.id); - }) !== undefined; - } - }); + ] + }, + sort: ['-startDate'], + pageSize: 100, + guard: function(updates) { + return _.find(updates, function(item) { + return (item.base.object.objectType === 'case_artifact') && (item.base.object.objectId === artifact.id); + }) !== undefined; + } + }); + } }; // Prepare the scope data diff --git a/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js b/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js index 1073e087b2..a6858bd2c3 100644 --- a/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js +++ b/frontend/app/scripts/controllers/case/CaseTasksItemCtrl.js @@ -82,30 +82,33 @@ } }); - $scope.actions = PSearchSrv(null, 'connector/cortex/action', { - scope: $scope, - streamObjectType: 'action', - filter: { - _and: [ - { - _not: { - status: 'Deleted' + var connectors = $scope.appConfig.connectors; + if(connectors.cortex && connectors.cortex.enabled) { + $scope.actions = PSearchSrv(null, 'connector/cortex/action', { + scope: $scope, + streamObjectType: 'action', + filter: { + _and: [ + { + _not: { + status: 'Deleted' + } + }, { + objectType: 'case_task' + }, { + objectId: taskId } - }, { - objectType: 'case_task' - }, { - objectId: taskId - } - ] - }, - sort: ['-startDate'], - pageSize: 100, - guard: function(updates) { - return _.find(updates, function(item) { - return (item.base.object.objectType === 'case_task') && (item.base.object.objectId === taskId); - }) !== undefined; - } - }); + ] + }, + sort: ['-startDate'], + pageSize: 100, + guard: function(updates) { + return _.find(updates, function(item) { + return (item.base.object.objectType === 'case_task') && (item.base.object.objectId === taskId); + }) !== undefined; + } + }); + } }; $scope.switchFlag = function () { diff --git a/frontend/app/views/partials/observables/details/analysers.html b/frontend/app/views/partials/observables/details/analysers.html index 2222d46253..5a3b1c486e 100644 --- a/frontend/app/views/partials/observables/details/analysers.html +++ b/frontend/app/views/partials/observables/details/analysers.html @@ -6,7 +6,12 @@

Run all

- + +
+
No records
+
+ +
Analyzer Last analysis