Skip to content
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

Feature request: adding severity in ModSecurityIntervention #2748

Open
wants to merge 2 commits into
base: v3/master
Choose a base branch
from
Open
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: 2 additions & 0 deletions headers/modsecurity/intervention.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ typedef struct ModSecurityIntervention_t {
char *url;
char *log;
int disruptive;
int severity;
} ModSecurityIntervention;

#ifdef __cplusplus
Expand All @@ -34,6 +35,7 @@ namespace intervention {
i->status = 200;
i->pause = 0;
i->disruptive = 0;
i->severity = 0;
}

static void clean(ModSecurityIntervention_t *i) {
Expand Down
3 changes: 3 additions & 0 deletions src/actions/disruptive/allow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ bool Allow::evaluate(RuleWithActions *rule, Transaction *transaction) {
+ allowTypeToName(m_allowType));

transaction->m_allowType = m_allowType;
if (rule->hasSeverity()) {
transaction->m_it.severity = rule->severity();
}

return true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/actions/disruptive/deny.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ bool Deny::evaluate(RuleWithActions *rule, Transaction *transaction,
rm->m_isDisruptive = true;
transaction->m_it.log = strdup(
rm->log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
if (rule->hasSeverity()) {
transaction->m_it.severity = rule->severity();
}

return true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/actions/disruptive/drop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ bool Drop::evaluate(RuleWithActions *rule, Transaction *transaction,
rm->m_isDisruptive = true;
transaction->m_it.log = strdup(
rm->log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
if (rule->hasSeverity()) {
transaction->m_it.severity = rule->severity();
}

return true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/actions/disruptive/pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ bool Pass::evaluate(RuleWithActions *rule, Transaction *transaction,
intervention::reset(&transaction->m_it);

ms_dbg_a(transaction, 8, "Running action pass");
if (rule->hasSeverity()) {
transaction->m_it.severity = rule->severity();
}

return true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/actions/disruptive/redirect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ bool Redirect::evaluate(RuleWithActions *rule, Transaction *transaction,
rm->m_isDisruptive = true;
transaction->m_it.log = strdup(
rm->log(RuleMessage::LogMessageInfo::ClientLogMessageInfo).c_str());
if (rule->hasSeverity()) {
transaction->m_it.severity = rule->severity();
}

return true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,7 @@ int Transaction::appendRequestBody(const unsigned char *buf, size_t len) {
"reject the request");
m_it.status = 403;
m_it.disruptive = true;
m_it.severity = 0;
} else {
ms_dbg(5, "Not rejecting the request as the engine is " \
"not Enabled");
Expand Down Expand Up @@ -1325,6 +1326,7 @@ int Transaction::appendResponseBody(const unsigned char *buf, size_t len) {
"the request");
m_it.status = 403;
m_it.disruptive = true;
m_it.severity = 0;
} else {
ms_dbg(5, "Not rejecting the request as the engine is " \
"not Enabled");
Expand Down Expand Up @@ -1484,6 +1486,7 @@ bool Transaction::intervention(ModSecurityIntervention *it) {
}
intervention::reset(&m_it);
}
it->severity = m_it.severity;

return it->disruptive;
}
Expand Down