mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Make old comm. system usages an error unless old_comm_usage_is_ok is set
This commit is contained in:
parent
3c6afc8409
commit
c11039cb73
9 changed files with 114 additions and 1 deletions
5
CHANGES
5
CHANGES
|
@ -1,4 +1,9 @@
|
||||||
|
|
||||||
|
2.5-668 | 2018-06-15 17:14:33 -0500
|
||||||
|
|
||||||
|
* Make old comm. system usages an error unless old_comm_usage_is_ok is set
|
||||||
|
(Corelight)
|
||||||
|
|
||||||
2.5-667 | 2018-06-15 15:30:11 -0500
|
2.5-667 | 2018-06-15 15:30:11 -0500
|
||||||
|
|
||||||
* Add --disable-broker-tests configure option (Corelight)
|
* Add --disable-broker-tests configure option (Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.5-667
|
2.5-668
|
||||||
|
|
|
@ -50,6 +50,13 @@ General Porting Tips
|
||||||
- The ``&synchronized`` and ``&persistent`` attributes are deprecated,
|
- The ``&synchronized`` and ``&persistent`` attributes are deprecated,
|
||||||
consider using `Data Stores`_ instead.
|
consider using `Data Stores`_ instead.
|
||||||
|
|
||||||
|
- Usages of the old communications system features are all deprecated,
|
||||||
|
however, they also do not work in the default Bro configuration unless
|
||||||
|
you manually take action to set up the old communication system.
|
||||||
|
To aid in porting, such usages will default to raising a fatal error
|
||||||
|
unless you explicitly acknowledge that such usages of the old system
|
||||||
|
are ok. Set the :bro:see:`old_comm_usage_is_ok`` flag in this case.
|
||||||
|
|
||||||
- Instead of using e.g. ``Cluster::manager2worker_events`` (and all
|
- Instead of using e.g. ``Cluster::manager2worker_events`` (and all
|
||||||
permutations for every node type), what you'd now use is either
|
permutations for every node type), what you'd now use is either
|
||||||
:bro:see:`Broker::publish` or :bro:see:`Broker::auto_publish` with
|
:bro:see:`Broker::publish` or :bro:see:`Broker::auto_publish` with
|
||||||
|
|
|
@ -4834,3 +4834,10 @@ const global_hash_seed: string = "" &redef;
|
||||||
## files. The larger the value, the more confidence in UID uniqueness.
|
## files. The larger the value, the more confidence in UID uniqueness.
|
||||||
## The maximum is currently 128 bits.
|
## The maximum is currently 128 bits.
|
||||||
const bits_per_uid: count = 96 &redef;
|
const bits_per_uid: count = 96 &redef;
|
||||||
|
|
||||||
|
## Whether usage of the old communication system is considered an error or
|
||||||
|
## not. The default Bro configuration no longer works with the non-Broker
|
||||||
|
## communication system unless you have manually taken action to initialize
|
||||||
|
## and set up the old comm. system. Deprecation warnings are still emitted
|
||||||
|
## when setting this flag, but they will not result in a fatal error.
|
||||||
|
const old_comm_usage_is_ok: bool = F &redef;
|
||||||
|
|
|
@ -83,6 +83,8 @@ extern iosource::PktDumper* pkt_dumper; // where to save packets
|
||||||
|
|
||||||
extern char* writefile;
|
extern char* writefile;
|
||||||
|
|
||||||
|
extern int old_comm_usage_count;
|
||||||
|
|
||||||
// Script file we have already scanned (or are in the process of scanning).
|
// Script file we have already scanned (or are in the process of scanning).
|
||||||
// They are identified by inode number.
|
// They are identified by inode number.
|
||||||
struct ScannedFile {
|
struct ScannedFile {
|
||||||
|
|
82
src/main.cc
82
src/main.cc
|
@ -44,6 +44,7 @@ extern "C" {
|
||||||
#include "EventRegistry.h"
|
#include "EventRegistry.h"
|
||||||
#include "Stats.h"
|
#include "Stats.h"
|
||||||
#include "Brofiler.h"
|
#include "Brofiler.h"
|
||||||
|
#include "Traverse.h"
|
||||||
|
|
||||||
#include "threading/Manager.h"
|
#include "threading/Manager.h"
|
||||||
#include "input/Manager.h"
|
#include "input/Manager.h"
|
||||||
|
@ -114,6 +115,7 @@ char* command_line_policy = 0;
|
||||||
vector<string> params;
|
vector<string> params;
|
||||||
set<string> requested_plugins;
|
set<string> requested_plugins;
|
||||||
char* proc_status_file = 0;
|
char* proc_status_file = 0;
|
||||||
|
int old_comm_usage_count = 0;
|
||||||
|
|
||||||
OpaqueType* md5_type = 0;
|
OpaqueType* md5_type = 0;
|
||||||
OpaqueType* sha1_type = 0;
|
OpaqueType* sha1_type = 0;
|
||||||
|
@ -424,6 +426,70 @@ static void bro_new_handler()
|
||||||
out_of_memory("new");
|
out_of_memory("new");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static auto old_comm_ids = std::set<const char*, CompareString>{
|
||||||
|
"connect",
|
||||||
|
"disconnect",
|
||||||
|
"request_remote_events",
|
||||||
|
"request_remote_sync",
|
||||||
|
"request_remote_logs",
|
||||||
|
"set_accept_state",
|
||||||
|
"set_compression_level",
|
||||||
|
"listen",
|
||||||
|
"send_id",
|
||||||
|
"terminate_communication",
|
||||||
|
"complete_handshake",
|
||||||
|
"send_ping",
|
||||||
|
"send_current_packet",
|
||||||
|
"get_event_peer",
|
||||||
|
"send_capture_filter",
|
||||||
|
"suspend_state_updates",
|
||||||
|
"resume_state_updates",
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool is_old_comm_usage(const ID* id)
|
||||||
|
{
|
||||||
|
auto name = id->Name();
|
||||||
|
|
||||||
|
if ( old_comm_ids.find(name) == old_comm_ids.end() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
class OldCommUsageTraversalCallback : public TraversalCallback {
|
||||||
|
public:
|
||||||
|
virtual TraversalCode PreExpr(const Expr* expr) override
|
||||||
|
{
|
||||||
|
switch ( expr->Tag() ) {
|
||||||
|
case EXPR_CALL:
|
||||||
|
{
|
||||||
|
const CallExpr* call = static_cast<const CallExpr*>(expr);
|
||||||
|
auto func = call->Func();
|
||||||
|
|
||||||
|
if ( func->Tag() == EXPR_NAME )
|
||||||
|
{
|
||||||
|
const NameExpr* ne = static_cast<const NameExpr*>(func);
|
||||||
|
auto id = ne->Id();
|
||||||
|
|
||||||
|
if ( is_old_comm_usage(id) )
|
||||||
|
++old_comm_usage_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TC_CONTINUE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void find_old_comm_usages()
|
||||||
|
{
|
||||||
|
OldCommUsageTraversalCallback cb;
|
||||||
|
traverse_all(&cb);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
std::set_new_handler(bro_new_handler);
|
std::set_new_handler(bro_new_handler);
|
||||||
|
@ -854,6 +920,22 @@ int main(int argc, char** argv)
|
||||||
yyparse();
|
yyparse();
|
||||||
is_parsing = false;
|
is_parsing = false;
|
||||||
|
|
||||||
|
find_old_comm_usages();
|
||||||
|
|
||||||
|
if ( old_comm_usage_count )
|
||||||
|
{
|
||||||
|
auto old_comm_ack_id = global_scope()->Lookup("old_comm_usage_is_ok");
|
||||||
|
|
||||||
|
if ( ! old_comm_ack_id->ID_Val()->AsBool() )
|
||||||
|
reporter->FatalError("Detected old, deprecated communication "
|
||||||
|
"system usages that will not work unless "
|
||||||
|
"you explicitly take action to initizialize "
|
||||||
|
"and set up the old comm. system. "
|
||||||
|
"Set the 'old_comm_usage_is_ok' flag "
|
||||||
|
"to bypass this error if you've taken such "
|
||||||
|
"actions.");
|
||||||
|
}
|
||||||
|
|
||||||
RecordVal::ResizeParseTimeRecords();
|
RecordVal::ResizeParseTimeRecords();
|
||||||
|
|
||||||
init_general_global_var();
|
init_general_global_var();
|
||||||
|
|
|
@ -310,6 +310,7 @@ when return TOK_WHEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
&synchronized {
|
&synchronized {
|
||||||
|
++old_comm_usage_count;
|
||||||
deprecated_attr(yytext);
|
deprecated_attr(yytext);
|
||||||
return TOK_ATTR_SYNCHRONIZED;
|
return TOK_ATTR_SYNCHRONIZED;
|
||||||
}
|
}
|
||||||
|
|
2
testing/btest/Baseline/core.old_comm_usage/out
Normal file
2
testing/btest/Baseline/core.old_comm_usage/out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
warning in /Users/jon/projects/bro/bro/testing/btest/.tmp/core.old_comm_usage/old_comm_usage.bro, line 6: deprecated (terminate_communication)
|
||||||
|
fatal error: Detected old, deprecated communication system usages that will not work unless you explicitly take action to initizialize and set up the old comm. system. Set the 'old_comm_usage_is_ok' flag to bypass this error if you've taken such actions.
|
7
testing/btest/core/old_comm_usage.bro
Normal file
7
testing/btest/core/old_comm_usage.bro
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# @TEST-EXEC-FAIL: bro -b %INPUT >out 2>&1
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
|
|
||||||
|
event bro_init()
|
||||||
|
{
|
||||||
|
terminate_communication();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue