Merge remote-tracking branch 'origin/topic/awelzel/3490-global-ids-type-name-change'

* origin/topic/awelzel/3490-global-ids-type-name-change:
  global_ids: Align script_id$type_name field with type_name()
This commit is contained in:
Arne Welzel 2024-02-26 21:15:25 +01:00
commit e87272f5a7
4 changed files with 18 additions and 7 deletions

4
NEWS
View file

@ -35,6 +35,10 @@ Changed Functionality
would reproduce the same fuid, even if the command itself did not result in would reproduce the same fuid, even if the command itself did not result in
a file transfer over a data connection (e.g., CWD, DEL, PASV, SIZE). a file transfer over a data connection (e.g., CWD, DEL, PASV, SIZE).
- The type_name field populated by ``global_ids()`` now aligns with the value
returned by ``type_name()`` for each identifier. E.g, ``Site::local_nets``
has a type_name of ``set[subnet]`` rather than ``table``.
Removed Functionality Removed Functionality
--------------------- ---------------------

View file

@ -2117,12 +2117,15 @@ function global_ids%(%): id_table
static auto id_table = zeek::id::find_type<zeek::TableType>("id_table"); static auto id_table = zeek::id::find_type<zeek::TableType>("id_table");
static auto script_id = zeek::id::find_type<zeek::RecordType>("script_id"); static auto script_id = zeek::id::find_type<zeek::RecordType>("script_id");
zeek::ODesc d;
auto ids = zeek::make_intrusive<zeek::TableVal>(id_table); auto ids = zeek::make_intrusive<zeek::TableVal>(id_table);
for ( const auto& [_, id] : zeek::detail::global_scope()->Vars() ) for ( const auto& [_, id] : zeek::detail::global_scope()->Vars() )
{ {
d.Clear();
id->GetType()->Describe(&d);
auto rec = zeek::make_intrusive<zeek::RecordVal>(script_id); auto rec = zeek::make_intrusive<zeek::RecordVal>(script_id);
rec->Assign(0, type_name(id->GetType()->Tag())); rec->Assign(0, d.Description());
rec->Assign(1, id->IsExport()); rec->Assign(1, id->IsExport());
rec->Assign(2, id->IsConst()); rec->Assign(2, id->IsConst());
rec->Assign(3, id->IsEnumConst()); rec->Assign(3, id->IsEnumConst());

View file

@ -1,2 +1,4 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
func Site::local_nets, set[subnet]
zeek_init, event()
Log::write, function(id:Log::ID, columns:any) : bool

View file

@ -5,12 +5,14 @@
event zeek_init() event zeek_init()
{ {
local a = global_ids(); local a = global_ids();
for ( i in a ) for ( k, v in a )
{ {
# the table is quite large, so just print one item we expect # the table is quite large, so just print the following.
if ( i == "zeek_init" ) if ( k in set("zeek_init", "Log::write", "Site::local_nets") )
print a[i]$type_name; {
print k, v$type_name;
assert type_name(lookup_ID(k)) == v$type_name, fmt("%s vs %s", type_name(lookup_ID(k)), v$type_name);
}
} }
} }