mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-19 18:54:23 +03:00
Adds support for RunTimeString
Using RunTimeStrings instead of runtime parser for macro expansion.
This commit is contained in:
@@ -30,17 +30,14 @@ namespace disruptive {
|
||||
|
||||
|
||||
bool Redirect::init(std::string *error) {
|
||||
m_url = m_parser_payload;
|
||||
m_url = utils::string::parserSanitizer(m_url);
|
||||
m_status = 302;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Redirect::evaluate(Rule *rule, Transaction *transaction,
|
||||
std::shared_ptr<RuleMessage> rm) {
|
||||
m_urlExpanded = MacroExpansion::expand(m_url, transaction);
|
||||
|
||||
std::shared_ptr<RuleMessage> rm) {
|
||||
std::string m_urlExpanded(m_string->evaluate(transaction));
|
||||
/* if it was changed before, lets keep it. */
|
||||
if (transaction->m_it.status == 200) {
|
||||
transaction->m_it.status = m_status;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "modsecurity/actions/action.h"
|
||||
#include "modsecurity/rule_message.h"
|
||||
#include "src/run_time_string.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_DISRUPTIVE_REDIRECT_H_
|
||||
#define SRC_ACTIONS_DISRUPTIVE_REDIRECT_H_
|
||||
@@ -36,9 +37,11 @@ class Redirect : public Action {
|
||||
public:
|
||||
explicit Redirect(const std::string &action)
|
||||
: Action(action, RunTimeOnlyIfMatchKind),
|
||||
m_status(0),
|
||||
m_urlExpanded(""),
|
||||
m_url("") { }
|
||||
m_status(0) { }
|
||||
|
||||
explicit Redirect(std::unique_ptr<RunTimeString> z)
|
||||
: Action("redirert", RunTimeOnlyIfMatchKind),
|
||||
m_string(std::move(z)) { }
|
||||
|
||||
bool evaluate(Rule *rule, Transaction *transaction,
|
||||
std::shared_ptr<RuleMessage> rm) override;
|
||||
@@ -47,8 +50,7 @@ class Redirect : public Action {
|
||||
|
||||
private:
|
||||
int m_status;
|
||||
std::string m_urlExpanded;
|
||||
std::string m_url;
|
||||
std::unique_ptr<RunTimeString> m_string;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user