mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-08-08 02:13:34 +00:00
first open-appsec support
This commit is contained in:
@@ -72,6 +72,7 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="custom-switch">
|
||||
@@ -90,6 +91,40 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-md-12">
|
||||
<hr class="my-3">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="custom-switch">
|
||||
<input type="checkbox" class="custom-switch-input" name="use_openappsec" value="1"<%- use_openappsec ? ' checked' : '' %>>
|
||||
<span class="custom-switch-indicator"></span>
|
||||
<span class="custom-switch-description font-weight-bold">open-appsec</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-md-12">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-6 col-form-label <%- use_openappsec ? '' : ' text-muted' %>">Enforcement Mode</label>
|
||||
<select name="openappsec_mode" class="col-sm-4 form-control custom-select" placeholder="Please Select" <%- use_openappsec ? '' : ' disabled' %>>
|
||||
<option value="detect-learn" <%- openappsec_mode === 'detect-learn' ? 'selected' : '' %>>Detect-Learn</option>
|
||||
<option value="prevent-learn" <%- openappsec_mode === 'prevent-learn' ? 'selected' : '' %>>Prevent-Learn</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-md-12">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-6 col-form-label <%- use_openappsec ? '' : ' text-muted' %>">Minimum confidence for prevent</label>
|
||||
<select name="minimum_confidence" class="col-sm-4 form-control custom-select" placeholder="Please Select" <%- use_openappsec ? '' : ' disabled' %>>
|
||||
<option value="critical" <%- minimum_confidence === 'critical' ? 'selected' : '' %>>Critical</option>
|
||||
<option value="high" <%- minimum_confidence === 'high' ? 'selected' : '' %>>High</option>
|
||||
<option value="medium" <%- minimum_confidence === 'medium' ? 'selected' : '' %>>Medium</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -33,6 +33,9 @@ module.exports = Mn.View.extend({
|
||||
certificate_select: 'select[name="certificate_id"]',
|
||||
access_list_select: 'select[name="access_list_id"]',
|
||||
ssl_forced: 'input[name="ssl_forced"]',
|
||||
use_openappsec: 'input[name="use_openappsec"]',
|
||||
openappsec_mode: 'select[name="openappsec_mode"]',
|
||||
minimum_confidence: 'select[name="minimum_confidence"]',
|
||||
hsts_enabled: 'input[name="hsts_enabled"]',
|
||||
hsts_subdomains: 'input[name="hsts_subdomains"]',
|
||||
http2_support: 'input[name="http2_support"]',
|
||||
@@ -75,6 +78,24 @@ module.exports = Mn.View.extend({
|
||||
inputs.trigger('change');
|
||||
},
|
||||
|
||||
'change @ui.use_openappsec': function () {
|
||||
let checked = this.ui.use_openappsec.prop('checked');
|
||||
this.ui.openappsec_mode
|
||||
.prop('disabled', !checked)
|
||||
.parents('.form-group')
|
||||
.css('opacity', checked ? 1 : 0.5);
|
||||
|
||||
this.ui.minimum_confidence
|
||||
.prop('disabled', !checked)
|
||||
.parents('.form-group')
|
||||
.css('opacity', checked ? 1 : 0.5);
|
||||
|
||||
/*** check this */
|
||||
if (!checked) {
|
||||
this.ui.openappsec_mode.prop('checked', false);
|
||||
}
|
||||
},
|
||||
|
||||
'change @ui.ssl_forced': function () {
|
||||
let checked = this.ui.ssl_forced.prop('checked');
|
||||
this.ui.hsts_enabled
|
||||
@@ -146,14 +167,32 @@ module.exports = Mn.View.extend({
|
||||
}
|
||||
|
||||
let view = this;
|
||||
let data = this.ui.form.serializeJSON();
|
||||
|
||||
// Add locations
|
||||
// enable openappsec inputs for serialization. if we don't do this, serialization of custom locations will be added to the root object instead of the missing root properties with the same name.
|
||||
|
||||
let topHostDisabledElements = this.ui.form.find('#details [name*="openappsec"]:disabled, [name="minimum_confidence"]:disabled');
|
||||
topHostDisabledElements.prop('disabled', false);
|
||||
let data = this.ui.form.serializeJSON();
|
||||
topHostDisabledElements.prop('disabled', true);
|
||||
|
||||
// Check if openappsec is enabled. serializeJSON() will only return its value attribute, not its checked attribute.
|
||||
let use_openappsec = this.ui.use_openappsec.prop('checked');
|
||||
data.use_openappsec = use_openappsec;
|
||||
|
||||
// Add locations using the model defined in file frontend/js/app/nginx/proxy/location.js and the template frontend/js/app/nginx/proxy/location-item.ejs.
|
||||
// input fields with the class 'model' will automatically update the model.
|
||||
data.locations = [];
|
||||
this.locationsCollection.models.forEach((location) => {
|
||||
data.locations.push(location.toJSON());
|
||||
});
|
||||
|
||||
// convert all "false" strings to false booleans in data.
|
||||
Object.keys(data).forEach(key => {
|
||||
if (typeof data[key] === 'string' && data[key].toLowerCase() === 'false') {
|
||||
data[key] = false;
|
||||
}
|
||||
});
|
||||
|
||||
// Serialize collects path from custom locations
|
||||
// This field must be removed from root object
|
||||
delete data.path;
|
||||
@@ -161,6 +200,7 @@ module.exports = Mn.View.extend({
|
||||
// Manipulate
|
||||
data.forward_port = parseInt(data.forward_port, 10);
|
||||
data.block_exploits = !!data.block_exploits;
|
||||
data.use_openappsec = !!data.use_openappsec;
|
||||
data.caching_enabled = !!data.caching_enabled;
|
||||
data.allow_websocket_upgrade = !!data.allow_websocket_upgrade;
|
||||
data.http2_support = !!data.http2_support;
|
||||
@@ -266,6 +306,7 @@ module.exports = Mn.View.extend({
|
||||
|
||||
this.ui.ssl_forced.trigger('change');
|
||||
this.ui.hsts_enabled.trigger('change');
|
||||
this.ui.use_openappsec.trigger('change');
|
||||
|
||||
// Domain names
|
||||
this.ui.domain_names.selectize({
|
||||
|
@@ -16,7 +16,7 @@
|
||||
<div class="col-auto">
|
||||
<div class="selectgroup">
|
||||
<label class="selectgroup-item">
|
||||
<input type="checkbox" class="selectgroup-input">
|
||||
<input id="advanced_config_toggle" type="checkbox" class="selectgroup-input">
|
||||
<span class="selectgroup-button">
|
||||
<i class="fe fe-settings"></i>
|
||||
</span>
|
||||
@@ -56,6 +56,41 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="my-3"/>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="custom-switch">
|
||||
<input type="checkbox" name="use_openappsec" id="use_openappsec" class="custom-switch-input" value="1"<%- use_openappsec ? ' checked' : '' %>>
|
||||
<span class="custom-switch-indicator"></span>
|
||||
<span class="custom-switch-description font-weight-bold">open-appsec</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-12">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-7 col-form-label <%- use_openappsec ? '' : ' text-muted' %>">Enforcement Mode</label>
|
||||
<select name="openappsec_mode" class="col-sm-4 form-control custom-select model" placeholder="Please Select" <%- use_openappsec ? '' : ' disabled' %>>
|
||||
<option value="detect-learn" <%- openappsec_mode === 'detect-learn' ? 'selected' : '' %>>Detect-Learn</option>
|
||||
<option value="prevent-learn" <%- openappsec_mode === 'prevent-learn' ? 'selected' : '' %>>Prevent-Learn</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-md-12">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-7 col-form-label <%- use_openappsec ? '' : ' text-muted' %>">Minimum confidence for prevent</label>
|
||||
<select name="minimum_confidence" class="col-sm-4 form-control custom-select model" placeholder="Please Select" <%- use_openappsec ? '' : ' disabled' %>>
|
||||
<option value="critical" <%- minimum_confidence === 'critical' ? 'selected' : '' %>>Critical</option>
|
||||
<option value="high" <%- minimum_confidence === 'high' ? 'selected' : '' %>>High</option>
|
||||
<option value="medium" <%- minimum_confidence === 'medium' ? 'selected' : '' %>>Medium</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="#" class="card-link location-delete">
|
||||
<i class="fa fa-trash"></i> <%- i18n('locations', 'delete') %>
|
||||
|
@@ -7,7 +7,10 @@ const LocationView = Mn.View.extend({
|
||||
className: 'location_block',
|
||||
|
||||
ui: {
|
||||
toggle: 'input[type="checkbox"]',
|
||||
use_openappsec: 'input[name="use_openappsec"]',
|
||||
openappsec_mode: 'select[name="openappsec_mode"]',
|
||||
minimum_confidence: 'select[name="minimum_confidence"]',
|
||||
toggle: 'input[type="checkbox"]#advanced_config_toggle',
|
||||
config: '.config',
|
||||
delete: '.location-delete'
|
||||
},
|
||||
@@ -21,6 +24,27 @@ const LocationView = Mn.View.extend({
|
||||
}
|
||||
},
|
||||
|
||||
'change @ui.use_openappsec': function () {
|
||||
let checked = this.ui.use_openappsec.prop('checked');
|
||||
this.model.set('use_openappsec', checked);
|
||||
|
||||
this.ui.openappsec_mode
|
||||
.prop('disabled', !checked)
|
||||
.parents('.form-group')
|
||||
.css('opacity', checked ? 1 : 0.5);
|
||||
|
||||
this.ui.minimum_confidence
|
||||
.prop('disabled', !checked)
|
||||
.parents('.form-group')
|
||||
.css('opacity', checked ? 1 : 0.5);
|
||||
|
||||
/*** check this */
|
||||
if (!checked) {
|
||||
this.ui.openappsec_mode.prop('checked', false);
|
||||
}
|
||||
},
|
||||
|
||||
// input fields with the class 'model' will automatically update the model.
|
||||
'change .model': function (e) {
|
||||
const map = {};
|
||||
map[e.target.name] = e.target.value;
|
||||
|
@@ -129,6 +129,7 @@ module.exports = Mn.View.extend({
|
||||
|
||||
// Manipulate
|
||||
data.block_exploits = !!data.block_exploits;
|
||||
data.use_openappsec = !!data.use_openappsec;
|
||||
data.preserve_path = !!data.preserve_path;
|
||||
data.http2_support = !!data.http2_support;
|
||||
data.hsts_enabled = !!data.hsts_enabled;
|
||||
|
Reference in New Issue
Block a user