Makes m_clientIpAddress a shared pointer

This commit is contained in:
Felipe Zimmerle 2019-01-22 14:52:18 -03:00
parent 196adcae23
commit 8df35deadb
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
4 changed files with 10 additions and 10 deletions

View File

@ -92,7 +92,7 @@ class RuleMessage {
static std::string _errorLogTail(const RuleMessage *rm); static std::string _errorLogTail(const RuleMessage *rm);
int m_accuracy; int m_accuracy;
std::string m_clientIpAddress; std::shared_ptr<std::string> m_clientIpAddress;
std::string m_data; std::string m_data;
std::string m_id; std::string m_id;
bool m_isDisruptive; bool m_isDisruptive;

View File

@ -390,7 +390,7 @@ class Transaction : public TransactionAnchoredVariables {
/** /**
* Holds the client IP address. * Holds the client IP address.
*/ */
std::string m_clientIpAddress; std::shared_ptr<std::string> m_clientIpAddress;
/** /**
* Holds the HTTP version: 1.2, 2.0, 3.0 and so on.... * Holds the HTTP version: 1.2, 2.0, 3.0 and so on....

View File

@ -65,7 +65,7 @@ std::string RuleMessage::log(const RuleMessage *rm, int props, int code) {
std::string msg(""); std::string msg("");
if (props & ClientLogMessageInfo) { if (props & ClientLogMessageInfo) {
msg.append("[client " + std::string(rm->m_clientIpAddress) + "] "); msg.append("[client " + std::string(*rm->m_clientIpAddress.get()) + "] ");
} }
if (rm->m_isDisruptive) { if (rm->m_isDisruptive) {

View File

@ -101,7 +101,7 @@ namespace modsecurity {
*/ */
Transaction::Transaction(ModSecurity *ms, RulesSet *rules, void *logCbData) Transaction::Transaction(ModSecurity *ms, RulesSet *rules, void *logCbData)
: m_creationTimeStamp(utils::cpu_seconds()), : m_creationTimeStamp(utils::cpu_seconds()),
m_clientIpAddress(""), /* m_clientIpAddress(nullptr), */
m_httpVersion(""), m_httpVersion(""),
m_serverIpAddress(""), m_serverIpAddress(""),
m_uri(""), m_uri(""),
@ -174,7 +174,7 @@ Transaction::Transaction(ModSecurity *ms, RulesSet *rules, void *logCbData)
Transaction::Transaction(ModSecurity *ms, RulesSet *rules, char *id, void *logCbData) Transaction::Transaction(ModSecurity *ms, RulesSet *rules, char *id, void *logCbData)
: m_creationTimeStamp(utils::cpu_seconds()), : m_creationTimeStamp(utils::cpu_seconds()),
m_clientIpAddress(""), /* m_clientIpAddress(""), */
m_httpVersion(""), m_httpVersion(""),
m_serverIpAddress(""), m_serverIpAddress(""),
m_uri(""), m_uri(""),
@ -309,7 +309,7 @@ void Transaction::debug(int level, std::string message) const {
*/ */
int Transaction::processConnection(const char *client, int cPort, int Transaction::processConnection(const char *client, int cPort,
const char *server, int sPort) { const char *server, int sPort) {
this->m_clientIpAddress = client; m_clientIpAddress = std::unique_ptr<std::string>(new std::string(client));
this->m_serverIpAddress = server; this->m_serverIpAddress = server;
this->m_clientPort = cPort; this->m_clientPort = cPort;
this->m_serverPort = sPort; this->m_serverPort = sPort;
@ -317,9 +317,9 @@ int Transaction::processConnection(const char *client, int cPort,
ms_dbg(4, "Starting phase CONNECTION. (SecRules 0)"); ms_dbg(4, "Starting phase CONNECTION. (SecRules 0)");
m_variableRemoteHost.set(m_clientIpAddress, m_variableOffset); m_variableRemoteHost.set(*m_clientIpAddress.get(), m_variableOffset);
m_variableUniqueID.set(m_id, m_variableOffset); m_variableUniqueID.set(m_id, m_variableOffset);
m_variableRemoteAddr.set(m_clientIpAddress, m_variableOffset); m_variableRemoteAddr.set(*m_clientIpAddress.get(), m_variableOffset);
m_variableServerAddr.set(m_serverIpAddress, m_variableOffset); m_variableServerAddr.set(m_serverIpAddress, m_variableOffset);
m_variableServerPort.set(std::to_string(this->m_serverPort), m_variableServerPort.set(std::to_string(this->m_serverPort),
m_variableOffset); m_variableOffset);
@ -1462,7 +1462,7 @@ std::string Transaction::toOldAuditLogFormatIndex(const std::string &filename,
ss << utils::string::dash_if_empty( ss << utils::string::dash_if_empty(
m_variableRequestHeaders.resolveFirst("Host").get()) m_variableRequestHeaders.resolveFirst("Host").get())
<< " "; << " ";
ss << utils::string::dash_if_empty(this->m_clientIpAddress.c_str()) << " "; ss << utils::string::dash_if_empty(this->m_clientIpAddress->c_str()) << " ";
/** TODO: Check variable */ /** TODO: Check variable */
variables::RemoteUser *r = new variables::RemoteUser("REMOTE_USER"); variables::RemoteUser *r = new variables::RemoteUser("REMOTE_USER");
std::vector<const VariableValue *> l; std::vector<const VariableValue *> l;
@ -1640,7 +1640,7 @@ std::string Transaction::toJSON(int parts) {
yajl_gen_map_open(g); yajl_gen_map_open(g);
/* Part: A (header mandatory) */ /* Part: A (header mandatory) */
LOGFY_ADD("client_ip", this->m_clientIpAddress.c_str()); LOGFY_ADD("client_ip", this->m_clientIpAddress->c_str());
LOGFY_ADD("time_stamp", ts.c_str()); LOGFY_ADD("time_stamp", ts.c_str());
LOGFY_ADD("server_id", uniqueId.c_str()); LOGFY_ADD("server_id", uniqueId.c_str());
LOGFY_ADD_NUM("client_port", m_clientPort); LOGFY_ADD_NUM("client_port", m_clientPort);