-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
592 additions
and
12 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...c/app/pages/admin/organizations/components/responders/responder-config-form.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
import _ from 'lodash/core'; | ||
|
||
export default class ResponderConfigFormController { | ||
constructor($log, Tlps, ResponderService) { | ||
'ngInject'; | ||
|
||
this.ResponderService = ResponderService; | ||
this.Tlps = Tlps; | ||
this.rateUnits = ['Day', 'Month']; | ||
} | ||
|
||
applyConfig(config) { | ||
_.forEach( | ||
_.keys(config), | ||
k => (this.responder.configuration[k] = config[k]) | ||
); | ||
} | ||
|
||
applyGlobalConfig() { | ||
this.applyConfig(this.globalConfig.config); | ||
} | ||
|
||
applyBaseConfig() { | ||
this.applyConfig(this.baseConfig.config); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
www/src/app/pages/admin/organizations/components/responders/responder-config-form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<section> | ||
<h4>Base details</h4> | ||
|
||
<div class="form-group"> | ||
<label class="col-sm-3 control-label">Name</label> | ||
<div class="col-sm-9"> | ||
<input class="form-control" type="text" name="name" ng-disabled="true" ng-model="$ctrl.responder.name" /> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<section ng-show="$ctrl.definition.configurationItems.length > 0"> | ||
<h4> | ||
Configuration | ||
<div class="clearfix pull-right"> | ||
<small> | ||
<a href ng-click="$ctrl.applyBaseConfig()"> | ||
<i class="fa fa-copy"></i> Apply defaults</a> | ||
</small> | ||
</div> | ||
</h4> | ||
<configuration-form items="$ctrl.definition.configurationItems" configuration="$ctrl.responder.configuration"></configuration-form> | ||
</section> | ||
|
||
<section> | ||
<h4> | ||
Options | ||
<div class="clearfix pull-right"> | ||
<small> | ||
<a href ng-click="$ctrl.applyGlobalConfig()"> | ||
<i class="fa fa-copy"></i> Apply defaults</a> | ||
</small> | ||
</div> | ||
</h4> | ||
<div class="form-group"> | ||
<label class="col-sm-3 control-label">Enable TLP check</label> | ||
<div class="col-sm-9 form-inline"> | ||
<div class="btn-group"> | ||
<label uib-btn-radio="true" class="btn btn-default" ng-model="$ctrl.responder.configuration.check_tlp">True</label> | ||
<label uib-btn-radio="false" class="btn btn-default" ng-model="$ctrl.responder.configuration.check_tlp">False</label> | ||
</div> | ||
<div class="form-group" style="margin-left: 30px;" ng-show="$ctrl.responder.configuration.check_tlp"> | ||
<label>Max TLP</label> | ||
<select class="form-control" style="width: 200px;" ng-model="$ctrl.responder.configuration.max_tlp" | ||
ng-options="tlp.value as tlp.key for tlp in $ctrl.Tlps" ng-required="$ctrl.responder.configuration.check_tlp"></select> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="col-sm-3 control-label">Enable PAP check</label> | ||
<div class="col-sm-9 form-inline"> | ||
<div class="btn-group"> | ||
<label uib-btn-radio="true" class="btn btn-default" ng-model="$ctrl.responder.configuration.check_pap">True</label> | ||
<label uib-btn-radio="false" class="btn btn-default" ng-model="$ctrl.responder.configuration.check_pap">False</label> | ||
</div> | ||
<div class="form-group" style="margin-left: 30px;" ng-show="$ctrl.responder.configuration.check_pap"> | ||
<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 class="form-group"> | ||
<label class="col-sm-3 control-label">HTTP Proxy</label> | ||
<div class="col-sm-9"> | ||
<input class="form-control" type="text" ng-model="$ctrl.responder.configuration.proxy_http"> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="col-sm-3 control-label">HTTPS Proxy</label> | ||
<div class="col-sm-9"> | ||
<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">Rate Limiting</label> | ||
<div class="col-sm-4"> | ||
<input class="form-control" type="text" ng-model="$ctrl.responder.rate" ui-number-mask="0" ui-hide-group-sep> | ||
</div> | ||
<div class="col-sm-5"> | ||
<select class="form-control" ng-model="$ctrl.responder.rateUnit" ng-options="unit for unit in $ctrl.rateUnits"> | ||
<option value="">-- choose unit --</option> | ||
</select> | ||
</div> | ||
<div class="col-sm-offset-3 col-sm-9"> | ||
<p class="help-block">Define the maximum number of requests and the associated unit if applicable.</p> | ||
</div> | ||
</div> | ||
</section> |
84 changes: 84 additions & 0 deletions
84
www/src/app/pages/admin/organizations/components/responders/responder.edit.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
'use strict'; | ||
|
||
import _ from 'lodash/core'; | ||
|
||
export default class ResponderEditController { | ||
constructor( | ||
$log, | ||
$uibModalInstance, | ||
definition, | ||
globalConfig, | ||
baseConfig, | ||
configuration, | ||
responder, | ||
mode | ||
) { | ||
'ngInject'; | ||
|
||
this.$log = $log; | ||
this.$uibModalInstance = $uibModalInstance; | ||
this.mode = mode; | ||
this.definition = definition; | ||
this.globalConfig = globalConfig; | ||
this.baseConfig = baseConfig; | ||
this.configuration = configuration; | ||
this.responder = responder; | ||
} | ||
|
||
$onInit() { | ||
if (_.isEmpty(this.responder)) { | ||
let responder = { | ||
name: this.definition.id, | ||
configuration: {}, | ||
rate: undefined, | ||
rateUnit: undefined | ||
}; | ||
|
||
_.forEach(this.definition.configurationItems, item => { | ||
const property = item.name, | ||
configValue = (this.configuration.config || {})[property]; | ||
|
||
responder.configuration[property] = | ||
configValue || | ||
item.defaultValue || | ||
(item.multi ? [undefined] : undefined); | ||
}); | ||
|
||
// Handle TLP default config | ||
const globalConfig = [ | ||
'proxy_http', | ||
'proxy_https' | ||
]; | ||
_.forEach(globalConfig, cnf => { | ||
if (responder.configuration[cnf] === undefined) { | ||
responder.configuration[cnf] = | ||
this.configuration.config[cnf] !== undefined ? | ||
this.configuration.config[cnf] : | ||
undefined; | ||
} | ||
}); | ||
|
||
if (responder.configuration.check_tlp === undefined) { | ||
responder.configuration.check_tlp = true; | ||
} | ||
if (responder.configuration.max_tlp === undefined) { | ||
responder.configuration.max_tlp = 2; | ||
} | ||
if (responder.configuration.check_pap === undefined) { | ||
responder.configuration.check_pap = true; | ||
} | ||
if (responder.configuration.max_pap === undefined) { | ||
responder.configuration.max_pap = 2; | ||
} | ||
|
||
this.responder = responder; | ||
} | ||
} | ||
|
||
save() { | ||
this.$uibModalInstance.close(this.responder); | ||
} | ||
cancel() { | ||
this.$uibModalInstance.dismiss('cancel'); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
www/src/app/pages/admin/organizations/components/responders/responder.edit.modal.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<form class="form-horizontal" name="form" ng-submit="$modal.save()"> | ||
<div class="modal-header bg-primary"> | ||
<h3 class="modal-title">{{$modal.mode === 'create' ? 'Enable' : 'Edit'}} responder {{$modal.definition.id}}</h3> | ||
</div> | ||
<div class="modal-body"> | ||
<responder-config-form definition="$modal.definition" global-config="$modal.globalConfig" base-config="$modal.baseConfig" | ||
configuration="$modal.configuration" responder="$modal.responder"></responder-config-form> | ||
</div> | ||
<div class="modal-footer"> | ||
<button class="btn btn-default pull-left" type="button" ng-click="$modal.cancel()">Cancel</button> | ||
<span class="btn pull-left"> | ||
<i class="fa fa-asterisk text-danger"></i> Required field</span> | ||
<button class="btn btn-primary pull-right" type="submit" ng-disabled="form.$invalid" auto-focus>Save</button> | ||
</div> | ||
</form> |
Oops, something went wrong.