mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Adds support to hexDecode transformation
This commit is contained in:
parent
93c3bc804e
commit
9932478705
@ -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
|
||||
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user