Skip to content

Commit

Permalink
Handle lua patterns.
Browse files Browse the repository at this point in the history
% requires escaping.
  • Loading branch information
mstemm committed Nov 29, 2016
1 parent 5e6532c commit 1253b8c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions userspace/engine/lua/rule_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,19 @@ function load_rules(rules_content, rules_mgr, verbose, all_events, extra, replac
-- If the format string contains %container.info, replace it
-- with extra. Otherwise, add extra onto the end of the format
-- string.
if string.find(v['output'], "%container.info") ~= nil then
if string.find(v['output'], "%container.info", nil, true) ~= nil then

-- There may not be any extra, or we're not supposed
-- to replace it, in which case we use the generic
-- "%container.name (id=%container.id)"
if extra == "" or replace_container_info == false then
v['output'] = string.gsub(v['output'], "%container.info", "%container.name (id=%container.id)")
if replace_container_info == false then
v['output'] = string.gsub(v['output'], "%%container.info", "%%container.name (id=%%container.id)")
if extra ~= "" then
v['output'] = v['output'].." "..extra
end
else
v['output'] = string.gsub(v['output'], "%container.info", extra)
safe_extra = string.gsub(extra, "%%", "%%%%")
v['output'] = string.gsub(v['output'], "%%container.info", safe_extra)
end
else
-- Just add the extra to the end
Expand Down

0 comments on commit 1253b8c

Please sign in to comment.