Skip to content

[V3] Allow the callback function to receive and log a http return code #1919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
2 changes: 1 addition & 1 deletion headers/modsecurity/modsecurity.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class ModSecurity {
*/
void setServerLogCb(ModSecLogCb cb, int properties);

void serverLog(void *data, std::shared_ptr<RuleMessage> rm);
void serverLog(void *data, std::shared_ptr<RuleMessage> rm, int httpCodeReturned);

const std::string& getConnectorInformation();

Expand Down
4 changes: 2 additions & 2 deletions src/modsecurity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const std::string& ModSecurity::getConnectorInformation() {
return m_connector;
}

void ModSecurity::serverLog(void *data, std::shared_ptr<RuleMessage> rm) {
void ModSecurity::serverLog(void *data, std::shared_ptr<RuleMessage> rm, int httpCodeReturned) {
if (m_logCb == NULL) {
std::cerr << "Server log callback is not set -- " << rm->errorLog();
std::cerr << std::endl;
Expand All @@ -198,7 +198,7 @@ void ModSecurity::serverLog(void *data, std::shared_ptr<RuleMessage> rm) {
}

if (m_logProperties & TextLogProperty) {
std::string &&d = rm->log();
std::string &&d = rm->log(0, httpCodeReturned);
const void *a = static_cast<const void *>(d.c_str());
m_logCb(data, a);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ std::string Transaction::toJSON(int parts) {


void Transaction::serverLog(std::shared_ptr<RuleMessage> rm) {
m_ms->serverLog(m_logCbData, rm);
m_ms->serverLog(m_logCbData, rm, this->m_httpCodeReturned);
}


Expand Down