mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-16 07:56:12 +03:00
Changed %p formatter to APRs %pp (wish that was documented).
Marked msr_log() as a printf style function so GNU compiler can check formatting types. Fixed a few other warnings with msr_log() formatters.
This commit is contained in:
parent
9447ae67b8
commit
e47fdeb420
@ -82,7 +82,7 @@ char DSOLOCAL *get_env_var(request_rec *r, char *name);
|
|||||||
void DSOLOCAL internal_log(request_rec *r, directory_config *dcfg, modsec_rec *msr,
|
void DSOLOCAL internal_log(request_rec *r, directory_config *dcfg, modsec_rec *msr,
|
||||||
int level, const char *text, va_list ap);
|
int level, const char *text, va_list ap);
|
||||||
|
|
||||||
void DSOLOCAL msr_log(modsec_rec *msr, int level, const char *text, ...);
|
void DSOLOCAL msr_log(modsec_rec *msr, int level, const char *text, ...) PRINTF_ATTRIBUTE(3,4);
|
||||||
|
|
||||||
char DSOLOCAL *format_error_log_message(apr_pool_t *mp, error_message *em);
|
char DSOLOCAL *format_error_log_message(apr_pool_t *mp, error_message *em);
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
|
|||||||
|
|
||||||
if ((msr->if_status == IF_STATUS_COMPLETE)||(msr->if_status == IF_STATUS_NONE)) {
|
if ((msr->if_status == IF_STATUS_COMPLETE)||(msr->if_status == IF_STATUS_NONE)) {
|
||||||
if (msr->txcfg->debuglog_level >= 4) {
|
if (msr->txcfg->debuglog_level >= 4) {
|
||||||
msr_log(msr, 4, "Input filter: Input forwarding already complete, skipping (f %p, r %p).", f, f->r);
|
msr_log(msr, 4, "Input filter: Input forwarding already complete, skipping (f %pp, r %pp).", f, f->r);
|
||||||
}
|
}
|
||||||
ap_remove_input_filter(f);
|
ap_remove_input_filter(f);
|
||||||
return ap_get_brigade(f->next, bb_out, mode, block, nbytes);
|
return ap_get_brigade(f->next, bb_out, mode, block, nbytes);
|
||||||
@ -56,7 +56,7 @@ apr_status_t input_filter(ap_filter_t *f, apr_bucket_brigade *bb_out,
|
|||||||
|
|
||||||
if (msr->txcfg->debuglog_level >= 4) {
|
if (msr->txcfg->debuglog_level >= 4) {
|
||||||
msr_log(msr, 4, "Input filter: Forwarding input: mode=%d, block=%d, nbytes=%" APR_OFF_T_FMT
|
msr_log(msr, 4, "Input filter: Forwarding input: mode=%d, block=%d, nbytes=%" APR_OFF_T_FMT
|
||||||
" (f %p, r %p).", mode, block, nbytes, f, f->r);
|
" (f %pp, r %pp).", mode, block, nbytes, f, f->r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msr->if_started_forwarding == 0) {
|
if (msr->if_started_forwarding == 0) {
|
||||||
@ -483,7 +483,7 @@ apr_status_t output_filter(ap_filter_t *f, apr_bucket_brigade *bb_in) {
|
|||||||
msr->r = r;
|
msr->r = r;
|
||||||
|
|
||||||
if (msr->txcfg->debuglog_level >= 4) {
|
if (msr->txcfg->debuglog_level >= 4) {
|
||||||
msr_log(msr, 4, "Output filter: Receiving output (f %p, r %p).", f, f->r);
|
msr_log(msr, 4, "Output filter: Receiving output (f %pp, r %pp).", f, f->r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise on first invocation */
|
/* Initialise on first invocation */
|
||||||
|
@ -246,7 +246,7 @@ void internal_log(request_rec *r, directory_config *dcfg, modsec_rec *msr,
|
|||||||
|
|
||||||
/* Construct the message. */
|
/* Construct the message. */
|
||||||
apr_vsnprintf(str1, sizeof(str1), text, ap);
|
apr_vsnprintf(str1, sizeof(str1), text, ap);
|
||||||
apr_snprintf(str2, sizeof(str2), "[%s] [%s/sid#%p][rid#%p][%s][%d] %s\n",
|
apr_snprintf(str2, sizeof(str2), "[%s] [%s/sid#%pp][rid#%pp][%s][%d] %s\n",
|
||||||
current_logtime(msr->mp), ap_get_server_name(r), (r->server),
|
current_logtime(msr->mp), ap_get_server_name(r), (r->server),
|
||||||
r, ((r->uri == NULL) ? "" : log_escape_nq(msr->mp, r->uri)),
|
r, ((r->uri == NULL) ? "" : log_escape_nq(msr->mp, r->uri)),
|
||||||
level, str1);
|
level, str1);
|
||||||
|
@ -348,7 +348,7 @@ static modsec_rec *create_tx_context(request_rec *r) {
|
|||||||
store_tx_context(msr, r);
|
store_tx_context(msr, r);
|
||||||
|
|
||||||
if (msr->txcfg->debuglog_level >= 4) {
|
if (msr->txcfg->debuglog_level >= 4) {
|
||||||
msr_log(msr, 4, "Transaction context created (dcfg %p).", msr->dcfg1);
|
msr_log(msr, 4, "Transaction context created (dcfg %pp).", msr->dcfg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return msr;
|
return msr;
|
||||||
@ -629,7 +629,7 @@ static int hook_request_late(request_rec *r) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msr->txcfg->debuglog_level >= 4) {
|
if (msr->txcfg->debuglog_level >= 4) {
|
||||||
msr_log(msr, 4, "Second phase starting (dcfg %p).", msr->dcfg2);
|
msr_log(msr, 4, "Second phase starting (dcfg %pp).", msr->dcfg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Figure out whether or not to extract multipart files. */
|
/* Figure out whether or not to extract multipart files. */
|
||||||
@ -899,7 +899,7 @@ static void hook_insert_filter(request_rec *r) {
|
|||||||
/* Add the input filter, but only if we need it to run. */
|
/* Add the input filter, but only if we need it to run. */
|
||||||
if (msr->if_status == IF_STATUS_WANTS_TO_RUN) {
|
if (msr->if_status == IF_STATUS_WANTS_TO_RUN) {
|
||||||
if (msr->txcfg->debuglog_level >= 4) {
|
if (msr->txcfg->debuglog_level >= 4) {
|
||||||
msr_log(msr, 4, "Hook insert_filter: Adding input forwarding filter %s(r %p).", (((r->main != NULL)||(r->prev != NULL)) ? "for subrequest " : ""), r);
|
msr_log(msr, 4, "Hook insert_filter: Adding input forwarding filter %s(r %pp).", (((r->main != NULL)||(r->prev != NULL)) ? "for subrequest " : ""), r);
|
||||||
}
|
}
|
||||||
|
|
||||||
ap_add_input_filter("MODSECURITY_IN", msr, r, r->connection);
|
ap_add_input_filter("MODSECURITY_IN", msr, r, r->connection);
|
||||||
@ -914,7 +914,7 @@ static void hook_insert_filter(request_rec *r) {
|
|||||||
|
|
||||||
/* We always add the PDF XSS protection filter. */
|
/* We always add the PDF XSS protection filter. */
|
||||||
if (msr->txcfg->debuglog_level >= 4) {
|
if (msr->txcfg->debuglog_level >= 4) {
|
||||||
msr_log(msr, 4, "Hook insert_filter: Adding PDF XSS protection output filter (r %p).", r);
|
msr_log(msr, 4, "Hook insert_filter: Adding PDF XSS protection output filter (r %pp).", r);
|
||||||
}
|
}
|
||||||
|
|
||||||
ap_add_output_filter("PDFP_OUT", msr, r, r->connection);
|
ap_add_output_filter("PDFP_OUT", msr, r, r->connection);
|
||||||
@ -934,7 +934,7 @@ static void hook_insert_filter(request_rec *r) {
|
|||||||
*/
|
*/
|
||||||
if (msr->of_status != OF_STATUS_COMPLETE) {
|
if (msr->of_status != OF_STATUS_COMPLETE) {
|
||||||
if (msr->txcfg->debuglog_level >= 4) {
|
if (msr->txcfg->debuglog_level >= 4) {
|
||||||
msr_log(msr, 4, "Hook insert_filter: Adding output filter (r %p).", r);
|
msr_log(msr, 4, "Hook insert_filter: Adding output filter (r %pp).", r);
|
||||||
}
|
}
|
||||||
|
|
||||||
ap_add_output_filter("MODSECURITY_OUT", msr, r, r->connection);
|
ap_add_output_filter("MODSECURITY_OUT", msr, r, r->connection);
|
||||||
@ -967,7 +967,7 @@ static void hook_insert_error_filter(request_rec *r) {
|
|||||||
*/
|
*/
|
||||||
if (msr->of_status != OF_STATUS_COMPLETE) {
|
if (msr->of_status != OF_STATUS_COMPLETE) {
|
||||||
if (msr->txcfg->debuglog_level >= 4) {
|
if (msr->txcfg->debuglog_level >= 4) {
|
||||||
msr_log(msr, 4, "Hook insert_error_filter: Adding output filter (r %p).", r);
|
msr_log(msr, 4, "Hook insert_error_filter: Adding output filter (r %pp).", r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make a note that the output we will be receiving is a
|
/* Make a note that the output we will be receiving is a
|
||||||
|
@ -30,6 +30,11 @@ typedef struct msc_string msc_string;
|
|||||||
#define DSOLOCAL
|
#define DSOLOCAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* For GNU C, tell the compiler to check printf like formatters */
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define PRINTF_ATTRIBUTE(a,b) __attribute__((format (printf, a, b)))
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "msc_logging.h"
|
#include "msc_logging.h"
|
||||||
#include "msc_multipart.h"
|
#include "msc_multipart.h"
|
||||||
#include "msc_pcre.h"
|
#include "msc_pcre.h"
|
||||||
|
@ -316,7 +316,7 @@ int geo_lookup(modsec_rec *msr, geo_rec *georec, const char *target, char **erro
|
|||||||
/* Why is this in host byte order? */
|
/* Why is this in host byte order? */
|
||||||
ipnum = ntohl(addr->sa.sin.sin_addr.s_addr);
|
ipnum = ntohl(addr->sa.sin.sin_addr.s_addr);
|
||||||
|
|
||||||
msr_log(msr, 9, "GEO: Using address \"%s\" (0x%08x).", targetip, ipnum);
|
msr_log(msr, 9, "GEO: Using address \"%s\" (0x%08lx).", targetip, ipnum);
|
||||||
|
|
||||||
for (level = 31; level >= 0; level--) {
|
for (level = 31; level >= 0; level--) {
|
||||||
|
|
||||||
|
@ -921,14 +921,14 @@ void sec_audit_logger(modsec_rec *msr) {
|
|||||||
|
|
||||||
nbytes = strlen(text);
|
nbytes = strlen(text);
|
||||||
if (msr->txcfg->debuglog_level >= 9) {
|
if (msr->txcfg->debuglog_level >= 9) {
|
||||||
msr_log(msr, 9, "Audit Log: Writing %d bytes to primary concurrent index", nbytes);
|
msr_log(msr, 9, "Audit Log: Writing %" APR_SIZE_T_FMT " bytes to primary concurrent index", nbytes);
|
||||||
}
|
}
|
||||||
apr_file_write_full(msr->txcfg->auditlog_fd, text, nbytes, &nbytes_written);
|
apr_file_write_full(msr->txcfg->auditlog_fd, text, nbytes, &nbytes_written);
|
||||||
|
|
||||||
/* Write to the secondary audit log if we have one */
|
/* Write to the secondary audit log if we have one */
|
||||||
if (msr->txcfg->auditlog2_fd != NULL) {
|
if (msr->txcfg->auditlog2_fd != NULL) {
|
||||||
if (msr->txcfg->debuglog_level >= 9) {
|
if (msr->txcfg->debuglog_level >= 9) {
|
||||||
msr_log(msr, 9, "Audit Log: Writing %d bytes to secondary concurrent index", nbytes);
|
msr_log(msr, 9, "Audit Log: Writing %" APR_SIZE_T_FMT " bytes to secondary concurrent index", nbytes);
|
||||||
}
|
}
|
||||||
apr_file_write_full(msr->txcfg->auditlog2_fd, text, nbytes, &nbytes_written);
|
apr_file_write_full(msr->txcfg->auditlog2_fd, text, nbytes, &nbytes_written);
|
||||||
}
|
}
|
||||||
|
@ -520,7 +520,7 @@ static int multipart_process_boundary(modsec_rec *msr, int last_part, char **err
|
|||||||
*(multipart_part **)apr_array_push(msr->mpd->parts) = msr->mpd->mpp;
|
*(multipart_part **)apr_array_push(msr->mpd->parts) = msr->mpd->mpp;
|
||||||
if (msr->mpd->mpp->type == MULTIPART_FILE) {
|
if (msr->mpd->mpp->type == MULTIPART_FILE) {
|
||||||
if (msr->txcfg->debuglog_level >= 9) {
|
if (msr->txcfg->debuglog_level >= 9) {
|
||||||
msr_log(msr, 9, "Multipart: Added file part %p to the list: name \"%s\" "
|
msr_log(msr, 9, "Multipart: Added file part %pp to the list: name \"%s\" "
|
||||||
"file name \"%s\" (offset %u, length %u)",
|
"file name \"%s\" (offset %u, length %u)",
|
||||||
msr->mpd->mpp, log_escape(msr->mp, msr->mpd->mpp->name),
|
msr->mpd->mpp, log_escape(msr->mp, msr->mpd->mpp->name),
|
||||||
log_escape(msr->mp, msr->mpd->mpp->filename),
|
log_escape(msr->mp, msr->mpd->mpp->filename),
|
||||||
@ -529,7 +529,7 @@ static int multipart_process_boundary(modsec_rec *msr, int last_part, char **err
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (msr->txcfg->debuglog_level >= 9) {
|
if (msr->txcfg->debuglog_level >= 9) {
|
||||||
msr_log(msr, 9, "Multipart: Added part %p to the list: name \"%s\" "
|
msr_log(msr, 9, "Multipart: Added part %pp to the list: name \"%s\" "
|
||||||
"(offset %u, length %u)", msr->mpd->mpp, log_escape(msr->mp, msr->mpd->mpp->name),
|
"(offset %u, length %u)", msr->mpd->mpp, log_escape(msr->mp, msr->mpd->mpp->name),
|
||||||
msr->mpd->mpp->offset, msr->mpd->mpp->length);
|
msr->mpd->mpp->offset, msr->mpd->mpp->length);
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ static apr_status_t modsecurity_request_body_store_memory(modsec_rec *msr,
|
|||||||
msr->msc_reqbody_chunks = NULL;
|
msr->msc_reqbody_chunks = NULL;
|
||||||
apr_pool_clear(msr->msc_reqbody_mp);
|
apr_pool_clear(msr->msc_reqbody_mp);
|
||||||
|
|
||||||
msr_log(msr, 4, "Input filter: Wrote %" APR_SIZE_T_FMT " bytes from memory to disk.", disklen);
|
msr_log(msr, 4, "Input filter: Wrote %u bytes from memory to disk.", disklen);
|
||||||
|
|
||||||
/* Continue with disk storage from now on */
|
/* Continue with disk storage from now on */
|
||||||
return modsecurity_request_body_store_disk(msr, data, length, error_msg);
|
return modsecurity_request_body_store_disk(msr, data, length, error_msg);
|
||||||
|
@ -782,7 +782,7 @@ apr_status_t msre_ruleset_process_phase(msre_ruleset *ruleset, modsec_rec *msr)
|
|||||||
if (rule->actionset != NULL && rule->actionset->rev != NULL) {
|
if (rule->actionset != NULL && rule->actionset->rev != NULL) {
|
||||||
rev = apr_psprintf(p, " [rev \"%s\"]", rule->actionset->rev);
|
rev = apr_psprintf(p, " [rev \"%s\"]", rule->actionset->rev);
|
||||||
}
|
}
|
||||||
msr_log(msr, 4, "Recipe: Invoking rule %p;%s%s%s.",
|
msr_log(msr, 4, "Recipe: Invoking rule %pp;%s%s%s.",
|
||||||
rule, (fn ? fn : ""), (id ? id : ""), (rev ? rev : ""));
|
rule, (fn ? fn : ""), (id ? id : ""), (rev ? rev : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -935,7 +935,7 @@ apr_status_t msre_ruleset_process_phase(msre_ruleset *ruleset, modsec_rec *msr)
|
|||||||
rules = (msre_rule **)arr->elts;
|
rules = (msre_rule **)arr->elts;
|
||||||
for (i = 0; i < arr->nelts; i++) {
|
for (i = 0; i < arr->nelts; i++) {
|
||||||
msre_rule *rule = rules[i];
|
msre_rule *rule = rules[i];
|
||||||
msr_log(msr, 1, "Rule %p [id \"%s\"][file \"%s\"][line \"%d\"]: %lu usec", rule,
|
msr_log(msr, 1, "Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"]: %lu usec", rule,
|
||||||
((rule->actionset != NULL)&&(rule->actionset->id != NULL)) ? rule->actionset->id : "-",
|
((rule->actionset != NULL)&&(rule->actionset->id != NULL)) ? rule->actionset->id : "-",
|
||||||
rule->filename != NULL ? rule->filename : "-",
|
rule->filename != NULL ? rule->filename : "-",
|
||||||
rule->line_num,
|
rule->line_num,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user