Adds support to base64 decode transformation

This commit is contained in:
Felipe Zimmerle 2016-05-24 10:04:06 -03:00
parent 348cf3bfab
commit e48f468cbc
3 changed files with 8 additions and 15 deletions

View File

@ -24,30 +24,22 @@
#include "modsecurity/transaction.h"
#include "actions/transformations/transformation.h"
#include "utils/base64.h"
namespace modsecurity {
namespace actions {
namespace transformations {
Base64Decode::Base64Decode(std::string action)
: Transformation(action) {
this->action_kind = 1;
}
std::string Base64Decode::evaluate(std::string value,
Transaction *transaction) {
/**
* @todo Implement the transformation base64decode
*/
if (transaction) {
#ifndef NO_LOGS
transaction->debug(4, "Transformation 64 is not implemented yet.");
#endif
}
return value;
std::string ret = Utils::Base64::decode(value);
return ret;
}
} // namespace transformations
} // namespace actions
} // namespace modsecurity

View File

@ -30,7 +30,8 @@ namespace transformations {
class Base64Decode : public Transformation {
public:
explicit Base64Decode(std::string action);
explicit Base64Decode(std::string action) : Transformation(action) { };
std::string evaluate(std::string exp,
Transaction *transaction) override;
};

View File

@ -74,7 +74,7 @@ std::string Transformation::evaluate(std::string value,
Transformation* Transformation::instantiate(std::string a) {
IF_MATCH(base64_decode_ext) { return new Base64DecodeExt(a); }
IF_MATCH(base64_decode) { return new Base64Decode(a); }
IF_MATCH(base64Decode) { return new Base64Decode(a); }
IF_MATCH(cmd_line) { return new CmdLine(a); }
IF_MATCH(compress_whitespace) { return new CompressWhitespace(a); }
IF_MATCH(cssDecode) { return new CssDecode(a); }