mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Adds hexEncode transformation
This commit is contained in:
parent
0ae09201f5
commit
93c3bc804e
@ -21,6 +21,7 @@
|
||||
#include <functional>
|
||||
#include <cctype>
|
||||
#include <locale>
|
||||
#include <iterator>
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "actions/transformations/transformation.h"
|
||||
@ -37,15 +38,14 @@ HexEncode::HexEncode(std::string action)
|
||||
|
||||
std::string HexEncode::evaluate(std::string value,
|
||||
Assay *assay) {
|
||||
/**
|
||||
* @todo Implement the transformation HexEncode
|
||||
*/
|
||||
if (assay) {
|
||||
#ifndef NO_LOGS
|
||||
assay->debug(4, "Transformation HexEncode is not implemented yet.");
|
||||
#endif
|
||||
|
||||
std::stringstream result;
|
||||
for (std::size_t i=0; i < value.length(); i++) {
|
||||
int ii = (char)value[i];
|
||||
result << std::setw(2) << std::setfill('0') << std::hex << ii;
|
||||
}
|
||||
return value;
|
||||
|
||||
return result.str();
|
||||
}
|
||||
|
||||
} // namespace transformations
|
||||
|
@ -81,7 +81,7 @@ Transformation* Transformation::instantiate(std::string 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(hex_encode) { return new HexEncode(a); }
|
||||
IF_MATCH(hexEncode) { return new HexEncode(a); }
|
||||
IF_MATCH(htmlEntityDecode) { return new HtmlEntityDecode(a); }
|
||||
IF_MATCH(jsDecode) { return new JsDecode(a); }
|
||||
IF_MATCH(length) { return new Length(a); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user