Remove APIs that were explicitly deprecated to be removed in 3.1.

Special handling for bro_{init,done,script_loaded} events: if still
used, they cause Zeek to abort at startup.
This commit is contained in:
Robin Sommer 2020-01-27 11:43:07 +00:00
parent 84b8ee3b06
commit d0b206fa36
21 changed files with 29 additions and 273 deletions

@ -1 +1 @@
Subproject commit 6933b86e60f22f7a39ac1a8adbee4867902ce02e Subproject commit e166c066b64b196a7dc5de285c68e0977344acc9

View file

@ -1,2 +0,0 @@
## This file is deprecated in favor of to_json in zeek.bif
@deprecated="Remove in 3.1. to_json is now always available as a built-in function."

View file

@ -154,12 +154,6 @@ public:
return max_entries; return max_entries;
} }
ZEEK_DEPRECATED("Remove in v3.1: Use std::sort instead")
void sort(list_cmp_func cmp_func)
{
qsort(entries, num_entries, sizeof(T), cmp_func);
}
int MemoryAllocation() const int MemoryAllocation() const
{ return padded_sizeof(*this) + pad_size(max_entries * sizeof(T)); } { return padded_sizeof(*this) + pad_size(max_entries * sizeof(T)); }
@ -174,7 +168,7 @@ public:
++num_entries; ++num_entries;
entries[0] = a; entries[0] = a;
} }
void push_back(const T& a) void push_back(const T& a)
{ {
if ( num_entries == max_entries ) if ( num_entries == max_entries )
@ -182,19 +176,13 @@ public:
entries[num_entries++] = a; entries[num_entries++] = a;
} }
void pop_front() { remove_nth(0); } void pop_front() { remove_nth(0); }
void pop_back() { remove_nth(num_entries-1); } void pop_back() { remove_nth(num_entries-1); }
T& front() { return entries[0]; } T& front() { return entries[0]; }
T& back() { return entries[num_entries-1]; } T& back() { return entries[num_entries-1]; }
ZEEK_DEPRECATED("Remove in v3.1: Use push_front instead")
void insert(const T& a) // add at head of list
{
push_front(a);
}
// The append method is maintained for historical/compatibility reasons. // The append method is maintained for historical/compatibility reasons.
// (It's commonly used in the event generation API) // (It's commonly used in the event generation API)
void append(const T& a) // add to end of list void append(const T& a) // add to end of list
@ -229,16 +217,6 @@ public:
return old_ent; return old_ent;
} }
ZEEK_DEPRECATED("Remove in v3.1: Use back()/pop_back() instead")
T get() // return and remove ent at end of list
{
assert(num_entries > 0);
return entries[--num_entries];
}
ZEEK_DEPRECATED("Remove in v3.1: Use back() instead")
T& last() { return back(); }
// Return 0 if ent is not in the list, ent otherwise. // Return 0 if ent is not in the list, ent otherwise.
bool is_member(const T& a) const bool is_member(const T& a) const
{ {

View file

@ -719,16 +719,6 @@ void IntervalVal::ValDescribe(ODesc* d) const
} }
} }
PortVal* PortManager::Get(uint32_t port_num) const
{
return val_mgr->GetPort(port_num);
}
PortVal* PortManager::Get(uint32_t port_num, TransportProto port_type) const
{
return val_mgr->GetPort(port_num, port_type);
}
uint32_t PortVal::Mask(uint32_t port_num, TransportProto port_type) uint32_t PortVal::Mask(uint32_t port_num, TransportProto port_type)
{ {
// Note, for ICMP one-way connections: // Note, for ICMP one-way connections:
@ -760,25 +750,8 @@ uint32_t PortVal::Mask(uint32_t port_num, TransportProto port_type)
return port_num; return port_num;
} }
PortVal::PortVal(uint32_t p, TransportProto port_type) : Val(TYPE_PORT)
{
auto port_num = PortVal::Mask(p, port_type);
val.uint_val = static_cast<bro_uint_t>(port_num);
}
PortVal::PortVal(uint32_t p, bool unused) : Val(TYPE_PORT)
{
val.uint_val = static_cast<bro_uint_t>(p);
}
PortVal::PortVal(uint32_t p) : Val(TYPE_PORT) PortVal::PortVal(uint32_t p) : Val(TYPE_PORT)
{ {
if ( p >= 65536 * NUM_PORT_SPACES )
{
InternalWarning("bad port number");
p = 0;
}
val.uint_val = static_cast<bro_uint_t>(p); val.uint_val = static_cast<bro_uint_t>(p);
} }
@ -3220,7 +3193,7 @@ ValManager::ValManager()
auto port_type = (TransportProto)i; auto port_type = (TransportProto)i;
for ( auto j = 0u; j < arr.size(); ++j ) for ( auto j = 0u; j < arr.size(); ++j )
arr[j] = new PortVal(PortVal::Mask(j, port_type), true); arr[j] = new PortVal(PortVal::Mask(j, port_type));
} }
} }

View file

@ -85,56 +85,6 @@ typedef union {
class Val : public BroObj { class Val : public BroObj {
public: public:
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetBool, GetFalse/GetTrue, GetInt, or GetCount instead")
Val(bool b, TypeTag t)
{
val.int_val = b;
type = base_type(t);
#ifdef DEBUG
bound_id = 0;
#endif
}
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetBool, GetFalse/GetTrue, GetInt, or GetCount instead")
Val(int32_t i, TypeTag t)
{
val.int_val = bro_int_t(i);
type = base_type(t);
#ifdef DEBUG
bound_id = 0;
#endif
}
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetBool, GetFalse/GetTrue, GetInt, or GetCount instead")
Val(uint32_t u, TypeTag t)
{
val.uint_val = bro_uint_t(u);
type = base_type(t);
#ifdef DEBUG
bound_id = 0;
#endif
}
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetBool, GetFalse/GetTrue, GetInt, or GetCount instead")
Val(int64_t i, TypeTag t)
{
val.int_val = i;
type = base_type(t);
#ifdef DEBUG
bound_id = 0;
#endif
}
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetBool, GetFalse/GetTrue, GetInt, or GetCount instead")
Val(uint64_t u, TypeTag t)
{
val.uint_val = u;
type = base_type(t);
#ifdef DEBUG
bound_id = 0;
#endif
}
Val(double d, TypeTag t) Val(double d, TypeTag t)
{ {
val.double_val = d; val.double_val = d;
@ -429,23 +379,6 @@ protected:
}; };
class PortManager {
public:
// Port number given in host order.
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetPort() instead")
PortVal* Get(uint32_t port_num, TransportProto port_type) const;
// Host-order port number already masked with port space protocol mask.
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetPort() instead")
PortVal* Get(uint32_t port_num) const;
// Returns a masked port number
ZEEK_DEPRECATED("Remove in v3.1: use PortVal::Mask() instead")
uint32_t Mask(uint32_t port_num, TransportProto port_type) const;
};
extern PortManager* port_mgr;
// Holds pre-allocated Val objects for those where it's more optimal to // Holds pre-allocated Val objects for those where it's more optimal to
// re-use existing ones rather than allocate anew. // re-use existing ones rather than allocate anew.
class ValManager { class ValManager {
@ -521,14 +454,6 @@ protected:
class PortVal : public Val { class PortVal : public Val {
public: public:
// Port number given in host order.
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetPort() instead")
PortVal(uint32_t p, TransportProto port_type);
// Host-order port number already masked with port space protocol mask.
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetPort() instead")
explicit PortVal(uint32_t p);
Val* SizeVal() const override { return val_mgr->GetInt(val.uint_val); } Val* SizeVal() const override { return val_mgr->GetInt(val.uint_val); }
// Returns the port number in host order (not including the mask). // Returns the port number in host order (not including the mask).
@ -559,7 +484,7 @@ protected:
friend class Val; friend class Val;
friend class ValManager; friend class ValManager;
PortVal() {} PortVal() {}
PortVal(uint32_t p, bool unused); PortVal(uint32_t p);
void ValDescribe(ODesc* d) const override; void ValDescribe(ODesc* d) const override;
Val* DoClone(CloneState* state) override; Val* DoClone(CloneState* state) override;
@ -1007,13 +932,6 @@ protected:
class EnumVal : public Val { class EnumVal : public Val {
public: public:
ZEEK_DEPRECATED("Remove in v3.1: use t->GetVal(i) instead")
EnumVal(int i, EnumType* t) : Val(t)
{
val.int_val = i;
}
Val* SizeVal() const override { return val_mgr->GetInt(val.int_val); } Val* SizeVal() const override { return val_mgr->GetInt(val.int_val); }
protected: protected:

View file

@ -1,8 +1,3 @@
## Generated for RFB event
##
## c: The connection record for the underlying transport-layer session/flow.
event rfb_event%(c: connection%) &deprecated="Remove in v3.1: This event never served a real purpose and will be removed. Please use the other rfb events instead.";
## Generated for RFB event authentication mechanism selection ## Generated for RFB event authentication mechanism selection
## ##
## c: The connection record for the underlying transport-layer session/flow. ## c: The connection record for the underlying transport-layer session/flow.

View file

@ -1,11 +1,4 @@
refine flow RFB_Flow += { refine flow RFB_Flow += {
function proc_rfb_message(msg: RFB_PDU): bool
%{
if ( rfb_event )
BifEvent::generate_rfb_event(connection()->bro_analyzer(), connection()->bro_analyzer()->Conn());
return true;
%}
function proc_rfb_version(client: bool, major: bytestring, minor: bytestring) : bool function proc_rfb_version(client: bool, major: bytestring, minor: bytestring) : bool
%{ %{
if (client) if (client)
@ -371,7 +364,3 @@ refine connection RFB_Conn += {
return true; return true;
%} %}
}; };
refine typeattr RFB_PDU += &let {
proc: bool = $context.flow.proc_rfb_message(this);
};

View file

@ -48,9 +48,6 @@
## ##
event zeek_init%(%); event zeek_init%(%);
## Deprecated synonym for :zeek:see:`zeek_init`.
event bro_init%(%) &deprecated="Remove in v3.1: use zeek_init";
## Generated at Zeek termination time. The event engine generates this event when ## Generated at Zeek termination time. The event engine generates this event when
## Zeek is about to terminate, either due to having exhausted reading its input ## Zeek is about to terminate, either due to having exhausted reading its input
## trace file(s), receiving a termination signal, or because Zeek was run without ## trace file(s), receiving a termination signal, or because Zeek was run without
@ -64,9 +61,6 @@ event bro_init%(%) &deprecated="Remove in v3.1: use zeek_init";
## is not generated. ## is not generated.
event zeek_done%(%); event zeek_done%(%);
## Deprecated synonym for :zeek:see:`zeek_done`.
event bro_done%(%) &deprecated="Remove in v3.1: use zeek_done";
## Generated for every new connection. This event is raised with the first ## Generated for every new connection. This event is raised with the first
## packet of a previously unknown connection. Zeek uses a flow-based definition ## packet of a previously unknown connection. Zeek uses a flow-based definition
## of "connection" here that includes not only TCP sessions but also UDP and ## of "connection" here that includes not only TCP sessions but also UDP and
@ -666,9 +660,6 @@ event reporter_error%(t: time, msg: string, location: string%) &error_handler;
## recursively for each ``@load``. ## recursively for each ``@load``.
event zeek_script_loaded%(path: string, level: count%); event zeek_script_loaded%(path: string, level: count%);
## Deprecated synonym for :zeek:see:`zeek_script_loaded`.
event bro_script_loaded%(path: string, level: count%) &deprecated="Remove in v3.1: use zeek_script_loaded";
## Generated each time Zeek's script interpreter opens a file. This event is ## Generated each time Zeek's script interpreter opens a file. This event is
## triggered only for files opened via :zeek:id:`open`, and in particular not for ## triggered only for files opened via :zeek:id:`open`, and in particular not for
## normal log files as created by log writers. ## normal log files as created by log writers.

View file

@ -84,7 +84,6 @@ int perftools_profile = 0;
DNS_Mgr* dns_mgr; DNS_Mgr* dns_mgr;
TimerMgr* timer_mgr; TimerMgr* timer_mgr;
ValManager* val_mgr = 0; ValManager* val_mgr = 0;
PortManager* port_mgr = 0;
logging::Manager* log_mgr = 0; logging::Manager* log_mgr = 0;
threading::Manager* thread_mgr = 0; threading::Manager* thread_mgr = 0;
input::Manager* input_mgr = 0; input::Manager* input_mgr = 0;
@ -364,7 +363,6 @@ void terminate_bro()
delete reporter; delete reporter;
delete plugin_mgr; delete plugin_mgr;
delete val_mgr; delete val_mgr;
delete port_mgr;
reporter = 0; reporter = 0;
} }
@ -735,7 +733,6 @@ int main(int argc, char** argv)
bro_start_time = current_time(true); bro_start_time = current_time(true);
val_mgr = new ValManager(); val_mgr = new ValManager();
port_mgr = new PortManager();
reporter = new Reporter(); reporter = new Reporter();
thread_mgr = new threading::Manager(); thread_mgr = new threading::Manager();
plugin_mgr = new plugin::Manager(); plugin_mgr = new plugin::Manager();

View file

@ -1164,14 +1164,12 @@ func_hdr:
} }
| TOK_EVENT event_id func_params opt_attr | TOK_EVENT event_id func_params opt_attr
{ {
// Gracefully handle the deprecation of bro_init, bro_done, const char* name = $2->Name();
// and bro_script_loaded if ( streq("bro_init", name) || streq("bro_done", name) || streq("bro_script_loaded", name) )
if ( streq("bro_init", $2->Name()) ) {
$2 = global_scope()->Lookup("zeek_init"); auto base = std::string(name).substr(4);
else if ( streq("bro_done", $2->Name()) ) reporter->Error(fmt("event %s() is no longer available, use zeek_%s() instead", name, base.c_str()));
$2 = global_scope()->Lookup("zeek_done"); }
else if ( streq("bro_script_loaded", $2->Name()) )
$2 = global_scope()->Lookup("zeek_script_loaded");
begin_func($2, current_module.c_str(), begin_func($2, current_module.c_str(),
FUNC_FLAVOR_EVENT, 0, $3, $4); FUNC_FLAVOR_EVENT, 0, $3, $4);

View file

@ -935,47 +935,6 @@ function safe_shell_quote%(source: string%): string
return new StringVal(new BroString(1, dst, j)); return new StringVal(new BroString(1, dst, j));
%} %}
## Takes a string and escapes characters that would allow execution of
## commands at the shell level. Must be used before including strings in
## :zeek:id:`system` or similar calls. This function is deprecated, use
## :zeek:see:`safe_shell_quote` as a replacement. The difference is that
## :zeek:see:`safe_shell_quote` automatically returns a value that is
## wrapped in double-quotes, which is required to correctly and fully
## escape any characters that might be interpreted by the shell.
##
## source: The string to escape.
##
## Returns: A shell-escaped version of *source*.
##
## .. zeek:see:: system safe_shell_quote
function str_shell_escape%(source: string%): string &deprecated="Remove in v3.1: use safe_shell_quote"
%{
unsigned j = 0;
const u_char* src = source->Bytes();
unsigned n = source->Len();
byte_vec dst = new u_char[n * 2 + 1];
for ( unsigned i = 0; i < n; ++i )
{
switch ( src[i] ) {
case '`': case '"': case '\\': case '$':
// case '|': case '&': case ';': case '(': case ')': case '<':
// case '>': case '\'': case '*': case '?': case '[': case ']':
// case '!': case '#': case '{': case '}':
dst[j++] = '\\';
break;
default:
break;
}
dst[j++] = src[i];
}
dst[j] = '\0';
return new StringVal(new BroString(1, dst, j));
%}
## Finds all occurrences of a pattern in a string. ## Finds all occurrences of a pattern in a string.
## ##
## str: The string to inspect. ## str: The string to inspect.

View file

@ -1820,15 +1820,6 @@ function getpid%(%) : count
extern const char* zeek_version(); extern const char* zeek_version();
%%} %%}
## Returns the Zeek version string. This function is deprecated, use
## :zeek:see:`zeek_version` instead.
##
## Returns: Zeek's version, e.g., 2.0-beta-47-debug.
function bro_version%(%): string &deprecated="Remove in v3.1: use zeek_version"
%{
return new StringVal(zeek_version());
%}
## Returns the Zeek version string. ## Returns the Zeek version string.
## ##
## Returns: Zeek's version, e.g., 2.0-beta-47-debug. ## Returns: Zeek's version, e.g., 2.0-beta-47-debug.
@ -2130,17 +2121,6 @@ function dump_rule_stats%(f: file%): bool
return val_mgr->GetBool(1); return val_mgr->GetBool(1);
%} %}
## Checks if Zeek is terminating. This function is deprecated, use
## :zeek:see:`zeek_is_terminating` instead.
##
## Returns: True if Zeek is in the process of shutting down.
##
## .. zeek:see:: terminate
function bro_is_terminating%(%): bool &deprecated="Remove in v3.1: use zeek_is_terminating"
%{
return val_mgr->GetBool(terminating);
%}
## Checks if Zeek is terminating. ## Checks if Zeek is terminating.
## ##
## Returns: True if Zeek is in the process of shutting down. ## Returns: True if Zeek is in the process of shutting down.

View file

@ -1,4 +0,0 @@
24
echo ${TEST} > "my file"
27
echo \${TEST} > \"my file\"

View file

@ -1 +0,0 @@
warning in /Users/tim/Desktop/projects/zeek/testing/btest/../../scripts//base/utils/json.zeek, line 2: deprecated script loaded from command line arguments ="Remove in 3.1. to_json is now always available as a built-in function."

View file

@ -8,4 +8,3 @@
-./frameworks/openflow/cluster.zeek -./frameworks/openflow/cluster.zeek
-./frameworks/packet-filter/cluster.zeek -./frameworks/packet-filter/cluster.zeek
-./frameworks/sumstats/cluster.zeek -./frameworks/sumstats/cluster.zeek
-./utils/json.zeek

View file

@ -1,8 +1,4 @@
zeek_init at priority 10! error in /home/robin/bro/master/testing/btest/.tmp/language.zeek_init/zeek_init.zeek, line 10: event bro_init() is no longer available, use zeek_init() instead
bro_init at priority 5! error in /home/robin/bro/master/testing/btest/.tmp/language.zeek_init/zeek_init.zeek, line 20: event bro_init() is no longer available, use zeek_init() instead
zeek_init at priority 0! error in /home/robin/bro/master/testing/btest/.tmp/language.zeek_init/zeek_init.zeek, line 31: event bro_done() is no longer available, use zeek_done() instead
bro_init at priority -10! error in /home/robin/bro/master/testing/btest/.tmp/language.zeek_init/zeek_init.zeek, line 41: event bro_done() is no longer available, use zeek_done() instead
zeek_done at priority 10!
bro_done at priority 5!
zeek_done at priority 0!
bro_done at priority -10!

View file

@ -1,4 +1,2 @@
zeek_script_loaded priority 10 error in /home/robin/bro/master/testing/btest/.tmp/language.zeek_script_loaded/zeek_script_loaded.zeek, line 11: event bro_script_loaded() is no longer available, use zeek_script_loaded() instead
bro_script_loaded priority 5 error in /home/robin/bro/master/testing/btest/.tmp/language.zeek_script_loaded/zeek_script_loaded.zeek, line 23: event bro_script_loaded() is no longer available, use zeek_script_loaded() instead
zeek_script_loaded priority 0
bro_script_loaded priority -10

View file

@ -1,15 +0,0 @@
#
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
event zeek_init()
{
local a = "echo ${TEST} > \"my file\"";
print |a|;
print a;
local b = str_shell_escape(a);
print |b|;
print b;
}

8
testing/btest/failed Normal file
View file

@ -0,0 +1,8 @@
bifs.str_shell_escape
core.load-explicit-bro-suffix-fallback
coverage.init-default
language.zeek_init
language.zeek_script_loaded
plugins.legacy
coverage.sphinx-zeekygen-docs
coverage.bare-mode-errors

View file

@ -1,6 +1,5 @@
# @TEST-EXEC: zeek -b %INPUT >out # @TEST-EXEC-FAIL: zeek -b %INPUT >out 2>&1
# @TEST-EXEC: btest-diff out # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
event zeek_init() &priority=10 event zeek_init() &priority=10
{ {

View file

@ -1,5 +1,5 @@
# @TEST-EXEC: zeek -b %INPUT >out # @TEST-EXEC-FAIL: zeek -b %INPUT >out 2>&1
# @TEST-EXEC: btest-diff out # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
event zeek_script_loaded(path: string, level: count) &priority=10 event zeek_script_loaded(path: string, level: count) &priority=10
{ {