Skip to content

Commit f239da6

Browse files
nadouaniTo-om
authored andcommitted
#52 Init misp export UI
1 parent de56e8d commit f239da6

File tree

7 files changed

+184
-0
lines changed

7 files changed

+184
-0
lines changed

ui/app/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
<script src="scripts/controllers/case/CaseCloseModalCtrl.js"></script>
148148
<script src="scripts/controllers/case/CaseCreationCtrl.js"></script>
149149
<script src="scripts/controllers/case/CaseDetailsCtrl.js"></script>
150+
<script src="scripts/controllers/case/CaseExportCtrl.js"></script>
150151
<script src="scripts/controllers/case/CaseLinksCtrl.js"></script>
151152
<script src="scripts/controllers/case/CaseListCtrl.js"></script>
152153
<script src="scripts/controllers/case/CaseMainCtrl.js"></script>

ui/app/scripts/app.js

+11
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,17 @@ angular.module('thehive', ['ngAnimate', 'ngMessages', 'ngSanitize', 'ui.bootstra
239239
templateUrl: 'views/partials/case/case.links.html',
240240
controller: 'CaseLinksCtrl'
241241
})
242+
.state('app.case.export', {
243+
url: '/export',
244+
templateUrl: 'views/partials/case/case.export.html',
245+
controller: 'CaseExportCtrl',
246+
controllerAs: '$vm',
247+
resolve: {
248+
categories: function(MispSrv) {
249+
return MispSrv.categories();
250+
}
251+
}
252+
})
242253
.state('app.case.tasks-item', {
243254
url: '/tasks/{itemId}',
244255
templateUrl: 'views/partials/case/case.tasks.item.html',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
(function() {
2+
'use strict';
3+
angular.module('theHiveControllers').controller('CaseExportCtrl',
4+
function($scope, $state, $stateParams, $timeout, PSearchSrv, CaseTabsSrv, categories) {
5+
var self = this;
6+
7+
this.caseId = $stateParams.caseId;
8+
this.searchForm = {};
9+
var tabName = 'export-' + this.caseId;
10+
11+
// MISP category/type map
12+
this.categories = categories;
13+
14+
// Add tab
15+
CaseTabsSrv.addTab(tabName, {
16+
name: tabName,
17+
label: 'Export',
18+
closable: true,
19+
state: 'app.case.export',
20+
params: {}
21+
});
22+
23+
// Select tab
24+
$timeout(function() {
25+
CaseTabsSrv.activateTab(tabName);
26+
}, 0);
27+
28+
29+
this.artifacts = PSearchSrv(this.caseId, 'case_artifact', {
30+
scope: $scope,
31+
baseFilter: {
32+
'_and': [{
33+
'_parent': {
34+
"_type": "case",
35+
"_query": {
36+
"_id": $scope.caseId
37+
}
38+
}
39+
}, {
40+
'ioc': true
41+
}, {
42+
'status': 'Ok'
43+
}]
44+
},
45+
filter: this.searchForm.searchQuery !== '' ? {
46+
_string: this.searchForm.searchQuery
47+
} : '',
48+
loadAll: true,
49+
sort: '-startDate',
50+
pageSize: 30,
51+
onUpdate: function () {
52+
self.enhanceArtifacts();
53+
},
54+
nstats: true
55+
});
56+
57+
this.enhanceArtifacts = function(data) {
58+
console.log(data);
59+
}
60+
61+
}
62+
);
63+
})();

ui/app/scripts/controllers/case/CaseMainCtrl.js

+6
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@
198198
});
199199
};
200200

201+
$scope.shareCase = function() {
202+
$state.go('app.case.export', {
203+
caseId: $scope.caseId
204+
});
205+
};
206+
201207
/**
202208
* A workaround filter to make sure the ngRepeat doesn't order the
203209
* object keys

ui/app/scripts/services/MispSrv.js

+17
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,23 @@
115115
defer.resolve(statuses);
116116
});
117117

118+
return defer.promise;
119+
},
120+
121+
categories: function() {
122+
var defer = $q.defer();
123+
124+
$q.resolve({
125+
'category1': [
126+
'type1.1', 'type1.2', 'type1.3'
127+
],
128+
'category2': [
129+
'type2.1', 'type2.2', 'type2.3'
130+
]
131+
}).then(function(response) {
132+
defer.resolve(response);
133+
});
134+
118135
return defer.promise;
119136
}
120137
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<div class="row">
2+
<div class="col-md-12 mv-s" ng-show="$vm.artifacts.total === 0">
3+
<div class="empty-message">No records.</div>
4+
</div>
5+
</div>
6+
7+
<!-- list of artifacts-->
8+
<div class="row">
9+
<div class="col-md-12" ng-show="$vm.artifacts.total > 0">
10+
11+
<psearch control="$vm.artifacts"></psearch>
12+
13+
<form class="form-inline">
14+
<div class="form-group">
15+
<label class="sr-only" for="exampleInputEmail3">Email address</label>
16+
<input type="email" class="form-control" id="exampleInputEmail3" placeholder="Email">
17+
</div>
18+
<div class="form-group">
19+
<label class="sr-only" for="exampleInputPassword3">Password</label>
20+
<input type="password" class="form-control" id="exampleInputPassword3" placeholder="Password">
21+
</div>
22+
<div class="checkbox">
23+
<label>
24+
<input type="checkbox"> Remember me
25+
</label>
26+
</div>
27+
<button type="submit" class="btn btn-default">Sign in</button>
28+
</form>
29+
30+
<table class="table table-striped table-hover valigned">
31+
<thead>
32+
<tr>
33+
<th width="10" class="p-0"></th>
34+
<th width="20">
35+
<input type="checkbox" ng-change="selectAll()" ng-model="selection.all" ng-disabled="switchTEList"></input>
36+
</th>
37+
<th width="150">Type</th>
38+
<th>Data/Filename</th>
39+
<th width="300">Tags</th>
40+
<th width="150">MISP Category</th>
41+
<th width="150">MISP Type</th>
42+
<th width="20">&nbsp;</th>
43+
</tr>
44+
</thead>
45+
<tbody>
46+
<tr ng-repeat="artifact in $vm.artifacts.values">
47+
<td class="p-0 bg-tlp-{{artifact.tlp}} clickable" ng-click="filterByTlp(artifact.tlp)"></td>
48+
<td>
49+
<input type="checkbox" ng-change="selectArtifact(artifact)" ng-model="selection.list[artifact.id]">
50+
</td>
51+
<td>
52+
<a href="" ng-click="addFilterValue('dataType', artifact.dataType)"><span ng-bind="artifact.dataType"></span></a>
53+
</td>
54+
<td class="wrap clickable" ng-click="openArtifact(artifact)">{{(artifact.data | fang) || (artifact.attachment.name | fang)}}</td>
55+
<td>
56+
<span ng-repeat="l in artifact.tags">
57+
<span class="label label-primary mr-xxxs pointer" ng-click="addFilterValue('tags', l)">
58+
<i class="glyphicon glyphicon-tag"></i> <span ng-bind="l"></span>
59+
</span>
60+
</span>
61+
</td>
62+
<td>
63+
<em ng-if="!artifact.exportCategory">Not specified</em>
64+
<em ng-if="artifact.exportCategory">Not specified</em>
65+
</td>
66+
<td>
67+
<em ng-if="!artifact.exportType">Not specified</em>
68+
<em ng-if="artifact.exportType">Not specified</em>
69+
</td>
70+
<td>
71+
<i class="fa fa-check"></i>
72+
<i class="fa fa-exclamation-triangle"></i>
73+
</td>
74+
</tr>
75+
</tbody>
76+
</table>
77+
<psearch ng-if="!switchTEList" control="artifacts"></psearch>
78+
</div>
79+
</div>

ui/app/views/partials/case/case.panelinfo.html

+7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ <h3 class="box-title">
3737
</span>
3838

3939
<!-- Right side -->
40+
<span class="ml-xs pull-right">
41+
<a href ng-click="shareCase()" class="text-primary noline" uib-tooltip="Share case">
42+
<i class="text-primary fa fa-share"></i>
43+
Share
44+
</a>
45+
</span>
46+
4047
<span class="ml-xs pull-right">
4148
<a href ng-click="mergeCase()" class="text-primary noline" uib-tooltip="Merge case">
4249
<i class="text-primary fa fa-compress"></i>

0 commit comments

Comments
 (0)