Skip to content

Commit

Permalink
Add condition before set hostname; move setRequestHostName() before p…
Browse files Browse the repository at this point in the history
…rocessConnection()
  • Loading branch information
airween committed Nov 12, 2024
1 parent ec506da commit d422b36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ int Transaction::processConnection(const char *client, int cPort,
const char *server, int sPort) {
m_clientIpAddress = client;
m_serverIpAddress = server;
m_requestHostName = server;
if (m_requestHostName.empty() == true) {
m_requestHostName = server;
}
this->m_clientPort = cPort;
this->m_serverPort = sPort;
ms_dbg(4, "Transaction context created.");
Expand Down
8 changes: 4 additions & 4 deletions test/regression/regression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,

auto modsec_transaction = context.create_transaction();

if (t->hostname != "") {
modsec_transaction.setRequestHostName(t->hostname);
}

clearAuditLog(modsec_transaction.m_rules->m_auditLog->m_path1);

modsec_transaction.processConnection(t->clientIp.c_str(),
t->clientPort, t->serverIp.c_str(), t->serverPort);

if (t->hostname != "") {
modsec_transaction.setRequestHostName(t->hostname);
}

actions(&r, &modsec_transaction, &context.m_server_log);

modsec_transaction.processURI(t->uri.c_str(), t->method.c_str(),
Expand Down

0 comments on commit d422b36

Please sign in to comment.