mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-20 19:16:40 +03:00
actions: Compute the rule association during rules load
This commit is contained in:
@@ -35,7 +35,7 @@ bool Redirect::init(std::string *error) {
|
||||
|
||||
|
||||
bool Redirect::execute(RuleWithActions *rule, Transaction *transaction) {
|
||||
std::string m_urlExpanded(m_string->evaluate(transaction));
|
||||
std::string m_urlExpanded(getEvaluatedRunTimeString(transaction));
|
||||
/* if it was changed before, lets keep it. */
|
||||
if (transaction->m_it.status == 200
|
||||
|| (!(transaction->m_it.status <= 307 && transaction->m_it.status >= 301))) {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "modsecurity/rule_message.h"
|
||||
#include "src/run_time_string.h"
|
||||
#include "src/actions/action_with_run_time_string.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_DISRUPTIVE_REDIRECT_H_
|
||||
#define SRC_ACTIONS_DISRUPTIVE_REDIRECT_H_
|
||||
@@ -34,25 +34,33 @@ namespace actions {
|
||||
namespace disruptive {
|
||||
|
||||
|
||||
class Redirect : public Action {
|
||||
class Redirect : public ActionWithRunTimeString {
|
||||
public:
|
||||
explicit Redirect(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind),
|
||||
m_status(0),
|
||||
m_string(nullptr) { }
|
||||
explicit Redirect(std::unique_ptr<RunTimeString> runTimeString)
|
||||
: ActionWithRunTimeString(
|
||||
"redirert",
|
||||
RunTimeOnlyIfMatchKind,
|
||||
std::move(runTimeString)),
|
||||
m_status(0)
|
||||
{ };
|
||||
|
||||
explicit Redirect(std::unique_ptr<RunTimeString> z)
|
||||
: Action("redirert", RunTimeOnlyIfMatchKind),
|
||||
m_status(0),
|
||||
m_string(std::move(z)) { }
|
||||
explicit Redirect(const Redirect &action)
|
||||
: ActionWithRunTimeString(action),
|
||||
m_status(action.m_status)
|
||||
{ };
|
||||
|
||||
bool init(std::string *error) override;
|
||||
|
||||
bool execute(RuleWithActions *rule, Transaction *transaction) override;
|
||||
bool init(std::string *error) override;
|
||||
|
||||
bool isDisruptive() override { return true; }
|
||||
|
||||
virtual ActionWithRunTimeString *clone() override {
|
||||
return new Redirect(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
int m_status;
|
||||
std::unique_ptr<RunTimeString> m_string;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user