diff options
author | seolheui, kim <s414.kim@samsung.com> | 2018-11-14 15:33:03 +0900 |
---|---|---|
committer | seolheui, kim <s414.kim@samsung.com> | 2019-01-02 12:45:55 +0900 |
commit | 7cb9a7f5df7a396c6632fd37796cf535bc46d560 (patch) | |
tree | efc052960f12d67499583df73f3625cc581a0978 | |
parent | e6b13e8919580119557223b24fe6f0ef9d5f6c42 (diff) | |
download | audit-trail-7cb9a7f5df7a396c6632fd37796cf535bc46d560.tar.gz audit-trail-7cb9a7f5df7a396c6632fd37796cf535bc46d560.tar.bz2 audit-trail-7cb9a7f5df7a396c6632fd37796cf535bc46d560.zip |
Change addAll() to apply rules in rule-apply-engine
- Change addAll() to apply() since it does not need to separate removeAll() and addAll()
- Instead of using optimizedList, changed it to import rules in real time to reset rules
Change-Id: I9169ed588b6c46a3e414b97da67238e1af77ebd0
Signed-off-by: seolheui, kim <s414.kim@samsung.com>
-rw-r--r-- | server/rule-apply-engine.cpp | 26 | ||||
-rw-r--r-- | server/rule-apply-engine.h | 3 |
2 files changed, 10 insertions, 19 deletions
diff --git a/server/rule-apply-engine.cpp b/server/rule-apply-engine.cpp index 0157ed5..2b096cc 100644 --- a/server/rule-apply-engine.cpp +++ b/server/rule-apply-engine.cpp @@ -39,13 +39,11 @@ void RuleApplyEngine::addRule(Audit &audit, const Rule &rule) } adminList.emplace_back(rule); - - removeAll(audit); addNeverRules(); optimize(rule); applyNeverRules(); - addAll(audit); + apply(audit); } void RuleApplyEngine::removeRule(Audit &audit, const Rule &rule) @@ -58,7 +56,6 @@ void RuleApplyEngine::removeRule(Audit &audit, const Rule &rule) else throw runtime::Exception("The rule does not exist"); - removeAll(audit); optimizedList.clear(); addNeverRules(); @@ -66,10 +63,8 @@ void RuleApplyEngine::removeRule(Audit &audit, const Rule &rule) optimize(r); } - if (optimizedList.size() > 1) { - applyNeverRules(); - addAll(audit); - } + applyNeverRules(); + apply(audit); } RuleApplyEngine::RuleList RuleApplyEngine::getRules() const @@ -77,19 +72,16 @@ RuleApplyEngine::RuleList RuleApplyEngine::getRules() const return adminList; } -void RuleApplyEngine::removeAll(Audit &audit) +void RuleApplyEngine::apply(Audit &audit) { - if (optimizedList.size() < 2) - return; - - for (auto &r : optimizedList) { + for (auto r : audit.getRules()) { audit.removeRule(r.data()); } -} -void RuleApplyEngine::addAll(Audit &audit) -{ - for (auto &r : optimizedList) { + if (optimizedList.size() < 2) + return; + + for (auto r : optimizedList) { audit.addRule(r.data()); } } diff --git a/server/rule-apply-engine.h b/server/rule-apply-engine.h index d4540b6..ec50235 100644 --- a/server/rule-apply-engine.h +++ b/server/rule-apply-engine.h @@ -33,8 +33,7 @@ public: RuleList getRules() const; private: - void removeAll(Audit &audit); - void addAll(Audit &audit); + void apply(Audit &audit); void optimize(const Rule &rule); void addNeverRules(); |