Skip to content

Option to disable logging of log producer (2nd try) #1400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
DD MMM YYYY - 2.9.2 - To be released
------------------------------------

* {dis|en}able-server-context-logging: Option to disable logging of
server info (log producer, sanitized objects, ...) in audit log.
[Issue #1069 - Marc Stern]
* Allow drop to work with mod_http2
[Issue #1308, #992 - @bazzadp]
* Fix SecConn(Read|Write)StateLimit on Apache 2.4
Expand Down
14 changes: 13 additions & 1 deletion apache2/msc_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,9 @@ void sec_audit_logger_json(modsec_rec *msr) {
yajl_kv_bool(g, "response_body_dechunked", 1);
}

#ifdef LOG_NO_SERVER_CONTEXT
if (msr->txcfg->debuglog_level >= 9) {
#endif
sec_auditlog_write_producer_header_json(msr, g);

/* Server */
Expand Down Expand Up @@ -1274,6 +1277,9 @@ void sec_audit_logger_json(modsec_rec *msr) {
if (been_opened == 1) {
yajl_gen_map_close(g); // sanitized args map is finished
}
#ifdef LOG_NO_SERVER_CONTEXT
}
#endif

/* Web application info. */
if ( ((msr->txcfg->webappid != NULL)&&(strcmp(msr->txcfg->webappid, "default") != 0))
Expand Down Expand Up @@ -2022,6 +2028,9 @@ void sec_audit_logger_native(modsec_rec *msr) {
sec_auditlog_write(msr, text, strlen(text));
}

#ifdef LOG_NO_SERVER_CONTEXT
if (msr->txcfg->debuglog_level >= 9) {
#endif
sec_auditlog_write_producer_header(msr);

/* Server */
Expand Down Expand Up @@ -2090,8 +2099,11 @@ void sec_audit_logger_native(modsec_rec *msr) {
sec_auditlog_write(msr, text, strlen(text));
}
}
#ifdef LOG_NO_SERVER_CONTEXT
}
#endif

/* Web application info. */
/* Web application info. */
if ( ((msr->txcfg->webappid != NULL)&&(strcmp(msr->txcfg->webappid, "default") != 0))
|| (msr->sessionid != NULL) || (msr->userid != NULL))
{
Expand Down
15 changes: 14 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,19 @@ AC_ARG_ENABLE(handler-logging,
log_handler=''
])

# Disable logging of server context
AC_ARG_ENABLE(server-context-logging,
AS_HELP_STRING([--enable-server-context-logging],
[Enable logging of server info (log producer, sanitized objects, ...) in audit log when log level < 9. This is the default]),
[
if test "$enableval" != "no"; then
log_server_context=
else
log_server_context="-DLOG_NO_SERVER_CONTEXT"
fi
],
[
log_server_context=''
# Disable logging of dechunking
AC_ARG_ENABLE(dechunk-logging,
AS_HELP_STRING([--enable-dechunk-logging],
Expand Down Expand Up @@ -767,7 +780,7 @@ else
fi
fi

MODSEC_EXTRA_CFLAGS="$pcre_study $pcre_match_limit $pcre_match_limit_recursion $pcre_jit $request_early $htaccess_config $lua_cache $debug_conf $debug_cache $debug_acmp $debug_mem $perf_meas $modsec_api $cpu_type $unique_id $log_filename $log_server $log_collection_delete_problem $log_dechunk $log_stopwatch $log_handler"
MODSEC_EXTRA_CFLAGS="$pcre_study $pcre_match_limit $pcre_match_limit_recursion $pcre_jit $request_early $htaccess_config $lua_cache $debug_conf $debug_cache $debug_acmp $debug_mem $perf_meas $modsec_api $cpu_type $unique_id $log_filename $log_server $log_collection_delete_problem $log_dechunk $log_stopwatch $log_handler $log_server_context"

APXS_WRAPPER=build/apxs-wrapper
APXS_EXTRA_CFLAGS=""
Expand Down