mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
global_ids: Align script_id$type_name field with type_name()
Populate script_id$type_name with what the type_name() bif would produce for the same identifier. Closes #3490
This commit is contained in:
parent
f96600391a
commit
1c2d1b3717
4 changed files with 18 additions and 7 deletions
4
NEWS
4
NEWS
|
@ -26,6 +26,10 @@ Changed Functionality
|
|||
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).
|
||||
|
||||
- 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
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -2117,12 +2117,15 @@ function global_ids%(%): 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");
|
||||
|
||||
zeek::ODesc d;
|
||||
auto ids = zeek::make_intrusive<zeek::TableVal>(id_table);
|
||||
|
||||
for ( const auto& [_, id] : zeek::detail::global_scope()->Vars() )
|
||||
{
|
||||
d.Clear();
|
||||
id->GetType()->Describe(&d);
|
||||
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(2, id->IsConst());
|
||||
rec->Assign(3, id->IsEnumConst());
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
### 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
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
event zeek_init()
|
||||
{
|
||||
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
|
||||
if ( i == "zeek_init" )
|
||||
print a[i]$type_name;
|
||||
|
||||
# the table is quite large, so just print the following.
|
||||
if ( k in set("zeek_init", "Log::write", "Site::local_nets") )
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue