Merge remote-tracking branch 'origin/topic/vern/ZAM-incr-op-opt-fix'

* origin/topic/vern/ZAM-incr-op-opt-fix:
  ZAM optimizer fix for += / -= set operations
This commit is contained in:
Tim Wojtulewicz 2025-07-09 15:10:03 -07:00
commit 0848ddfb9f
5 changed files with 50 additions and 1 deletions

19
CHANGES
View file

@ -1,3 +1,22 @@
8.0.0-dev.622 | 2025-07-09 15:10:03 -0700
* ZAM optimizer fix for += / -= set operations (Vern Paxson, Corelight)
* Bump `spicy-format` pre-commit hook (Benjamin Bannier, Corelight)
pre-commit ignores Cargo.lock files for Rust projects, so any movement
in a Rust project's dependencies can break a hook, even if no code in
the hook changed. I have tried to work with upstream on a fix, but they
basically told me they weren't interested and to get lost.
This bumps the `spicy-format` pre-commit hook to a new version which
explicitly deals with bumps of its dependencies. Having to do this
semi-regularly is not fun, and ideally somebody interested in using this
hook would help set up infrastructure in the hook so it just pulls
pre-built binaries. This is not directly supported by pre-commit, but
many projects work around this by declaring a Python module which then
pulls pre-build binaries which already exist for spicy-format.
8.0.0-dev.618 | 2025-07-08 17:45:16 -0700 8.0.0-dev.618 | 2025-07-08 17:45:16 -0700
* Clarify the cookie field's origin in the RDP log. (Christian Kreibich, Corelight) * Clarify the cookie field's origin in the RDP log. (Christian Kreibich, Corelight)

View file

@ -1 +1 @@
8.0.0-dev.618 8.0.0-dev.622

View file

@ -767,6 +767,9 @@ bool AddToExpr::IsReduced(Reducer* c) const {
} }
ExprPtr AddToExpr::Reduce(Reducer* c, StmtPtr& red_stmt) { ExprPtr AddToExpr::Reduce(Reducer* c, StmtPtr& red_stmt) {
if ( c->Optimizing() )
op2 = c->UpdateExpr(op2);
auto tag = op1->GetType()->Tag(); auto tag = op1->GetType()->Tag();
switch ( tag ) { switch ( tag ) {
@ -869,6 +872,9 @@ bool RemoveFromExpr::IsReduced(Reducer* c) const {
} }
ExprPtr RemoveFromExpr::Reduce(Reducer* c, StmtPtr& red_stmt) { ExprPtr RemoveFromExpr::Reduce(Reducer* c, StmtPtr& red_stmt) {
if ( c->Optimizing() )
op2 = c->UpdateExpr(op2);
if ( op1->GetType()->Tag() == TYPE_TABLE ) { if ( op1->GetType()->Tag() == TYPE_TABLE ) {
StmtPtr red_stmt1; StmtPtr red_stmt1;
StmtPtr red_stmt2; StmtPtr red_stmt2;

View file

@ -0,0 +1,4 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[my_set={
}]

View file

@ -0,0 +1,20 @@
# @TEST-DOC: Regression test for ZAM optimizer mis-transforming set +=/-= ops
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# @TEST-EXEC: zeek -b -O ZAM %INPUT >output
# @TEST-EXEC: btest-diff output
type R: record {
my_set: set[string];
};
event zeek_init()
{
local r1 = R();
local r2 = R();
if ( |r1$my_set| > 0 )
print T;
r2$my_set += r1$my_set;
print r2;
}