Skip to content

Commit

Permalink
Merge pull request #125 from draios/add-pmatch
Browse files Browse the repository at this point in the history
Add the new pmatch operator.
  • Loading branch information
mstemm committed Oct 3, 2016
2 parents 82597c9 + 930b38b commit 5008003
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions userspace/engine/lua/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function check_for_ignored_syscalls_events(ast, filter_type, source)
(node.left.value == "evt.type" or
node.left.value == "syscall.type") then

if node.operator == "in" then
if node.operator == "in" or node.operator == "pmatch" then
for i, v in ipairs(node.right.elements) do
if v.type == "BareString" then
if node.left.value == "evt.type" then
Expand Down Expand Up @@ -200,7 +200,7 @@ function get_evttypes(name, ast, source)
if found_not then
found_event_after_not = true
end
if node.operator == "in" then
if node.operator == "in" or node.operator == "pmatch" then
for i, v in ipairs(node.right.elements) do
if v.type == "BareString" then
evtnames[v.value] = 1
Expand Down
2 changes: 2 additions & 0 deletions userspace/engine/lua/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ local G = {
RelationalExpression =
rel(terminal "FieldName", V"RelOp", V"Value") +
rel(terminal "FieldName", V"InOp", V"InList") +
rel(terminal "FieldName", V"PmatchOp", V"InList") +
V"PrimaryExp";

PrimaryExp = symb("(") * V"Filter" * symb(")");
Expand Down Expand Up @@ -248,6 +249,7 @@ local G = {
symb("glob") / "glob" +
symb("startswith") / "startswith";
InOp = kw("in") / "in";
PmatchOp = kw("pmatch") / "pmatch";
UnaryBoolOp = kw("not") / "not";
ExistsOp = kw("exists") / "exists";

Expand Down
2 changes: 1 addition & 1 deletion userspace/engine/lua/rule_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ local function install_filter(node, parent_bool_op)
filter.unnest() -- io.write(")")

elseif t == "BinaryRelOp" then
if (node.operator == "in") then
if (node.operator == "in" or node.operator == "pmatch") then
elements = map(function (el) return el.value end, node.right.elements)
filter.rel_expr(node.left.value, node.operator, elements, node.index)
else
Expand Down

0 comments on commit 5008003

Please sign in to comment.