Skip to content

Commit f45cfd8

Browse files
author
Till Brehm
committed
Implemented #4872 Extend Apache and Nginx Excludes list
1 parent b0f89e5 commit f45cfd8

30 files changed

+73
-1
lines changed

interface/lib/classes/validate_domain.inc.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,44 @@ function web_apache_directives($field_name, $field_value, $validator) {
141141
}
142142
}
143143

144+
/* Check nginx directives */
145+
function web_nginx_directives($field_name, $field_value, $validator) {
146+
global $app;
147+
148+
if(trim($field_value) != '') {
149+
$security_config = $app->getconf->get_security_config('ids');
150+
151+
if($security_config['nginx_directives_scan_enabled'] == 'yes') {
152+
153+
// Get blacklist
154+
$blacklist_path = '/usr/local/ispconfig/security/nginx_directives.blacklist';
155+
if(is_file('/usr/local/ispconfig/security/nginx_directives.blacklist.custom')) $blacklist_path = '/usr/local/ispconfig/security/nginx_directives.blacklist.custom';
156+
if(!is_file($blacklist_path)) $blacklist_path = realpath(ISPC_ROOT_PATH.'/../security/nginx_directives.blacklist');
157+
158+
$directives = explode("\n",$field_value);
159+
$regex = explode("\n",file_get_contents($blacklist_path));
160+
$blocked = false;
161+
$blocked_line = '';
162+
163+
if(is_array($directives) && is_array($regex)) {
164+
foreach($directives as $directive) {
165+
$directive = trim($directive);
166+
foreach($regex as $r) {
167+
if(preg_match(trim($r),$directive)) {
168+
$blocked = true;
169+
$blocked_line .= $directive.'<br />';
170+
};
171+
}
172+
}
173+
}
174+
}
175+
}
176+
177+
if($blocked === true) {
178+
return $this->get_error('nginx_directive_blocked_error').' '.$blocked_line;
179+
}
180+
}
181+
144182

145183
/* internal validator function to match regexp */
146184
function _regex_validate($domain_name, $allow_wildcard = false) {

interface/web/sites/form/web_vhost_domain.tform.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,13 @@
859859
'nginx_directives' => array (
860860
'datatype' => 'TEXT',
861861
'formtype' => 'TEXT',
862+
'validators' => array ( 0 => array(
863+
'type' => 'CUSTOM',
864+
'class' => 'validate_domain',
865+
'function' => 'web_nginx_directives',
866+
'errmsg' => 'nginx_directive_blockd_error'
867+
),
868+
),
862869
'default' => '',
863870
'value' => '',
864871
'width' => '30',

interface/web/sites/lib/lang/ar_web_domain.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ $wb['http_port_txt'] = 'HTTP Port';
133133
$wb['https_port_txt'] = 'HTTPS Port';
134134
$wb['http_port_error_regex'] = 'HTTP Port invalid.';
135135
$wb['https_port_error_regex'] = 'HTTPS Port invalid.';
136+
$wb['nginx_directive_blocked_error'] = 'Nginx directive blocked by security settings:';
136137
?>

interface/web/sites/lib/lang/bg_web_domain.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ $wb['http_port_txt'] = 'HTTP Port';
133133
$wb['https_port_txt'] = 'HTTPS Port';
134134
$wb['http_port_error_regex'] = 'HTTP Port invalid.';
135135
$wb['https_port_error_regex'] = 'HTTPS Port invalid.';
136+
$wb['nginx_directive_blocked_error'] = 'Nginx directive blocked by security settings:';
136137
?>

interface/web/sites/lib/lang/br_web_domain.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ $wb['http_port_txt'] = 'Porta HTTP';
133133
$wb['https_port_txt'] = 'Porta HTTPS';
134134
$wb['http_port_error_regex'] = 'Porta HTTP inválida.';
135135
$wb['https_port_error_regex'] = 'Porta HTTPS inválida.';
136+
$wb['nginx_directive_blocked_error'] = 'Nginx directive blocked by security settings:';
136137
?>

interface/web/sites/lib/lang/ca_web_domain.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ $wb['http_port_txt'] = 'HTTP Port';
133133
$wb['https_port_txt'] = 'HTTPS Port';
134134
$wb['http_port_error_regex'] = 'HTTP Port invalid.';
135135
$wb['https_port_error_regex'] = 'HTTPS Port invalid.';
136+
$wb['nginx_directive_blocked_error'] = 'Nginx directive blocked by security settings:';
136137
?>

interface/web/sites/lib/lang/cz_web_domain.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ $wb['http_port_txt'] = 'HTTP Port';
133133
$wb['https_port_txt'] = 'HTTPS Port';
134134
$wb['http_port_error_regex'] = 'HTTP Port invalid.';
135135
$wb['https_port_error_regex'] = 'HTTPS Port invalid.';
136+
$wb['nginx_directive_blocked_error'] = 'Nginx directive blocked by security settings:';
136137
?>

interface/web/sites/lib/lang/de_web_domain.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ $wb['http_port_txt'] = 'HTTP Port';
133133
$wb['https_port_txt'] = 'HTTPS Port';
134134
$wb['http_port_error_regex'] = 'HTTP Port invalid.';
135135
$wb['https_port_error_regex'] = 'HTTPS Port invalid.';
136+
$wb['nginx_directive_blocked_error'] = 'Nginx directive blocked by security settings:';
136137
?>

interface/web/sites/lib/lang/dk_web_domain.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ $wb['http_port_txt'] = 'HTTP Port';
133133
$wb['https_port_txt'] = 'HTTPS Port';
134134
$wb['http_port_error_regex'] = 'HTTP Port invalid.';
135135
$wb['https_port_error_regex'] = 'HTTPS Port invalid.';
136+
$wb['nginx_directive_blocked_error'] = 'Nginx directive blocked by security settings:';
136137
?>

interface/web/sites/lib/lang/el_web_domain.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ $wb['http_port_txt'] = 'HTTP Port';
133133
$wb['https_port_txt'] = 'HTTPS Port';
134134
$wb['http_port_error_regex'] = 'HTTP Port invalid.';
135135
$wb['https_port_error_regex'] = 'HTTPS Port invalid.';
136+
$wb['nginx_directive_blocked_error'] = 'Nginx directive blocked by security settings:';
136137
?>

0 commit comments

Comments
 (0)