mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Do not compile in JSON logging support if yajl is not found
This commit is contained in:
committed by
Felipe Zimmerle
parent
0c95a7a2cd
commit
5bc75ec871
@@ -73,7 +73,9 @@ void *create_directory_config(apr_pool_t *mp, char *path)
|
||||
/* audit log variables */
|
||||
dcfg->auditlog_flag = NOT_SET;
|
||||
dcfg->auditlog_type = NOT_SET;
|
||||
#ifdef WITH_YAJL
|
||||
dcfg->auditlog_format = NOT_SET;
|
||||
#endif
|
||||
dcfg->max_rule_time = NOT_SET;
|
||||
dcfg->auditlog_dirperms = NOT_SET;
|
||||
dcfg->auditlog_fileperms = NOT_SET;
|
||||
@@ -504,8 +506,10 @@ void *merge_directory_configs(apr_pool_t *mp, void *_parent, void *_child)
|
||||
merged->auditlog2_fd = parent->auditlog2_fd;
|
||||
merged->auditlog2_name = parent->auditlog2_name;
|
||||
}
|
||||
#ifdef WITH_YAJL
|
||||
merged->auditlog_format = (child->auditlog_format == NOT_SET
|
||||
? parent->auditlog_format : child->auditlog_format);
|
||||
#endif
|
||||
merged->auditlog_storage_dir = (child->auditlog_storage_dir == NOT_SET_P
|
||||
? parent->auditlog_storage_dir : child->auditlog_storage_dir);
|
||||
merged->auditlog_parts = (child->auditlog_parts == NOT_SET_P
|
||||
@@ -670,7 +674,9 @@ void init_directory_config(directory_config *dcfg)
|
||||
/* audit log variables */
|
||||
if (dcfg->auditlog_flag == NOT_SET) dcfg->auditlog_flag = 0;
|
||||
if (dcfg->auditlog_type == NOT_SET) dcfg->auditlog_type = AUDITLOG_SERIAL;
|
||||
#ifdef WITH_YAJL
|
||||
if (dcfg->auditlog_format == NOT_SET) dcfg->auditlog_format = AUDITLOGFORMAT_NATIVE;
|
||||
#endif
|
||||
if (dcfg->max_rule_time == NOT_SET) dcfg->max_rule_time = 0;
|
||||
if (dcfg->auditlog_dirperms == NOT_SET) dcfg->auditlog_dirperms = CREATEMODE_DIR;
|
||||
if (dcfg->auditlog_fileperms == NOT_SET) dcfg->auditlog_fileperms = CREATEMODE;
|
||||
@@ -1295,6 +1301,7 @@ static const char *cmd_audit_log_type(cmd_parms *cmd, void *_dcfg,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef WITH_YAJL
|
||||
static const char *cmd_audit_log_mode(cmd_parms *cmd, void *_dcfg,
|
||||
const char *p1)
|
||||
{
|
||||
@@ -1309,6 +1316,7 @@ static const char *cmd_audit_log_mode(cmd_parms *cmd, void *_dcfg,
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *cmd_audit_log_dirmode(cmd_parms *cmd, void *_dcfg,
|
||||
const char *p1)
|
||||
@@ -3251,6 +3259,7 @@ const command_rec module_directives[] = {
|
||||
"whether to use the old audit log format (Serial) or new (Concurrent)"
|
||||
),
|
||||
|
||||
#ifdef WITH_YAJL
|
||||
AP_INIT_TAKE1 (
|
||||
"SecAuditLogFormat",
|
||||
cmd_audit_log_mode,
|
||||
@@ -3258,6 +3267,7 @@ const command_rec module_directives[] = {
|
||||
CMD_SCOPE_ANY,
|
||||
"whether to emit audit log data in native format or JSON"
|
||||
),
|
||||
#endif
|
||||
|
||||
AP_INIT_TAKE1 (
|
||||
"SecAuditLogStorageDir",
|
||||
|
@@ -519,8 +519,10 @@ struct directory_config {
|
||||
/* AUDITLOG_SERIAL (single file) or AUDITLOG_CONCURRENT (multiple files) */
|
||||
int auditlog_type;
|
||||
|
||||
#ifdef WITH_YAJL
|
||||
/* AUDITLOGFORMAT_NATIVE or AUDITLOGFORMAT_JSON */
|
||||
int auditlog_format;
|
||||
#endif
|
||||
|
||||
/* Mode for audit log directories and files */
|
||||
apr_fileperms_t auditlog_dirperms;
|
||||
|
@@ -25,8 +25,10 @@
|
||||
#include "apr_version.h"
|
||||
#include <libxml/xmlversion.h>
|
||||
|
||||
#ifdef WITH_YAJL
|
||||
#include <yajl/yajl_gen.h>
|
||||
#include "msc_logging_json.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Write the supplied data to the audit log (if the FD is ready), update
|
||||
@@ -384,6 +386,7 @@ static void sec_auditlog_write_producer_header(modsec_rec *msr) {
|
||||
sec_auditlog_write(msr, ".\n", 2);
|
||||
}
|
||||
|
||||
#ifdef WITH_YAJL
|
||||
/**
|
||||
* Ouput the Producer header into a JSON generator
|
||||
*/
|
||||
@@ -415,6 +418,7 @@ static void sec_auditlog_write_producer_header_json(modsec_rec *msr, yajl_gen g)
|
||||
|
||||
yajl_gen_array_close(g); // array for producers is finished
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* \brief This function will returns the next chain node
|
||||
@@ -515,6 +519,7 @@ static int chained_is_matched(modsec_rec *msr, const msre_rule *next_rule) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WITH_YAJL
|
||||
/**
|
||||
* Write detailed information about performance metrics into a JSON generator
|
||||
*/
|
||||
@@ -1516,6 +1521,7 @@ void sec_audit_logger_json(modsec_rec *msr) {
|
||||
apr_file_write_full(msr->txcfg->auditlog2_fd, text, nbytes, &nbytes_written);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Produce an audit log entry in native format.
|
||||
@@ -2282,9 +2288,13 @@ void sec_audit_logger_native(modsec_rec *msr) {
|
||||
* Handler for audit log writers.
|
||||
*/
|
||||
void sec_audit_logger(modsec_rec *msr) {
|
||||
#ifdef WITH_YAJL
|
||||
if (msr->txcfg->auditlog_format == AUDITLOGFORMAT_JSON) {
|
||||
sec_audit_logger_json(msr);
|
||||
} else {
|
||||
#endif
|
||||
sec_audit_logger_native(msr);
|
||||
#ifdef WITH_YAJL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -22,8 +22,10 @@
|
||||
#define AUDITLOG_SERIAL 0
|
||||
#define AUDITLOG_CONCURRENT 1
|
||||
|
||||
#ifdef WITH_YAJL
|
||||
#define AUDITLOGFORMAT_JSON 0
|
||||
#define AUDITLOGFORMAT_NATIVE 1
|
||||
#endif
|
||||
|
||||
#define AUDITLOG_PART_FIRST 'A'
|
||||
#define AUDITLOG_PART_HEADER 'A'
|
||||
|
Reference in New Issue
Block a user