diff --git a/CHANGES b/CHANGES index 1721e5c322..19f23b713a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ +7.1.0-dev.676 | 2024-12-05 11:08:55 -0700 + + * update of BTest that tracks number of (and validates) ZAM operations (Vern Paxson, Corelight) + + * ZAM support for pattern equality/inequality operations (Vern Paxson, Corelight) + + * expanded ZAM operations for bit-shifting to allow for int/count shift values (Vern Paxson, Corelight) + + * added type coercion for bit-shifting expressions (Vern Paxson, Corelight) + 7.1.0-dev.671 | 2024-12-05 14:51:01 +0100 * zeek-testing: Add Experiment-VM-Microsoft-Windows7AD-1 PCAP and baselines (Arne Welzel, Corelight) diff --git a/VERSION b/VERSION index a577539636..cb94f6c958 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.1.0-dev.671 +7.1.0-dev.676 diff --git a/auxil/gen-zam b/auxil/gen-zam index 3c17f9797e..0f32b4a05a 160000 --- a/auxil/gen-zam +++ b/auxil/gen-zam @@ -1 +1 @@ -Subproject commit 3c17f9797ebab5157d7b08265540cd7f4de15d1f +Subproject commit 0f32b4a05a7e1772d1a0a9b366ebd7a815e1af39 diff --git a/src/Expr.cc b/src/Expr.cc index 878002d598..cd1c98ebd3 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -1860,8 +1860,11 @@ BitExpr::BitExpr(ExprTag arg_tag, ExprPtr arg_op1, ExprPtr arg_op2) if ( IsIntegral(bt1) && bt2 == TYPE_COUNT ) { if ( is_vector(op1) || is_vector(op2) ) SetType(make_intrusive(base_type(bt1))); - else + else { SetType(base_type(bt1)); + if ( bt1 != bt2 ) + op2 = make_intrusive(op2, bt1); + } } else if ( IsIntegral(bt1) && bt2 == TYPE_INT ) diff --git a/src/script_opt/ZAM/OPs/binary-exprs.op b/src/script_opt/ZAM/OPs/binary-exprs.op index 17d90f9979..9b5643d746 100644 --- a/src/script_opt/ZAM/OPs/binary-exprs.op +++ b/src/script_opt/ZAM/OPs/binary-exprs.op @@ -37,15 +37,19 @@ binary-expr-op Mask # Signal that this expression only has mixed-type evaluation. op-type X explicit-result-type -eval-mixed A I auto mask = static_cast($2); - auto a = $1->AsAddr(); - if ( a.GetFamily() == IPv4 && mask > 32 ) - ERROR(util::fmt("bad IPv4 subnet prefix length: %" PRIu32, mask)); - if ( a.GetFamily() == IPv6 && mask > 128 ) - ERROR(util::fmt("bad IPv6 subnet prefix length: %" PRIu32, mask)); - auto v = make_intrusive(a, mask); - Unref($$.AsSubNet()); - $$.AsSubNetRef() = v.release(); +eval-mixed A I DoMask($$, $1, static_cast($2)) +eval-mixed A U DoMask($$, $1, $2) + +macro DoMask(lhs, op1, op2) + auto mask = static_cast(op2); + auto a = op1->AsAddr(); + if ( a.GetFamily() == IPv4 && mask > 32 ) + ERROR(util::fmt("bad IPv4 subnet prefix length: %" PRIu32, mask)); + if ( a.GetFamily() == IPv6 && mask > 128 ) + ERROR(util::fmt("bad IPv6 subnet prefix length: %" PRIu32, mask)); + auto v = make_intrusive(a, mask); + Unref(lhs.AsSubNet()); + lhs.AsSubNetRef() = v.release(); binary-expr-op Mod op-type I U diff --git a/src/script_opt/ZAM/OPs/rel-exprs.op b/src/script_opt/ZAM/OPs/rel-exprs.op index fd74886fb9..92c35b7ce6 100644 --- a/src/script_opt/ZAM/OPs/rel-exprs.op +++ b/src/script_opt/ZAM/OPs/rel-exprs.op @@ -17,7 +17,7 @@ eval-type T $1->IsSubsetOf(*$2) eval-type A $1->AsAddr() < $2->AsAddr() || $1->AsAddr() == $2->AsAddr() rel-expr-op EQ -op-type I U D S T A N F +op-type I U D S T A N F P vector eval $1 == $2 eval-type S Bstr_cmp($1->AsString(), $2->AsString()) == 0 @@ -25,6 +25,7 @@ eval-type T $1->EqualTo(*$2) eval-type A $1->AsAddr() == $2->AsAddr() eval-type N $1->AsSubNet() == $2->AsSubNet() eval-type F $1->GetName() == $2->GetName() +eval-type P strcmp($1->Get()->PatternText(), $2->Get()->PatternText()) == 0 eval-mixed P S $1->MatchExactly($2->AsString()) rel-expr-op NE diff --git a/testing/btest/Baseline.zam/opt.validate-ZAM/output b/testing/btest/Baseline.zam/opt.validate-ZAM/output index 10a684fd93..1707dacb53 100644 --- a/testing/btest/Baseline.zam/opt.validate-ZAM/output +++ b/testing/btest/Baseline.zam/opt.validate-ZAM/output @@ -1,2 +1,2 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -1232 valid, 1853 tested, 425 skipped +1245 valid, 1883 tested, 437 skipped