Adds hexEncode transformation

This commit is contained in:
Felipe Zimmerle 2015-10-23 13:35:23 -03:00
parent 0ae09201f5
commit 93c3bc804e
2 changed files with 9 additions and 9 deletions

View File

@ -21,6 +21,7 @@
#include <functional> #include <functional>
#include <cctype> #include <cctype>
#include <locale> #include <locale>
#include <iterator>
#include "modsecurity/assay.h" #include "modsecurity/assay.h"
#include "actions/transformations/transformation.h" #include "actions/transformations/transformation.h"
@ -37,15 +38,14 @@ HexEncode::HexEncode(std::string action)
std::string HexEncode::evaluate(std::string value, std::string HexEncode::evaluate(std::string value,
Assay *assay) { Assay *assay) {
/**
* @todo Implement the transformation HexEncode std::stringstream result;
*/ for (std::size_t i=0; i < value.length(); i++) {
if (assay) { int ii = (char)value[i];
#ifndef NO_LOGS result << std::setw(2) << std::setfill('0') << std::hex << ii;
assay->debug(4, "Transformation HexEncode is not implemented yet.");
#endif
} }
return value;
return result.str();
} }
} // namespace transformations } // namespace transformations

View File

@ -81,7 +81,7 @@ Transformation* Transformation::instantiate(std::string 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(hex_decode) { return new HexDecode(a); }
IF_MATCH(hex_encode) { 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); }
IF_MATCH(length) { return new Length(a); } IF_MATCH(length) { return new Length(a); }