mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Adds support to base64 encode transformation
This commit is contained in:
parent
bb5cbc969f
commit
056753d57a
@ -101,6 +101,7 @@ ACTIONS = \
|
|||||||
actions/skip_after.cc \
|
actions/skip_after.cc \
|
||||||
actions/tag.cc \
|
actions/tag.cc \
|
||||||
actions/transformations/base64_decode.cc \
|
actions/transformations/base64_decode.cc \
|
||||||
|
actions/transformations/base64_encode.cc \
|
||||||
actions/transformations/base64_decode_ext.cc \
|
actions/transformations/base64_decode_ext.cc \
|
||||||
actions/transformations/cmd_line.cc \
|
actions/transformations/cmd_line.cc \
|
||||||
actions/transformations/compress_whitespace.cc \
|
actions/transformations/compress_whitespace.cc \
|
||||||
|
45
src/actions/transformations/base64_encode.cc
Normal file
45
src/actions/transformations/base64_encode.cc
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* ModSecurity, http://www.modsecurity.org/
|
||||||
|
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||||
|
*
|
||||||
|
* You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* If any of the files related to licensing are missing or if you have any
|
||||||
|
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||||
|
* directly using the email address security@modsecurity.org.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "actions/transformations/base64_encode.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <functional>
|
||||||
|
#include <cctype>
|
||||||
|
#include <locale>
|
||||||
|
|
||||||
|
#include "modsecurity/transaction.h"
|
||||||
|
#include "actions/transformations/transformation.h"
|
||||||
|
#include "utils/base64.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace modsecurity {
|
||||||
|
namespace actions {
|
||||||
|
namespace transformations {
|
||||||
|
|
||||||
|
|
||||||
|
std::string Base64Encode::evaluate(std::string value,
|
||||||
|
Transaction *transaction) {
|
||||||
|
std::string ret = Utils::Base64::encode(value);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace transformations
|
||||||
|
} // namespace actions
|
||||||
|
} // namespace modsecurity
|
45
src/actions/transformations/base64_encode.h
Normal file
45
src/actions/transformations/base64_encode.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* ModSecurity, http://www.modsecurity.org/
|
||||||
|
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||||
|
*
|
||||||
|
* You may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* If any of the files related to licensing are missing or if you have any
|
||||||
|
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||||
|
* directly using the email address security@modsecurity.org.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "actions/action.h"
|
||||||
|
#include "actions/transformations/transformation.h"
|
||||||
|
|
||||||
|
#ifndef SRC_ACTIONS_TRANSFORMATIONS_BASE64_ENCODE_H_
|
||||||
|
#define SRC_ACTIONS_TRANSFORMATIONS_BASE64_ENCODE_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace modsecurity {
|
||||||
|
class Transaction;
|
||||||
|
|
||||||
|
namespace actions {
|
||||||
|
namespace transformations {
|
||||||
|
|
||||||
|
class Base64Encode : public Transformation {
|
||||||
|
public:
|
||||||
|
explicit Base64Encode(std::string action) : Transformation(action) { };
|
||||||
|
|
||||||
|
std::string evaluate(std::string exp,
|
||||||
|
Transaction *transaction) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace transformations
|
||||||
|
} // namespace actions
|
||||||
|
} // namespace modsecurity
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // SRC_ACTIONS_TRANSFORMATIONS_BASE64_ENCODE_H_
|
@ -24,6 +24,7 @@
|
|||||||
#include "actions/action.h"
|
#include "actions/action.h"
|
||||||
#include "actions/transformations/base64_decode_ext.h"
|
#include "actions/transformations/base64_decode_ext.h"
|
||||||
#include "actions/transformations/base64_decode.h"
|
#include "actions/transformations/base64_decode.h"
|
||||||
|
#include "actions/transformations/base64_encode.h"
|
||||||
#include "actions/transformations/cmd_line.h"
|
#include "actions/transformations/cmd_line.h"
|
||||||
#include "actions/transformations/compress_whitespace.h"
|
#include "actions/transformations/compress_whitespace.h"
|
||||||
#include "actions/transformations/css_decode.h"
|
#include "actions/transformations/css_decode.h"
|
||||||
@ -75,6 +76,7 @@ std::string Transformation::evaluate(std::string value,
|
|||||||
Transformation* Transformation::instantiate(std::string a) {
|
Transformation* Transformation::instantiate(std::string a) {
|
||||||
IF_MATCH(base64_decode_ext) { return new Base64DecodeExt(a); }
|
IF_MATCH(base64_decode_ext) { return new Base64DecodeExt(a); }
|
||||||
IF_MATCH(base64Decode) { return new Base64Decode(a); }
|
IF_MATCH(base64Decode) { return new Base64Decode(a); }
|
||||||
|
IF_MATCH(base64Encode) { return new Base64Encode(a); }
|
||||||
IF_MATCH(cmd_line) { return new CmdLine(a); }
|
IF_MATCH(cmd_line) { return new CmdLine(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); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user