mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-17 01:36:08 +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,
|
const actions::transformations::Transformation &a,
|
||||||
std::string &value,
|
std::string &value,
|
||||||
const Transaction *trans,
|
const Transaction *trans,
|
||||||
TransformationResults *ret,
|
TransformationResults &ret,
|
||||||
std::string *path,
|
std::string &path,
|
||||||
int *nth) const;
|
int &nth) const;
|
||||||
|
|
||||||
/* actions */
|
/* actions */
|
||||||
actions::Action *m_disruptiveAction;
|
actions::Action *m_disruptiveAction;
|
||||||
|
@ -327,24 +327,24 @@ inline void RuleWithActions::executeTransformation(
|
|||||||
const actions::transformations::Transformation &a,
|
const actions::transformations::Transformation &a,
|
||||||
std::string &value,
|
std::string &value,
|
||||||
const Transaction *trans,
|
const Transaction *trans,
|
||||||
TransformationResults *ret,
|
TransformationResults &ret,
|
||||||
std::string *path,
|
std::string &path,
|
||||||
int *nth) const {
|
int &nth) const {
|
||||||
|
|
||||||
if (a.transform(value, trans) &&
|
if (a.transform(value, trans) &&
|
||||||
m_containsMultiMatchAction) {
|
m_containsMultiMatchAction) {
|
||||||
ret.emplace_back(value, a.m_name);
|
ret.emplace_back(value, a.m_name);
|
||||||
(*nth)++;
|
nth++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path->empty()) {
|
if (path.empty()) {
|
||||||
path->append(*a.m_name.get());
|
path.append(*a.m_name.get());
|
||||||
} else {
|
} else {
|
||||||
path->append("," + *a.m_name.get());
|
path.append("," + *a.m_name.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
ms_dbg_a(trans, 9, " T (" + \
|
ms_dbg_a(trans, 9, " T (" + \
|
||||||
std::to_string(*nth) + ") " + \
|
std::to_string(nth) + ") " + \
|
||||||
*a.m_name.get() + ": \"" + \
|
*a.m_name.get() + ": \"" + \
|
||||||
utils::string::limitTo(80, value) +"\"");
|
utils::string::limitTo(80, value) +"\"");
|
||||||
}
|
}
|
||||||
@ -353,7 +353,7 @@ void RuleWithActions::executeTransformations(
|
|||||||
const Transaction *trans, const std::string &in, TransformationResults &ret) {
|
const Transaction *trans, const std::string &in, TransformationResults &ret) {
|
||||||
int none = 0;
|
int none = 0;
|
||||||
int transformations = 0;
|
int transformations = 0;
|
||||||
std::string path("");
|
std::string path;
|
||||||
auto value = in;
|
auto value = in;
|
||||||
|
|
||||||
if (m_containsMultiMatchAction == true) {
|
if (m_containsMultiMatchAction == true) {
|
||||||
@ -381,16 +381,16 @@ void RuleWithActions::executeTransformations(
|
|||||||
// FIXME: here the object needs to be a transformation already.
|
// FIXME: here the object needs to be a transformation already.
|
||||||
auto t = dynamic_cast<const Transformation*>(a.get());
|
auto t = dynamic_cast<const Transformation*>(a.get());
|
||||||
assert(t != nullptr);
|
assert(t != nullptr);
|
||||||
executeTransformation(*t, value, trans, &ret, &path,
|
executeTransformation(*t, value, trans, ret, path,
|
||||||
&transformations);
|
transformations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const Transformation *a : m_transformations) {
|
for (const Transformation *a : m_transformations) {
|
||||||
assert(a != nullptr);
|
assert(a != nullptr);
|
||||||
if (none == 0) {
|
if (none == 0) {
|
||||||
executeTransformation(*a, value, trans, &ret, &path,
|
executeTransformation(*a, value, trans, ret, path,
|
||||||
&transformations);
|
transformations);
|
||||||
}
|
}
|
||||||
if (a->m_isNone) {
|
if (a->m_isNone) {
|
||||||
none--;
|
none--;
|
||||||
@ -419,8 +419,8 @@ void RuleWithActions::executeTransformations(
|
|||||||
auto a = dynamic_cast<const Transformation*>(b.second.get());
|
auto a = dynamic_cast<const Transformation*>(b.second.get());
|
||||||
assert(a != nullptr);
|
assert(a != nullptr);
|
||||||
if (none == 0) {
|
if (none == 0) {
|
||||||
executeTransformation(*a, value, trans, &ret, &path,
|
executeTransformation(*a, value, trans, ret, path,
|
||||||
&transformations);
|
transformations);
|
||||||
}
|
}
|
||||||
if (a->m_isNone) {
|
if (a->m_isNone) {
|
||||||
none--;
|
none--;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user