diff --git a/frontend/app/scripts/controllers/case/CaseObservablesCtrl.js b/frontend/app/scripts/controllers/case/CaseObservablesCtrl.js index 7c92180906..919c1d67b3 100644 --- a/frontend/app/scripts/controllers/case/CaseObservablesCtrl.js +++ b/frontend/app/scripts/controllers/case/CaseObservablesCtrl.js @@ -366,11 +366,12 @@ $scope.showReport = function(observable, analyzerId) { CortexSrv.getJobs($scope.caseId, observable._id, analyzerId, 1) - .then(function(response) { - return CortexSrv.getJob(response.data[0].id); - }) .then(function(response){ - var job = response.data; + if(!response.data || response.data.length !== 1) { + return; + } + + var job = response.data[0]; var report = { job: job, template: job.analyzerName || job.analyzerId, diff --git a/frontend/app/scripts/services/api/CortexSrv.js b/frontend/app/scripts/services/api/CortexSrv.js index b24169c4cc..00921b0fae 100644 --- a/frontend/app/scripts/services/api/CortexSrv.js +++ b/frontend/app/scripts/services/api/CortexSrv.js @@ -1,6 +1,6 @@ (function() { 'use strict'; - angular.module('theHiveServices').service('CortexSrv', function($q, $http, $rootScope, $uibModal, StatSrv, StreamSrv, AnalyzerSrv, PSearchSrv, ModalUtilsSrv) { + angular.module('theHiveServices').service('CortexSrv', function($q, $http, $rootScope, $uibModal, QuerySrv, StatSrv, StreamSrv, AnalyzerSrv, PSearchSrv, ModalUtilsSrv) { var self = this; var baseUrl = './api/connector/cortex'; @@ -24,32 +24,45 @@ }; this.getJobs = function(caseId, observableId, analyzerId, limit) { - return $http.post(baseUrl + '/job/_search', { - sort: ['-startDate'], - range: '0-' + ( - limit || 10), - query: { - _and: [ + + return QuerySrv.query('v1', [ + { + '_name': 'getObservable', + 'idOrName': observableId + }, + { + '_name': 'jobs' + }, + { + '_name': 'filter', + '_or': [ { - _parent: { - _type: 'case_artifact', - _query: { - _id: observableId - } + 'analyzerId': analyzerId + }, + { + '_like': { + '_field': 'analyzerDefinition', + '_value': analyzerId } - }, { - _or: [ - { - analyzerId: analyzerId - }, { - _like: { - _field: 'analyzerDefinition', - _value: analyzerId - } - } - ] } ] + }, + { + '_name': 'sort', + '_fields': [ + { + 'startDate': 'desc' + } + ] + }, + { + '_name': 'page', + 'from': 0, + 'to': limit || 10 + } + ], { + params: { + name: 'observable-jobs-' + observableId } }); };