Adds support to base64DecodeExt transformation

More info on #964
This commit is contained in:
Felipe Zimmerle
2016-05-24 15:42:32 -03:00
parent 056753d57a
commit bf4a9d7633
5 changed files with 156 additions and 22 deletions

View File

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

View File

@@ -30,7 +30,8 @@ namespace transformations {
class Base64DecodeExt : public Transformation {
public:
explicit Base64DecodeExt(std::string action);
explicit Base64DecodeExt(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(base64DecodeExt) { return new Base64DecodeExt(a); }
IF_MATCH(base64Decode) { return new Base64Decode(a); }
IF_MATCH(base64Encode) { return new Base64Encode(a); }
IF_MATCH(cmd_line) { return new CmdLine(a); }