mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Pass RuleWithActions::executeTransformation arguments by reference
- This function already expects these arguments not to be null pointers, doesn't validate them and just dereference them. - In order to make this explicit and enforced by the compiler, they're now passed as references.
This commit is contained in:
parent
b647dbd905
commit
34da8eeeee
@ -161,9 +161,9 @@ class RuleWithActions : public Rule {
|
||||
const actions::transformations::Transformation &a,
|
||||
std::string &value,
|
||||
const Transaction *trans,
|
||||
TransformationResults *ret,
|
||||
std::string *path,
|
||||
int *nth) const;
|
||||
TransformationResults &ret,
|
||||
std::string &path,
|
||||
int &nth) const;
|
||||
|
||||
/* actions */
|
||||
actions::Action *m_disruptiveAction;
|
||||
|
@ -327,24 +327,24 @@ inline void RuleWithActions::executeTransformation(
|
||||
const actions::transformations::Transformation &a,
|
||||
std::string &value,
|
||||
const Transaction *trans,
|
||||
TransformationResults *ret,
|
||||
std::string *path,
|
||||
int *nth) const {
|
||||
TransformationResults &ret,
|
||||
std::string &path,
|
||||
int &nth) const {
|
||||
|
||||
if (a.transform(value, trans) &&
|
||||
m_containsMultiMatchAction) {
|
||||
ret.emplace_back(value, a.m_name);
|
||||
(*nth)++;
|
||||
nth++;
|
||||
}
|
||||
|
||||
if (path->empty()) {
|
||||
path->append(*a.m_name.get());
|
||||
if (path.empty()) {
|
||||
path.append(*a.m_name.get());
|
||||
} else {
|
||||
path->append("," + *a.m_name.get());
|
||||
path.append("," + *a.m_name.get());
|
||||
}
|
||||
|
||||
ms_dbg_a(trans, 9, " T (" + \
|
||||
std::to_string(*nth) + ") " + \
|
||||
std::to_string(nth) + ") " + \
|
||||
*a.m_name.get() + ": \"" + \
|
||||
utils::string::limitTo(80, value) +"\"");
|
||||
}
|
||||
@ -353,7 +353,7 @@ void RuleWithActions::executeTransformations(
|
||||
const Transaction *trans, const std::string &in, TransformationResults &ret) {
|
||||
int none = 0;
|
||||
int transformations = 0;
|
||||
std::string path("");
|
||||
std::string path;
|
||||
auto value = in;
|
||||
|
||||
if (m_containsMultiMatchAction == true) {
|
||||
@ -381,16 +381,16 @@ void RuleWithActions::executeTransformations(
|
||||
// FIXME: here the object needs to be a transformation already.
|
||||
auto t = dynamic_cast<const Transformation*>(a.get());
|
||||
assert(t != nullptr);
|
||||
executeTransformation(*t, value, trans, &ret, &path,
|
||||
&transformations);
|
||||
executeTransformation(*t, value, trans, ret, path,
|
||||
transformations);
|
||||
}
|
||||
}
|
||||
|
||||
for (const Transformation *a : m_transformations) {
|
||||
assert(a != nullptr);
|
||||
if (none == 0) {
|
||||
executeTransformation(*a, value, trans, &ret, &path,
|
||||
&transformations);
|
||||
executeTransformation(*a, value, trans, ret, path,
|
||||
transformations);
|
||||
}
|
||||
if (a->m_isNone) {
|
||||
none--;
|
||||
@ -419,8 +419,8 @@ void RuleWithActions::executeTransformations(
|
||||
auto a = dynamic_cast<const Transformation*>(b.second.get());
|
||||
assert(a != nullptr);
|
||||
if (none == 0) {
|
||||
executeTransformation(*a, value, trans, &ret, &path,
|
||||
&transformations);
|
||||
executeTransformation(*a, value, trans, ret, path,
|
||||
transformations);
|
||||
}
|
||||
if (a->m_isNone) {
|
||||
none--;
|
||||
|
Loading…
x
Reference in New Issue
Block a user