mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Refactoring conditional directives for if wrappers, alternative if statements and incomplete if conditions.
This commit is contained in:
committed by
Felipe Zimmerle
parent
c373256d46
commit
3a7fdf8fc0
@@ -755,6 +755,9 @@ static const char *add_rule(cmd_parms *cmd, directory_config *dcfg, int type,
|
||||
char *rid = NULL;
|
||||
msre_rule *rule = NULL;
|
||||
extern msc_engine *modsecurity;
|
||||
int type_with_lua = 1;
|
||||
int type_rule;
|
||||
int rule_actionset;
|
||||
int offset = 0;
|
||||
|
||||
#ifdef DEBUG_CONF
|
||||
@@ -787,25 +790,25 @@ static const char *add_rule(cmd_parms *cmd, directory_config *dcfg, int type,
|
||||
}
|
||||
|
||||
/* Rules must have uniq ID */
|
||||
if (
|
||||
type_rule = (dcfg->tmp_chain_starter == NULL);
|
||||
#if defined(WITH_LUA)
|
||||
type != RULE_TYPE_LUA &&
|
||||
type_rule = (type != RULE_TYPE_LUA && type_rule);
|
||||
#endif
|
||||
(dcfg->tmp_chain_starter == NULL))
|
||||
if (type_rule)
|
||||
if(rule->actionset == NULL)
|
||||
return "ModSecurity: Rules must have at least id action";
|
||||
|
||||
if(rule->actionset != NULL && (dcfg->tmp_chain_starter == NULL)) {
|
||||
if(rule->actionset->id == NOT_SET_P
|
||||
rule_actionset = (rule->actionset->id == NOT_SET_P);
|
||||
#if defined(WITH_LUA)
|
||||
&& (type != RULE_TYPE_LUA)
|
||||
rule_actionset = (rule_actionset && (type != RULE_TYPE_LUA));
|
||||
#endif
|
||||
)
|
||||
return "ModSecurity: No action id present within the rule";
|
||||
if (rule_actionset)
|
||||
return "ModSecurity: No action id present within the rule";
|
||||
#if defined(WITH_LUA)
|
||||
if(type != RULE_TYPE_LUA)
|
||||
type_with_lua = (type != RULE_TYPE_LUA);
|
||||
#endif
|
||||
{
|
||||
if (type_with_lua){
|
||||
rid = apr_hash_get(dcfg->rule_id_htab, rule->actionset->id, APR_HASH_KEY_STRING);
|
||||
if(rid != NULL) {
|
||||
return "ModSecurity: Found another rule with the same id";
|
||||
|
@@ -1086,6 +1086,7 @@ static void hook_error_log(const char *file, int line, int level, apr_status_t s
|
||||
{
|
||||
modsec_rec *msr = NULL;
|
||||
error_message_t *em = NULL;
|
||||
int msr_ap_server;
|
||||
|
||||
#if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2
|
||||
if (info == NULL) return;
|
||||
@@ -1102,15 +1103,15 @@ static void hook_error_log(const char *file, int line, int level, apr_status_t s
|
||||
|
||||
/* Create a context for requests we never had the chance to process */
|
||||
#if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2
|
||||
if ((msr == NULL)
|
||||
msr_ap_server = ((msr == NULL)
|
||||
&& ((info->level & APLOG_LEVELMASK) < APLOG_DEBUG)
|
||||
&& apr_table_get(info->r->subprocess_env, "UNIQUE_ID"))
|
||||
&& apr_table_get(info->r->subprocess_env, "UNIQUE_ID"));
|
||||
#else
|
||||
if ((msr == NULL)
|
||||
msr_ap_server = ((msr == NULL)
|
||||
&& ((level & APLOG_LEVELMASK) < APLOG_DEBUG)
|
||||
&& apr_table_get(r->subprocess_env, "UNIQUE_ID"))
|
||||
&& apr_table_get(r->subprocess_env, "UNIQUE_ID"));
|
||||
#endif
|
||||
{
|
||||
if (msr_ap_server) {
|
||||
#if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER > 2
|
||||
msr = create_tx_context((request_rec *)info->r);
|
||||
#else
|
||||
|
@@ -432,6 +432,7 @@ AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg,
|
||||
apr_file_t *file = NULL;
|
||||
apr_finfo_t finfo;
|
||||
apr_status_t status;
|
||||
int exist_type;
|
||||
#ifdef DEBUG
|
||||
char buf[120];
|
||||
#endif
|
||||
@@ -457,13 +458,13 @@ AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg,
|
||||
if (status != APR_SUCCESS)
|
||||
return status;
|
||||
|
||||
if (finfo.filetype != APR_REG &&
|
||||
exist_type = (finfo.filetype != APR_REG);
|
||||
#if defined(WIN32) || defined(OS2) || defined(NETWARE)
|
||||
strcasecmp(apr_filepath_name_get(name), "nul") != 0) {
|
||||
exist_type = (exist_type && strcasecmp(apr_filepath_name_get(name), "nul") != 0);
|
||||
#else
|
||||
strcmp(name, "/dev/null") != 0) {
|
||||
exist_type = (exist_type && strcmp(name, "/dev/null") != 0);
|
||||
#endif /* WIN32 || OS2 */
|
||||
ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
|
||||
if (exist_type){ ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
|
||||
"Access to file %s denied by server: not a regular file",
|
||||
name);
|
||||
apr_file_close(file);
|
||||
|
Reference in New Issue
Block a user