mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Generate error messages when registration fails. Change all examples to use modsecurity.h to avoid the duplication of the optional function declarations.
This commit is contained in:
parent
c60ab6bfda
commit
ce106df275
@ -6,7 +6,8 @@ ModSecurity without having to touch it directly, simply
|
||||
by creating custom Apache modules.
|
||||
|
||||
NOTE: ModSecurity must be compiled with API support
|
||||
to use this feature (do not use -DNO_MODSEC_API).
|
||||
to use this feature (the API is enabled by default,
|
||||
but it will have been disabled if you used -DNO_MODSEC_API).
|
||||
|
||||
|
||||
Building the Example Custom Modules
|
||||
@ -18,8 +19,9 @@ Module mod_tfn_reverse.c creates a custom transformation
|
||||
function "reverse" that reverses the content it receives
|
||||
on input.
|
||||
|
||||
# Compile as a normal user
|
||||
apxs -ca mod_tfn_reverse.c
|
||||
# Compile as a normal user
|
||||
apxs -I<MODSECURITY_SOURCE_CODE> -I/usr/include/libxml2 \
|
||||
-ca mod_tfn_reverse.c
|
||||
|
||||
# Install as superuser
|
||||
sudo apxs -i mod_tfn_reverse.la
|
||||
@ -31,9 +33,6 @@ Module mod_op_strstr.c creates a custom operator "strstr"
|
||||
that implements fast matching using the Boyer-Moore-Horspool
|
||||
algorithm.
|
||||
|
||||
Compiling this module is more involved because it requires
|
||||
access to ModSecurity structures.
|
||||
|
||||
# Compile as a normal user
|
||||
apxs -I<MODSECURITY_SOURCE_CODE> -I/usr/include/libxml2 \
|
||||
-ca mod_op_strstr.c
|
||||
@ -47,9 +46,6 @@ access to ModSecurity structures.
|
||||
Module mod_var_remote_addr_port.c creates a custom variable "REMOTE_ADDR_PORT"
|
||||
that combines the REMOTE_ADDR and REMOTE_PORT into a.b.c.d:port format.
|
||||
|
||||
Compiling this module is more involved because it requires
|
||||
access to ModSecurity structures.
|
||||
|
||||
# Compile as a normal user
|
||||
apxs -I<MODSECURITY_SOURCE_CODE> -I/usr/include/libxml2 \
|
||||
-ca mod_var_remote_addr_port.c
|
||||
|
@ -87,6 +87,9 @@ static int hook_pre_config(apr_pool_t *mp, apr_pool_t *mp_log, apr_pool_t *mp_te
|
||||
* name "reverse".
|
||||
*/
|
||||
fn("strstr", (void *)op_strstr_init, (void *)op_strstr_exec);
|
||||
} else {
|
||||
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, NULL,
|
||||
"mod_op_strstr: Unable to find modsec_register_operator.");
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
@ -7,9 +7,7 @@
|
||||
#include "ap_config.h"
|
||||
#include "apr_optional.h"
|
||||
|
||||
/* Must be declared if modsecurity.h is not included */
|
||||
APR_DECLARE_OPTIONAL_FN(void, modsec_register_tfn, (const char *name, void *fn));
|
||||
|
||||
#include "modsecurity.h"
|
||||
|
||||
/**
|
||||
* This function will be invoked by
|
||||
@ -66,6 +64,9 @@ static int hook_pre_config(apr_pool_t *mp, apr_pool_t *mp_log, apr_pool_t *mp_te
|
||||
* name "reverse".
|
||||
*/
|
||||
fn("reverse", (void *)reverse);
|
||||
} else {
|
||||
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, NULL,
|
||||
"mod_tfn_reverse: Unable to find modsec_register_tfn.");
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "ap_config.h"
|
||||
#include "apr_optional.h"
|
||||
|
||||
#include "re.h"
|
||||
#include "modsecurity.h"
|
||||
|
||||
/* -- Generic generators/validators from re_variables.c -- */
|
||||
|
||||
@ -77,6 +77,9 @@ static int hook_pre_config(apr_pool_t *mp, apr_pool_t *mp_log, apr_pool_t *mp_te
|
||||
VAR_DONT_CACHE,
|
||||
PHASE_REQUEST_HEADERS
|
||||
);
|
||||
} else {
|
||||
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, NULL,
|
||||
"mod_var_remote_addr_port: Unable to find modsec_register_variable.");
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user