Fix static analysis issues 99/295399/1 accepted/tizen_unified tizen accepted/tizen/unified/20230712.040717
authorTomasz Swierczek <t.swierczek@samsung.com>
Thu, 6 Jul 2023 09:49:12 +0000 (11:49 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Thu, 6 Jul 2023 09:49:12 +0000 (11:49 +0200)
Change-Id: Id7beea03b2504e2a39aaaaf7ded57a1ff2b4e713

lib/audit-rule/rule.cpp
lib/audit-trail/rule.cpp
plugins/base-rule-set.cpp
server/rule-apply-engine.cpp

index fbf8d6a38525afd5ab4c47b4f5d5683fa2bcb70a..7dc8a21d4ca7e83f9062c758f1fbf9e0bce845a1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2018 - 2023 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -88,7 +88,7 @@ std::vector<char> Rule::data() const
 
 bool Rule::compareFieldType(const Rule &rule)
 {
-       for (auto c : rule.condition) {
+       for (auto &c : rule.condition) {
                if (c.first == FieldType::Tag)
                        continue;
 
@@ -100,7 +100,7 @@ bool Rule::compareFieldType(const Rule &rule)
 
 bool Rule::compareCondition(Rule &rule)
 {
-       for (auto c : condition) {
+       for (auto &c : condition) {
                if (c.first == FieldType::Tag)
                        continue;
 
index b60afb077bbe7f6054e56357b0cb5b5c14fe811b..ba2c23e4008a9994150a62e9c650d9116c93591a 100644 (file)
@@ -209,7 +209,7 @@ int audit_trail_foreach_rule(audit_trail_h handle,
        auto manager = client.createInterface<RuleManagement>();
        auto rulesData = manager.getRules();
 
-       for (auto data : rulesData) {
+       for (auto &data : rulesData) {
                audit_rule_h rule;
 
                try {
index 4ba9f5f0d9c44ce4c13907180cc3c1b0f1569b61..0440e5a2ffe7788b04c92fce461af319d5d08e12 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2018 - 2023 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -197,7 +197,7 @@ void setMaskFileSystemcalls(Rule &rule, unsigned int perm)
 void BaseRuleSet::addDir(const std::vector<std::string>& dirs,
                                                        unsigned int perm, Result result)
 {
-       for (auto dir : dirs) {
+       for (auto &dir : dirs) {
                WatchDirRule rule(dir, perm);
 
                setMaskFileSystemcalls(rule, perm);
@@ -219,7 +219,7 @@ void BaseRuleSet::addDir(const std::vector<std::string>& dirs,
 void BaseRuleSet::addPath(const std::vector<std::string>& paths,
                                                        unsigned int perm, Result result)
 {
-       for (auto path : paths) {
+       for (auto &path : paths) {
                WatchPathRule rule(path, perm);
 
                setMaskFileSystemcalls(rule, perm);
index 2b096cc0e00f031043fcd27fad7b426148929391..dc6f58927abcdce30dec6a5388a2f5388340f33f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2018 - 2023 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -74,14 +74,14 @@ RuleApplyEngine::RuleList RuleApplyEngine::getRules() const
 
 void RuleApplyEngine::apply(Audit &audit)
 {
-       for (auto r : audit.getRules()) {
+       for (auto &r : audit.getRules()) {
                audit.removeRule(r.data());
        }
 
        if (optimizedList.size() < 2)
                return;
 
-       for (auto r : optimizedList) {
+       for (auto &r : optimizedList) {
                audit.addRule(r.data());
        }
 }