mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
parent
d0e0002283
commit
c85529158e
@ -30,24 +30,58 @@ namespace modsecurity {
|
|||||||
namespace actions {
|
namespace actions {
|
||||||
namespace transformations {
|
namespace transformations {
|
||||||
|
|
||||||
CmdLine::CmdLine(std::string action)
|
|
||||||
: Transformation(action) {
|
|
||||||
this->action_kind = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CmdLine::evaluate(std::string value,
|
std::string CmdLine::evaluate(std::string value,
|
||||||
Transaction *transaction) {
|
Transaction *transaction) {
|
||||||
/**
|
std::string ret;
|
||||||
* @todo Implement the transformation CmdLine
|
int space = 0;
|
||||||
*/
|
|
||||||
if (transaction) {
|
for (auto& a : value) {
|
||||||
#ifndef NO_LOGS
|
switch (a) {
|
||||||
transaction->debug(4, "Transformation CmdLine is not implemented yet.");
|
/* remove some characters */
|
||||||
#endif
|
case '"':
|
||||||
|
case '\'':
|
||||||
|
case '\\':
|
||||||
|
case '^':
|
||||||
|
//ret.append("i was here");
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* replace some characters to space (only one) */
|
||||||
|
case ' ':
|
||||||
|
case ',':
|
||||||
|
case ';':
|
||||||
|
case '\t':
|
||||||
|
case '\r':
|
||||||
|
case '\n':
|
||||||
|
if (space == 0) {
|
||||||
|
ret.append(" ");
|
||||||
|
space++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* remove space before / or ( */
|
||||||
|
case '/':
|
||||||
|
case '(':
|
||||||
|
if (space) {
|
||||||
|
ret.pop_back();
|
||||||
|
}
|
||||||
|
space = 0;
|
||||||
|
ret.append(&a, 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* copy normal characters */
|
||||||
|
default :
|
||||||
|
char b = std::tolower(a);
|
||||||
|
ret.append(&b);
|
||||||
|
space = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return value;
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace transformations
|
} // namespace transformations
|
||||||
} // namespace actions
|
} // namespace actions
|
||||||
} // namespace modsecurity
|
} // namespace modsecurity
|
||||||
|
@ -30,7 +30,9 @@ namespace transformations {
|
|||||||
|
|
||||||
class CmdLine : public Transformation {
|
class CmdLine : public Transformation {
|
||||||
public:
|
public:
|
||||||
explicit CmdLine(std::string action);
|
explicit CmdLine(std::string action)
|
||||||
|
: Transformation(action) { }
|
||||||
|
|
||||||
std::string evaluate(std::string exp,
|
std::string evaluate(std::string exp,
|
||||||
Transaction *transaction) override;
|
Transaction *transaction) override;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user