zeek/testing/btest/doc/zeekygen/declaring_script_enum.zeek
Arne Welzel ef166649bf zeekygen: Add BIFs to access declaring scripts
Two new BIFs get_identifier_declaring_script() and get_record_field_declaring_script()
mirroring existing functions for comments. This allows to query the declaring
script information from Zeek scripts and further determine if a redef operations
were involved for record fields or enum names by comparing the declaring script
with the one of the involved type. See the tests.

Yet another one of @stevesmoot's requests.
2022-11-22 13:23:01 +01:00

25 lines
720 B
Text

# @TEST-DOC: Test zeekygen declaring script function for enum names;
#
# @TEST-EXEC: unset ZEEK_DISABLE_ZEEKYGEN; zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
@load base/protocols/conn
@load base/protocols/ftp
@load base/protocols/http
# Avoid the noise from reporter, broker, ...
global only: set[Log::ID] = [Log::UNKNOWN, HTTP::LOG, FTP::LOG, Conn::LOG];
event zeek_init()
{
local log_id_script = get_identifier_declaring_script("Log::ID");
print "Log::ID", log_id_script;
for ( name in enum_names("Log::ID") )
{
if ( lookup_ID(name) !in only )
next;
local enum_script = get_identifier_declaring_script(name);
print name, log_id_script != enum_script ? "redef" : "original", enum_script;
}
}