Skip to content

Commit

Permalink
#689 Add the ability to search cross in all document types
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Sep 3, 2018
1 parent f18ccbc commit 4a53013
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion thehive-backend/app/controllers/DescribeCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DescribeCtrl @Inject() (
.getOrElse(NotFound(s"Model $modelName not found"))
}

private val allModels: Seq[String] = Seq("case", "case_artifact", "case_task", "alert", "case_artifact_job", "audit")
private val allModels: Seq[String] = Seq("case", "case_artifact", "case_task", "case_task_log", "alert", "case_artifact_job", "audit")
def describeAll: Action[AnyContent] = authenticated(Roles.read) { implicit request
val entityDefinitions = modelSrv.list
.collect {
Expand Down
17 changes: 10 additions & 7 deletions ui/app/scripts/controllers/SearchCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
.controller('SearchCtrl', function($scope, $q, $stateParams, $uibModal, PSearchSrv, CaseTemplateSrv, CaseTaskSrv, NotificationSrv, EntitySrv, UserInfoSrv, QueryBuilderSrv, GlobalSearchSrv, metadata) {
$scope.metadata = metadata;
$scope.toolbar = [
{name: 'all', label: 'All', icon: 'glyphicon glyphicon-search'},
{name: 'case', label: 'Cases', icon: 'glyphicon glyphicon-folder-open'},
{name: 'case_task', label: 'Tasks', icon: 'glyphicon glyphicon-tasks'},
{name: 'case_task_log', label: 'Tasks Logs', icon: 'glyphicon glyphicon-comment'},
{name: 'case_artifact', label: 'Observables', icon: 'glyphicon glyphicon-pushpin'},
{name: 'alert', label: 'Alerts', icon: 'glyphicon glyphicon-alert'},
{name: 'case_artifact_job', label: 'Jobs', icon: 'glyphicon glyphicon-cog'},
Expand Down Expand Up @@ -104,15 +106,16 @@
};

$scope.search = function() {
var entity = $scope.config.entity,
search = $scope.config[entity].search,
filters = $scope.config[entity].filters || [],
var entityName = $scope.config.entity,
entity = $scope.config[entityName] || {},
search = entity.search,
filters = entity.filters || [],
filters_query = null,
search_query = null;

try {
if(filters.length > 0) {
filters_query = QueryBuilderSrv.buildFiltersQuery($scope.metadata[entity].attributes, filters);
if(entityName !== 'all' && filters.length > 0) {
filters_query = QueryBuilderSrv.buildFiltersQuery($scope.metadata[entityName].attributes, filters);
}

if(search) {
Expand All @@ -125,11 +128,11 @@
if(query) {
GlobalSearchSrv.save($scope.config);

$scope.searchResults = PSearchSrv(undefined, $scope.metadata[entity].path, {
$scope.searchResults = PSearchSrv(undefined, entityName === 'all' ? 'any' : $scope.metadata[entityName].path, {
filter: query,
baseFilter: $scope.baseFilter,
nparent: 10,
nstats: entity === 'audit',
nstats: entityName === 'audit',
skipStream: true
});
} else {
Expand Down
4 changes: 2 additions & 2 deletions ui/app/views/partials/search/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h3>Search scope</h3>
</div>
</div>
<div class="m-xs text-primary">
<h3>Search filters <small>{{config[config.entity].filters.length || 0 }} filter(s) applied</small></h3>
<h3>Search filters <small ng-show="config.entity !== 'all'">{{config[config.entity].filters.length || 0 }} filter(s) applied</small></h3>
</div>
<div class="m-xs">
<!-- <div ng-if="!config[config.entity].search && !config[config.entity].filters.length > 0" class="empty-message">
Expand Down Expand Up @@ -56,7 +56,7 @@ <h3>Search filters <small>{{config[config.entity].filters.length || 0 }} filter(
</div>
<div class="mv-xs row">
<div class="col-sm-12 col-md-12 col-lg-8">
<a href class="btn btn-link btn-clear" ng-click="addFilter()">
<a href class="btn btn-link btn-clear" ng-click="addFilter()" ng-show="config.entity !== 'all'">
<i class="fa fa-plus"></i> Add a filter
</a>
<a href class="btn btn-danger" ng-click="clearFilters()">
Expand Down

0 comments on commit 4a53013

Please sign in to comment.