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

View File

@ -80,7 +80,7 @@ Transformation* Transformation::instantiate(std::string a) {
IF_MATCH(compress_whitespace) { return new CompressWhitespace(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(hexDecode) { return new HexDecode(a); }
IF_MATCH(hexEncode) { return new HexEncode(a); }
IF_MATCH(htmlEntityDecode) { return new HtmlEntityDecode(a); }
IF_MATCH(jsDecode) { return new JsDecode(a); }

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