mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 11:44:32 +03:00
Refactoring: new structure for logging alerts
Disruptive actions were moved to actions::disruptive namespace
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "modsecurity/rule_message.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_STATUS_H_
|
||||
#define SRC_ACTIONS_STATUS_H_
|
||||
#ifndef SRC_ACTIONS_DATA_STATUS_H_
|
||||
#define SRC_ACTIONS_DATA_STATUS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
class Transaction;
|
||||
@@ -48,4 +48,4 @@ class Status : public Action {
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
#endif // SRC_ACTIONS_STATUS_H_
|
||||
#endif // SRC_ACTIONS_DATA_STATUS_H_
|
||||
|
@@ -17,8 +17,8 @@
|
||||
|
||||
#include "modsecurity/actions/action.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_ALLOW_H_
|
||||
#define SRC_ACTIONS_ALLOW_H_
|
||||
#ifndef SRC_ACTIONS_DISRUPTIVE_ALLOW_H_
|
||||
#define SRC_ACTIONS_DISRUPTIVE_ALLOW_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
class Transaction;
|
||||
@@ -84,4 +84,4 @@ class Allow : public Action {
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
#endif // SRC_ACTIONS_ALLOW_H_
|
||||
#endif // SRC_ACTIONS_DISRUPTIVE_ALLOW_H_
|
||||
|
@@ -30,8 +30,6 @@ namespace disruptive {
|
||||
|
||||
|
||||
bool Block::evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) {
|
||||
std::string log;
|
||||
|
||||
transaction->debug(8, "Marking request as disruptive.");
|
||||
|
||||
for (Action *a : transaction->m_rules->defaultActions[rule->phase]) {
|
||||
|
@@ -18,8 +18,8 @@
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "modsecurity/rule_message.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_BLOCK_H_
|
||||
#define SRC_ACTIONS_BLOCK_H_
|
||||
#ifndef SRC_ACTIONS_DISRUPTIVE_BLOCK_H_
|
||||
#define SRC_ACTIONS_DISRUPTIVE_BLOCK_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
class Transaction;
|
||||
@@ -46,4 +46,4 @@ class Block : public Action {
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
#endif // SRC_ACTIONS_BLOCK_H_
|
||||
#endif // SRC_ACTIONS_DISRUPTIVE_BLOCK_H_
|
||||
|
@@ -15,10 +15,10 @@
|
||||
|
||||
#include "src/actions/disruptive/deny.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <string.h>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
|
||||
@@ -42,7 +42,9 @@ bool Deny::evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) {
|
||||
log.append(std::to_string(rm->m_rule->phase - 1) + "). ");
|
||||
|
||||
transaction->m_it.disruptive = true;
|
||||
transaction->m_it.log = strdup(rm->disruptiveErrorLog(transaction, log).c_str());
|
||||
intervention::freeLog(&transaction->m_it);
|
||||
transaction->m_it.log = strdup(
|
||||
rm->disruptiveErrorLog(transaction, log).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -19,8 +19,8 @@
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "modsecurity/rule_message.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_DENY_H_
|
||||
#define SRC_ACTIONS_DENY_H_
|
||||
#ifndef SRC_ACTIONS_DISRUPTIVE_DENY_H_
|
||||
#define SRC_ACTIONS_DISRUPTIVE_DENY_H_
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
@@ -41,4 +41,4 @@ class Deny : public Action {
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_ACTIONS_DENY_H_
|
||||
#endif // SRC_ACTIONS_DISRUPTIVE_DENY_H_
|
||||
|
@@ -28,11 +28,8 @@ namespace disruptive {
|
||||
|
||||
|
||||
bool Pass::evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) {
|
||||
transaction->m_it.status = 200;
|
||||
transaction->m_it.disruptive = false;
|
||||
transaction->m_it.url = NULL;
|
||||
transaction->m_it.log = NULL;
|
||||
transaction->m_it.pause = 0;
|
||||
intervention::free(&transaction->m_it);
|
||||
intervention::reset(&transaction->m_it);
|
||||
|
||||
transaction->debug(8, "Running action pass");
|
||||
|
||||
|
@@ -15,9 +15,9 @@
|
||||
|
||||
#include "src/actions/disruptive/redirect.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
@@ -35,7 +35,8 @@ bool Redirect::init(std::string *error) {
|
||||
}
|
||||
|
||||
|
||||
bool Redirect::evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) {
|
||||
bool Redirect::evaluate(Rule *rule, Transaction *transaction,
|
||||
RuleMessage *rm) {
|
||||
m_urlExpanded = MacroExpansion::expand(m_url, transaction);
|
||||
std::string log;
|
||||
|
||||
@@ -47,9 +48,12 @@ bool Redirect::evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) {
|
||||
log.append(" (phase ");
|
||||
log.append(std::to_string(rm->m_rule->phase - 1) + "). ");
|
||||
|
||||
intervention::freeUrl(&transaction->m_it);
|
||||
transaction->m_it.url = strdup(m_urlExpanded.c_str());
|
||||
transaction->m_it.disruptive = true;
|
||||
transaction->m_it.log = strdup(rm->disruptiveErrorLog(transaction, log).c_str());
|
||||
intervention::freeLog(&transaction->m_it);
|
||||
transaction->m_it.log = strdup(
|
||||
rm->disruptiveErrorLog(transaction, log).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -18,8 +18,8 @@
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "modsecurity/rule_message.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_REDIRECT_H_
|
||||
#define SRC_ACTIONS_REDIRECT_H_
|
||||
#ifndef SRC_ACTIONS_DISRUPTIVE_REDIRECT_H_
|
||||
#define SRC_ACTIONS_DISRUPTIVE_REDIRECT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
class Transaction;
|
||||
@@ -39,7 +39,8 @@ class Redirect : public Action {
|
||||
m_urlExpanded(""),
|
||||
m_url("") { }
|
||||
|
||||
bool evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm) override;
|
||||
bool evaluate(Rule *rule, Transaction *transaction, RuleMessage *rm)
|
||||
override;
|
||||
bool init(std::string *error) override;
|
||||
bool isDisruptive() override { return true; }
|
||||
|
||||
@@ -55,4 +56,4 @@ class Redirect : public Action {
|
||||
} // namespace modsecurity
|
||||
#endif
|
||||
|
||||
#endif // SRC_ACTIONS_REDIRECT_H_
|
||||
#endif // SRC_ACTIONS_DISRUPTIVE_REDIRECT_H_
|
||||
|
Reference in New Issue
Block a user