updates to ZAM to track recent changes in script semantics

This commit is contained in:
Vern Paxson 2021-12-04 20:24:39 -05:00
parent e7412e257f
commit 3f9f47980a
7 changed files with 38 additions and 2588 deletions

View file

@ -941,6 +941,12 @@ TraversalCode CSE_ValidityChecker::PreExpr(const Expr* e)
}
break;
case EXPR_TABLE_CONSTRUCTOR:
// These have EXPR_ASSIGN's in them that don't
// correspond to actual assignments to variables,
// so we don't want to traverse them.
return TC_ABORTSTMT;
default:
if ( in_aggr_mod_stmt && (t == EXPR_INDEX || t == EXPR_FIELD) )
{

View file

@ -230,7 +230,8 @@ const ZAMStmt ZAMCompiler::CompileAssignToIndex(const NameExpr* lhs, const Index
auto n = const_aggr ? nullptr : aggr->AsNameExpr();
auto con = const_aggr ? aggr->AsConstExpr() : nullptr;
if ( indexes.length() == 1 && indexes[0]->GetType()->Tag() == TYPE_VECTOR )
if ( indexes.length() == 1 && indexes[0]->GetType()->Tag() == TYPE_VECTOR &&
aggr->GetType()->Tag() != TYPE_TABLE )
{
auto index1 = indexes[0];
if ( index1->Tag() == EXPR_CONST )

View file

@ -1055,7 +1055,17 @@ macro EvalConstructRecord(map_init, map_accessor)
auto n = aux->n;
map_init
for ( auto i = 0; i < n; ++i )
new_r->Assign(map_accessor, aux->ToVal(frame, i));
{
auto v_i = aux->ToVal(frame, i);
auto ind = map_accessor;
if ( v_i && v_i->GetType()->Tag() == TYPE_VECTOR &&
v_i->GetType<VectorType>()->IsUnspecifiedVector() )
{
const auto& t_ind = rt->GetFieldType(ind);
v_i->AsVectorVal()->Concretize(t_ind->Yield());
}
new_r->Assign(ind, aux->ToVal(frame, i));
}
auto& r = frame[z.v1].record_val;
Unref(r);
r = new_r;
@ -2084,9 +2094,17 @@ eval EvalStrStr(frame[z.v2], z.c)
internal-op Analyzer--Name
type VV
eval auto atype = frame[z.v2].ToVal(z.t);
auto& name = analyzer_mgr->GetComponentName(cast_intrusive<EnumVal>(atype));
auto val = atype->AsEnumVal();
Unref(frame[z.v1].string_val);
frame[z.v1].string_val = new StringVal(name);
plugin::Component* component = zeek::analyzer_mgr->Lookup(val);
if ( ! component )
component = zeek::packet_mgr->Lookup(val);
if ( ! component )
component = zeek::file_mgr->Lookup(val);
if ( component )
frame[z.v1].string_val = new StringVal(component->CanonicalName());
else
frame[z.v1].string_val = new StringVal("<error>");
internal-op Files--Enable-Reassembly
op1-read

View file

@ -21,6 +21,7 @@
#include "zeek/broker/Manager.h"
#include "zeek/file_analysis/Manager.h"
#include "zeek/logging/Manager.h"
#include "zeek/packet_analysis/Manager.h"
namespace zeek::detail
{

View file

@ -0,0 +1,7 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
proto confirm, AllAnalyzers::ANALYZER_ANALYZER_HTTP
http_request, GET, /style/enhanced.css
T
total http messages, {
[[orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp]] = 1
}

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,4 @@
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
# @TEST-EXEC: ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Demo Hooks
# @TEST-EXEC: cp -r %DIR/hooks-plugin/* .
# @TEST-EXEC: ./configure --zeek-dist=${DIST} && make