diff --git a/headers/modsecurity/actions/action.h b/headers/modsecurity/actions/action.h index 03ab5c7d..9fb4398b 100644 --- a/headers/modsecurity/actions/action.h +++ b/headers/modsecurity/actions/action.h @@ -57,7 +57,7 @@ class Action { virtual ~Action() { } - virtual std::string evaluate(std::string exp, + virtual std::string evaluate(const std::string &exp, Transaction *transaction); virtual bool evaluate(Rule *rule, Transaction *transaction); virtual bool evaluate(Rule *rule, Transaction *transaction, diff --git a/src/actions/action.cc b/src/actions/action.cc index 4e781458..e07a3b0a 100644 --- a/src/actions/action.cc +++ b/src/actions/action.cc @@ -45,7 +45,7 @@ namespace modsecurity { namespace actions { -std::string Action::evaluate(std::string value, +std::string Action::evaluate(const std::string &value, Transaction *transaction) { return value; } diff --git a/src/actions/transformations/base64_decode.cc b/src/actions/transformations/base64_decode.cc index 9b81e4e9..e72fefea 100644 --- a/src/actions/transformations/base64_decode.cc +++ b/src/actions/transformations/base64_decode.cc @@ -32,7 +32,7 @@ namespace actions { namespace transformations { -std::string Base64Decode::evaluate(std::string value, +std::string Base64Decode::evaluate(const std::string &value, Transaction *transaction) { std::string ret = Utils::Base64::decode(value); diff --git a/src/actions/transformations/base64_decode.h b/src/actions/transformations/base64_decode.h index a9dbc4cf..6676a99e 100644 --- a/src/actions/transformations/base64_decode.h +++ b/src/actions/transformations/base64_decode.h @@ -32,7 +32,7 @@ class Base64Decode : public Transformation { public: explicit Base64Decode(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/base64_decode_ext.cc b/src/actions/transformations/base64_decode_ext.cc index 6f4f524d..3ea9887c 100644 --- a/src/actions/transformations/base64_decode_ext.cc +++ b/src/actions/transformations/base64_decode_ext.cc @@ -32,7 +32,7 @@ namespace actions { namespace transformations { -std::string Base64DecodeExt::evaluate(std::string value, +std::string Base64DecodeExt::evaluate(const std::string &value, Transaction *transaction) { std::string ret = Utils::Base64::decode_forgiven(value); diff --git a/src/actions/transformations/base64_decode_ext.h b/src/actions/transformations/base64_decode_ext.h index a8793c0f..595e31f2 100644 --- a/src/actions/transformations/base64_decode_ext.h +++ b/src/actions/transformations/base64_decode_ext.h @@ -32,7 +32,7 @@ class Base64DecodeExt : public Transformation { public: explicit Base64DecodeExt(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/base64_encode.cc b/src/actions/transformations/base64_encode.cc index 7f256d63..ffc2465a 100644 --- a/src/actions/transformations/base64_encode.cc +++ b/src/actions/transformations/base64_encode.cc @@ -32,7 +32,7 @@ namespace actions { namespace transformations { -std::string Base64Encode::evaluate(std::string value, +std::string Base64Encode::evaluate(const std::string &value, Transaction *transaction) { std::string ret = Utils::Base64::encode(value); diff --git a/src/actions/transformations/base64_encode.h b/src/actions/transformations/base64_encode.h index 8db2b817..a5dfd0ba 100644 --- a/src/actions/transformations/base64_encode.h +++ b/src/actions/transformations/base64_encode.h @@ -32,7 +32,7 @@ class Base64Encode : public Transformation { public: explicit Base64Encode(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/cmd_line.cc b/src/actions/transformations/cmd_line.cc index da8a80c1..8fd73e81 100644 --- a/src/actions/transformations/cmd_line.cc +++ b/src/actions/transformations/cmd_line.cc @@ -31,7 +31,7 @@ namespace actions { namespace transformations { -std::string CmdLine::evaluate(std::string value, +std::string CmdLine::evaluate(const std::string &value, Transaction *transaction) { std::string ret; int space = 0; diff --git a/src/actions/transformations/cmd_line.h b/src/actions/transformations/cmd_line.h index db357407..81baf848 100644 --- a/src/actions/transformations/cmd_line.h +++ b/src/actions/transformations/cmd_line.h @@ -33,7 +33,7 @@ class CmdLine : public Transformation { explicit CmdLine(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/compress_whitespace.cc b/src/actions/transformations/compress_whitespace.cc index 7b110519..3a0518d7 100644 --- a/src/actions/transformations/compress_whitespace.cc +++ b/src/actions/transformations/compress_whitespace.cc @@ -35,7 +35,7 @@ CompressWhitespace::CompressWhitespace(const std::string &action) this->action_kind = 1; } -std::string CompressWhitespace::evaluate(std::string value, +std::string CompressWhitespace::evaluate(const std::string &value, Transaction *transaction) { std::string a; diff --git a/src/actions/transformations/compress_whitespace.h b/src/actions/transformations/compress_whitespace.h index f38094fa..d8b19370 100644 --- a/src/actions/transformations/compress_whitespace.h +++ b/src/actions/transformations/compress_whitespace.h @@ -30,8 +30,10 @@ namespace transformations { class CompressWhitespace : public Transformation { public: + explicit CompressWhitespace(const std::string &action) ; - std::string evaluate(std::string exp, + + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/css_decode.cc b/src/actions/transformations/css_decode.cc index cadf68cc..4b23618f 100644 --- a/src/actions/transformations/css_decode.cc +++ b/src/actions/transformations/css_decode.cc @@ -34,7 +34,7 @@ namespace actions { namespace transformations { -std::string CssDecode::evaluate(std::string value, +std::string CssDecode::evaluate(const std::string &value, Transaction *transaction) { char *tmp = reinterpret_cast( diff --git a/src/actions/transformations/css_decode.h b/src/actions/transformations/css_decode.h index cab69740..5d41e04d 100644 --- a/src/actions/transformations/css_decode.h +++ b/src/actions/transformations/css_decode.h @@ -33,7 +33,7 @@ class CssDecode : public Transformation { public: explicit CssDecode(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; static int css_decode_inplace(unsigned char *input, int64_t input_len); diff --git a/src/actions/transformations/escape_seq_decode.cc b/src/actions/transformations/escape_seq_decode.cc index d8fbea5a..e32a42d0 100644 --- a/src/actions/transformations/escape_seq_decode.cc +++ b/src/actions/transformations/escape_seq_decode.cc @@ -140,7 +140,7 @@ int EscapeSeqDecode::ansi_c_sequences_decode_inplace(unsigned char *input, } -std::string EscapeSeqDecode::evaluate(std::string value, +std::string EscapeSeqDecode::evaluate(const std::string &value, Transaction *transaction) { unsigned char *tmp = (unsigned char *) malloc(sizeof(char) diff --git a/src/actions/transformations/escape_seq_decode.h b/src/actions/transformations/escape_seq_decode.h index 98370a02..654548aa 100644 --- a/src/actions/transformations/escape_seq_decode.h +++ b/src/actions/transformations/escape_seq_decode.h @@ -30,8 +30,10 @@ namespace transformations { class EscapeSeqDecode : public Transformation { public: + explicit EscapeSeqDecode(const std::string &action) ; - std::string evaluate(std::string exp, + + std::string evaluate(const std::string &exp, Transaction *transaction) override; int ansi_c_sequences_decode_inplace(unsigned char *input, int input_len); }; diff --git a/src/actions/transformations/hex_decode.cc b/src/actions/transformations/hex_decode.cc index 44e30f5f..bc72228f 100644 --- a/src/actions/transformations/hex_decode.cc +++ b/src/actions/transformations/hex_decode.cc @@ -32,7 +32,7 @@ namespace actions { namespace transformations { -std::string HexDecode::evaluate(std::string value, +std::string HexDecode::evaluate(const std::string &value, Transaction *transaction) { std::string ret; unsigned char *input; diff --git a/src/actions/transformations/hex_decode.h b/src/actions/transformations/hex_decode.h index bbf49b2a..8f8aa2eb 100644 --- a/src/actions/transformations/hex_decode.h +++ b/src/actions/transformations/hex_decode.h @@ -32,7 +32,7 @@ class HexDecode : public Transformation { public: explicit HexDecode(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; static int inplace(unsigned char *data, int len); diff --git a/src/actions/transformations/hex_encode.cc b/src/actions/transformations/hex_encode.cc index 4b01230c..912c6f27 100644 --- a/src/actions/transformations/hex_encode.cc +++ b/src/actions/transformations/hex_encode.cc @@ -36,7 +36,7 @@ HexEncode::HexEncode(const std::string &action) this->action_kind = 1; } -std::string HexEncode::evaluate(std::string value, +std::string HexEncode::evaluate(const std::string &value, Transaction *transaction) { std::stringstream result; diff --git a/src/actions/transformations/hex_encode.h b/src/actions/transformations/hex_encode.h index d785c0b1..b76e2672 100644 --- a/src/actions/transformations/hex_encode.h +++ b/src/actions/transformations/hex_encode.h @@ -30,8 +30,10 @@ namespace transformations { class HexEncode : public Transformation { public: - explicit HexEncode(const std::string &action) ; - std::string evaluate(std::string exp, + + explicit HexEncode(const std::string &action); + + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/html_entity_decode.cc b/src/actions/transformations/html_entity_decode.cc index 0a3e996d..48257e76 100644 --- a/src/actions/transformations/html_entity_decode.cc +++ b/src/actions/transformations/html_entity_decode.cc @@ -33,7 +33,7 @@ namespace actions { namespace transformations { -std::string HtmlEntityDecode::evaluate(std::string value, +std::string HtmlEntityDecode::evaluate(const std::string &value, Transaction *transaction) { std::string ret; unsigned char *input; diff --git a/src/actions/transformations/html_entity_decode.h b/src/actions/transformations/html_entity_decode.h index 1c8c620d..eaf5ae0b 100644 --- a/src/actions/transformations/html_entity_decode.h +++ b/src/actions/transformations/html_entity_decode.h @@ -36,7 +36,7 @@ class HtmlEntityDecode : public Transformation { explicit HtmlEntityDecode(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; static int inplace(unsigned char *input, uint64_t input_len); diff --git a/src/actions/transformations/js_decode.cc b/src/actions/transformations/js_decode.cc index 6c01e7fd..89f33b9f 100644 --- a/src/actions/transformations/js_decode.cc +++ b/src/actions/transformations/js_decode.cc @@ -34,7 +34,7 @@ namespace actions { namespace transformations { -std::string JsDecode::evaluate(std::string value, +std::string JsDecode::evaluate(const std::string &value, Transaction *transaction) { std::string ret; unsigned char *input; diff --git a/src/actions/transformations/js_decode.h b/src/actions/transformations/js_decode.h index 1689501c..e680aebc 100644 --- a/src/actions/transformations/js_decode.h +++ b/src/actions/transformations/js_decode.h @@ -33,7 +33,7 @@ class JsDecode : public Transformation { explicit JsDecode(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; static int inplace(unsigned char *input, uint64_t input_len); }; diff --git a/src/actions/transformations/length.cc b/src/actions/transformations/length.cc index 8a902427..e27cd41b 100644 --- a/src/actions/transformations/length.cc +++ b/src/actions/transformations/length.cc @@ -35,7 +35,7 @@ Length::Length(const std::string &action) this->action_kind = 1; } -std::string Length::evaluate(std::string value, +std::string Length::evaluate(const std::string &value, Transaction *transaction) { return std::to_string(value.size()); diff --git a/src/actions/transformations/length.h b/src/actions/transformations/length.h index 07606469..7974b5c1 100644 --- a/src/actions/transformations/length.h +++ b/src/actions/transformations/length.h @@ -30,8 +30,10 @@ namespace transformations { class Length : public Transformation { public: - explicit Length(const std::string &action) ; - std::string evaluate(std::string exp, + + explicit Length(const std::string &action); + + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/lower_case.cc b/src/actions/transformations/lower_case.cc index baabc77c..fcf3ba79 100644 --- a/src/actions/transformations/lower_case.cc +++ b/src/actions/transformations/lower_case.cc @@ -31,9 +31,10 @@ LowerCase::LowerCase(const std::string &a) : Transformation(a) { } -std::string LowerCase::evaluate(std::string value, +std::string LowerCase::evaluate(const std::string &val, Transaction *transaction) { std::locale loc; + std::string value(val); for (std::string::size_type i=0; i < value.length(); ++i) { value[i] = std::tolower(value[i], loc); diff --git a/src/actions/transformations/lower_case.h b/src/actions/transformations/lower_case.h index 41ddf795..12eee321 100644 --- a/src/actions/transformations/lower_case.h +++ b/src/actions/transformations/lower_case.h @@ -32,8 +32,8 @@ namespace transformations { class LowerCase : public Transformation { public: - explicit LowerCase(const std::string &action) ; - std::string evaluate(std::string exp, + explicit LowerCase(const std::string &action); + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/md5.cc b/src/actions/transformations/md5.cc index 17e15c07..8becdb26 100644 --- a/src/actions/transformations/md5.cc +++ b/src/actions/transformations/md5.cc @@ -31,9 +31,9 @@ namespace actions { namespace transformations { -std::string Md5::evaluate(std::string value, +std::string Md5::evaluate(const std::string &value, Transaction *transaction) { - std::string ret = Utils::Md5::digest(value); + std::string ret = Utils::Md5::digest(value); return ret; } diff --git a/src/actions/transformations/md5.h b/src/actions/transformations/md5.h index 7e04ed15..1742b8b5 100644 --- a/src/actions/transformations/md5.h +++ b/src/actions/transformations/md5.h @@ -32,7 +32,7 @@ class Md5 : public Transformation { public: explicit Md5(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/none.cc b/src/actions/transformations/none.cc index 67229e7a..79ab0b84 100644 --- a/src/actions/transformations/none.cc +++ b/src/actions/transformations/none.cc @@ -31,7 +31,7 @@ namespace actions { namespace transformations { -std::string None::evaluate(std::string value, +std::string None::evaluate(const std::string &value, Transaction *transaction) { return value; } diff --git a/src/actions/transformations/none.h b/src/actions/transformations/none.h index 7cee4b42..00bf37a7 100644 --- a/src/actions/transformations/none.h +++ b/src/actions/transformations/none.h @@ -34,7 +34,7 @@ class None : public Transformation { : Transformation(action) { m_isNone = true; } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/normalise_path.cc b/src/actions/transformations/normalise_path.cc index 3c184976..ad76a22a 100644 --- a/src/actions/transformations/normalise_path.cc +++ b/src/actions/transformations/normalise_path.cc @@ -37,7 +37,7 @@ NormalisePath::NormalisePath(const std::string &action) this->action_kind = 1; } -std::string NormalisePath::evaluate(std::string value, +std::string NormalisePath::evaluate(const std::string &value, Transaction *transaction) { int changed = 0; diff --git a/src/actions/transformations/normalise_path.h b/src/actions/transformations/normalise_path.h index e41a915c..3c98d7f9 100644 --- a/src/actions/transformations/normalise_path.h +++ b/src/actions/transformations/normalise_path.h @@ -30,8 +30,10 @@ namespace transformations { class NormalisePath : public Transformation { public: - explicit NormalisePath(const std::string &action) ; - std::string evaluate(std::string exp, + + explicit NormalisePath(const std::string &action); + + std::string evaluate(const std::string &exp, Transaction *transaction) override; static int normalize_path_inplace(unsigned char *input, int input_len, diff --git a/src/actions/transformations/normalise_path_win.cc b/src/actions/transformations/normalise_path_win.cc index d4198acd..8970e8b9 100644 --- a/src/actions/transformations/normalise_path_win.cc +++ b/src/actions/transformations/normalise_path_win.cc @@ -34,7 +34,7 @@ namespace actions { namespace transformations { -std::string NormalisePathWin::evaluate(std::string value, +std::string NormalisePathWin::evaluate(const std::string &value, Transaction *transaction) { int changed; diff --git a/src/actions/transformations/normalise_path_win.h b/src/actions/transformations/normalise_path_win.h index 360bc832..61ce0ca0 100644 --- a/src/actions/transformations/normalise_path_win.h +++ b/src/actions/transformations/normalise_path_win.h @@ -33,7 +33,7 @@ class NormalisePathWin : public Transformation { explicit NormalisePathWin(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/parity_even_7bit.cc b/src/actions/transformations/parity_even_7bit.cc index 1da74b8c..357fe759 100644 --- a/src/actions/transformations/parity_even_7bit.cc +++ b/src/actions/transformations/parity_even_7bit.cc @@ -32,7 +32,7 @@ namespace actions { namespace transformations { -std::string ParityEven7bit::evaluate(std::string value, +std::string ParityEven7bit::evaluate(const std::string &value, Transaction *transaction) { std::string ret; unsigned char *input; diff --git a/src/actions/transformations/parity_even_7bit.h b/src/actions/transformations/parity_even_7bit.h index 5996f3d8..7ec5f2aa 100644 --- a/src/actions/transformations/parity_even_7bit.h +++ b/src/actions/transformations/parity_even_7bit.h @@ -32,7 +32,7 @@ class ParityEven7bit : public Transformation { public: explicit ParityEven7bit(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, Transaction *transaction) override; + std::string evaluate(const std::string &exp, Transaction *transaction) override; static bool inplace(unsigned char *input, uint64_t input_len); }; diff --git a/src/actions/transformations/parity_odd_7bit.cc b/src/actions/transformations/parity_odd_7bit.cc index 28447291..fbd6c8fc 100644 --- a/src/actions/transformations/parity_odd_7bit.cc +++ b/src/actions/transformations/parity_odd_7bit.cc @@ -32,7 +32,7 @@ namespace actions { namespace transformations { -std::string ParityOdd7bit::evaluate(std::string value, +std::string ParityOdd7bit::evaluate(const std::string &value, Transaction *transaction) { std::string ret; unsigned char *input; diff --git a/src/actions/transformations/parity_odd_7bit.h b/src/actions/transformations/parity_odd_7bit.h index c5e74e73..9af53722 100644 --- a/src/actions/transformations/parity_odd_7bit.h +++ b/src/actions/transformations/parity_odd_7bit.h @@ -32,7 +32,7 @@ class ParityOdd7bit : public Transformation { public: explicit ParityOdd7bit(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, Transaction *transaction) override; + std::string evaluate(const std::string &exp, Transaction *transaction) override; static bool inplace(unsigned char *input, uint64_t input_len); }; diff --git a/src/actions/transformations/parity_zero_7bit.cc b/src/actions/transformations/parity_zero_7bit.cc index 3ab6987c..93a0f974 100644 --- a/src/actions/transformations/parity_zero_7bit.cc +++ b/src/actions/transformations/parity_zero_7bit.cc @@ -32,7 +32,7 @@ namespace actions { namespace transformations { -std::string ParityZero7bit::evaluate(std::string value, +std::string ParityZero7bit::evaluate(const std::string &value, Transaction *transaction) { std::string ret; unsigned char *input; diff --git a/src/actions/transformations/parity_zero_7bit.h b/src/actions/transformations/parity_zero_7bit.h index 6c3897f9..5e30dd5d 100644 --- a/src/actions/transformations/parity_zero_7bit.h +++ b/src/actions/transformations/parity_zero_7bit.h @@ -32,7 +32,7 @@ class ParityZero7bit : public Transformation { public: explicit ParityZero7bit(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, Transaction *transaction) override; + std::string evaluate(const std::string &exp, Transaction *transaction) override; static bool inplace(unsigned char *input, uint64_t input_len); }; diff --git a/src/actions/transformations/remove_comments.cc b/src/actions/transformations/remove_comments.cc index 5d2a9774..4bce61b5 100644 --- a/src/actions/transformations/remove_comments.cc +++ b/src/actions/transformations/remove_comments.cc @@ -32,7 +32,7 @@ namespace actions { namespace transformations { -std::string RemoveComments::evaluate(std::string value, +std::string RemoveComments::evaluate(const std::string &value, Transaction *transaction) { std::string ret; unsigned char *input; diff --git a/src/actions/transformations/remove_comments.h b/src/actions/transformations/remove_comments.h index 711ca9ef..46ad2a7e 100644 --- a/src/actions/transformations/remove_comments.h +++ b/src/actions/transformations/remove_comments.h @@ -33,7 +33,7 @@ class RemoveComments : public Transformation { public: explicit RemoveComments(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/remove_comments_char.cc b/src/actions/transformations/remove_comments_char.cc index 010d7aa3..68bd28c3 100644 --- a/src/actions/transformations/remove_comments_char.cc +++ b/src/actions/transformations/remove_comments_char.cc @@ -35,9 +35,10 @@ RemoveCommentsChar::RemoveCommentsChar(const std::string &action) this->action_kind = 1; } -std::string RemoveCommentsChar::evaluate(std::string value, +std::string RemoveCommentsChar::evaluate(const std::string &val, Transaction *transaction) { int64_t i; + std::string value(val); i = 0; while (i < value.size()) { diff --git a/src/actions/transformations/remove_comments_char.h b/src/actions/transformations/remove_comments_char.h index f5f60467..03091ceb 100644 --- a/src/actions/transformations/remove_comments_char.h +++ b/src/actions/transformations/remove_comments_char.h @@ -30,8 +30,9 @@ namespace transformations { class RemoveCommentsChar : public Transformation { public: - explicit RemoveCommentsChar(const std::string &action) ; - std::string evaluate(std::string exp, + explicit RemoveCommentsChar(const std::string &action); + + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/remove_nulls.cc b/src/actions/transformations/remove_nulls.cc index d419c81b..991956d0 100644 --- a/src/actions/transformations/remove_nulls.cc +++ b/src/actions/transformations/remove_nulls.cc @@ -33,9 +33,10 @@ namespace actions { namespace transformations { -std::string RemoveNulls::evaluate(std::string value, +std::string RemoveNulls::evaluate(const std::string &val, Transaction *transaction) { int64_t i; + std::string value(val); i = 0; while (i < value.size()) { diff --git a/src/actions/transformations/remove_nulls.h b/src/actions/transformations/remove_nulls.h index 20c0e9db..6d5a0820 100644 --- a/src/actions/transformations/remove_nulls.h +++ b/src/actions/transformations/remove_nulls.h @@ -33,7 +33,7 @@ class RemoveNulls : public Transformation { explicit RemoveNulls(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/remove_whitespace.cc b/src/actions/transformations/remove_whitespace.cc index b5f7d5b7..a3687cc3 100644 --- a/src/actions/transformations/remove_whitespace.cc +++ b/src/actions/transformations/remove_whitespace.cc @@ -36,8 +36,9 @@ RemoveWhitespace::RemoveWhitespace(const std::string &action) this->action_kind = 1; } -std::string RemoveWhitespace::evaluate(std::string value, +std::string RemoveWhitespace::evaluate(const std::string &val, Transaction *transaction) { + std::string value(val); int64_t i = 0; diff --git a/src/actions/transformations/remove_whitespace.h b/src/actions/transformations/remove_whitespace.h index 746e1556..c2968ddc 100644 --- a/src/actions/transformations/remove_whitespace.h +++ b/src/actions/transformations/remove_whitespace.h @@ -30,8 +30,9 @@ namespace transformations { class RemoveWhitespace : public Transformation { public: - explicit RemoveWhitespace(const std::string &action) ; - std::string evaluate(std::string exp, + explicit RemoveWhitespace(const std::string &action); + + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/replace_comments.cc b/src/actions/transformations/replace_comments.cc index 48a40fbc..6f0250cb 100644 --- a/src/actions/transformations/replace_comments.cc +++ b/src/actions/transformations/replace_comments.cc @@ -36,7 +36,7 @@ ReplaceComments::ReplaceComments(const std::string &action) this->action_kind = 1; } -std::string ReplaceComments::evaluate(std::string value, +std::string ReplaceComments::evaluate(const std::string &value, Transaction *transaction) { uint64_t i, j, incomment; diff --git a/src/actions/transformations/replace_comments.h b/src/actions/transformations/replace_comments.h index 24648160..a2c06a4c 100644 --- a/src/actions/transformations/replace_comments.h +++ b/src/actions/transformations/replace_comments.h @@ -30,8 +30,10 @@ namespace transformations { class ReplaceComments : public Transformation { public: + explicit ReplaceComments(const std::string &action) ; - std::string evaluate(std::string exp, + + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/replace_nulls.cc b/src/actions/transformations/replace_nulls.cc index df59300d..7f20d0da 100644 --- a/src/actions/transformations/replace_nulls.cc +++ b/src/actions/transformations/replace_nulls.cc @@ -35,9 +35,10 @@ ReplaceNulls::ReplaceNulls(const std::string &action) this->action_kind = 1; } -std::string ReplaceNulls::evaluate(std::string value, +std::string ReplaceNulls::evaluate(const std::string &val, Transaction *transaction) { int64_t i; + std::string value(val); i = 0; while (i < value.size()) { diff --git a/src/actions/transformations/replace_nulls.h b/src/actions/transformations/replace_nulls.h index 87155b86..7af92643 100644 --- a/src/actions/transformations/replace_nulls.h +++ b/src/actions/transformations/replace_nulls.h @@ -30,8 +30,10 @@ namespace transformations { class ReplaceNulls : public Transformation { public: + explicit ReplaceNulls(const std::string &action) ; - std::string evaluate(std::string exp, + + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/sha1.cc b/src/actions/transformations/sha1.cc index 3cb69dee..0c30512a 100644 --- a/src/actions/transformations/sha1.cc +++ b/src/actions/transformations/sha1.cc @@ -36,7 +36,7 @@ Sha1::Sha1(const std::string &action) this->action_kind = 1; } -std::string Sha1::evaluate(std::string value, +std::string Sha1::evaluate(const std::string &value, Transaction *transaction) { return Utils::Sha1::digest(value); diff --git a/src/actions/transformations/sha1.h b/src/actions/transformations/sha1.h index 318128b0..87e5aaa1 100644 --- a/src/actions/transformations/sha1.h +++ b/src/actions/transformations/sha1.h @@ -31,7 +31,7 @@ namespace transformations { class Sha1 : public Transformation { public: explicit Sha1(const std::string &action) ; - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/sql_hex_decode.cc b/src/actions/transformations/sql_hex_decode.cc index dcf872b7..b33deac7 100644 --- a/src/actions/transformations/sql_hex_decode.cc +++ b/src/actions/transformations/sql_hex_decode.cc @@ -41,7 +41,7 @@ namespace transformations { #define ISODIGIT(X) ((X >= '0') && (X <= '7')) #endif -std::string SqlHexDecode::evaluate(std::string value, +std::string SqlHexDecode::evaluate(const std::string &value, Transaction *transaction) { std::string ret; unsigned char *input; diff --git a/src/actions/transformations/sql_hex_decode.h b/src/actions/transformations/sql_hex_decode.h index 2d04d90e..4ef5a63e 100644 --- a/src/actions/transformations/sql_hex_decode.h +++ b/src/actions/transformations/sql_hex_decode.h @@ -32,7 +32,7 @@ class SqlHexDecode : public Transformation { public: explicit SqlHexDecode(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; static int inplace(unsigned char *data, int len); diff --git a/src/actions/transformations/transformation.cc b/src/actions/transformations/transformation.cc index 71ea175f..fae80ee6 100644 --- a/src/actions/transformations/transformation.cc +++ b/src/actions/transformations/transformation.cc @@ -69,7 +69,7 @@ namespace actions { namespace transformations { -std::string Transformation::evaluate(std::string value, +std::string Transformation::evaluate(const std::string &value, Transaction *transaction) { return value; } diff --git a/src/actions/transformations/transformation.h b/src/actions/transformations/transformation.h index 77baeff2..57f20416 100644 --- a/src/actions/transformations/transformation.h +++ b/src/actions/transformations/transformation.h @@ -35,7 +35,7 @@ class Transformation : public Action { explicit Transformation(const std::string& _action, int kind) : Action(_action, kind) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; static Transformation* instantiate(std::string a); diff --git a/src/actions/transformations/trim.cc b/src/actions/transformations/trim.cc index 2c8f158b..4954237a 100644 --- a/src/actions/transformations/trim.cc +++ b/src/actions/transformations/trim.cc @@ -57,8 +57,9 @@ Trim::Trim(const std::string &action) std::string -Trim::evaluate(std::string value, +Trim::evaluate(const std::string &val, Transaction *transaction) { + std::string value(val); return *this->trim(&value); } diff --git a/src/actions/transformations/trim.h b/src/actions/transformations/trim.h index dd215ec0..4deebb4f 100644 --- a/src/actions/transformations/trim.h +++ b/src/actions/transformations/trim.h @@ -30,8 +30,10 @@ namespace transformations { class Trim : public Transformation { public: + explicit Trim(const std::string &action) ; - std::string evaluate(std::string exp, + + std::string evaluate(const std::string &exp, Transaction *transaction) override; std::string *ltrim(std::string *s); diff --git a/src/actions/transformations/trim_left.cc b/src/actions/transformations/trim_left.cc index eff0167d..9116e3c8 100644 --- a/src/actions/transformations/trim_left.cc +++ b/src/actions/transformations/trim_left.cc @@ -38,8 +38,9 @@ TrimLeft::TrimLeft(const std::string &action) this->action_kind = 1; } -std::string TrimLeft::evaluate(std::string value, +std::string TrimLeft::evaluate(const std::string &val, Transaction *transaction) { + std::string value(val); return *ltrim(&value); } diff --git a/src/actions/transformations/trim_left.h b/src/actions/transformations/trim_left.h index dedfd1d0..e7799208 100644 --- a/src/actions/transformations/trim_left.h +++ b/src/actions/transformations/trim_left.h @@ -32,7 +32,8 @@ namespace transformations { class TrimLeft : public Trim { public: explicit TrimLeft(const std::string &action) ; - std::string evaluate(std::string exp, + + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/trim_right.cc b/src/actions/transformations/trim_right.cc index 1c77a1b7..bb7cac08 100644 --- a/src/actions/transformations/trim_right.cc +++ b/src/actions/transformations/trim_right.cc @@ -36,8 +36,9 @@ TrimRight::TrimRight(const std::string &action) this->action_kind = 1; } -std::string TrimRight::evaluate(std::string value, +std::string TrimRight::evaluate(const std::string &val, Transaction *transaction) { + std::string value(val); return *this->rtrim(&value); } diff --git a/src/actions/transformations/trim_right.h b/src/actions/transformations/trim_right.h index dca5bef7..8c100928 100644 --- a/src/actions/transformations/trim_right.h +++ b/src/actions/transformations/trim_right.h @@ -32,7 +32,8 @@ namespace transformations { class TrimRight : public Trim { public: explicit TrimRight(const std::string &action) ; - std::string evaluate(std::string exp, + + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/upper_case.cc b/src/actions/transformations/upper_case.cc index 91256e50..0ae77c0e 100644 --- a/src/actions/transformations/upper_case.cc +++ b/src/actions/transformations/upper_case.cc @@ -31,8 +31,9 @@ UpperCase::UpperCase(const std::string &a) : Transformation(a) { } -std::string UpperCase::evaluate(std::string value, +std::string UpperCase::evaluate(const std::string &val, Transaction *transaction) { + std::string value(val); std::locale loc; for (std::string::size_type i=0; i < value.length(); ++i) { diff --git a/src/actions/transformations/upper_case.h b/src/actions/transformations/upper_case.h index 70cf2e70..542df283 100644 --- a/src/actions/transformations/upper_case.h +++ b/src/actions/transformations/upper_case.h @@ -33,7 +33,8 @@ namespace transformations { class UpperCase : public Transformation { public: explicit UpperCase(const std::string &action) ; - std::string evaluate(std::string exp, + + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/url_decode.cc b/src/actions/transformations/url_decode.cc index f721b784..c533b7e8 100644 --- a/src/actions/transformations/url_decode.cc +++ b/src/actions/transformations/url_decode.cc @@ -37,7 +37,7 @@ UrlDecode::UrlDecode(const std::string &action) this->action_kind = 1; } -std::string UrlDecode::evaluate(std::string value, +std::string UrlDecode::evaluate(const std::string &value, Transaction *transaction) { unsigned char *val = NULL; int invalid_count = 0; diff --git a/src/actions/transformations/url_decode.h b/src/actions/transformations/url_decode.h index 26a0e2a7..9e39045b 100644 --- a/src/actions/transformations/url_decode.h +++ b/src/actions/transformations/url_decode.h @@ -32,8 +32,10 @@ namespace transformations { class UrlDecode : public Transformation { public: + explicit UrlDecode(const std::string &action) ; - std::string evaluate(std::string exp, + + std::string evaluate(const std::string &exp, Transaction *transaction) override; }; diff --git a/src/actions/transformations/url_decode_uni.cc b/src/actions/transformations/url_decode_uni.cc index 0485a03c..95331250 100644 --- a/src/actions/transformations/url_decode_uni.cc +++ b/src/actions/transformations/url_decode_uni.cc @@ -38,7 +38,7 @@ namespace actions { namespace transformations { -std::string UrlDecodeUni::evaluate(std::string value, +std::string UrlDecodeUni::evaluate(const std::string &value, Transaction *t) { std::string ret; unsigned char *input; diff --git a/src/actions/transformations/url_decode_uni.h b/src/actions/transformations/url_decode_uni.h index 6bc7415b..b04aef89 100644 --- a/src/actions/transformations/url_decode_uni.h +++ b/src/actions/transformations/url_decode_uni.h @@ -33,7 +33,7 @@ class UrlDecodeUni : public Transformation { public: explicit UrlDecodeUni(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, Transaction *transaction) override; + std::string evaluate(const std::string &exp, Transaction *transaction) override; static int inplace(unsigned char *input, uint64_t input_len, Transaction *transaction); }; diff --git a/src/actions/transformations/url_encode.cc b/src/actions/transformations/url_encode.cc index a83028b4..23a8f167 100644 --- a/src/actions/transformations/url_encode.cc +++ b/src/actions/transformations/url_encode.cc @@ -87,7 +87,7 @@ std::string UrlEncode::url_enc(const char *input, } -std::string UrlEncode::evaluate(std::string value, +std::string UrlEncode::evaluate(const std::string &value, Transaction *transaction) { int changed; diff --git a/src/actions/transformations/url_encode.h b/src/actions/transformations/url_encode.h index 3f56ec48..438301f7 100644 --- a/src/actions/transformations/url_encode.h +++ b/src/actions/transformations/url_encode.h @@ -30,8 +30,10 @@ namespace transformations { class UrlEncode : public Transformation { public: + explicit UrlEncode(const std::string &action) ; - std::string evaluate(std::string exp, + + std::string evaluate(const std::string &exp, Transaction *transaction) override; std::string url_enc(const char *input, diff --git a/src/actions/transformations/utf8_to_unicode.cc b/src/actions/transformations/utf8_to_unicode.cc index d9f4f4e0..38d9a2b7 100644 --- a/src/actions/transformations/utf8_to_unicode.cc +++ b/src/actions/transformations/utf8_to_unicode.cc @@ -33,7 +33,7 @@ namespace actions { namespace transformations { -std::string Utf8ToUnicode::evaluate(std::string value, +std::string Utf8ToUnicode::evaluate(const std::string &value, Transaction *transaction) { std::string ret; unsigned char *input; diff --git a/src/actions/transformations/utf8_to_unicode.h b/src/actions/transformations/utf8_to_unicode.h index 038f8a14..c76bb0a2 100644 --- a/src/actions/transformations/utf8_to_unicode.h +++ b/src/actions/transformations/utf8_to_unicode.h @@ -37,7 +37,7 @@ class Utf8ToUnicode : public Transformation { public: explicit Utf8ToUnicode(const std::string &action) : Transformation(action) { } - std::string evaluate(std::string exp, + std::string evaluate(const std::string &exp, Transaction *transaction) override; static char *inplace(unsigned char *input, uint64_t input_len, diff --git a/src/utils/md5.cc b/src/utils/md5.cc index 0601bf93..84746007 100644 --- a/src/utils/md5.cc +++ b/src/utils/md5.cc @@ -7,7 +7,7 @@ namespace modsecurity { namespace Utils { -std::string Md5::hexdigest(std::string& input) { +std::string Md5::hexdigest(const std::string& input) { unsigned char digest[16]; mbedtls_md5(reinterpret_cast(input.c_str()), @@ -22,7 +22,7 @@ std::string Md5::hexdigest(std::string& input) { } -std::string Md5::digest(std::string& input) { +std::string Md5::digest(const std::string& input) { unsigned char output[16]; std::string ret; diff --git a/src/utils/md5.h b/src/utils/md5.h index a7cfd85b..6720a8b3 100644 --- a/src/utils/md5.h +++ b/src/utils/md5.h @@ -31,8 +31,8 @@ class Md5 { public: Md5() { } - static std::string hexdigest(std::string& input); - static std::string digest(std::string& input); + static std::string hexdigest(const std::string& input); + static std::string digest(const std::string& input); }; } // namespace Utils