diff --git a/NEWS b/NEWS index 53e5f31eb0..ca5a9b51fd 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,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 --------------------- diff --git a/src/zeek.bif b/src/zeek.bif index 18ffb101bd..8afcb2e718 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -2117,12 +2117,15 @@ function global_ids%(%): id_table static auto id_table = zeek::id::find_type("id_table"); static auto script_id = zeek::id::find_type("script_id"); + zeek::ODesc d; auto ids = zeek::make_intrusive(id_table); for ( const auto& [_, id] : zeek::detail::global_scope()->Vars() ) { + d.Clear(); + id->GetType()->Describe(&d); auto rec = zeek::make_intrusive(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()); diff --git a/testing/btest/Baseline/bifs.global_ids/out b/testing/btest/Baseline/bifs.global_ids/out index 167bc20d48..bab35543ac 100644 --- a/testing/btest/Baseline/bifs.global_ids/out +++ b/testing/btest/Baseline/bifs.global_ids/out @@ -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 diff --git a/testing/btest/bifs/global_ids.zeek b/testing/btest/bifs/global_ids.zeek index b3cf1d3645..38a6f6fdfb 100644 --- a/testing/btest/bifs/global_ids.zeek +++ b/testing/btest/bifs/global_ids.zeek @@ -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); + } } }