mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 11:44:32 +03:00
Adds support to the cssDecode transformation
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "actions/transformations/css_decode.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
@@ -24,26 +26,24 @@
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "actions/transformations/transformation.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace actions {
|
||||
namespace transformations {
|
||||
|
||||
CssDecode::CssDecode(std::string action)
|
||||
: Transformation(action) {
|
||||
this->action_kind = 1;
|
||||
}
|
||||
|
||||
std::string CssDecode::evaluate(std::string value,
|
||||
Assay *assay) {
|
||||
/**
|
||||
* @todo Implement the transformation CssDecode
|
||||
*/
|
||||
assay->debug(4, "Transformation CssDecode is not implemented yet.");
|
||||
return value;
|
||||
char *tmp = strdup(value.c_str());
|
||||
int res = css_decode_inplace((unsigned char *)tmp, value.size());
|
||||
std::string ret(tmp, 0, value.size());
|
||||
free(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
} // namespace transformations
|
||||
} // namespace actions
|
||||
} // namespace ModSecurity
|
||||
|
@@ -28,13 +28,16 @@ class Assay;
|
||||
namespace actions {
|
||||
namespace transformations {
|
||||
|
||||
|
||||
class CssDecode : public Transformation {
|
||||
public:
|
||||
explicit CssDecode(std::string action);
|
||||
explicit CssDecode(std::string action)
|
||||
: Transformation(action) { }
|
||||
std::string evaluate(std::string exp,
|
||||
Assay *assay) override;
|
||||
};
|
||||
|
||||
|
||||
} // namespace transformations
|
||||
} // namespace actions
|
||||
} // namespace ModSecurity
|
||||
|
@@ -77,7 +77,7 @@ Transformation* Transformation::instantiate(std::string a) {
|
||||
IF_MATCH(base64_decode) { return new Base64Decode(a); }
|
||||
IF_MATCH(cmd_line) { return new CmdLine(a); }
|
||||
IF_MATCH(compress_whitespace) { return new CompressWhitespace(a); }
|
||||
IF_MATCH(css_decode) { return new CssDecode(a); }
|
||||
IF_MATCH(cssDecode) { return new CssDecode(a); }
|
||||
IF_MATCH(escape_seq_decode) { return new EscapeSeqDecode(a); }
|
||||
IF_MATCH(hex_decode) { return new HexDecode(a); }
|
||||
IF_MATCH(hex_encode) { return new HexEncode(a); }
|
||||
|
Reference in New Issue
Block a user