Adds support to hexDecode transformation

This commit is contained in:
Felipe Zimmerle 2015-10-23 14:01:12 -03:00
parent 93c3bc804e
commit 9932478705
3 changed files with 14 additions and 10 deletions

View File

@ -30,24 +30,28 @@ namespace ModSecurity {
namespace actions { namespace actions {
namespace transformations { namespace transformations {
HexDecode::HexDecode(std::string action) HexDecode::HexDecode(std::string action)
: Transformation(action) { : Transformation(action) {
this->action_kind = 1; this->action_kind = 1;
} }
std::string HexDecode::evaluate(std::string value, std::string HexDecode::evaluate(std::string value,
Assay *assay) { Assay *assay) {
/** int len = value.length();
* @todo Implement the transformation HexDecode std::string newString;
*/
if (assay) { for(int i=0; i< len; i+=2) {
#ifndef NO_LOGS std::string byte = value.substr(i,2);
assay->debug(4, "Transformation HexDecode is not implemented yet."); char chr = (char) (int)strtol(byte.c_str(), NULL, 16);
#endif newString.push_back(chr);
} }
return value;
return newString;
} }
} // namespace transformations } // namespace transformations
} // namespace actions } // namespace actions
} // namespace ModSecurity } // namespace ModSecurity

View File

@ -80,7 +80,7 @@ Transformation* Transformation::instantiate(std::string a) {
IF_MATCH(compress_whitespace) { return new CompressWhitespace(a); } IF_MATCH(compress_whitespace) { return new CompressWhitespace(a); }
IF_MATCH(cssDecode) { return new CssDecode(a); } IF_MATCH(cssDecode) { return new CssDecode(a); }
IF_MATCH(escape_seq_decode) { return new EscapeSeqDecode(a); } IF_MATCH(escape_seq_decode) { return new EscapeSeqDecode(a); }
IF_MATCH(hex_decode) { return new HexDecode(a); } IF_MATCH(hexDecode) { return new HexDecode(a); }
IF_MATCH(hexEncode) { return new HexEncode(a); } IF_MATCH(hexEncode) { return new HexEncode(a); }
IF_MATCH(htmlEntityDecode) { return new HtmlEntityDecode(a); } IF_MATCH(htmlEntityDecode) { return new HtmlEntityDecode(a); }
IF_MATCH(jsDecode) { return new JsDecode(a); } IF_MATCH(jsDecode) { return new JsDecode(a); }

@ -1 +1 @@
Subproject commit 444dfbea3390cf54f6d59e331bc4fbcabb77eb4e Subproject commit 635d86d6f87d56de656da73e3026a6ef2cc9a5f1