diff --git a/scripts/base/frameworks/signatures/main.bro b/scripts/base/frameworks/signatures/main.bro index 4102214075..7e2f71ea8c 100644 --- a/scripts/base/frameworks/signatures/main.bro +++ b/scripts/base/frameworks/signatures/main.bro @@ -161,7 +161,7 @@ event signature_match(state: signature_state, msg: string, data: string) return; # Trim the matched data down to something reasonable - if ( byte_len(data) > 140 ) + if ( |data| > 140 ) data = fmt("%s...", sub_bytes(data, 0, 140)); local src_addr: addr; @@ -259,8 +259,8 @@ event signature_match(state: signature_state, msg: string, data: string) add vert_table[orig, resp][sig_id]; - local hcount = length(horiz_table[orig, sig_id]); - local vcount = length(vert_table[orig, resp]); + local hcount = |horiz_table[orig, sig_id]|; + local vcount = |vert_table[orig, resp]|; if ( hcount in horiz_scan_thresholds && hcount != last_hthresh[orig] ) { diff --git a/scripts/base/utils/paths.bro b/scripts/base/utils/paths.bro index 92f0745be4..aa083ddf5b 100644 --- a/scripts/base/utils/paths.bro +++ b/scripts/base/utils/paths.bro @@ -27,7 +27,7 @@ function compress_path(dir: string): string const cdup_sep = /((\/)*([^\/]|\\\/)+)?((\/)+\.\.(\/)*)/; local parts = split_n(dir, cdup_sep, T, 1); - if ( length(parts) > 1 ) + if ( |parts| > 1 ) { # reaching a point with two parent dir references back-to-back means # we don't know about anything higher in the tree to pop off diff --git a/scripts/base/utils/strings.bro b/scripts/base/utils/strings.bro index 2836f368b4..560ba6d160 100644 --- a/scripts/base/utils/strings.bro +++ b/scripts/base/utils/strings.bro @@ -6,7 +6,7 @@ ## characters. function is_string_binary(s: string): bool { - return byte_len(gsub(s, /[\x00-\x7f]/, "")) * 100 / |s| >= 25; + return |gsub(s, /[\x00-\x7f]/, "")| * 100 / |s| >= 25; } ## Joins a set of string together, with elements delimited by a constant string. diff --git a/scripts/policy/protocols/http/detect-MHR.bro b/scripts/policy/protocols/http/detect-MHR.bro index 1898022978..0594276c93 100644 --- a/scripts/policy/protocols/http/detect-MHR.bro +++ b/scripts/policy/protocols/http/detect-MHR.bro @@ -32,7 +32,7 @@ event log_http(rec: HTTP::Info) { # Data is returned as " " local MHR_answer = split1(MHR_result, / /); - if ( length(MHR_answer) == 2 && to_count(MHR_answer[2]) >= MHR_threshold ) + if ( |MHR_answer| == 2 && to_count(MHR_answer[2]) >= MHR_threshold ) { local url = HTTP::build_url_http(rec); local message = fmt("%s %s %s", rec$id$orig_h, rec$md5, url); diff --git a/src/bro.bif b/src/bro.bif index 8cea9d9123..15c2e8da3f 100644 --- a/src/bro.bif +++ b/src/bro.bif @@ -1033,29 +1033,6 @@ function clear_table%(v: any%): any return 0; %} -## Returns the number of elements in a container. This function works with all -## container types, i.e., sets, tables, and vectors. -## -## v: The container whose elements are counted. -## -## Returns: The number of elements in *v*. -function length%(v: any%): count - %{ - TableVal* tv = v->Type()->Tag() == TYPE_TABLE ? v->AsTableVal() : 0; - - if ( tv ) - return new Val(tv->Size(), TYPE_COUNT); - - else if ( v->Type()->Tag() == TYPE_VECTOR ) - return new Val(v->AsVectorVal()->Size(), TYPE_COUNT); - - else - { - builtin_error("length() requires a table/set/vector argument"); - return new Val(0, TYPE_COUNT); - } - %} - ## Checks whether two objects reference the same internal object. This function ## uses equality comparison of C++ raw pointer values to determine if the two ## objects are the same. diff --git a/src/strings.bif b/src/strings.bif index dc5e064dc6..22f5429a8b 100644 --- a/src/strings.bif +++ b/src/strings.bif @@ -265,19 +265,6 @@ function edit%(arg_s: string, arg_edit_char: string%): string return new StringVal(new BroString(1, byte_vec(new_s), ind)); %} -## Returns the number of characters (bytes) in the given string. The -## length computation includes any embedded NULs, and also a trailing NUL, -## if any (which is why the function isn't called ``strlen``; to remind -## the user that Bro strings can include NULs). -## -## s: The string to compute the length for. -## -## Returns: The number of characters in *s*. -function byte_len%(s: string%): count - %{ - return new Val(s->Len(), TYPE_COUNT); - %} - ## Get a substring from a string, given a starting position and length. ## ## s: The string to obtain a substring from. diff --git a/testing/btest/bifs/byte_len.bro b/testing/btest/bifs/byte_len.bro deleted file mode 100644 index bd15b0c390..0000000000 --- a/testing/btest/bifs/byte_len.bro +++ /dev/null @@ -1,10 +0,0 @@ -# -# @TEST-EXEC: bro -b %INPUT >out -# @TEST-EXEC: btest-diff out - -event bro_init() - { - local a = "hello\0there"; - - print byte_len(a); - } diff --git a/testing/btest/bifs/length.bro b/testing/btest/bifs/length.bro deleted file mode 100644 index ca82d7eab7..0000000000 --- a/testing/btest/bifs/length.bro +++ /dev/null @@ -1,22 +0,0 @@ -# -# @TEST-EXEC: bro -b %INPUT > out -# @TEST-EXEC: btest-diff out - -event bro_init() - { - local mytable: table[string] of string = { ["key1"] = "val1" }; - local myset: set[count] = set( 3, 6, 2, 7 ); - local myvec: vector of string = vector( "value1", "value2" ); - - print length(mytable); - print length(myset); - print length(myvec); - - mytable = table(); - myset = set(); - myvec = vector(); - - print length(mytable); - print length(myset); - print length(myvec); - }