Remove to set default mask, rule type and tag 56/178256/5
authorseolheui kim <s414.kim@samsung.com>
Wed, 9 May 2018 04:53:59 +0000 (13:53 +0900)
committerseolheui kim <s414.kim@samsung.com>
Wed, 9 May 2018 08:00:27 +0000 (17:00 +0900)
Change-Id: I4c106f24553fbb65023a5e6bf84db69b01f5195b
Signed-off-by: seolheui kim <s414.kim@samsung.com>
lib/audit-rule/rule.cpp
lib/audit-rule/rule.h
lib/audit-rule/watch-dir-rule.h
lib/audit-rule/watch-path-rule.h

index a347e49fcf052a5f28f07937055e302394d9933a..2f39454ffb83c6f8dcb174852d2ea1627c6617ad 100644 (file)
  *  See the License for the specific language governing permissions and
  *  limitations under the License
  */
-
 #include "rule.h"
 
-Rule::Rule(RuleType type, Action action, Filter filter)
-       : _type(type), buf(sizeof(RuleData))
+Rule::Rule(Action action, Filter filter)
+       : buf(sizeof(RuleData))
 {
        set(action);
        set(filter);
 }
 
 Rule::Rule(const std::vector<char> &rule)
-       : _type(RuleType::Default), buf(sizeof(RuleData))
+       : buf(sizeof(RuleData))
 {
        setComponents(rule);
 }
 
 Rule::Rule(const Rule &rule)
-       : _type(rule._type), buf(sizeof(RuleData))
+       : buf(sizeof(RuleData))
 {
        conditions.insert(rule.conditions.begin(), rule.conditions.end());
        setComponents(rule.buf);
@@ -43,10 +42,6 @@ Rule::~Rule()
 std::vector<char> Rule::data() const
 {
        std::vector<char> ret(buf);
-       if (!isSetMask(ret)) {
-               auto r = reinterpret_cast<RuleData*>(ret.data());
-               std::fill_n(r->mask, AUDIT_BITMASK_SIZE, ~0);
-       }
 
        for (auto &c : conditions) {
                if (c.second)
@@ -55,22 +50,6 @@ std::vector<char> Rule::data() const
        return ret;
 }
 
-bool Rule::isSetMask(std::vector<char> rule) const
-{
-       auto r = reinterpret_cast<RuleData*>(rule.data());
-       for (auto &m : r->mask) {
-               if (m != 0)
-                       return true;
-       }
-       return false;
-}
-
-void Rule::setTag(const std::string &tag)
-{
-       //[TODO]: save tags
-       setCondition(Tag(tag));
-}
-
 void Rule::set(Action action)
 {
        ruleData()->action = static_cast<unsigned int>(action);
index 9fac288ba97a05dd0f5f7e8ff2e6ef303b9ee7c2..9ed8340f2e2254dd1e3c326de4af1e507322f141 100644 (file)
@@ -39,14 +39,6 @@ enum class Filter : unsigned int {
        Exclude = AUDIT_FILTER_TYPE,
 };
 
-enum class RuleType {
-       Default,
-       User,
-       Syscall,
-       Watch,
-       Exclude,
-};
-
 class Rule {
 public:
        enum Perm {
@@ -57,8 +49,7 @@ public:
        };
        using RuleData = struct audit_rule_data;
 
-       Rule(RuleType type = RuleType::Syscall,
-                       Action action = Action::Always, Filter filter = Filter::Exit);
+       Rule(Action action = Action::Always, Filter filter = Filter::Exit);
        virtual ~Rule();
 
        Rule(Rule &&) = delete;
@@ -83,19 +74,8 @@ public:
                return (data() == rule.data());
        }
 
-       RuleType type() const
-       {
-               return _type;
-       }
-
        std::vector<char> data() const;
 
-       void set(RuleType type)
-       {
-               _type = type;
-       }
-       void setTag(const std::string &tag);
-
        template <typename T>
        void setCondition(const Field<T> &field);
        template <typename T>
@@ -123,9 +103,7 @@ private:
                return reinterpret_cast<RuleData*>(buf.data());
        }
        void setComponents(const std::vector<char> &rule);
-       bool isSetMask(std::vector<char> rule) const;
 private:
-       RuleType _type;
        std::vector<char> buf;
 };
 
index ee4f5061ea2863fe15ed9b0a0cc7005c59a19905..ce876ff189ca6aa8c290b4056c7f7e18aa631e5a 100644 (file)
@@ -23,7 +23,6 @@ class WatchDirRule : public Rule {
 public:
        WatchDirRule(const std::string &path,
                        unsigned int perm = Rule::Perm::r | Rule::Perm::w | Rule::Perm::x | Rule::Perm::a)
-               : Rule(RuleType::Watch)
        {
                setCondition(WatchDir(path));
                setPerm(perm);
index b803b9e2eab7f924befee290520e5dd5875a828d..0950bca2de731c315c7ab9c361ad743271f2aee4 100644 (file)
@@ -23,7 +23,6 @@ class WatchPathRule : public Rule {
 public:
        WatchPathRule(std::string path,
                        unsigned int perm = Rule::Perm::r | Rule::Perm::w | Rule::Perm::x | Rule::Perm::a)
-               : Rule(RuleType::Watch)
        {
                if (*(path.end()-1) == '/')
                        path.pop_back();