Fix actions: returning string copy after evaluation

This commit is contained in:
Felipe Zimmerle 2015-07-24 18:47:47 -03:00
parent b2bbe24e29
commit ec9a97324f
72 changed files with 85 additions and 72 deletions

View File

@ -36,7 +36,7 @@ namespace ModSecurity {
namespace actions {
std::string & Action::evaluate(std::string value,
std::string Action::evaluate(std::string value,
Assay *assay) {
return value;
}

View File

@ -74,7 +74,7 @@ class Action {
int action_kind;
std::string name;
virtual std::string& evaluate(std::string exp,
virtual std::string evaluate(std::string exp,
Assay *assay);
virtual bool evaluate(Assay *assay);
virtual bool evaluate(Rule *rule);

View File

@ -35,12 +35,13 @@ Base64Decode::Base64Decode(std::string action)
this->action_kind = 1;
}
std::string& Base64Decode::evaluate(std::string value,
std::string Base64Decode::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation base64decode
*/
assay->debug(4, "Transformation 64 is not implemented yet.");
return value;
}
} // namespace transformations

View File

@ -31,7 +31,7 @@ namespace transformations {
class Base64Decode : public Transformation {
public:
explicit Base64Decode(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,12 +35,13 @@ Base64DecodeExt::Base64DecodeExt(std::string action)
this->action_kind = 1;
}
std::string& Base64DecodeExt::evaluate(std::string value,
std::string Base64DecodeExt::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation Base64DecodeExt
*/
assay->debug(4, "Transformation Base64DecodeExt is not implemented yet.");
return value;
}
} // namespace transformations

View File

@ -31,7 +31,7 @@ namespace transformations {
class Base64DecodeExt : public Transformation {
public:
explicit Base64DecodeExt(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,12 +35,13 @@ CmdLine::CmdLine(std::string action)
this->action_kind = 1;
}
std::string& CmdLine::evaluate(std::string value,
std::string CmdLine::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation CmdLine
*/
assay->debug(4, "Transformation CmdLine is not implemented yet.");
return value;
}
} // namespace transformations

View File

@ -31,7 +31,7 @@ namespace transformations {
class CmdLine : public Transformation {
public:
explicit CmdLine(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,13 +35,14 @@ CompressWhitespace::CompressWhitespace(std::string action)
this->action_kind = 1;
}
std::string& CompressWhitespace::evaluate(std::string value,
std::string CompressWhitespace::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation CompressWhitespace
*/
assay->debug(4, "Transformation CompressWhitespace is " \
"not implemented yet.");
return value;
}
} // namespace transformations

View File

@ -31,7 +31,7 @@ namespace transformations {
class CompressWhitespace : public Transformation {
public:
explicit CompressWhitespace(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,12 +35,13 @@ CssDecode::CssDecode(std::string action)
this->action_kind = 1;
}
std::string& CssDecode::evaluate(std::string value,
std::string CssDecode::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation CssDecode
*/
assay->debug(4, "Transformation CssDecode is not implemented yet.");
return value;
}
} // namespace transformations

View File

@ -31,7 +31,7 @@ namespace transformations {
class CssDecode : public Transformation {
public:
explicit CssDecode(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ EscapeSeqDecode::EscapeSeqDecode(std::string action)
this->action_kind = 1;
}
std::string& EscapeSeqDecode::evaluate(std::string value,
std::string EscapeSeqDecode::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation EscapeSeqDecode

View File

@ -31,7 +31,7 @@ namespace transformations {
class EscapeSeqDecode : public Transformation {
public:
explicit EscapeSeqDecode(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,12 +35,13 @@ HexDecode::HexDecode(std::string action)
this->action_kind = 1;
}
std::string& HexDecode::evaluate(std::string value,
std::string HexDecode::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation HexDecode
*/
assay->debug(4, "Transformation HexDecode is not implemented yet.");
return value;
}
} // namespace transformations

View File

@ -31,7 +31,7 @@ namespace transformations {
class HexDecode : public Transformation {
public:
explicit HexDecode(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ HexEncode::HexEncode(std::string action)
this->action_kind = 1;
}
std::string& HexEncode::evaluate(std::string value,
std::string HexEncode::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation HexEncode

View File

@ -31,7 +31,7 @@ namespace transformations {
class HexEncode : public Transformation {
public:
explicit HexEncode(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ HtmlEntityDecode::HtmlEntityDecode(std::string action)
this->action_kind = 1;
}
std::string& HtmlEntityDecode::evaluate(std::string value,
std::string HtmlEntityDecode::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation HtmlEntityDecode

View File

@ -31,7 +31,7 @@ namespace transformations {
class HtmlEntityDecode : public Transformation {
public:
explicit HtmlEntityDecode(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,12 +35,13 @@ JsDecode::JsDecode(std::string action)
this->action_kind = 1;
}
std::string& JsDecode::evaluate(std::string value,
std::string JsDecode::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation JsDecode
*/
assay->debug(4, "Transformation JsDecode is not implemented yet.");
return value;
}
} // namespace transformations

View File

@ -31,7 +31,7 @@ namespace transformations {
class JsDecode : public Transformation {
public:
explicit JsDecode(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,12 +35,13 @@ Length::Length(std::string action)
this->action_kind = 1;
}
std::string& Length::evaluate(std::string value,
std::string Length::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation Length
*/
assay->debug(4, "Transformation Length is not implemented yet.");
return value;
}
} // namespace transformations

View File

@ -31,7 +31,7 @@ namespace transformations {
class Length : public Transformation {
public:
explicit Length(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -31,7 +31,7 @@ LowerCase::LowerCase(std::string a)
: Transformation(a) {
}
std::string & LowerCase::evaluate(std::string value,
std::string LowerCase::evaluate(std::string value,
Assay *assay) {
std::locale loc;

View File

@ -32,7 +32,7 @@ namespace transformations {
class LowerCase : public Transformation {
public:
explicit LowerCase(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ Md5::Md5(std::string action)
this->action_kind = 1;
}
std::string& Md5::evaluate(std::string value,
std::string Md5::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation Md5

View File

@ -31,7 +31,8 @@ namespace transformations {
class Md5 : public Transformation {
public:
explicit Md5(std::string action);
std::string& evaluate(std::string exp,
std::string
evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,12 +35,13 @@ None::None(std::string action)
this->action_kind = 1;
}
std::string& None::evaluate(std::string value,
std::string None::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation None
*/
assay->debug(4, "Transformation None is not implemented yet.");
return value;
}
} // namespace transformations

View File

@ -31,7 +31,7 @@ namespace transformations {
class None : public Transformation {
public:
explicit None(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ NormalisePath::NormalisePath(std::string action)
this->action_kind = 1;
}
std::string& NormalisePath::evaluate(std::string value,
std::string NormalisePath::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation NormalisePath

View File

@ -31,7 +31,7 @@ namespace transformations {
class NormalisePath : public Transformation {
public:
explicit NormalisePath(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ NormalisePathWin::NormalisePathWin(std::string action)
this->action_kind = 1;
}
std::string& NormalisePathWin::evaluate(std::string value,
std::string NormalisePathWin::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation NormalisePathWin

View File

@ -31,7 +31,7 @@ namespace transformations {
class NormalisePathWin : public Transformation {
public:
explicit NormalisePathWin(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ ParityEven7bit::ParityEven7bit(std::string action)
this->action_kind = 1;
}
std::string& ParityEven7bit::evaluate(std::string value,
std::string ParityEven7bit::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation ParityEven7bit

View File

@ -31,7 +31,7 @@ namespace transformations {
class ParityEven7bit : public Transformation {
public:
explicit ParityEven7bit(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ ParityOdd7bit::ParityOdd7bit(std::string action)
this->action_kind = 1;
}
std::string& ParityOdd7bit::evaluate(std::string value,
std::string ParityOdd7bit::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation ParityOdd7bit

View File

@ -31,7 +31,7 @@ namespace transformations {
class ParityOdd7bit : public Transformation {
public:
explicit ParityOdd7bit(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ ParityZero7bit::ParityZero7bit(std::string action)
this->action_kind = 1;
}
std::string& ParityZero7bit::evaluate(std::string value,
std::string ParityZero7bit::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation ParityZero7bit

View File

@ -31,7 +31,7 @@ namespace transformations {
class ParityZero7bit : public Transformation {
public:
explicit ParityZero7bit(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ RemoveComments::RemoveComments(std::string action)
this->action_kind = 1;
}
std::string& RemoveComments::evaluate(std::string value,
std::string RemoveComments::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation RemoveComments

View File

@ -31,7 +31,7 @@ namespace transformations {
class RemoveComments : public Transformation {
public:
explicit RemoveComments(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ RemoveCommentsChar::RemoveCommentsChar(std::string action)
this->action_kind = 1;
}
std::string& RemoveCommentsChar::evaluate(std::string value,
std::string RemoveCommentsChar::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation RemoveCommentsChar

View File

@ -31,7 +31,7 @@ namespace transformations {
class RemoveCommentsChar : public Transformation {
public:
explicit RemoveCommentsChar(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ RemoveNulls::RemoveNulls(std::string action)
this->action_kind = 1;
}
std::string& RemoveNulls::evaluate(std::string value,
std::string RemoveNulls::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation RemoveNulls

View File

@ -31,7 +31,7 @@ namespace transformations {
class RemoveNulls : public Transformation {
public:
explicit RemoveNulls(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ RemoveWhitespace::RemoveWhitespace(std::string action)
this->action_kind = 1;
}
std::string& RemoveWhitespace::evaluate(std::string value,
std::string RemoveWhitespace::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation RemoveWhitespace

View File

@ -31,7 +31,7 @@ namespace transformations {
class RemoveWhitespace : public Transformation {
public:
explicit RemoveWhitespace(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ ReplaceComments::ReplaceComments(std::string action)
this->action_kind = 1;
}
std::string& ReplaceComments::evaluate(std::string value,
std::string ReplaceComments::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation ReplaceComments

View File

@ -31,7 +31,7 @@ namespace transformations {
class ReplaceComments : public Transformation {
public:
explicit ReplaceComments(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ ReplaceNulls::ReplaceNulls(std::string action)
this->action_kind = 1;
}
std::string& ReplaceNulls::evaluate(std::string value,
std::string ReplaceNulls::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation ReplaceNulls

View File

@ -31,7 +31,7 @@ namespace transformations {
class ReplaceNulls : public Transformation {
public:
explicit ReplaceNulls(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ Sha1::Sha1(std::string action)
this->action_kind = 1;
}
std::string& Sha1::evaluate(std::string value,
std::string Sha1::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation Sha1

View File

@ -31,7 +31,7 @@ namespace transformations {
class Sha1 : public Transformation {
public:
explicit Sha1(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,12 +35,13 @@ SqlHexDecode::SqlHexDecode(std::string action)
this->action_kind = 1;
}
std::string& SqlHexDecode::evaluate(std::string value,
std::string SqlHexDecode::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation SqlHexDecode
*/
assay->debug(4, "Transformation SqlHexDecode is not implemented yet.");
return value;
}
} // namespace transformations

View File

@ -31,7 +31,8 @@ namespace transformations {
class SqlHexDecode : public Transformation {
public:
explicit SqlHexDecode(std::string action);
std::string& evaluate(std::string exp,
std::string
evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -72,7 +72,7 @@ Transformation::Transformation(std::string action)
this->action_kind = 1;
}
std::string &Transformation::evaluate(std::string value,
std::string Transformation::evaluate(std::string value,
Assay *assay) {
return value;
}

View File

@ -33,7 +33,7 @@ class Transformation : public Action {
explicit Transformation(std::string action);
static Transformation* instantiate(std::string);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -56,7 +56,8 @@ Trim::Trim(std::string action)
}
std::string& Trim::evaluate(std::string value,
std::string
Trim::evaluate(std::string value,
Assay *assay) {
return *this->trim(&value);
}

View File

@ -31,7 +31,7 @@ namespace transformations {
class Trim : public Transformation {
public:
explicit Trim(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
std::string *ltrim(std::string *s);

View File

@ -38,7 +38,7 @@ TrimLeft::TrimLeft(std::string action)
this->action_kind = 1;
}
std::string& TrimLeft::evaluate(std::string value,
std::string TrimLeft::evaluate(std::string value,
Assay *assay) {
return *trim(&value);
}

View File

@ -32,7 +32,7 @@ namespace transformations {
class TrimLeft : public Trim {
public:
explicit TrimLeft(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -36,7 +36,7 @@ TrimRight::TrimRight(std::string action)
this->action_kind = 1;
}
std::string& TrimRight::evaluate(std::string value,
std::string TrimRight::evaluate(std::string value,
Assay *assay) {
return *this->trim(&value);
}

View File

@ -32,7 +32,7 @@ namespace transformations {
class TrimRight : public Trim {
public:
explicit TrimRight(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ UrlDecode::UrlDecode(std::string action)
this->action_kind = 1;
}
std::string& UrlDecode::evaluate(std::string value,
std::string UrlDecode::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation UrlDecode

View File

@ -31,7 +31,7 @@ namespace transformations {
class UrlDecode : public Transformation {
public:
explicit UrlDecode(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ UrlDecodeUni::UrlDecodeUni(std::string action)
this->action_kind = 1;
}
std::string& UrlDecodeUni::evaluate(std::string value,
std::string UrlDecodeUni::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation UrlDecodeUni

View File

@ -31,7 +31,7 @@ namespace transformations {
class UrlDecodeUni : public Transformation {
public:
explicit UrlDecodeUni(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ UrlEncode::UrlEncode(std::string action)
this->action_kind = 1;
}
std::string& UrlEncode::evaluate(std::string value,
std::string UrlEncode::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation UrlEncode

View File

@ -31,7 +31,7 @@ namespace transformations {
class UrlEncode : public Transformation {
public:
explicit UrlEncode(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};

View File

@ -35,7 +35,7 @@ Utf8Unicode::Utf8Unicode(std::string action)
this->action_kind = 1;
}
std::string& Utf8Unicode::evaluate(std::string value,
std::string Utf8Unicode::evaluate(std::string value,
Assay *assay) {
/**
* @todo Implement the transformation Utf8Unicode

View File

@ -31,7 +31,7 @@ namespace transformations {
class Utf8Unicode : public Transformation {
public:
explicit Utf8Unicode(std::string action);
std::string& evaluate(std::string exp,
std::string evaluate(std::string exp,
Assay *assay) override;
};