mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Adds t:none transformation
This commit is contained in:
@@ -30,20 +30,13 @@ namespace ModSecurity {
|
||||
namespace actions {
|
||||
namespace transformations {
|
||||
|
||||
None::None(std::string action)
|
||||
: Transformation(action) {
|
||||
this->action_kind = 1;
|
||||
}
|
||||
|
||||
std::string None::evaluate(std::string value,
|
||||
Assay *assay) {
|
||||
/**
|
||||
* @todo Implement the transformation None
|
||||
*/
|
||||
assay->debug(4, "Transformation None is not implemented yet.");
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
} // namespace transformations
|
||||
} // namespace actions
|
||||
} // namespace ModSecurity
|
||||
|
@@ -30,7 +30,9 @@ namespace transformations {
|
||||
|
||||
class None : public Transformation {
|
||||
public:
|
||||
explicit None(std::string action);
|
||||
explicit None(std::string action)
|
||||
: Transformation(action) { }
|
||||
|
||||
std::string evaluate(std::string exp,
|
||||
Assay *assay) override;
|
||||
};
|
||||
|
30
src/rule.cc
30
src/rule.cc
@@ -25,7 +25,8 @@
|
||||
|
||||
#include "operators/operator.h"
|
||||
#include "actions/action.h"
|
||||
#include "../headers/modsecurity/modsecurity.h"
|
||||
#include "modsecurity/modsecurity.h"
|
||||
#include "actions/transformations/none.h"
|
||||
|
||||
|
||||
namespace ModSecurity {
|
||||
@@ -33,6 +34,7 @@ namespace ModSecurity {
|
||||
using operators::Operator;
|
||||
using actions::Action;
|
||||
using Variables::Variable;
|
||||
using actions::transformations::None;
|
||||
|
||||
Rule::~Rule() {
|
||||
delete op;
|
||||
@@ -115,13 +117,25 @@ bool Rule::evaluate(Assay *assay) {
|
||||
|
||||
for (auto &v : e) {
|
||||
std::string value = v.second;
|
||||
for (Action *a :
|
||||
this->actions_runtime_pre) {
|
||||
value = a->evaluate(value, assay);
|
||||
assay->debug(9, " T (" + \
|
||||
std::to_string(transformations) + ") " + \
|
||||
a->name + ": \"" + value +"\"");
|
||||
transformations++;
|
||||
int none = 0;
|
||||
for (Action *a : this->actions_runtime_pre) {
|
||||
None *z = dynamic_cast<None *>(a);
|
||||
if (z != NULL) {
|
||||
none++;
|
||||
}
|
||||
}
|
||||
for (Action *a : this->actions_runtime_pre) {
|
||||
None *z = dynamic_cast<None *>(a);
|
||||
if (none == 0) {
|
||||
value = a->evaluate(value, assay);
|
||||
assay->debug(9, " T (" + \
|
||||
std::to_string(transformations) + ") " + \
|
||||
a->name + ": \"" + value +"\"");
|
||||
transformations++;
|
||||
}
|
||||
if (z != NULL) {
|
||||
none--;
|
||||
}
|
||||
}
|
||||
|
||||
assay->debug(9, "Target value: \"" + value + "\" (Variable: " + \
|
||||
|
Reference in New Issue
Block a user