fix: remove target by {id,tag} are now considering collections

Fix issue #1409
This commit is contained in:
Felipe Zimmerle
2017-07-25 09:19:21 -03:00
parent 7c2dbf48cf
commit 337216fd87
4 changed files with 95 additions and 5 deletions

View File

@@ -502,7 +502,7 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
!= exclusions_update_by_tag_remove.end()) {
#ifndef NO_LOGS
trans->debug(9, "Variable: " + *key +
" is part of the exclusion list (from update by tag " +
" is part of the exclusion list (from update by tag" +
"), skipping...");
#endif
if (v->m_dynamic) {
@@ -530,15 +530,27 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
for (auto &i : trans->m_ruleRemoveTargetByTag) {
std::string tag = i.first;
std::string args = i.second;
size_t posa = key->find(":");
if (containsTag(tag, trans) == false) {
continue;
}
if (args == *key) {
trans->debug(9, "Variable: " + *key +
" was excluded by ruleRemoteTargetByTag...");
ignoreVariable = true;
break;
}
if (posa != std::string::npos) {
std::string var = std::string(*key, posa);
if (var == args) {
trans->debug(9, "Variable: " + *key +
" was excluded by ruleRemoteTargetByTag...");
ignoreVariable = true;
break;
}
}
}
if (ignoreVariable) {
if (v->m_dynamic) {
@@ -551,15 +563,29 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
for (auto &i : trans->m_ruleRemoveTargetById) {
int id = i.first;
std::string args = i.second;
size_t posa = key->find(":");
if (m_ruleId != id) {
continue;
}
if (args == *key) {
trans->debug(9, "Variable: " + *key +
" was excluded by ruleRemoveTargetById...");
ignoreVariable = true;
break;
}
if (posa != std::string::npos) {
if (key->size() > posa) {
std::string var = std::string(*key, 0, posa);
if (var == args) {
trans->debug(9, "Variable: " + var +
" was excluded by ruleRemoveTargetById...");
ignoreVariable = true;
break;
}
}
}
}
if (ignoreVariable) {
if (v->m_dynamic) {