Replaces getKeyWithCollection with getName on VariableValue

This commit is contained in:
Felipe Zimmerle 2020-08-25 12:52:04 -03:00 committed by Felipe Zimmerle
parent ae74d37f96
commit 1eedf3e898
7 changed files with 21 additions and 20 deletions

View File

@ -74,26 +74,27 @@ class VariableValue {
} }
} }
const std::string& getKey() const {
return m_key;
}
const std::string& getName() const noexcept {
const std::string& getKeyWithCollection() const {
return m_keyWithCollection; return m_keyWithCollection;
} }
const std::string& getCollection() const { const std::string& getValue() const noexcept {
return m_collection;
}
const std::string& getValue() const {
return m_value; 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) { void setValue(const std::string &value) {
m_value = value; m_value = value;
} }

View File

@ -304,7 +304,7 @@ int Lua::getvars(lua_State *L) {
lua_newtable(L); lua_newtable(L);
lua_pushstring(L, "name"); 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_settable(L, -3);
lua_pushstring(L, "value"); lua_pushstring(L, "value");

View File

@ -87,7 +87,7 @@ std::string Operator::resolveMatchMessage(Transaction *t,
std::string ret = m_match_message; std::string ret = m_match_message;
if (ret.empty() == true) { if (ret.empty() == true) {
const std::string &key = v->getKeyWithCollection(); const std::string &key = v->getName();
const std::string &value = v->getValue(); const std::string &value = v->getValue();
if (m_couldContainsMacro == false) { if (m_couldContainsMacro == false) {
ret = "Matched \"Operator `" + m_op + "' with parameter `" + ret = "Matched \"Operator `" + m_op + "' with parameter `" +

View File

@ -81,7 +81,7 @@ RuleWithOperator::~RuleWithOperator() {
void RuleWithOperator::updateMatchedVars(Transaction *trans, void RuleWithOperator::updateMatchedVars(Transaction *trans,
const VariableValue *v, const VariableValue *v,
const bpstd::string_view &value) { 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."); ms_dbg_a(trans, 9, "Matched vars updated.");
trans->m_variableMatchedVar.set(value, trans->m_variableOffset); trans->m_variableMatchedVar.set(value, trans->m_variableOffset);
trans->m_variableMatchedVarName.set(key, 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: \"" \ ms_dbg_a(trans, 9, "Target value: \"" \
+ utils::string::limitTo(80, + utils::string::limitTo(80,
utils::string::toHexIfNeeded(value.to_string())) \ utils::string::toHexIfNeeded(value.to_string())) \
+ "\" (Variable: " + v->getKeyWithCollection() + ")"); + "\" (Variable: " + v->getName() + ")");
ret = m_operator->evaluateInternal(trans, this, value, trans->messageGetLast()); 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(), std::find_if(trans->m_ruleRemoveTargetById.begin(),
trans->m_ruleRemoveTargetById.end(), trans->m_ruleRemoveTargetById.end(),
[&, v, this](std::pair<int, std::string> &m) -> bool { [&, v, this](std::pair<int, std::string> &m) -> bool {
return m.first == getId() && m.second == v->getKeyWithCollection(); return m.first == getId() && m.second == v->getName();
}) != trans->m_ruleRemoveTargetById.end() }) != trans->m_ruleRemoveTargetById.end()
) { ) {
continue; continue;
@ -292,7 +292,7 @@ bool RuleWithOperator::evaluate(Transaction *trans) const {
std::find_if(trans->m_ruleRemoveTargetByTag.begin(), std::find_if(trans->m_ruleRemoveTargetByTag.begin(),
trans->m_ruleRemoveTargetByTag.end(), trans->m_ruleRemoveTargetByTag.end(),
[&, v, trans, this](std::pair<std::string, std::string> &m) -> bool { [&, v, trans, this](std::pair<std::string, std::string> &m) -> bool {
return containsTag(m.first, trans) && m.second == v->getKeyWithCollection(); return containsTag(m.first, trans) && m.second == v->getName();
}) != trans->m_ruleRemoveTargetByTag.end() }) != trans->m_ruleRemoveTargetByTag.end()
) { ) {
continue; continue;

View File

@ -1563,7 +1563,7 @@ std::string Transaction::toOldAuditLogFormat(int parts,
m_variableRequestHeaders.resolve(&l); m_variableRequestHeaders.resolve(&l);
for (const auto &h : l) { for (const auto &h : l) {
size_t pos = strlen("REQUEST_HEADERS:"); 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 << h->getValue().c_str() << std::endl;
} }
audit_log << std::endl; audit_log << std::endl;

View File

@ -63,7 +63,7 @@ void RemoteUser::evaluate(Transaction *transaction,
} }
transaction->m_variableRemoteUser.assign(std::string(base64, 0, pos)); transaction->m_variableRemoteUser.assign(std::string(base64, 0, pos));
auto var = std::make_shared<VariableValue>(&l2[0]->getKeyWithCollection(), &transaction->m_variableRemoteUser); auto var = std::make_shared<VariableValue>(&l2[0]->getName(), &transaction->m_variableRemoteUser);
for (auto &i : l2[0]->getOrigin()) { for (auto &i : l2[0]->getOrigin()) {
var->addOrigin(i); var->addOrigin(i);

View File

@ -701,7 +701,7 @@ class Variables : public std::vector<Variable *> {
if (r) { if (r) {
return r->m_r.searchAll(v->getKey()).size() > 0; return r->m_r.searchAll(v->getKey()).size() > 0;
} }
return v->getKeyWithCollection() == *m->getVariableKeyWithCollection(); return v->getName() == *m->getVariableKeyWithCollection();
}) != end(); }) != end();
}; };