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)
c.second->emit(ret);
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
void Rule::setMask()
{
- for (auto &m : ruleData()->mask) {
- m = ~0;
- }
+ std::fill_n(ruleData()->mask, AUDIT_BITMASK_SIZE, ~0);
}
void Rule::setMask(unsigned int syscall)
void Rule::unsetMask()
{
- for (auto &m : ruleData()->mask) {
- m = 0;
- }
+ std::fill_n(ruleData()->mask, AUDIT_BITMASK_SIZE, 0);
}
void Rule::unsetMask(unsigned int syscall)
return *this;
}
+ Rule &operator + (unsigned int mask)
+ {
+ setMask(mask);
+ return *this;
+ }
+
bool operator == (const Rule &rule)
{
return (data() == rule.data());
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;
SyscallRule(int syscall) {
setMask(syscall);
}
+ template <typename T, typename ...T2>
+ SyscallRule(T syscall, T2... syscalls) : SyscallRule(syscalls...)
+ {
+ setMask(syscall);
+ }
+
~SyscallRule() {}
};