Skip to content

Commit

Permalink
#52 Init misp export UI
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani authored and To-om committed Aug 7, 2017
1 parent de56e8d commit f239da6
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 0 deletions.
1 change: 1 addition & 0 deletions ui/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<script src="scripts/controllers/case/CaseCloseModalCtrl.js"></script>
<script src="scripts/controllers/case/CaseCreationCtrl.js"></script>
<script src="scripts/controllers/case/CaseDetailsCtrl.js"></script>
<script src="scripts/controllers/case/CaseExportCtrl.js"></script>
<script src="scripts/controllers/case/CaseLinksCtrl.js"></script>
<script src="scripts/controllers/case/CaseListCtrl.js"></script>
<script src="scripts/controllers/case/CaseMainCtrl.js"></script>
Expand Down
11 changes: 11 additions & 0 deletions ui/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ angular.module('thehive', ['ngAnimate', 'ngMessages', 'ngSanitize', 'ui.bootstra
templateUrl: 'views/partials/case/case.links.html',
controller: 'CaseLinksCtrl'
})
.state('app.case.export', {
url: '/export',
templateUrl: 'views/partials/case/case.export.html',
controller: 'CaseExportCtrl',
controllerAs: '$vm',
resolve: {
categories: function(MispSrv) {
return MispSrv.categories();
}
}
})
.state('app.case.tasks-item', {
url: '/tasks/{itemId}',
templateUrl: 'views/partials/case/case.tasks.item.html',
Expand Down
63 changes: 63 additions & 0 deletions ui/app/scripts/controllers/case/CaseExportCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
(function() {
'use strict';
angular.module('theHiveControllers').controller('CaseExportCtrl',
function($scope, $state, $stateParams, $timeout, PSearchSrv, CaseTabsSrv, categories) {
var self = this;

this.caseId = $stateParams.caseId;
this.searchForm = {};
var tabName = 'export-' + this.caseId;

// MISP category/type map
this.categories = categories;

// Add tab
CaseTabsSrv.addTab(tabName, {
name: tabName,
label: 'Export',
closable: true,
state: 'app.case.export',
params: {}
});

// Select tab
$timeout(function() {
CaseTabsSrv.activateTab(tabName);
}, 0);


this.artifacts = PSearchSrv(this.caseId, 'case_artifact', {
scope: $scope,
baseFilter: {
'_and': [{
'_parent': {
"_type": "case",
"_query": {
"_id": $scope.caseId
}
}
}, {
'ioc': true
}, {
'status': 'Ok'
}]
},
filter: this.searchForm.searchQuery !== '' ? {
_string: this.searchForm.searchQuery
} : '',
loadAll: true,
sort: '-startDate',
pageSize: 30,
onUpdate: function () {
self.enhanceArtifacts();
},
nstats: true
});

this.enhanceArtifacts = function(data) {
console.log(data);
}

}
);
})();
6 changes: 6 additions & 0 deletions ui/app/scripts/controllers/case/CaseMainCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@
});
};

$scope.shareCase = function() {
$state.go('app.case.export', {
caseId: $scope.caseId
});
};

/**
* A workaround filter to make sure the ngRepeat doesn't order the
* object keys
Expand Down
17 changes: 17 additions & 0 deletions ui/app/scripts/services/MispSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@
defer.resolve(statuses);
});

return defer.promise;
},

categories: function() {
var defer = $q.defer();

$q.resolve({
'category1': [
'type1.1', 'type1.2', 'type1.3'
],
'category2': [
'type2.1', 'type2.2', 'type2.3'
]
}).then(function(response) {
defer.resolve(response);
});

return defer.promise;
}
};
Expand Down
79 changes: 79 additions & 0 deletions ui/app/views/partials/case/case.export.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<div class="row">
<div class="col-md-12 mv-s" ng-show="$vm.artifacts.total === 0">
<div class="empty-message">No records.</div>
</div>
</div>

<!-- list of artifacts-->
<div class="row">
<div class="col-md-12" ng-show="$vm.artifacts.total > 0">

<psearch control="$vm.artifacts"></psearch>

<form class="form-inline">
<div class="form-group">
<label class="sr-only" for="exampleInputEmail3">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail3" placeholder="Email">
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword3">Password</label>
<input type="password" class="form-control" id="exampleInputPassword3" placeholder="Password">
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
<button type="submit" class="btn btn-default">Sign in</button>
</form>

<table class="table table-striped table-hover valigned">
<thead>
<tr>
<th width="10" class="p-0"></th>
<th width="20">
<input type="checkbox" ng-change="selectAll()" ng-model="selection.all" ng-disabled="switchTEList"></input>
</th>
<th width="150">Type</th>
<th>Data/Filename</th>
<th width="300">Tags</th>
<th width="150">MISP Category</th>
<th width="150">MISP Type</th>
<th width="20">&nbsp;</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="artifact in $vm.artifacts.values">
<td class="p-0 bg-tlp-{{artifact.tlp}} clickable" ng-click="filterByTlp(artifact.tlp)"></td>
<td>
<input type="checkbox" ng-change="selectArtifact(artifact)" ng-model="selection.list[artifact.id]">
</td>
<td>
<a href="" ng-click="addFilterValue('dataType', artifact.dataType)"><span ng-bind="artifact.dataType"></span></a>
</td>
<td class="wrap clickable" ng-click="openArtifact(artifact)">{{(artifact.data | fang) || (artifact.attachment.name | fang)}}</td>
<td>
<span ng-repeat="l in artifact.tags">
<span class="label label-primary mr-xxxs pointer" ng-click="addFilterValue('tags', l)">
<i class="glyphicon glyphicon-tag"></i> <span ng-bind="l"></span>
</span>
</span>
</td>
<td>
<em ng-if="!artifact.exportCategory">Not specified</em>
<em ng-if="artifact.exportCategory">Not specified</em>
</td>
<td>
<em ng-if="!artifact.exportType">Not specified</em>
<em ng-if="artifact.exportType">Not specified</em>
</td>
<td>
<i class="fa fa-check"></i>
<i class="fa fa-exclamation-triangle"></i>
</td>
</tr>
</tbody>
</table>
<psearch ng-if="!switchTEList" control="artifacts"></psearch>
</div>
</div>
7 changes: 7 additions & 0 deletions ui/app/views/partials/case/case.panelinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ <h3 class="box-title">
</span>

<!-- Right side -->
<span class="ml-xs pull-right">
<a href ng-click="shareCase()" class="text-primary noline" uib-tooltip="Share case">
<i class="text-primary fa fa-share"></i>
Share
</a>
</span>

<span class="ml-xs pull-right">
<a href ng-click="mergeCase()" class="text-primary noline" uib-tooltip="Merge case">
<i class="text-primary fa fa-compress"></i>
Expand Down

0 comments on commit f239da6

Please sign in to comment.