Skip to content
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
8 changes: 4 additions & 4 deletions headers/modsecurity/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,22 +348,22 @@ class Transaction : public TransactionAnchoredVariables {
/**
* Holds the client IP address.
*/
const char *m_clientIpAddress;
std::string m_clientIpAddress;

/**
* Holds the HTTP version: 1.2, 2.0, 3.0 and so on....
*/
const char *m_httpVersion;
std::string m_httpVersion;

/**
* Holds the server IP Address
*/
const char *m_serverIpAddress;
std::string m_serverIpAddress;

/**
* Holds the raw URI that was requested.
*/
const char *m_uri;
std::string m_uri;

/**
* Holds the URI that was requests (without the query string).
Expand Down
26 changes: 11 additions & 15 deletions src/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,9 @@ namespace modsecurity {
*
*/
Transaction::Transaction(ModSecurity *ms, Rules *rules, void *logCbData)
: m_clientIpAddress(""),
m_serverIpAddress(""),
m_clientPort(0),
: m_clientPort(0),
m_serverPort(0),
m_uri(""),
m_uri_no_query_string_decoded(""),
m_httpVersion(""),
m_rules(rules),
m_timeStamp(std::time(NULL)),
m_httpCodeReturned(200),
Expand Down Expand Up @@ -1355,7 +1351,7 @@ std::string Transaction::toOldAuditLogFormatIndex(const std::string &filename,
ss << utils::string::dash_if_empty(
m_variableRequestHeaders.resolveFirst("Host").get())
<< " ";
ss << utils::string::dash_if_empty(this->m_clientIpAddress) << " ";
ss << utils::string::dash_if_empty(this->m_clientIpAddress.c_str()) << " ";
/** TODO: Check variable */
ss << utils::string::dash_if_empty(
m_collections.resolveFirst("REMOTE_USER").get());
Expand All @@ -1369,8 +1365,8 @@ std::string Transaction::toOldAuditLogFormatIndex(const std::string &filename,
ss << "\"";
ss << utils::string::dash_if_empty(m_variableRequestMethod.evaluate());
ss << " ";
ss << this->m_uri << " ";
ss << "HTTP/" << m_httpVersion;
ss << this->m_uri.c_str() << " ";
ss << "HTTP/" << m_httpVersion.c_str();
ss << "\" ";

ss << this->m_httpCodeReturned << " ";
Expand Down Expand Up @@ -1420,8 +1416,8 @@ std::string Transaction::toOldAuditLogFormat(int parts,
audit_log << "--" << trailer << "-" << "B--" << std::endl;
audit_log << utils::string::dash_if_empty(
m_variableRequestMethod.evaluate());
audit_log << " " << this->m_uri << " " << "HTTP/";
audit_log << this->m_httpVersion << std::endl;
audit_log << " " << this->m_uri.c_str() << " " << "HTTP/";
audit_log << this->m_httpVersion.c_str() << std::endl;

m_variableRequestHeaders.resolve(&l);
for (auto &h : l) {
Expand Down Expand Up @@ -1459,7 +1455,7 @@ std::string Transaction::toOldAuditLogFormat(int parts,
std::vector<const collection::Variable *> l;

audit_log << "--" << trailer << "-" << "F--" << std::endl;
audit_log << "HTTP/" << m_httpVersion << " " << this->m_httpCodeReturned << std::endl;
audit_log << "HTTP/" << m_httpVersion.c_str() << " " << this->m_httpCodeReturned << std::endl;
m_variableResponseHeaders.resolve(&l);
for (auto &h : l) {
size_t pos = strlen("RESPONSE_HEADERS:");
Expand Down Expand Up @@ -1528,11 +1524,11 @@ std::string Transaction::toJSON(int parts) {

yajl_gen_map_open(g);
/* Part: A (header mandatory) */
LOGFY_ADD("client_ip", this->m_clientIpAddress);
LOGFY_ADD("client_ip", this->m_clientIpAddress.c_str());
LOGFY_ADD("time_stamp", ts.c_str());
LOGFY_ADD("server_id", uniqueId.c_str());
LOGFY_ADD_NUM("client_port", m_clientPort);
LOGFY_ADD("host_ip", m_serverIpAddress);
LOGFY_ADD("host_ip", m_serverIpAddress.c_str());
LOGFY_ADD_NUM("host_port", m_serverPort);
LOGFY_ADD("id", this->m_id.c_str());

Expand All @@ -1545,8 +1541,8 @@ std::string Transaction::toJSON(int parts) {
utils::string::dash_if_empty(
m_variableRequestMethod.evaluate()).c_str());

LOGFY_ADD_INT("http_version", m_httpVersion);
LOGFY_ADD("uri", this->m_uri);
LOGFY_ADD_INT("http_version", m_httpVersion.c_str());
LOGFY_ADD("uri", this->m_uri.c_str());

if (parts & audit_log::AuditLog::CAuditLogPart) {
// FIXME: check for the binary content size.
Expand Down