diff --git a/src/script_opt/CPP/InitsInfo.cc b/src/script_opt/CPP/InitsInfo.cc index b887eec1b4..b4c03bf541 100644 --- a/src/script_opt/CPP/InitsInfo.cc +++ b/src/script_opt/CPP/InitsInfo.cc @@ -47,7 +47,7 @@ void CPP_InitsInfo::GenerateInitializers(CPPCompile* c) { if ( ++n > 1 ) c->Emit(""); - if ( cohort.size() == 1 ) + if ( cohort.size() == 1 && ! IsCompound() ) BuildCohort(c, cohort); else { c->Emit("{"); diff --git a/src/script_opt/CPP/InitsInfo.h b/src/script_opt/CPP/InitsInfo.h index 57121817bc..cbdaaf806d 100644 --- a/src/script_opt/CPP/InitsInfo.h +++ b/src/script_opt/CPP/InitsInfo.h @@ -124,6 +124,11 @@ public: // Sets the associated C++ type. virtual void SetCPPType(std::string ct) { CPP_type = std::move(ct); } + // Whether this initializer is in terms of compound objects. Used + // for avoiding compiler warnings about singleton initializations in + // braces. + virtual bool IsCompound() const { return false; } + // Returns the type associated with the table used for initialization // (i.e., this is the type of the global returned by InitializersName()). std::string InitsType() const { return inits_type; } @@ -187,7 +192,8 @@ protected: // A class for a collection of initialization items for which each item // has a "custom" initializer (that is, a bespoke C++ object, rather than -// a simple C++ type or a vector of indices). +// a simple C++ type or a vector of indices). These are things like lambdas, +// global identifiers, or call expressions. class CPP_CustomInitsInfo : public CPP_InitsInfo { public: CPP_CustomInitsInfo(std::string _tag, std::string _type) : CPP_InitsInfo(std::move(_tag), std::move(_type)) { @@ -199,6 +205,8 @@ public: BuildInitType(); } + bool IsCompound() const override { return true; } + private: void BuildInitType() { inits_type = std::string("CPP_CustomInits<") + CPPType() + ">"; } }; @@ -219,6 +227,8 @@ public: inits_type = std::string("CPP_BasicConsts<") + CPP_type + ", " + c_type + ", " + tag + "Val>"; } + bool IsCompound() const override { return false; } + void BuildCohortElement(CPPCompile* c, std::string init_type, std::vector& ivs) override; }; @@ -235,6 +245,8 @@ public: inits_type = std::string("CPP_IndexedInits<") + CPPType() + ">"; } + bool IsCompound() const override { return true; } + void BuildCohortElement(CPPCompile* c, std::string init_type, std::vector& ivs) override; }; diff --git a/src/script_opt/ZAM/ZInst.h b/src/script_opt/ZAM/ZInst.h index 11dccade13..0ff812a035 100644 --- a/src/script_opt/ZAM/ZInst.h +++ b/src/script_opt/ZAM/ZInst.h @@ -313,7 +313,7 @@ public: void SetInt(int _i) { i = _i; } void SetInt(int _i, TypePtr _t) { i = _i; - SetType(_t); + SetType(std::move(_t)); } void SetSlot(int slot) { i = slot; } void SetConstant(ValPtr _c) { diff --git a/testing/btest/Baseline.cpp/broker.store.create-failure/zeek.err b/testing/btest/Baseline.cpp/broker.store.create-failure/zeek.err index 982e06a3ca..177bb34a52 100644 --- a/testing/btest/Baseline.cpp/broker.store.create-failure/zeek.err +++ b/testing/btest/Baseline.cpp/broker.store.create-failure/zeek.err @@ -1,11 +1,11 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. error in <...>/create-failure.zeek (C++), line 61: Failed to attach master store backend_failure: (<___>testing_btest__tmp_broker_store_create_failure_create_failure_zeek__zeek_init__36__zf()) error in <...>/create-failure.zeek (C++), line 61: Could not create Broker master store '../fail' (<___>testing_btest__tmp_broker_store_create_failure_create_failure_zeek__zeek_init__36__zf()) -error in : invalid Broker store handle (broker::store::{}) -error in : invalid Broker store handle (broker::store::{}) -error in : invalid Broker store handle (broker::store::{}) -error in : invalid Broker store handle (broker::store::{}) -error in : invalid Broker store handle (broker::store::{}) -error in : invalid Broker store handle (broker::store::{}) -error in : invalid Broker store handle (broker::store::{}) +error in <...>/create-failure.zeek, line 53: invalid Broker store handle (lambda_8863924235512554227__lb_cl() and broker::store::{}) +error in <...>/create-failure.zeek, line 53: invalid Broker store handle (lambda_8863924235512554227__lb_cl() and broker::store::{}) +error in <...>/create-failure.zeek, line 53: invalid Broker store handle (lambda_8863924235512554227__lb_cl() and broker::store::{}) +error in <...>/create-failure.zeek, line 53: invalid Broker store handle (lambda_8863924235512554227__lb_cl() and broker::store::{}) +error in <...>/create-failure.zeek, line 53: invalid Broker store handle (lambda_8863924235512554227__lb_cl() and broker::store::{}) +error in <...>/create-failure.zeek, line 53: invalid Broker store handle (lambda_8863924235512554227__lb_cl() and broker::store::{}) +error in <...>/create-failure.zeek, line 53: invalid Broker store handle (lambda_8863924235512554227__lb_cl() and broker::store::{}) received termination signal diff --git a/testing/btest/Baseline.cpp/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/conn.log.cut b/testing/btest/Baseline.cpp/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/conn.log.cut new file mode 100644 index 0000000000..43dce97d68 --- /dev/null +++ b/testing/btest/Baseline.cpp/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/conn.log.cut @@ -0,0 +1,4 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +ts uid history service +XXXXXXXXXX.XXXXXX CHhAvVGS1DHFjwGM9 ShADadR http +XXXXXXXXXX.XXXXXX ClEkJM2Vm5giqnMf4h ShADadR http diff --git a/testing/btest/Baseline.cpp/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/out b/testing/btest/Baseline.cpp/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/out new file mode 100644 index 0000000000..9ebb1d46b0 --- /dev/null +++ b/testing/btest/Baseline.cpp/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/out @@ -0,0 +1,5 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +WebSocket::configure_analyzer, CHhAvVGS1DHFjwGM9, 7 +disabling_analyzer, CHhAvVGS1DHFjwGM9, AllAnalyzers::ANALYZER_ANALYZER_WEBSOCKET, 7 +WebSocket::configure_analyzer, ClEkJM2Vm5giqnMf4h, 14 +disabling_analyzer, ClEkJM2Vm5giqnMf4h, AllAnalyzers::ANALYZER_ANALYZER_WEBSOCKET, 14 diff --git a/testing/btest/Baseline.cpp/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/websocket.log b/testing/btest/Baseline.cpp/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/websocket.log new file mode 100644 index 0000000000..e993d7b4cf --- /dev/null +++ b/testing/btest/Baseline.cpp/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/websocket.log @@ -0,0 +1,12 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +#separator \x09 +#set_separator , +#empty_field (empty) +#unset_field - +#path websocket +#open XXXX-XX-XX-XX-XX-XX +#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p host uri user_agent subprotocol client_protocols server_extensions client_extensions +#types time string addr port addr port string string string string vector[string] vector[string] vector[string] +XXXXXXXXXX.XXXXXX CHhAvVGS1DHFjwGM9 127.0.0.1 42906 127.0.0.1 8888 localhost:8888 /v1/events - v1 v1,authorization.bearer.eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjAxOGQwNTVkLTQ5OTgtNzI5Zi04Yjg2LTMwZTBiZWEyZGE4ZiIsInAiOiJUY3AiLCJyIjoiMTk1LjIwMS4xNDguMjA5IiwicnAiOjIyfQ.jjTNJL12tQbAuhTB9p_geFXRkEHkxcvOS6zf76qDklQ - - +XXXXXXXXXX.XXXXXX ClEkJM2Vm5giqnMf4h 127.0.0.1 46796 127.0.0.1 8888 localhost:8888 /v1/events - v1 v1,authorization.bearer.eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjAxOGQwNTVkLTc4MWYtNzNiYi1hZDkwLTEzNjA5NzRjY2JmMyIsInAiOiJUY3AiLCJyIjoiMTk1LjIwMS4xNDguMjA5IiwicnAiOjIyfQ.2HQ4uC23p_OYIXnQWeSZCqdA3jc_lVVH7-T5xZDPrz4 - - +#close XXXX-XX-XX-XX-XX-XX diff --git a/testing/btest/Baseline.zam/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/conn.log.cut b/testing/btest/Baseline.zam/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/conn.log.cut new file mode 100644 index 0000000000..43dce97d68 --- /dev/null +++ b/testing/btest/Baseline.zam/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/conn.log.cut @@ -0,0 +1,4 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +ts uid history service +XXXXXXXXXX.XXXXXX CHhAvVGS1DHFjwGM9 ShADadR http +XXXXXXXXXX.XXXXXX ClEkJM2Vm5giqnMf4h ShADadR http diff --git a/testing/btest/Baseline.zam/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/out b/testing/btest/Baseline.zam/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/out new file mode 100644 index 0000000000..9ebb1d46b0 --- /dev/null +++ b/testing/btest/Baseline.zam/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/out @@ -0,0 +1,5 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +WebSocket::configure_analyzer, CHhAvVGS1DHFjwGM9, 7 +disabling_analyzer, CHhAvVGS1DHFjwGM9, AllAnalyzers::ANALYZER_ANALYZER_WEBSOCKET, 7 +WebSocket::configure_analyzer, ClEkJM2Vm5giqnMf4h, 14 +disabling_analyzer, ClEkJM2Vm5giqnMf4h, AllAnalyzers::ANALYZER_ANALYZER_WEBSOCKET, 14 diff --git a/testing/btest/Baseline.zam/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/websocket.log b/testing/btest/Baseline.zam/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/websocket.log new file mode 100644 index 0000000000..e993d7b4cf --- /dev/null +++ b/testing/btest/Baseline.zam/scripts.base.protocols.websocket.wstunnel-ssh-configure-break/websocket.log @@ -0,0 +1,12 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +#separator \x09 +#set_separator , +#empty_field (empty) +#unset_field - +#path websocket +#open XXXX-XX-XX-XX-XX-XX +#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p host uri user_agent subprotocol client_protocols server_extensions client_extensions +#types time string addr port addr port string string string string vector[string] vector[string] vector[string] +XXXXXXXXXX.XXXXXX CHhAvVGS1DHFjwGM9 127.0.0.1 42906 127.0.0.1 8888 localhost:8888 /v1/events - v1 v1,authorization.bearer.eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjAxOGQwNTVkLTQ5OTgtNzI5Zi04Yjg2LTMwZTBiZWEyZGE4ZiIsInAiOiJUY3AiLCJyIjoiMTk1LjIwMS4xNDguMjA5IiwicnAiOjIyfQ.jjTNJL12tQbAuhTB9p_geFXRkEHkxcvOS6zf76qDklQ - - +XXXXXXXXXX.XXXXXX ClEkJM2Vm5giqnMf4h 127.0.0.1 46796 127.0.0.1 8888 localhost:8888 /v1/events - v1 v1,authorization.bearer.eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjAxOGQwNTVkLTc4MWYtNzNiYi1hZDkwLTEzNjA5NzRjY2JmMyIsInAiOiJUY3AiLCJyIjoiMTk1LjIwMS4xNDguMjA5IiwicnAiOjIyfQ.2HQ4uC23p_OYIXnQWeSZCqdA3jc_lVVH7-T5xZDPrz4 - - +#close XXXX-XX-XX-XX-XX-XX diff --git a/testing/btest/Baseline.zam/spicy.ssh-banner/analyzer.log b/testing/btest/Baseline.zam/spicy.ssh-banner/analyzer.log index 08d61c5ea6..f34ea0483b 100644 --- a/testing/btest/Baseline.zam/spicy.ssh-banner/analyzer.log +++ b/testing/btest/Baseline.zam/spicy.ssh-banner/analyzer.log @@ -8,5 +8,5 @@ #fields ts cause analyzer_kind analyzer_name uid fuid id.orig_h id.orig_p id.resp_h id.resp_p failure_reason failure_data #types time string string string string string addr port addr port string string XXXXXXXXXX.XXXXXX violation protocol SPICY_SSH CHhAvVGS1DHFjwGM9 - 141.142.228.5 53595 54.243.55.129 80 kaputt - -XXXXXXXXXX.XXXXXX violation protocol SPICY_SSH CHhAvVGS1DHFjwGM9 - 141.142.228.5 53595 54.243.55.129 80 failed to match regular expression (<...>/ssh.spicy:7:15) POST /post HTTP/1.1\x0d\x0aUser-Agent: curl/7. +XXXXXXXXXX.XXXXXX violation protocol SPICY_SSH CHhAvVGS1DHFjwGM9 - 141.142.228.5 53595 54.243.55.129 80 failed to match regular expression (<...>/ssh.spicy:7:15-7:20) POST /post HTTP/1.1\x0d\x0aUser-Agent: curl/7. #close XXXX-XX-XX-XX-XX-XX diff --git a/testing/btest/Baseline.zam/spicy.ssh-banner/output b/testing/btest/Baseline.zam/spicy.ssh-banner/output index e84de82dad..c404581064 100644 --- a/testing/btest/Baseline.zam/spicy.ssh-banner/output +++ b/testing/btest/Baseline.zam/spicy.ssh-banner/output @@ -6,5 +6,5 @@ SSH banner, [orig_h=192.150.186.169, orig_p=49244/tcp, resp_h=131.159.14.23, res SSH banner, [orig_h=192.150.186.169, orig_p=49244/tcp, resp_h=131.159.14.23, resp_p=22/tcp], T, 2.0, OpenSSH_3.8.1p1 confirm, AllAnalyzers::ANALYZER_ANALYZER_SPICY_SSH === violation -violation, AllAnalyzers::ANALYZER_ANALYZER_SPICY_SSH, failed to match regular expression (<...>/ssh.spicy:7:15) +violation, AllAnalyzers::ANALYZER_ANALYZER_SPICY_SSH, failed to match regular expression (<...>/ssh.spicy:7:15-7:20) violation, AllAnalyzers::ANALYZER_ANALYZER_SPICY_SSH, kaputt