mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
Merge remote-tracking branch 'origin/topic/awelzel/propagate-on-change-through-copy'
* origin/topic/awelzel/propagate-on-change-through-copy: TableVal: Propagate &on_change attribute through copy() testing/btest: Add test showing &expire_func/&create_expire is copied
This commit is contained in:
commit
0fd92555d9
8 changed files with 145 additions and 1 deletions
17
CHANGES
17
CHANGES
|
@ -1,3 +1,20 @@
|
|||
6.0.0-dev.64 | 2023-02-17 17:36:40 +0100
|
||||
|
||||
* TableVal: Propagate &on_change attribute through copy() (Arne Welzel, Corelight)
|
||||
|
||||
Mostly for consistency with &default, &expire_func and other attributes
|
||||
being propagated through a copy(). Seems this was just missed during
|
||||
the implementation and/or was never tested for.
|
||||
|
||||
* GH-2793: TableVal: Propagate &ordered through copy() (Arne Welzel, Corelight)
|
||||
|
||||
Copying an &ordered table or set would result in a copy that is not ordered.
|
||||
This seems rather surprising behavior, so propagate the &ordered attribute.
|
||||
|
||||
* GH-2690: Type/is_supported_index_type: Deal with recursive record types (Arne Welzel, Corelight)
|
||||
|
||||
This plugs the issue reported in #2690, there might be more though.
|
||||
|
||||
6.0.0-dev.57 | 2023-02-16 15:10:33 -0700
|
||||
|
||||
* Move get_relative_seq and get_segment_len to public static methods (Tim Wojtulewicz, Corelight)
|
||||
|
|
3
NEWS
3
NEWS
|
@ -20,6 +20,9 @@ Changed Functionality
|
|||
an appropriate callback function, log a warning and return a generic handle
|
||||
value based on the analyzer and connection information.
|
||||
|
||||
- The ``&on_change`` attribute of set and tables is propagated through ``copy()``.
|
||||
|
||||
|
||||
Zeek 5.2.0
|
||||
==========
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
6.0.0-dev.57
|
||||
6.0.0-dev.64
|
||||
|
|
|
@ -2661,6 +2661,9 @@ ValPtr TableVal::DoClone(CloneState* state)
|
|||
detail::timer_mgr->Add(tv->timer);
|
||||
}
|
||||
|
||||
if ( change_func )
|
||||
tv->change_func = change_func;
|
||||
|
||||
if ( expire_func )
|
||||
tv->expire_func = expire_func;
|
||||
|
||||
|
|
54
testing/btest/Baseline/language.expire_func-copy/output
Normal file
54
testing/btest/Baseline/language.expire_func-copy/output
Normal file
|
@ -0,0 +1,54 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
@XXXXXXXXXX.XXXXXX expired a
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.1, orig_p=5353/udp, resp_h=224.0.0.251, resp_p=5353/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=fe80::20c:29ff:febd:6f01, orig_p=5353/udp, resp_h=ff02::fb, resp_p=5353/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.1, orig_p=49658/tcp, resp_h=172.16.238.131, resp_p=80/tcp]
|
||||
@XXXXXXXXXX.XXXXXX expired b
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.1, orig_p=17500/udp, resp_h=172.16.238.255, resp_p=17500/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.1, orig_p=49656/tcp, resp_h=172.16.238.131, resp_p=22/tcp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=5353/udp, resp_h=224.0.0.251, resp_p=5353/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=37975/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.1, orig_p=49657/tcp, resp_h=172.16.238.131, resp_p=80/tcp]
|
||||
@XXXXXXXXXX.XXXXXX expired a
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=5353/udp, resp_h=224.0.0.251, resp_p=5353/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.1, orig_p=49658/tcp, resp_h=172.16.238.131, resp_p=80/tcp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.1, orig_p=5353/udp, resp_h=224.0.0.251, resp_p=5353/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=37975/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.1, orig_p=17500/udp, resp_h=172.16.238.255, resp_p=17500/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=fe80::20c:29ff:febd:6f01, orig_p=5353/udp, resp_h=ff02::fb, resp_p=5353/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.1, orig_p=49657/tcp, resp_h=172.16.238.131, resp_p=80/tcp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.1, orig_p=49656/tcp, resp_h=172.16.238.131, resp_p=22/tcp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=45126/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.1, orig_p=49659/tcp, resp_h=172.16.238.131, resp_p=21/tcp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=45126/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.1, orig_p=49659/tcp, resp_h=172.16.238.131, resp_p=21/tcp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=53102/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=48621/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=33109/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=57272/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=50205/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=54304/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=44555/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=51970/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=59573/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=55515/tcp, resp_h=74.125.225.81, resp_p=80/tcp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=33818/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=55368/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=37846/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=45140/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired [orig_h=172.16.238.131, orig_p=52952/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=53102/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=48621/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=51970/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=52952/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=33818/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=37846/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=50205/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=59573/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=55368/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=55515/tcp, resp_h=74.125.225.81, resp_p=80/tcp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=57272/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=44555/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=33109/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=45140/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
||||
@XXXXXXXXXX.XXXXXX expired copy [orig_h=172.16.238.131, orig_p=54304/udp, resp_h=172.16.238.2, resp_p=53/udp]
|
9
testing/btest/Baseline/language.on_change-copy/output
Normal file
9
testing/btest/Baseline/language.on_change-copy/output
Normal file
|
@ -0,0 +1,9 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
inserting
|
||||
tbl_change, a, 1, 5, TABLE_ELEMENT_NEW
|
||||
set_change, hi, TABLE_ELEMENT_NEW
|
||||
changing
|
||||
tbl_change, a, 1, 5, TABLE_ELEMENT_CHANGED
|
||||
deleting
|
||||
tbl_change, a, 1, 2, TABLE_ELEMENT_REMOVED
|
||||
set_change, hi, TABLE_ELEMENT_REMOVED
|
27
testing/btest/language/expire_func-copy.zeek
Normal file
27
testing/btest/language/expire_func-copy.zeek
Normal file
|
@ -0,0 +1,27 @@
|
|||
# @TEST-DOC: Test that expire_func is copied (the expiration behavior of existing elements
|
||||
#
|
||||
# @TEST-EXEC: zeek -b -C -r $TRACES/var-services-std-ports.trace %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
function inform_me(s: table[string] of count, idx: string): interval
|
||||
{
|
||||
print fmt("@%.2f expired %s", time_to_double(network_time()), idx);
|
||||
return 0secs;
|
||||
}
|
||||
|
||||
global s: table[string] of count &create_expire=1secs &expire_func=inform_me;
|
||||
global scopy: table[string] of count;
|
||||
|
||||
event new_connection(c: connection)
|
||||
{
|
||||
s[fmt("%s", c$id)] = 1;
|
||||
scopy[fmt("copy %s", c$id)] = 1;
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
# This copies &expire_func and &create_expire from the value s;
|
||||
s["a"] = 5;
|
||||
scopy = copy(s);
|
||||
scopy["b"] = 5;
|
||||
}
|
31
testing/btest/language/on_change-copy.test
Normal file
31
testing/btest/language/on_change-copy.test
Normal file
|
@ -0,0 +1,31 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
module TestModule;
|
||||
|
||||
function tbl_change(t: table[string, int] of count, tpe: TableChange, idxa: string, idxb: int, val: count)
|
||||
{
|
||||
print "tbl_change", idxa, idxb, val, tpe;
|
||||
}
|
||||
|
||||
function set_change(t: set[string], tpe: TableChange, idx: string)
|
||||
{
|
||||
print "set_change", idx, tpe;
|
||||
}
|
||||
|
||||
global t: table[string, int] of count &on_change=tbl_change;
|
||||
global s: set[string] &on_change=set_change;
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
local tc = copy(t);
|
||||
local sc = copy(s);
|
||||
print "inserting";
|
||||
tc["a", 1] = 5;
|
||||
add sc["hi"];
|
||||
print "changing";
|
||||
tc["a", 1] = 2;
|
||||
print "deleting";
|
||||
delete tc["a", 1];
|
||||
delete sc["hi"];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue