Refactoring: rename evaluate to execute on actions

This commit is contained in:
Felipe Zimmerle
2019-02-25 21:47:51 -03:00
parent 47ec32fba8
commit affdc49a9e
170 changed files with 234 additions and 239 deletions

View File

@@ -32,7 +32,7 @@ namespace actions {
namespace transformations {
std::string Base64Decode::evaluate(const std::string &value,
std::string Base64Decode::execute(const std::string &value,
Transaction *transaction) {
std::string ret = Utils::Base64::decode(value);

View File

@@ -32,7 +32,7 @@ class Base64Decode : public Transformation {
public:
explicit Base64Decode(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -32,7 +32,7 @@ namespace actions {
namespace transformations {
std::string Base64DecodeExt::evaluate(const std::string &value,
std::string Base64DecodeExt::execute(const std::string &value,
Transaction *transaction) {
std::string ret = Utils::Base64::decode_forgiven(value);

View File

@@ -32,7 +32,7 @@ class Base64DecodeExt : public Transformation {
public:
explicit Base64DecodeExt(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -32,7 +32,7 @@ namespace actions {
namespace transformations {
std::string Base64Encode::evaluate(const std::string &value,
std::string Base64Encode::execute(const std::string &value,
Transaction *transaction) {
std::string ret = Utils::Base64::encode(value);

View File

@@ -32,7 +32,7 @@ class Base64Encode : public Transformation {
public:
explicit Base64Encode(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -31,7 +31,7 @@ namespace actions {
namespace transformations {
std::string CmdLine::evaluate(const std::string &value,
std::string CmdLine::execute(const std::string &value,
Transaction *transaction) {
std::string ret;
int space = 0;

View File

@@ -33,7 +33,7 @@ class CmdLine : public Transformation {
explicit CmdLine(const std::string &action)
: Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -35,7 +35,7 @@ CompressWhitespace::CompressWhitespace(const std::string &action)
this->action_kind = 1;
}
std::string CompressWhitespace::evaluate(const std::string &value,
std::string CompressWhitespace::execute(const std::string &value,
Transaction *transaction) {
std::string a;

View File

@@ -30,10 +30,9 @@ namespace transformations {
class CompressWhitespace : public Transformation {
public:
explicit CompressWhitespace(const std::string &action) ;
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -34,7 +34,7 @@ namespace actions {
namespace transformations {
std::string CssDecode::evaluate(const std::string &value,
std::string CssDecode::execute(const std::string &value,
Transaction *transaction) {
char *tmp = reinterpret_cast<char *>(

View File

@@ -33,7 +33,7 @@ class CssDecode : public Transformation {
public:
explicit CssDecode(const std::string &action)
: Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
static int css_decode_inplace(unsigned char *input, int64_t input_len);

View File

@@ -140,7 +140,7 @@ int EscapeSeqDecode::ansi_c_sequences_decode_inplace(unsigned char *input,
}
std::string EscapeSeqDecode::evaluate(const std::string &value,
std::string EscapeSeqDecode::execute(const std::string &value,
Transaction *transaction) {
unsigned char *tmp = (unsigned char *) malloc(sizeof(char)

View File

@@ -30,10 +30,8 @@ namespace transformations {
class EscapeSeqDecode : public Transformation {
public:
explicit EscapeSeqDecode(const std::string &action) ;
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
static int ansi_c_sequences_decode_inplace(unsigned char *input, int input_len);
};

View File

@@ -32,7 +32,7 @@ namespace actions {
namespace transformations {
std::string HexDecode::evaluate(const std::string &value,
std::string HexDecode::execute(const std::string &value,
Transaction *transaction) {
std::string ret;
unsigned char *input;

View File

@@ -32,7 +32,7 @@ class HexDecode : public Transformation {
public:
explicit HexDecode(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
static int inplace(unsigned char *data, int len);

View File

@@ -36,7 +36,7 @@ HexEncode::HexEncode(const std::string &action)
this->action_kind = 1;
}
std::string HexEncode::evaluate(const std::string &value,
std::string HexEncode::execute(const std::string &value,
Transaction *transaction) {
std::stringstream result;

View File

@@ -30,10 +30,9 @@ namespace transformations {
class HexEncode : public Transformation {
public:
explicit HexEncode(const std::string &action);
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -33,7 +33,7 @@ namespace actions {
namespace transformations {
std::string HtmlEntityDecode::evaluate(const std::string &value,
std::string HtmlEntityDecode::execute(const std::string &value,
Transaction *transaction) {
std::string ret;
unsigned char *input;

View File

@@ -36,7 +36,7 @@ class HtmlEntityDecode : public Transformation {
explicit HtmlEntityDecode(const std::string &action)
: Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
static int inplace(unsigned char *input, uint64_t input_len);

View File

@@ -34,7 +34,7 @@ namespace actions {
namespace transformations {
std::string JsDecode::evaluate(const std::string &value,
std::string JsDecode::execute(const std::string &value,
Transaction *transaction) {
std::string ret;
unsigned char *input;

View File

@@ -33,7 +33,7 @@ class JsDecode : public Transformation {
explicit JsDecode(const std::string &action)
: Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
static int inplace(unsigned char *input, uint64_t input_len);
};

View File

@@ -35,7 +35,7 @@ Length::Length(const std::string &action)
this->action_kind = 1;
}
std::string Length::evaluate(const std::string &value,
std::string Length::execute(const std::string &value,
Transaction *transaction) {
return std::to_string(value.size());

View File

@@ -30,10 +30,9 @@ namespace transformations {
class Length : public Transformation {
public:
explicit Length(const std::string &action);
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -31,7 +31,7 @@ LowerCase::LowerCase(const std::string &a)
: Transformation(a) {
}
std::string LowerCase::evaluate(const std::string &val,
std::string LowerCase::execute(const std::string &val,
Transaction *transaction) {
std::locale loc;
std::string value(val);

View File

@@ -33,7 +33,7 @@ namespace transformations {
class LowerCase : public Transformation {
public:
explicit LowerCase(const std::string &action);
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -31,7 +31,7 @@ namespace actions {
namespace transformations {
std::string Md5::evaluate(const std::string &value,
std::string Md5::execute(const std::string &value,
Transaction *transaction) {
std::string ret = Utils::Md5::digest(value);

View File

@@ -32,7 +32,7 @@ class Md5 : public Transformation {
public:
explicit Md5(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -31,7 +31,7 @@ namespace actions {
namespace transformations {
std::string None::evaluate(const std::string &value,
std::string None::execute(const std::string &value,
Transaction *transaction) {
return value;
}

View File

@@ -34,7 +34,7 @@ class None : public Transformation {
: Transformation(action)
{ m_isNone = true; }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -37,7 +37,7 @@ NormalisePath::NormalisePath(const std::string &action)
this->action_kind = 1;
}
std::string NormalisePath::evaluate(const std::string &value,
std::string NormalisePath::execute(const std::string &value,
Transaction *transaction) {
int changed = 0;

View File

@@ -30,10 +30,9 @@ namespace transformations {
class NormalisePath : public Transformation {
public:
explicit NormalisePath(const std::string &action);
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
static int normalize_path_inplace(unsigned char *input, int input_len,

View File

@@ -34,7 +34,7 @@ namespace actions {
namespace transformations {
std::string NormalisePathWin::evaluate(const std::string &value,
std::string NormalisePathWin::execute(const std::string &value,
Transaction *transaction) {
int changed;

View File

@@ -33,7 +33,7 @@ class NormalisePathWin : public Transformation {
explicit NormalisePathWin(const std::string &action)
: Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -32,7 +32,7 @@ namespace actions {
namespace transformations {
std::string ParityEven7bit::evaluate(const std::string &value,
std::string ParityEven7bit::execute(const std::string &value,
Transaction *transaction) {
std::string ret;
unsigned char *input;

View File

@@ -32,7 +32,7 @@ class ParityEven7bit : public Transformation {
public:
explicit ParityEven7bit(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp, Transaction *transaction) override;
std::string execute(const std::string &exp, Transaction *transaction) override;
static bool inplace(unsigned char *input, uint64_t input_len);
};

View File

@@ -32,7 +32,7 @@ namespace actions {
namespace transformations {
std::string ParityOdd7bit::evaluate(const std::string &value,
std::string ParityOdd7bit::execute(const std::string &value,
Transaction *transaction) {
std::string ret;
unsigned char *input;

View File

@@ -32,7 +32,7 @@ class ParityOdd7bit : public Transformation {
public:
explicit ParityOdd7bit(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp, Transaction *transaction) override;
std::string execute(const std::string &exp, Transaction *transaction) override;
static bool inplace(unsigned char *input, uint64_t input_len);
};

View File

@@ -32,7 +32,7 @@ namespace actions {
namespace transformations {
std::string ParityZero7bit::evaluate(const std::string &value,
std::string ParityZero7bit::execute(const std::string &value,
Transaction *transaction) {
std::string ret;
unsigned char *input;

View File

@@ -32,7 +32,7 @@ class ParityZero7bit : public Transformation {
public:
explicit ParityZero7bit(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp, Transaction *transaction) override;
std::string execute(const std::string &exp, Transaction *transaction) override;
static bool inplace(unsigned char *input, uint64_t input_len);
};

View File

@@ -32,7 +32,8 @@ PhpArgsNames::PhpArgsNames(const std::string &a)
: Transformation(a) {
}
std::string PhpArgsNames::evaluate(const std::string &val,
std::string PhpArgsNames::execute(const std::string &val,
Transaction *transaction) {
//Took the logic from php src code:
//https://github.com/php/php-src/blob/master/main/php_variables.c

View File

@@ -33,7 +33,8 @@ namespace transformations {
class PhpArgsNames : public Transformation {
public:
explicit PhpArgsNames(const std::string &action);
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -32,7 +32,7 @@ namespace actions {
namespace transformations {
std::string RemoveComments::evaluate(const std::string &value,
std::string RemoveComments::execute(const std::string &value,
Transaction *transaction) {
std::string ret;
unsigned char *input;

View File

@@ -33,7 +33,7 @@ class RemoveComments : public Transformation {
public:
explicit RemoveComments(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -35,7 +35,7 @@ RemoveCommentsChar::RemoveCommentsChar(const std::string &action)
this->action_kind = 1;
}
std::string RemoveCommentsChar::evaluate(const std::string &val,
std::string RemoveCommentsChar::execute(const std::string &val,
Transaction *transaction) {
int64_t i;
std::string value(val);

View File

@@ -32,7 +32,7 @@ class RemoveCommentsChar : public Transformation {
public:
explicit RemoveCommentsChar(const std::string &action);
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -33,7 +33,7 @@ namespace actions {
namespace transformations {
std::string RemoveNulls::evaluate(const std::string &val,
std::string RemoveNulls::execute(const std::string &val,
Transaction *transaction) {
int64_t i;
std::string value(val);

View File

@@ -33,7 +33,7 @@ class RemoveNulls : public Transformation {
explicit RemoveNulls(const std::string &action)
: Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -36,7 +36,7 @@ RemoveWhitespace::RemoveWhitespace(const std::string &action)
this->action_kind = 1;
}
std::string RemoveWhitespace::evaluate(const std::string &val,
std::string RemoveWhitespace::execute(const std::string &val,
Transaction *transaction) {
std::string value(val);

View File

@@ -32,7 +32,7 @@ class RemoveWhitespace : public Transformation {
public:
explicit RemoveWhitespace(const std::string &action);
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -36,7 +36,7 @@ ReplaceComments::ReplaceComments(const std::string &action)
this->action_kind = 1;
}
std::string ReplaceComments::evaluate(const std::string &value,
std::string ReplaceComments::execute(const std::string &value,
Transaction *transaction) {
uint64_t i, j, incomment;

View File

@@ -30,10 +30,9 @@ namespace transformations {
class ReplaceComments : public Transformation {
public:
explicit ReplaceComments(const std::string &action) ;
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -35,7 +35,7 @@ ReplaceNulls::ReplaceNulls(const std::string &action)
this->action_kind = 1;
}
std::string ReplaceNulls::evaluate(const std::string &val,
std::string ReplaceNulls::execute(const std::string &val,
Transaction *transaction) {
int64_t i;
std::string value(val);

View File

@@ -30,10 +30,9 @@ namespace transformations {
class ReplaceNulls : public Transformation {
public:
explicit ReplaceNulls(const std::string &action) ;
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -36,7 +36,7 @@ Sha1::Sha1(const std::string &action)
this->action_kind = 1;
}
std::string Sha1::evaluate(const std::string &value,
std::string Sha1::execute(const std::string &value,
Transaction *transaction) {
return Utils::Sha1::digest(value);

View File

@@ -31,7 +31,8 @@ namespace transformations {
class Sha1 : public Transformation {
public:
explicit Sha1(const std::string &action) ;
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -41,7 +41,7 @@ namespace transformations {
#define ISODIGIT(X) ((X >= '0') && (X <= '7'))
#endif
std::string SqlHexDecode::evaluate(const std::string &value,
std::string SqlHexDecode::execute(const std::string &value,
Transaction *transaction) {
std::string ret;
unsigned char *input;

View File

@@ -32,7 +32,7 @@ class SqlHexDecode : public Transformation {
public:
explicit SqlHexDecode(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
static int inplace(unsigned char *data, int len);

View File

@@ -70,7 +70,7 @@ namespace actions {
namespace transformations {
std::string Transformation::evaluate(const std::string &value,
std::string Transformation::execute(const std::string &value,
Transaction *transaction) {
return value;
}

View File

@@ -32,10 +32,10 @@ class Transformation : public Action {
explicit Transformation(const std::string& _action)
: Action(_action, RunTimeBeforeMatchAttemptKind) { }
explicit Transformation(const std::string& _action, int kind)
Transformation(const std::string& _action, int kind)
: Action(_action, kind) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
static Transformation* instantiate(std::string a);

View File

@@ -57,7 +57,7 @@ Trim::Trim(const std::string &action)
std::string
Trim::evaluate(const std::string &val,
Trim::execute(const std::string &val,
Transaction *transaction) {
std::string value(val);
return *this->trim(&value);

View File

@@ -30,10 +30,9 @@ namespace transformations {
class Trim : public Transformation {
public:
explicit Trim(const std::string &action) ;
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
std::string *ltrim(std::string *s);

View File

@@ -38,7 +38,7 @@ TrimLeft::TrimLeft(const std::string &action)
this->action_kind = 1;
}
std::string TrimLeft::evaluate(const std::string &val,
std::string TrimLeft::execute(const std::string &val,
Transaction *transaction) {
std::string value(val);
return *ltrim(&value);

View File

@@ -33,7 +33,7 @@ class TrimLeft : public Trim {
public:
explicit TrimLeft(const std::string &action) ;
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -36,7 +36,7 @@ TrimRight::TrimRight(const std::string &action)
this->action_kind = 1;
}
std::string TrimRight::evaluate(const std::string &val,
std::string TrimRight::execute(const std::string &val,
Transaction *transaction) {
std::string value(val);
return *this->rtrim(&value);

View File

@@ -33,7 +33,7 @@ class TrimRight : public Trim {
public:
explicit TrimRight(const std::string &action) ;
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -31,7 +31,7 @@ UpperCase::UpperCase(const std::string &a)
: Transformation(a) {
}
std::string UpperCase::evaluate(const std::string &val,
std::string UpperCase::execute(const std::string &val,
Transaction *transaction) {
std::string value(val);
std::locale loc;

View File

@@ -34,7 +34,7 @@ class UpperCase : public Transformation {
public:
explicit UpperCase(const std::string &action) ;
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -37,7 +37,7 @@ UrlDecode::UrlDecode(const std::string &action)
this->action_kind = 1;
}
std::string UrlDecode::evaluate(const std::string &value,
std::string UrlDecode::execute(const std::string &value,
Transaction *transaction) {
unsigned char *val = NULL;
int invalid_count = 0;

View File

@@ -32,10 +32,9 @@ namespace transformations {
class UrlDecode : public Transformation {
public:
explicit UrlDecode(const std::string &action) ;
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
};

View File

@@ -38,7 +38,7 @@ namespace actions {
namespace transformations {
std::string UrlDecodeUni::evaluate(const std::string &value,
std::string UrlDecodeUni::execute(const std::string &value,
Transaction *t) {
std::string ret;
unsigned char *input;

View File

@@ -33,7 +33,7 @@ class UrlDecodeUni : public Transformation {
public:
explicit UrlDecodeUni(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp, Transaction *transaction) override;
std::string execute(const std::string &exp, Transaction *transaction) override;
static int inplace(unsigned char *input, uint64_t input_len,
Transaction *transaction);
};

View File

@@ -87,7 +87,7 @@ std::string UrlEncode::url_enc(const char *input,
}
std::string UrlEncode::evaluate(const std::string &value,
std::string UrlEncode::execute(const std::string &value,
Transaction *transaction) {
int changed;

View File

@@ -30,10 +30,9 @@ namespace transformations {
class UrlEncode : public Transformation {
public:
explicit UrlEncode(const std::string &action) ;
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
static std::string url_enc(const char *input,

View File

@@ -33,7 +33,7 @@ namespace actions {
namespace transformations {
std::string Utf8ToUnicode::evaluate(const std::string &value,
std::string Utf8ToUnicode::execute(const std::string &value,
Transaction *transaction) {
std::string ret;
unsigned char *input;

View File

@@ -37,7 +37,7 @@ class Utf8ToUnicode : public Transformation {
public:
explicit Utf8ToUnicode(const std::string &action) : Transformation(action) { }
std::string evaluate(const std::string &exp,
std::string execute(const std::string &exp,
Transaction *transaction) override;
static char *inplace(unsigned char *input, uint64_t input_len,