diff --git a/CHANGES b/CHANGES index 3ef88e415a..2f27a53b46 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,14 @@ +2.6-377 | 2019-06-05 16:15:58 -0700 + + * Deprecate functions with "bro" in them. (Jon Siwek, Corelight) + + * "bro_is_terminating" is now "zeek_is_terminating" + + * "bro_version" is now "zeek_version" + + The old functions still exist for now, but are deprecated. + 2.6-376 | 2019-06-05 13:29:57 -0700 * GH-379: move catch-and-release and unified2 scripts to policy/ (Jon Siwek, Corelight) diff --git a/NEWS b/NEWS index 72752817eb..c1e634f0f8 100644 --- a/NEWS +++ b/NEWS @@ -361,6 +361,9 @@ Deprecated Functionality such that existing code will not break, but will emit a deprecation warning. +- The ``bro_is_terminating`` and ``bro_version`` function are deprecated and + replaced by functions named ``zeek_is_terminating`` and ``zeek_version``. + - The ``rotate_file``, ``rotate_file_by_name`` and ``calc_next_rotate`` functions were marked as deprecated. These functions were used with the old pre-2.0 logging framework and are no longer used. They also were marked as deprecated in their diff --git a/VERSION b/VERSION index 8e8d4265a7..8bf897ac13 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6-376 +2.6-377 diff --git a/doc b/doc index 09d21c86c3..69a337c5c7 160000 --- a/doc +++ b/doc @@ -1 +1 @@ -Subproject commit 09d21c86c3f68b1fde426fe93d0b044ca839b968 +Subproject commit 69a337c5c7958014566f138bfbce9ce95db47b3d diff --git a/scripts/base/frameworks/netcontrol/main.zeek b/scripts/base/frameworks/netcontrol/main.zeek index dae23072d6..f22d1eb06c 100644 --- a/scripts/base/frameworks/netcontrol/main.zeek +++ b/scripts/base/frameworks/netcontrol/main.zeek @@ -889,7 +889,7 @@ function remove_rule_impl(id: string, reason: string) : bool function rule_expire_impl(r: Rule, p: PluginState) &priority=-5 { # do not emit timeout events on shutdown - if ( bro_is_terminating() ) + if ( zeek_is_terminating() ) return; if ( r$id !in rules ) diff --git a/scripts/base/frameworks/notice/main.zeek b/scripts/base/frameworks/notice/main.zeek index 67d2920106..ab4288de1a 100644 --- a/scripts/base/frameworks/notice/main.zeek +++ b/scripts/base/frameworks/notice/main.zeek @@ -405,7 +405,7 @@ function email_headers(subject_desc: string, dest: string): string "From: ", mail_from, "\n", "Subject: ", mail_subject_prefix, " ", subject_desc, "\n", "To: ", dest, "\n", - "User-Agent: Bro-IDS/", bro_version(), "\n"); + "User-Agent: Bro-IDS/", zeek_version(), "\n"); if ( reply_to != "" ) header_text = string_cat(header_text, "Reply-To: ", reply_to, "\n"); return header_text; diff --git a/scripts/base/frameworks/openflow/consts.zeek b/scripts/base/frameworks/openflow/consts.zeek index 7b1e635014..ea6a5e5eec 100644 --- a/scripts/base/frameworks/openflow/consts.zeek +++ b/scripts/base/frameworks/openflow/consts.zeek @@ -11,7 +11,7 @@ const COOKIE_BID_SIZE = 16777216; # start at bit 40 (1 << 40) const COOKIE_BID_START = 1099511627776; # Zeek specific cookie ID shall have the 42 bit set (1 << 42) -const BRO_COOKIE_ID = 4; +const ZEEK_COOKIE_ID = 4; # 8 bits group identifier const COOKIE_GID_SIZE = 256; # start at bit 32 (1 << 32) diff --git a/scripts/base/frameworks/openflow/main.zeek b/scripts/base/frameworks/openflow/main.zeek index 09e9ba0f68..9649000b21 100644 --- a/scripts/base/frameworks/openflow/main.zeek +++ b/scripts/base/frameworks/openflow/main.zeek @@ -198,7 +198,7 @@ function match_conn(id: conn_id, reverse: bool &default=F): ofp_match # 42 bit of the cookie set. function generate_cookie(cookie: count &default=0): count { - local c = BRO_COOKIE_ID * COOKIE_BID_START; + local c = ZEEK_COOKIE_ID * COOKIE_BID_START; if ( cookie >= COOKIE_UID_SIZE ) Reporter::warning(fmt("The given cookie uid '%d' is > 32bit and will be discarded", cookie)); @@ -211,7 +211,7 @@ function generate_cookie(cookie: count &default=0): count # local function to check if a given flow_mod cookie is forged from this framework. function is_valid_cookie(cookie: count): bool { - if ( cookie / COOKIE_BID_START == BRO_COOKIE_ID ) + if ( cookie / COOKIE_BID_START == ZEEK_COOKIE_ID ) return T; Reporter::warning(fmt("The given Openflow cookie '%d' is not valid", cookie)); @@ -231,7 +231,7 @@ function get_cookie_gid(cookie: count): count { if( is_valid_cookie(cookie) ) return ( - (cookie - (COOKIE_BID_START * BRO_COOKIE_ID) - + (cookie - (COOKIE_BID_START * ZEEK_COOKIE_ID) - (cookie - ((cookie / COOKIE_GID_START) * COOKIE_GID_START))) / COOKIE_GID_START ); diff --git a/scripts/base/frameworks/openflow/types.zeek b/scripts/base/frameworks/openflow/types.zeek index ef57b25e2e..e208775549 100644 --- a/scripts/base/frameworks/openflow/types.zeek +++ b/scripts/base/frameworks/openflow/types.zeek @@ -89,7 +89,7 @@ export { ## Opaque controller-issued identifier. # This is optional in the specification - but let's force # it so we always can identify our flows... - cookie: count; # &default=BRO_COOKIE_ID * COOKIE_BID_START; + cookie: count; # &default=ZEEK_COOKIE_ID * COOKIE_BID_START; # Flow actions ## Table to put the flow in. OFPTT_ALL can be used for delete, ## to delete flows from all matching tables. diff --git a/scripts/base/frameworks/sumstats/non-cluster.zeek b/scripts/base/frameworks/sumstats/non-cluster.zeek index b4292431c5..630f36bbcd 100644 --- a/scripts/base/frameworks/sumstats/non-cluster.zeek +++ b/scripts/base/frameworks/sumstats/non-cluster.zeek @@ -35,7 +35,7 @@ event SumStats::finish_epoch(ss: SumStat) { local data = result_store[ss$name]; local now = network_time(); - if ( bro_is_terminating() ) + if ( zeek_is_terminating() ) { for ( key, val in data ) ss$epoch_result(now, key, val); diff --git a/scripts/base/misc/version.zeek b/scripts/base/misc/version.zeek index 1a453487b2..4d0894c49e 100644 --- a/scripts/base/misc/version.zeek +++ b/scripts/base/misc/version.zeek @@ -78,10 +78,10 @@ export { ## The format of the number is ABBCC with A being the major version, ## bb being the minor version (2 digits) and CC being the patchlevel (2 digits). ## As an example, Zeek 2.4.1 results in the number 20401 - const number = Version::parse(bro_version())$version_number; + const number = Version::parse(zeek_version())$version_number; ## `VersionDescription` record pertaining to the currently running version of Zeek. - const info = Version::parse(bro_version()); + const info = Version::parse(zeek_version()); } function at_least(version_string: string): bool diff --git a/scripts/base/protocols/dhcp/main.zeek b/scripts/base/protocols/dhcp/main.zeek index f72283a503..3ba83ffae7 100644 --- a/scripts/base/protocols/dhcp/main.zeek +++ b/scripts/base/protocols/dhcp/main.zeek @@ -141,7 +141,7 @@ function join_data_expiration(t: table[count] of Info, idx: count): interval # Also, if Zeek is shutting down. if ( (now - info$last_message_ts) > 5sec || (now - info$ts) > max_txid_watch_time || - bro_is_terminating() ) + zeek_is_terminating() ) { Log::write(LOG, info); diff --git a/scripts/policy/misc/stats.zeek b/scripts/policy/misc/stats.zeek index 8c59c30c30..df092ea064 100644 --- a/scripts/policy/misc/stats.zeek +++ b/scripts/policy/misc/stats.zeek @@ -99,7 +99,7 @@ event check_stats(then: time, last_ns: NetStats, last_cs: ConnStats, last_ps: Pr local fs = get_file_analysis_stats(); local ds = get_dns_stats(); - if ( bro_is_terminating() ) + if ( zeek_is_terminating() ) # No more stats will be written or scheduled when Zeek is # shutting down. return; diff --git a/scripts/policy/misc/trim-trace-file.zeek b/scripts/policy/misc/trim-trace-file.zeek index 3f50406f3b..81f54e991f 100644 --- a/scripts/policy/misc/trim-trace-file.zeek +++ b/scripts/policy/misc/trim-trace-file.zeek @@ -17,7 +17,7 @@ export { event TrimTraceFile::go(first_trim: bool) { - if ( bro_is_terminating() || trace_output_file == "" ) + if ( zeek_is_terminating() || trace_output_file == "" ) return; if ( ! first_trim ) diff --git a/src/bro.bif b/src/bro.bif index 039053f4f2..038ca48862 100644 --- a/src/bro.bif +++ b/src/bro.bif @@ -1735,15 +1735,24 @@ function getpid%(%) : count %} %%{ -extern const char* bro_version(); +extern const char* zeek_version(); %%} -## Returns the Bro version string. +## Returns the Zeek version string. This function is deprecated, use +## :zeek:see:`zeek_version` instead. ## -## Returns: Bro's version, e.g., 2.0-beta-47-debug. -function bro_version%(%): string +## Returns: Zeek's version, e.g., 2.0-beta-47-debug. +function bro_version%(%): string &deprecated %{ - return new StringVal(bro_version()); + return new StringVal(zeek_version()); + %} + +## Returns the Zeek version string. +## +## Returns: Zeek's version, e.g., 2.0-beta-47-debug. +function zeek_version%(%): string + %{ + return new StringVal(zeek_version()); %} ## Converts a record type name to a vector of strings, where each element is @@ -2068,12 +2077,23 @@ function dump_rule_stats%(f: file%): bool return val_mgr->GetBool(1); %} -## Checks if Bro is terminating. +## Checks if Zeek is terminating. This function is deprecated, use +## :zeek:see:`zeek_is_terminating` instead. ## -## Returns: True if Bro is in the process of shutting down. +## Returns: True if Zeek is in the process of shutting down. ## ## .. zeek:see:: terminate -function bro_is_terminating%(%): bool +function bro_is_terminating%(%): bool &deprecated + %{ + return val_mgr->GetBool(terminating); + %} + +## Checks if Zeek is terminating. +## +## Returns: True if Zeek is in the process of shutting down. +## +## .. zeek:see:: terminate +function zeek_is_terminating%(%): bool %{ return val_mgr->GetBool(terminating); %} diff --git a/src/main.cc b/src/main.cc index 10026eea7e..90d7ebd6b4 100644 --- a/src/main.cc +++ b/src/main.cc @@ -127,7 +127,7 @@ OpaqueType* ocsp_resp_opaque_type = 0; int bro_argc; char** bro_argv; -const char* bro_version() +const char* zeek_version() { #ifdef DEBUG static char* debug_version = 0; @@ -152,7 +152,7 @@ bool bro_dns_fake() void usage(int code = 1) { - fprintf(stderr, "bro version %s\n", bro_version()); + fprintf(stderr, "zeek version %s\n", zeek_version()); fprintf(stderr, "usage: %s [options] [file ...]\n", prog); fprintf(stderr, " | policy file, or read stdin\n"); fprintf(stderr, " -a|--parse-only | exit immediately after parsing scripts\n"); @@ -569,7 +569,7 @@ int main(int argc, char** argv) break; case 'v': - fprintf(stdout, "%s version %s\n", prog, bro_version()); + fprintf(stdout, "%s version %s\n", prog, zeek_version()); exit(0); break; diff --git a/src/plugin/Plugin.h b/src/plugin/Plugin.h index 4ce2a87dc0..66a9b90376 100644 --- a/src/plugin/Plugin.h +++ b/src/plugin/Plugin.h @@ -69,7 +69,7 @@ extern const char* hook_name(HookType h); struct VersionNumber { int major; //< Major version number. int minor; //< Minor version number. - int patch; //< Patch version number (available since Bro 2.7). + int patch; //< Patch version number (available since Zeek 3.0). /** * Constructor. diff --git a/testing/btest/bifs/bro_version.zeek b/testing/btest/bifs/zeek_version.zeek similarity index 75% rename from testing/btest/bifs/bro_version.zeek rename to testing/btest/bifs/zeek_version.zeek index 84d485a292..fd96d31676 100644 --- a/testing/btest/bifs/bro_version.zeek +++ b/testing/btest/bifs/zeek_version.zeek @@ -3,7 +3,7 @@ event zeek_init() { - local a = bro_version(); + local a = zeek_version(); if ( |a| == 0 ) exit(1); } diff --git a/testing/btest/scripts/base/misc/version.zeek b/testing/btest/scripts/base/misc/version.zeek index 9826c69d58..c6723f4e54 100644 --- a/testing/btest/scripts/base/misc/version.zeek +++ b/testing/btest/scripts/base/misc/version.zeek @@ -22,7 +22,7 @@ print Version::parse("1.12-beta-drunk"); print Version::parse("JustARandomString"); # check that current running version of Zeek parses without error -Version::parse(bro_version()); +Version::parse(zeek_version()); @TEST-START-NEXT