tests: py: extend meta time coverage
Pablo Neira Ayuso
maintainerPATCH 1/1 tests: py: extend meta time coverage
Add meta time tests using < and > operands.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- tests/py/any/meta.t | 2 ++ tests/py/any/meta.t.json | 36 ++++++++++++++++++++++++++++++++++++ tests/py/any/meta.t.payload | 14 ++++++++++++++ 3 files changed, 52 insertions(+)
tests/py/any/meta.t +2 -0
@@ -208,6 +208,8 @@ meta time "2019-06-21 17:00:00" drop;ok meta time "2019-07-01 00:00:00" drop;ok meta time "2019-07-01 00:01:00" drop;ok meta time "2019-07-01 00:00:01" drop;ok +meta time < "2022-07-01 11:00:00" accept;ok +meta time > "2022-07-01 11:00:00" accept;ok meta day "Saturday" drop;ok meta day 6 drop;ok;meta day "Saturday" drop meta day "Satturday" drop;fail
tests/py/any/meta.t.json +36 -0
@@ -2561,6 +2561,42 @@ } ] +# meta time < "2022-07-01 11:00:00" accept +[ + { + "match": { + "left": { + "meta": { + "key": "time" + } + }, + "op": "<", + "right": "2022-07-01 11:00:00" + } + }, + { + "accept": null + } +] + +# meta time > "2022-07-01 11:00:00" accept +[ + { + "match": { + "left": { + "meta": { + "key": "time" + } + }, + "op": ">", + "right": "2022-07-01 11:00:00" + } + }, + { + "accept": null + } +] + # meta day "Saturday" drop [ {
tests/py/any/meta.t.payload +14 -0
@@ -1003,6 +1003,20 @@ ip meta-test input [ cmp eq reg 1 0x22eb8a00 0x15ad18e1 ] [ immediate reg 0 drop ] +# meta time < "2022-07-01 11:00:00" accept +ip test-ip4 input + [ meta load time => reg 1 ] + [ byteorder reg 1 = hton(reg 1, 8, 8) ] + [ cmp lt reg 1 0xf3a8fd16 0x00a07719 ] + [ immediate reg 0 accept ] + +# meta time > "2022-07-01 11:00:00" accept +ip test-ip4 input + [ meta load time => reg 1 ] + [ byteorder reg 1 = hton(reg 1, 8, 8) ] + [ cmp gt reg 1 0xf3a8fd16 0x00a07719 ] + [ immediate reg 0 accept ] + # meta day "Saturday" drop ip test-ip4 input [ meta load day => reg 1 ]
Signature · 1 line
2.30.2
By the way, I have just noticed that while this gives an error on 1.0.2:
add rule inet filter input iif lo time < "2022-07-01 11:00" accept
This does not:
add rule inet filter input iif lo meta time < "2022-07-01 11:00" accept
The use of 'meta' in front of 'time' works around the bug.
Should the tests include a few statements *without* 'meta'?
-Martin
Quoted 98 lines · Pablo Neira Ayuso
Add meta time tests using < and > operands.
Signed-off-by Pablo Neira Ayuso <[email protected]>--- tests/py/any/meta.t | 2 ++ tests/py/any/meta.t.json | 36 ++++++++++++++++++++++++++++++++++++ tests/py/any/meta.t.payload | 14 ++++++++++++++ 3 files changed, 52 insertions(+)tests/py/any/meta.t +2
-0@@ -208,6 +208,8 @@ meta time "2019-06-21 17:00:00" drop;ok meta time "2019-07-01 00:00:00" drop;ok meta time "2019-07-01 00:01:00" drop;ok meta time "2019-07-01 00:00:01" drop;ok +meta time < "2022-07-01 11:00:00" accept;ok +meta time > "2022-07-01 11:00:00" accept;ok meta day "Saturday" drop;ok meta day 6 drop;ok;meta day "Saturday" drop meta day "Satturday" drop;failtests/py/any/meta.t.json +36
-0@@ -2561,6 +2561,42 @@ } ] +# meta time < "2022-07-01 11:00:00" accept +[ + { + "match": { + "left": { + "meta": { + "key": "time" + } + }, + "op": "<", + "right": "2022-07-01 11:00:00" + } + }, + { + "accept": null + } +] + +# meta time > "2022-07-01 11:00:00" accept +[ + { + "match": { + "left": { + "meta": { + "key": "time" + } + }, + "op": ">", + "right": "2022-07-01 11:00:00" + } + }, + { + "accept": null + } +] + # meta day "Saturday" drop [ {tests/py/any/meta.t.payload +14
-1@@ -1003,6 +1003,20 @@ ip meta-test input [ cmp eq reg 1 0x22eb8a00 0x15ad18e1 ] [ immediate reg 0 drop ] +# meta time < "2022-07-01 11:00:00" accept +ip test-ip4 input + [ meta load time => reg 1 ] + [ byteorder reg 1 = hton(reg 1, 8, 8) ] + [ cmp lt reg 1 0xf3a8fd16 0x00a07719 ] + [ immediate reg 0 accept ] + +# meta time > "2022-07-01 11:00:00" accept +ip test-ip4 input + [ meta load time => reg 1 ] + [ byteorder reg 1 = hton(reg 1, 8, 8) ] + [ cmp gt reg 1 0xf3a8fd16 0x00a07719 ] + [ immediate reg 0 accept ] + # meta day "Saturday" drop ip test-ip4 input [ meta load day => reg 1 ] --2.30.2
Florian Westphal
maintainerQuoted 11 lines · Martin Gignac
By the way, I have just noticed that while this gives an error on 1.0.2:
add rule inet filter input iif lo time < "2022-07-01 11:00" acceptThis does not:
add rule inet filter input iif lo meta time < "2022-07-01 11:00" acceptThe use of 'meta' in front of 'time' works around the bug.
Should the tests include a few statements *without* 'meta'?
Yes, please consider sending a patch to extend the tests.