@@ -97,6 +97,45 @@ function web_domain_autosub($field_name, $field_value, $validator) {
9797 $ result = $ this ->_check_unique ($ field_value . '. ' . $ check_domain , true );
9898 if (!$ result ) return $ this ->get_error ('domain_error_autosub ' );
9999 }
100+
101+ /* Check apache directives */
102+ function web_apache_directives ($ field_name , $ field_value , $ validator ) {
103+ global $ app ;
104+
105+ if (trim ($ field_value ) != '' ) {
106+ $ security_config = $ app ->getconf ->get_security_config ('ids ' );
107+
108+ if ($ security_config ['apache_directives_scan_enabled ' ] == 'yes ' ) {
109+
110+ // Get blacklist
111+ $ blacklist_path = '/usr/local/ispconfig/security/apache_directives.blacklist ' ;
112+ if (is_file ('/usr/local/ispconfig/security/apache_directives.blacklist.custom ' )) $ blacklist_path = '/usr/local/ispconfig/security/apache_directives.blacklist.custom ' ;
113+ if (!is_file ($ blacklist_path )) $ blacklist_path = realpath (ISPC_ROOT_PATH .'/../security/apache_directives.blacklist ' );
114+
115+ $ directives = explode ("\n" ,$ field_value );
116+ $ regex = explode ("\n" ,file_get_contents ($ blacklist_path ));
117+ $ blocked = false ;
118+ $ blocked_line = '' ;
119+
120+ if (is_array ($ directives ) && is_array ($ regex )) {
121+ foreach ($ directives as $ directive ) {
122+ $ directive = trim ($ directive );
123+ foreach ($ regex as $ r ) {
124+ if (preg_match (trim ($ r ),$ directive )) {
125+ $ blocked = true ;
126+ $ blocked_line = $ directive ;
127+ };
128+ }
129+ }
130+ }
131+ }
132+ }
133+
134+ if ($ blocked === true ) {
135+ return $ this ->get_error ('apache_directive_blocked_error ' ).' ' .$ blocked_line ;
136+ }
137+ }
138+
100139
101140 /* internal validator function to match regexp */
102141 function _regex_validate ($ domain_name , $ allow_wildcard = false ) {
@@ -175,5 +214,6 @@ function _wildcard_limit() {
175214 }
176215 return true ; // admin may always add wildcard domain
177216 }
217+
178218
179219}
0 commit comments