diff --git a/headers/modsecurity/variable_value.h b/headers/modsecurity/variable_value.h index 8de869dd..8754403b 100644 --- a/headers/modsecurity/variable_value.h +++ b/headers/modsecurity/variable_value.h @@ -74,26 +74,27 @@ class VariableValue { } } - const std::string& getKey() const { - return m_key; - } - - const std::string& getKeyWithCollection() const { + const std::string& getName() const noexcept { return m_keyWithCollection; } - const std::string& getCollection() const { - return m_collection; - } - - - const std::string& getValue() const { + const std::string& getValue() const noexcept { return m_value; } + + + const std::string& getKey() const { + return m_key; + } + + const std::string& getCollection() const { + return m_collection; + } + void setValue(const std::string &value) { m_value = value; } diff --git a/src/engine/lua.cc b/src/engine/lua.cc index 20ed11dd..8d111f49 100644 --- a/src/engine/lua.cc +++ b/src/engine/lua.cc @@ -304,7 +304,7 @@ int Lua::getvars(lua_State *L) { lua_newtable(L); lua_pushstring(L, "name"); - lua_pushlstring(L, i->getKeyWithCollection().c_str(), i->getKeyWithCollection().size()); + lua_pushlstring(L, i->getName().c_str(), i->getName().size()); lua_settable(L, -3); lua_pushstring(L, "value"); diff --git a/src/operators/operator.cc b/src/operators/operator.cc index a9c984ee..b1086d81 100644 --- a/src/operators/operator.cc +++ b/src/operators/operator.cc @@ -87,7 +87,7 @@ std::string Operator::resolveMatchMessage(Transaction *t, std::string ret = m_match_message; if (ret.empty() == true) { - const std::string &key = v->getKeyWithCollection(); + const std::string &key = v->getName(); const std::string &value = v->getValue(); if (m_couldContainsMacro == false) { ret = "Matched \"Operator `" + m_op + "' with parameter `" + diff --git a/src/rule_with_operator.cc b/src/rule_with_operator.cc index 15845651..e5798318 100644 --- a/src/rule_with_operator.cc +++ b/src/rule_with_operator.cc @@ -81,7 +81,7 @@ RuleWithOperator::~RuleWithOperator() { void RuleWithOperator::updateMatchedVars(Transaction *trans, const VariableValue *v, const bpstd::string_view &value) { - const std::string &key = v->getKeyWithCollection(); + const std::string &key = v->getName(); ms_dbg_a(trans, 9, "Matched vars updated."); trans->m_variableMatchedVar.set(value, trans->m_variableOffset); trans->m_variableMatchedVarName.set(key, trans->m_variableOffset); @@ -113,7 +113,7 @@ bool RuleWithOperator::executeOperatorAt(Transaction *trans, ms_dbg_a(trans, 9, "Target value: \"" \ + utils::string::limitTo(80, utils::string::toHexIfNeeded(value.to_string())) \ - + "\" (Variable: " + v->getKeyWithCollection() + ")"); + + "\" (Variable: " + v->getName() + ")"); ret = m_operator->evaluateInternal(trans, this, value, trans->messageGetLast()); @@ -282,7 +282,7 @@ bool RuleWithOperator::evaluate(Transaction *trans) const { std::find_if(trans->m_ruleRemoveTargetById.begin(), trans->m_ruleRemoveTargetById.end(), [&, v, this](std::pair &m) -> bool { - return m.first == getId() && m.second == v->getKeyWithCollection(); + return m.first == getId() && m.second == v->getName(); }) != trans->m_ruleRemoveTargetById.end() ) { continue; @@ -292,7 +292,7 @@ bool RuleWithOperator::evaluate(Transaction *trans) const { std::find_if(trans->m_ruleRemoveTargetByTag.begin(), trans->m_ruleRemoveTargetByTag.end(), [&, v, trans, this](std::pair &m) -> bool { - return containsTag(m.first, trans) && m.second == v->getKeyWithCollection(); + return containsTag(m.first, trans) && m.second == v->getName(); }) != trans->m_ruleRemoveTargetByTag.end() ) { continue; diff --git a/src/transaction.cc b/src/transaction.cc index 4ec5fef3..af6f3d77 100644 --- a/src/transaction.cc +++ b/src/transaction.cc @@ -1563,7 +1563,7 @@ std::string Transaction::toOldAuditLogFormat(int parts, m_variableRequestHeaders.resolve(&l); for (const auto &h : l) { size_t pos = strlen("REQUEST_HEADERS:"); - audit_log << h->getKeyWithCollection().c_str() + pos << ": "; + audit_log << h->getName().c_str() + pos << ": "; audit_log << h->getValue().c_str() << std::endl; } audit_log << std::endl; diff --git a/src/variables/remote_user.cc b/src/variables/remote_user.cc index 253f2992..bc2b46a2 100644 --- a/src/variables/remote_user.cc +++ b/src/variables/remote_user.cc @@ -63,7 +63,7 @@ void RemoteUser::evaluate(Transaction *transaction, } transaction->m_variableRemoteUser.assign(std::string(base64, 0, pos)); - auto var = std::make_shared(&l2[0]->getKeyWithCollection(), &transaction->m_variableRemoteUser); + auto var = std::make_shared(&l2[0]->getName(), &transaction->m_variableRemoteUser); for (auto &i : l2[0]->getOrigin()) { var->addOrigin(i); diff --git a/src/variables/variable.h b/src/variables/variable.h index fad44e28..5febf268 100644 --- a/src/variables/variable.h +++ b/src/variables/variable.h @@ -701,7 +701,7 @@ class Variables : public std::vector { if (r) { return r->m_r.searchAll(v->getKey()).size() > 0; } - return v->getKeyWithCollection() == *m->getVariableKeyWithCollection(); + return v->getName() == *m->getVariableKeyWithCollection(); }) != end(); };