Skip to content

Commit

Permalink
#175 Add CA Certs input in global config, analyzers and responders co…
Browse files Browse the repository at this point in the history
…nfig dialogs
  • Loading branch information
To-om committed Mar 11, 2019
1 parent cbe7a69 commit 93b8894
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
6 changes: 4 additions & 2 deletions app/org/thp/cortex/models/BaseConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.elastic4play.utils.Collection.distinctBy
case class BaseConfig(name: String, workerNames: Seq[String], items: Seq[ConfigurationDefinitionItem], config: Option[WorkerConfig]) {
def +(other: BaseConfig) = BaseConfig(name, workerNames ++ other.workerNames, distinctBy(items ++ other.items)(_.name), config.orElse(other.config))
}

object BaseConfig {
implicit val writes: Writes[BaseConfig] = Writes[BaseConfig] { baseConfig
Json.obj(
Expand All @@ -15,15 +16,16 @@ object BaseConfig {
"configurationItems" baseConfig.items,
"config" baseConfig.config.fold(JsObject.empty)(_.jsonConfig))
}
def global(tpe: WorkerType.Type) = {
def global(tpe: WorkerType.Type): BaseConfig = {
val typedItems = tpe match {
case WorkerType.responder Nil
case WorkerType.analyzer Seq(
ConfigurationDefinitionItem("auto_extract_artifacts", "extract artifacts from full report automatically", WorkerConfigItemType.boolean, multi = false, required = false, Some(JsFalse)))
}
BaseConfig("global", Nil, typedItems ++ Seq(
ConfigurationDefinitionItem("proxy_http", "url of http proxy", WorkerConfigItemType.string, multi = false, required = false, None),
ConfigurationDefinitionItem("proxy_https", "url of https proxy", WorkerConfigItemType.string, multi = false, required = false, None)),
ConfigurationDefinitionItem("proxy_https", "url of https proxy", WorkerConfigItemType.string, multi = false, required = false, None),
ConfigurationDefinitionItem("cacerts", "Certificate authotities", WorkerConfigItemType.text, multi = false, required = false, None)),
None)
}
val tlp = BaseConfig("tlp", Nil, Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ <h4>
<label class="col-sm-3 control-label">HTTPS Proxy</label>
<div class="col-sm-9">
<input class="form-control" type="text" ng-model="$ctrl.analyzer.configuration.proxy_https">
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">CA Certs</label>
<div class="col-sm-9">
<textarea class="form-control vertical" rows="5" ng-model="$ctrl.analyzer.configuration.cacerts"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Extract observables</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export default class AnalyzerEditController {
const globalConfig = [
'proxy_http',
'proxy_https',
'auto_extract_artifacts'
'auto_extract_artifacts',
'cacerts'
];
_.forEach(globalConfig, cnf => {
if (analyzer.configuration[cnf] === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<div class="col-sm-9" ng-switch="$ctrl.typeOf(config)">
<input ng-switch-when="string" class="form-control" type="text" ng-required="config.required" ng-model="$ctrl.configuration[config.name]">
<input ng-switch-when="number" class="form-control" type="number" ng-required="config.required" ng-model="$ctrl.configuration[config.name]">
<textarea ng-switch-when="text" class="form-control vertical" rows="5" ng-required="config.required" ng-model="$ctrl.configuration[config.name]"></textarea>
<div ng-switch-when="boolean">
<div class="btn-group">
<label uib-btn-radio="true" class="btn btn-default" ng-model="$ctrl.configuration[config.name]">True</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h4>
<label>Max PAP</label>
<select class="form-control" style="width: 200px;" ng-model="$ctrl.responder.configuration.max_pap"
ng-options="tlp.value as tlp.key for tlp in $ctrl.Tlps" ng-required="$ctrl.responder.configuration.check_pap"></select>
</div>
</div>
</div>
</div>
<div class="form-group">
Expand All @@ -72,6 +72,12 @@ <h4>
<input class="form-control" type="text" ng-model="$ctrl.responder.configuration.proxy_https">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">CA Certs</label>
<div class="col-sm-9">
<textarea class="form-control vertical" rows="5" ng-model="$ctrl.responder.configuration.cacerts"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Rate Limiting</label>
<div class="col-sm-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export default class ResponderEditController {
// Handle TLP default config
const globalConfig = [
'proxy_http',
'proxy_https'
'proxy_https',
'cacerts'
];
_.forEach(globalConfig, cnf => {
if (responder.configuration[cnf] === undefined) {
Expand Down
4 changes: 4 additions & 0 deletions www/src/assets/styles/sass/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,7 @@ a.text-white:hover {
.x-ng-cloak {
display: none !important;
}

textarea.vertical {
resize: vertical;
}

0 comments on commit 93b8894

Please sign in to comment.