Merge remote-tracking branch 'origin/topic/timw/3969-broker-stores-at-global-scope'

* origin/topic/timw/3969-broker-stores-at-global-scope:
  Return a warning and fail if creating a store at global scope
This commit is contained in:
Tim Wojtulewicz 2024-12-17 12:15:42 -07:00
commit e4489616c6
5 changed files with 21 additions and 1 deletions

View file

@ -1,3 +1,7 @@
7.2.0-dev.13 | 2024-12-17 12:15:42 -0700
* Return a warning and fail if creating a store at global scope (Tim Wojtulewicz, Corelight)
7.2.0-dev.11 | 2024-12-16 12:37:25 -0700 7.2.0-dev.11 | 2024-12-16 12:37:25 -0700
* ZAM/relexpr-op NE for patterns (Vern Paxson, Corelight) * ZAM/relexpr-op NE for patterns (Vern Paxson, Corelight)

View file

@ -1 +1 @@
7.2.0-dev.11 7.2.0-dev.13

View file

@ -1582,6 +1582,13 @@ void Manager::ProcessStoreResponse(detail::StoreHandleVal* s, broker::store::res
} }
detail::StoreHandleVal* Manager::MakeMaster(const string& name, broker::backend type, broker::backend_options opts) { detail::StoreHandleVal* Manager::MakeMaster(const string& name, broker::backend type, broker::backend_options opts) {
if ( ! bstate ) {
if ( zeek::detail::current_scope() == zeek::detail::global_scope() )
reporter->Error("Broker stores cannot be created at the global scope");
return nullptr;
}
if ( bstate->endpoint.is_shutdown() ) if ( bstate->endpoint.is_shutdown() )
return nullptr; return nullptr;

View file

@ -0,0 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error in <...>/create-global-failure.zeek, line 5: Broker stores cannot be created at the global scope
error in <...>/create-global-failure.zeek, line 5: Could not create Broker master store 'store'

View file

@ -0,0 +1,6 @@
# @TEST-DOC: Tests that creating a broker store at global scope returns an error
# @TEST-EXEC-FAIL: zeek -b %INPUT >out 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
const x = Broker::create_master("store");
global t: table[string] of count &broker_store="store";