From d45ba348fd12a058e8925bf08827eadc0d3c82b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Tue, 5 Oct 2021 12:13:15 +0100 Subject: dfilter: Strengthen sanity check for range Allow an entity in the grammar as range body. Perform a stronger sanity check during semantic analysis everywhere a range is used. This is both safer (unless we want to allow FIELD bodies only, but functions are allowed too) and also provides better error messages. Previously a range of range only compiled on the RHS. Now it can appear on both sides of a relation. This fixes a crash with STRING entities similar to #10690 for UNPARSED. This also adds back support for slicing functions that was removed in f3f833ccecce0e8611b2f1990d0fcf81959fcb78 (by accident presumably). Ping #10690 --- test/suite_dfilter/group_range_method.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/suite_dfilter/group_range_method.py b/test/suite_dfilter/group_range_method.py index 4570171bb3..c3068a6ea0 100644 --- a/test/suite_dfilter/group_range_method.py +++ b/test/suite_dfilter/group_range_method.py @@ -34,3 +34,15 @@ class case_range(unittest.TestCase): def test_slice_2_neg(self, checkDFilterCount): dfilter = "ipx.src.node[3:2] == cc:dd" checkDFilterCount(dfilter, 0) + + def test_slice_string_1(self, checkDFilterFail): + dfilter = "frame == \"00\"[1]" + checkDFilterFail(dfilter, "Range is not supported for entity 00 of type STRING") + + def test_slice_unparsed_1(self, checkDFilterFail): + dfilter = "a == b[1]" + checkDFilterFail(dfilter, "Range is not supported for entity b of type UNPARSED") + + def test_slice_func_1(self, checkDFilterSucceed): + dfilter = "string(ipx.src.node)[3:2] == \"cc:dd\"" + checkDFilterSucceed(dfilter) -- cgit v1.2.3