Skip to content

Commit

Permalink
Allow lists to contain list references.
Browse files Browse the repository at this point in the history
Allow lists to contain list references by expanding any references to
the items in the list, before storing the list items in
state.lists. Prior to this change, some list references might be
expanded simply due to the way the list items were iterated over in
compile_macro/compile_filter.
  • Loading branch information
mstemm committed Jul 11, 2016
1 parent fd948c1 commit 0f6cbe7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion userspace/falco/lua/rule_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,21 @@ function load_rules(filename)
elseif (v['list']) then
-- list items are represented in yaml as a native list, so no
-- parsing necessary
state.lists[v['list']] = v['items']
local items = {}

-- List items may be references to other lists, so go through
-- the items and expand any references to the items in the list
for i, item in ipairs(v['items']) do
if (state.lists[item] == nil) then
items[#items+1] = item
else
for i, exp_item in ipairs(state.lists[item]) do
items[#items+1] = exp_item
end
end
end

state.lists[v['list']] = items

else -- rule

Expand Down

0 comments on commit 0f6cbe7

Please sign in to comment.