Adds support to the cssDecode transformation

This commit is contained in:
Felipe Zimmerle
2015-08-05 16:47:11 -03:00
parent 1924b4ebca
commit ce298165dd
5 changed files with 168 additions and 11 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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); }