aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite_dfilter
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2023-06-24 17:52:44 +0100
committerJoão Valverde <j@v6e.pt>2023-06-26 00:46:18 +0000
commit58110d76496799a6a0257635b1180dda96130962 (patch)
tree2f6de30f2ff7dfe4f34a74200c1da6753070f117 /test/suite_dfilter
parent38a5b44d61cabf4ccda8adb89c94ae730f87d48c (diff)
dfilter: Fix raw slices
Fix raw slices to always have FT_BYTES type. Before: Filter: @_ws.ftypes.string[3:4] == ff:ff Instructions: 0000 READ_TREE @_ws.ftypes.string <FT_STRING> -> R0 0001 IF_FALSE_GOTO 4 0002 SLICE R0[3:4] -> R1 0003 ANY_EQ R1 == ff:ff <FT_BYTES> 0004 RETURN After: Filter: @_ws.ftypes.string[3:4] == ff:ff Instructions: 0000 READ_TREE @_ws.ftypes.string <FT_BYTES> -> R0 0001 IF_FALSE_GOTO 4 0002 SLICE R0[3:4] -> R1 0003 ANY_EQ R1 == ff:ff <FT_BYTES> 0004 RETURN
Diffstat (limited to 'test/suite_dfilter')
-rw-r--r--test/suite_dfilter/group_syntax.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/suite_dfilter/group_syntax.py b/test/suite_dfilter/group_syntax.py
index 63fb94fbeb..be6ab52928 100644
--- a/test/suite_dfilter/group_syntax.py
+++ b/test/suite_dfilter/group_syntax.py
@@ -396,3 +396,22 @@ class TestDfilterRawModifier:
dfilter = '@s7comm.blockinfo.blocktype == ${@s7comm.blockinfo.blocktype}'
# select frame 3, expect 2 frames out of 3.
checkDFilterCountWithSelectedFrame(dfilter, 2, 3)
+
+class TestDfilterRawSlice:
+ trace_file = "http.pcap"
+
+ def test_raw_slice1(self, checkDFilterFail):
+ dfilter = 'tcp.port[1] == 0xc3'
+ checkDFilterFail(dfilter, "cannot be sliced")
+
+ def test_raw_slice2(self, checkDFilterCount):
+ dfilter = '@tcp.port[1] == 0xc3'
+ checkDFilterCount(dfilter, 1)
+
+ def test_raw_slice3(self, checkDFilterFail):
+ dfilter = 'tcp.port[0:] == 0c:c3'
+ checkDFilterFail(dfilter, "cannot be sliced")
+
+ def test_raw_slice4(self, checkDFilterCount):
+ dfilter = '@tcp.port[0:] == 0c:c3'
+ checkDFilterCount(dfilter, 1)