Skip to content

Commit

Permalink
#83 Display the password specified in the configuration file to prote…
Browse files Browse the repository at this point in the history
…ct zipped observable files
  • Loading branch information
nadouani committed Feb 9, 2017
1 parent 93641cd commit 9b6bdfb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion thehive-backend/app/controllers/Status.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import javax.inject.{ Inject, Singleton }

import scala.collection.immutable

import play.api.Configuration
import play.api.libs.json.Json
import play.api.libs.json.Json.toJsFieldJsValueWrapper
import play.api.mvc.{ Action, Controller }
Expand All @@ -23,6 +24,7 @@ import org.elastic4play.services.AuthSrv
@Singleton
class StatusCtrl @Inject() (
connectors: immutable.Set[Connector],
configuration: Configuration,
authSrv: AuthSrv) extends Controller {

private[controllers] def getVersion(c: Class[_]) = Option(c.getPackage.getImplementationVersion).getOrElse("SNAPSHOT")
Expand All @@ -38,10 +40,11 @@ class StatusCtrl @Inject() (
"ElasticSearch" getVersion(classOf[org.elasticsearch.Build])),
"connectors" JsObject(connectors.map(c c.name c.status).toSeq),
"config" Json.obj(
"protectDownloadsWith" configuration.getString("datastore.attachment.password").get,
"authType" (authSrv match {
case multiAuthSrv: MultiAuthSrv multiAuthSrv.authProviders.map { a JsString(a.name) }
case _ JsString(authSrv.name)
}),
"capabilities" authSrv.capabilities.map(c JsString(c.toString)))))
}
}
}
7 changes: 6 additions & 1 deletion ui/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ angular.module('thehive', ['ngAnimate', 'ngMessages', 'ui.bootstrap', 'ui.router
.state('app.case.observables-item', {
url: '/observables/{itemId}',
templateUrl: 'views/partials/case/case.observables.item.html',
controller: 'CaseObservablesItemCtrl'
controller: 'CaseObservablesItemCtrl',
resolve: {
appConfig: function(VersionSrv) {
return VersionSrv.get();
}
}
})
.state('app.misp-list', {
url: 'misp/list',
Expand Down
5 changes: 3 additions & 2 deletions ui/app/scripts/controllers/case/CaseObservablesItemCtrl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function () {
'use strict';
angular.module('theHiveControllers').controller('CaseObservablesItemCtrl',
function ($scope, $state, $stateParams, $q, CaseTabsSrv, CaseArtifactSrv, CortexSrv, PSearchSrv, AnalyzerSrv, JobSrv, AlertSrv, VersionSrv) {
function ($scope, $state, $stateParams, $q, CaseTabsSrv, CaseArtifactSrv, CortexSrv, PSearchSrv, AnalyzerSrv, JobSrv, AlertSrv, VersionSrv, appConfig) {
var observableId = $stateParams.itemId,
observableName = 'observable-' + observableId;

Expand All @@ -20,6 +20,7 @@
$scope.artifact = {};
$scope.artifact.tlp = $scope.artifact.tlp || -1;
$scope.analysisEnabled = VersionSrv.hasCortex();
$scope.protectDownloadsWith = appConfig.config.protectDownloadsWith;

$scope.editorOptions = {
lineNumbers: true,
Expand Down Expand Up @@ -135,7 +136,7 @@

return CaseArtifactSrv.api().update({
artifactId: $scope.artifact.id
}, field, function (response) {
}, field, function (response) {
$scope.artifact = response.toJSON();
}, function (response) {
AlertSrv.error('artifactDetails', response.data, response.status);
Expand Down
2 changes: 1 addition & 1 deletion ui/app/views/partials/case/case.observables.item.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h4>
<span class="glyphicon glyphicon-download"></span><br/>
<span class="wrap">{{artifact.attachment.name}}</span>
</a><br/>
<small class="text-danger">Zip are protected with password "malware"</small>
<small class="text-danger">Zip are protected with password "{{protectDownloadsWith}}"</small>
</div>
</div>
<!-- Observable analysers short reports -->
Expand Down

0 comments on commit 9b6bdfb

Please sign in to comment.