From 0f6cbe78145c226ec0a512c6d79d0f34ac178a05 Mon Sep 17 00:00:00 2001 From: Mark Stemm Date: Mon, 11 Jul 2016 13:07:37 -0700 Subject: [PATCH] Allow lists to contain list references. 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. --- userspace/falco/lua/rule_loader.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/userspace/falco/lua/rule_loader.lua b/userspace/falco/lua/rule_loader.lua index a90caa75346..f668de6040d 100644 --- a/userspace/falco/lua/rule_loader.lua +++ b/userspace/falco/lua/rule_loader.lua @@ -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