Commit 46794855 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

generate test policy: filter-limits

parent 65c82f54
......@@ -8,10 +8,14 @@
cd "$(dirname "$0")"
export LUA_PATH="./?.lua;;"
LUA=lua${LUA_VERSION}
for cls in mandatory optional private; do
eval "export AWALL_PATH_$(echo $cls | tr a-z A-Z)=test/$cls"
mkdir -p test/$cls
for script in test/$cls/*.lua; do
[ -f "$script" ] && $LUA "$script" > "${script%.lua}.json"
done
done
exec lua${LUA_VERSION} ./awall-cli ${1:-diff} -o test/output
exec $LUA ./awall-cli ${1:-diff} -o test/output
{
"filter": [
{ "conn-limit": 1 },
{ "conn-limit": 1, "action": "pass" },
{ "conn-limit": 1, "log": true },
{ "conn-limit": 1, "log": true, "action": "pass" },
{ "conn-limit": 1, "log": "none" },
{ "conn-limit": 1, "log": "none", "action": "pass" },
{ "conn-limit": { "count": 1, "log": false } },
{ "conn-limit": { "count": 1, "log": false }, "action": "pass" },
{ "conn-limit": { "count": 1, "log": false }, "log": true },
{
"conn-limit": { "count": 1, "log": false },
"log": true,
"action": "pass"
},
{ "conn-limit": { "count": 1, "log": false }, "log": "none" },
{
"conn-limit": { "count": 1, "log": false },
"log": "none",
"action": "pass"
},
{ "conn-limit": { "count": 1, "log": "none" } },
{ "conn-limit": { "count": 1, "log": "none" }, "action": "pass" },
{ "conn-limit": { "count": 1, "log": "none" }, "log": true },
{
"conn-limit": { "count": 1, "log": "none" },
"log": true,
"action": "pass"
},
{ "conn-limit": { "count": 1, "log": "none" }, "log": "none" },
{
"conn-limit": { "count": 1, "log": "none" },
"log": "none",
"action": "pass"
},
{ "conn-limit": 30 },
{ "conn-limit": 30, "action": "pass" },
{ "conn-limit": 30, "log": true },
{ "conn-limit": 30, "log": "none" },
{ "conn-limit": { "count": 30, "log": false } },
{ "conn-limit": { "count": 30, "log": false }, "action": "pass" },
{ "conn-limit": { "count": 30, "log": false }, "log": true },
{ "conn-limit": { "count": 30, "log": false }, "log": "none" },
{ "conn-limit": { "count": 30, "log": "none" } },
{ "conn-limit": { "count": 30, "log": "none" }, "action": "pass" },
{ "conn-limit": { "count": 30, "log": "none" }, "log": true },
{ "conn-limit": { "count": 30, "log": "none" }, "log": "none" },
{ "flow-limit": 1 },
{ "flow-limit": 1, "action": "pass" },
{ "flow-limit": 1, "log": true },
{ "flow-limit": 1, "log": true, "action": "pass" },
{ "flow-limit": 1, "log": "none" },
{ "flow-limit": 1, "log": "none", "action": "pass" },
{ "flow-limit": { "count": 1, "log": false } },
{ "flow-limit": { "count": 1, "log": false }, "action": "pass" },
{ "flow-limit": { "count": 1, "log": false }, "log": true },
{
"flow-limit": { "count": 1, "log": false },
"log": true,
"action": "pass"
},
{ "flow-limit": { "count": 1, "log": false }, "log": "none" },
{
"flow-limit": { "count": 1, "log": false },
"log": "none",
"action": "pass"
},
{ "flow-limit": { "count": 1, "log": "none" } },
{ "flow-limit": { "count": 1, "log": "none" }, "action": "pass" },
{ "flow-limit": { "count": 1, "log": "none" }, "log": true },
{
"flow-limit": { "count": 1, "log": "none" },
"log": true,
"action": "pass"
},
{ "flow-limit": { "count": 1, "log": "none" }, "log": "none" },
{
"flow-limit": { "count": 1, "log": "none" },
"log": "none",
"action": "pass"
},
{ "flow-limit": 30 },
{ "flow-limit": 30, "action": "pass" },
{ "flow-limit": 30, "log": true },
{ "flow-limit": 30, "log": "none" },
{ "flow-limit": { "count": 30, "log": false } },
{ "flow-limit": { "count": 30, "log": false }, "action": "pass" },
{ "flow-limit": { "count": 30, "log": false }, "log": true },
{ "flow-limit": { "count": 30, "log": false }, "log": "none" },
{ "flow-limit": { "count": 30, "log": "none" } },
{ "flow-limit": { "count": 30, "log": "none" }, "action": "pass" },
{ "flow-limit": { "count": 30, "log": "none" }, "log": true },
{ "flow-limit": { "count": 30, "log": "none" }, "log": "none" },
{ "in": "A", "out": "_fw", "flow-limit": 1, "no-track": true },
{
"in": "A",
"out": "_fw",
"flow-limit": 1,
"action": "pass",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": 1,
"log": true,
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": 1,
"log": true,
"action": "pass",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": 1,
"log": "none",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": 1,
"log": "none",
"action": "pass",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": false },
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": false },
"action": "pass",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": false },
"log": true,
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": false },
"log": true,
"action": "pass",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": false },
"log": "none",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": false },
"log": "none",
"action": "pass",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": "none" },
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": "none" },
"action": "pass",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": "none" },
"log": true,
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": "none" },
"log": true,
"action": "pass",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": "none" },
"log": "none",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 1, "log": "none" },
"log": "none",
"action": "pass",
"no-track": true
},
{ "in": "A", "out": "_fw", "flow-limit": 30, "no-track": true },
{
"in": "A",
"out": "_fw",
"flow-limit": 30,
"action": "pass",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": 30,
"log": true,
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": 30,
"log": "none",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 30, "log": false },
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 30, "log": false },
"action": "pass",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 30, "log": false },
"log": true,
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 30, "log": false },
"log": "none",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 30, "log": "none" },
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 30, "log": "none" },
"action": "pass",
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 30, "log": "none" },
"log": true,
"no-track": true
},
{
"in": "A",
"out": "_fw",
"flow-limit": { "count": 30, "log": "none" },
"log": "none",
"no-track": true
}
]
}
util = require('awall.util')
json = require('cjson')
res = {}
function add(limit_type, base)
for _, count in ipairs{1, 30} do
for _, limit in ipairs{
count, {count=count, log=false}, {count=count, log='none'}
} do
for _, log in ipairs{false, true, 'none'} do
for _, action in ipairs{false, 'pass'} do
if not (count == 30 and log and action) then
table.insert(
res,
util.update(
util.copy(base or {}),
{
[limit_type..'-limit']=limit,
log=log or nil,
action=action or nil
}
)
)
end
end
end
end
end
end
add('conn')
add('flow')
add('flow', {['in']='A', out='_fw', ['no-track']=true})
print(json.encode{filter=res})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment