Skip to content

Commit 5a0e71f

Browse files
committed
Replaces getKeyWithCollection with getName on VariableValue
1 parent 00a3964 commit 5a0e71f

File tree

7 files changed

+19
-18
lines changed

7 files changed

+19
-18
lines changed

headers/modsecurity/variable_value.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,26 @@ class VariableValue {
7474
}
7575
}
7676

77-
const std::string& getKey() const {
78-
return m_key;
79-
}
80-
8177

82-
const std::string& getKeyWithCollection() const {
78+
const std::string& getName() const noexcept {
8379
return m_keyWithCollection;
8480
}
8581

8682

87-
const std::string& getCollection() const {
88-
return m_collection;
83+
const std::string& getValue() const noexcept {
84+
return m_value;
8985
}
9086

9187

92-
const std::string& getValue() const {
93-
return m_value;
88+
89+
90+
const std::string& getKey() const {
91+
return m_key;
9492
}
9593

94+
const std::string& getCollection() const {
95+
return m_collection;
96+
}
9697

9798
void setValue(const std::string &value) {
9899
m_value = value;

src/engine/lua.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ int Lua::getvars(lua_State *L) {
304304
lua_newtable(L);
305305

306306
lua_pushstring(L, "name");
307-
lua_pushlstring(L, i->getKeyWithCollection().c_str(), i->getKeyWithCollection().size());
307+
lua_pushlstring(L, i->getName().c_str(), i->getName().size());
308308
lua_settable(L, -3);
309309

310310
lua_pushstring(L, "value");

src/operators/operator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ std::string Operator::resolveMatchMessage(Transaction *t,
8787
std::string ret = m_match_message;
8888

8989
if (ret.empty() == true) {
90-
const std::string &key = v->getKeyWithCollection();
90+
const std::string &key = v->getName();
9191
const std::string &value = v->getValue();
9292
if (m_couldContainsMacro == false) {
9393
ret = "Matched \"Operator `" + m_op + "' with parameter `" +

src/rule_with_operator.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ RuleWithOperator::~RuleWithOperator() {
8181
void RuleWithOperator::updateMatchedVars(Transaction *trans,
8282
const VariableValue *v,
8383
const bpstd::string_view &value) {
84-
const std::string &key = v->getKeyWithCollection();
84+
const std::string &key = v->getName();
8585
ms_dbg_a(trans, 9, "Matched vars updated.");
8686
trans->m_variableMatchedVar.set(value, trans->m_variableOffset);
8787
trans->m_variableMatchedVarName.set(key, trans->m_variableOffset);
@@ -113,7 +113,7 @@ bool RuleWithOperator::executeOperatorAt(Transaction *trans,
113113
ms_dbg_a(trans, 9, "Target value: \"" \
114114
+ utils::string::limitTo(80,
115115
utils::string::toHexIfNeeded(value.to_string())) \
116-
+ "\" (Variable: " + v->getKeyWithCollection() + ")");
116+
+ "\" (Variable: " + v->getName() + ")");
117117

118118
ret = m_operator->evaluateInternal(trans, this, value, trans->messageGetLast());
119119

@@ -282,7 +282,7 @@ bool RuleWithOperator::evaluate(Transaction *trans) const {
282282
std::find_if(trans->m_ruleRemoveTargetById.begin(),
283283
trans->m_ruleRemoveTargetById.end(),
284284
[&, v, this](std::pair<int, std::string> &m) -> bool {
285-
return m.first == getId() && m.second == v->getKeyWithCollection();
285+
return m.first == getId() && m.second == v->getName();
286286
}) != trans->m_ruleRemoveTargetById.end()
287287
) {
288288
continue;
@@ -292,7 +292,7 @@ bool RuleWithOperator::evaluate(Transaction *trans) const {
292292
std::find_if(trans->m_ruleRemoveTargetByTag.begin(),
293293
trans->m_ruleRemoveTargetByTag.end(),
294294
[&, v, trans, this](std::pair<std::string, std::string> &m) -> bool {
295-
return containsTag(m.first, trans) && m.second == v->getKeyWithCollection();
295+
return containsTag(m.first, trans) && m.second == v->getName();
296296
}) != trans->m_ruleRemoveTargetByTag.end()
297297
) {
298298
continue;

src/transaction.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ std::string Transaction::toOldAuditLogFormat(int parts,
15631563
m_variableRequestHeaders.resolve(&l);
15641564
for (const auto &h : l) {
15651565
size_t pos = strlen("REQUEST_HEADERS:");
1566-
audit_log << h->getKeyWithCollection().c_str() + pos << ": ";
1566+
audit_log << h->getName().c_str() + pos << ": ";
15671567
audit_log << h->getValue().c_str() << std::endl;
15681568
}
15691569
audit_log << std::endl;

src/variables/remote_user.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void RemoteUser::evaluate(Transaction *transaction,
6363
}
6464
transaction->m_variableRemoteUser.assign(std::string(base64, 0, pos));
6565

66-
auto var = std::make_shared<VariableValue>(&l2[0]->getKeyWithCollection(), &transaction->m_variableRemoteUser);
66+
auto var = std::make_shared<VariableValue>(&l2[0]->getName(), &transaction->m_variableRemoteUser);
6767

6868
for (auto &i : l2[0]->getOrigin()) {
6969
var->addOrigin(i);

src/variables/variable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ class Variables : public std::vector<Variable *> {
701701
if (r) {
702702
return r->m_r.searchAll(v->getKey()).size() > 0;
703703
}
704-
return v->getKeyWithCollection() == *m->getVariableKeyWithCollection();
704+
return v->getName() == *m->getVariableKeyWithCollection();
705705
}) != end();
706706
};
707707

0 commit comments

Comments
 (0)