mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-16 07:56:12 +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 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
|
||||||
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user