diff --git a/src/packet_analysis/Component.cc b/src/packet_analysis/Component.cc index 7ca6f24bcc..0fec613648 100644 --- a/src/packet_analysis/Component.cc +++ b/src/packet_analysis/Component.cc @@ -6,12 +6,11 @@ using namespace zeek::packet_analysis; -Component::Component(const std::string& name, factory_callback arg_factory, Tag::subtype_t arg_subtype, bool arg_enabled) +Component::Component(const std::string& name, factory_callback arg_factory, Tag::subtype_t arg_subtype) : plugin::Component(plugin::component::PACKET_ANALYZER, name), plugin::TaggedComponent(arg_subtype) { factory = arg_factory; - enabled = arg_enabled; } void Component::Initialize() @@ -26,8 +25,5 @@ void Component::DoDescribe(ODesc* d) const { d->Add("ANALYZER_"); d->Add(CanonicalName()); - d->Add(", "); } - - d->Add(enabled ? "enabled" : "disabled"); } diff --git a/src/packet_analysis/Component.h b/src/packet_analysis/Component.h index ded61ac744..61986719f7 100644 --- a/src/packet_analysis/Component.h +++ b/src/packet_analysis/Component.h @@ -19,7 +19,7 @@ class Component : public plugin::Component, public: typedef AnalyzerPtr (*factory_callback)(); - Component(const std::string& name, factory_callback factory, Tag::subtype_t subtype = 0, bool enabled = true); + Component(const std::string& name, factory_callback factory, Tag::subtype_t subtype = 0); ~Component() override = default; /** @@ -34,20 +34,6 @@ public: */ factory_callback Factory() const { return factory; } - /** - * Returns true if the analyzer is currently enabled and hence - * available for use. - */ - bool Enabled() const { return enabled; } - - /** - * Enables or disables this analyzer. - * - * @param arg_enabled True to enabled, false to disable. - * - */ - void SetEnabled(bool arg_enabled) { enabled = arg_enabled; } - protected: /** * Overriden from plugin::Component. @@ -56,7 +42,6 @@ protected: private: factory_callback factory; // The analyzer's factory callback. - bool enabled; // True if the analyzer is enabled. }; } diff --git a/src/packet_analysis/Manager.cc b/src/packet_analysis/Manager.cc index 8826ccf1e0..5ba5fae028 100644 --- a/src/packet_analysis/Manager.cc +++ b/src/packet_analysis/Manager.cc @@ -88,7 +88,7 @@ void Manager::DumpDebug() DBG_LOG(DBG_PACKET_ANALYSIS, "Available packet analyzers after zeek_init():"); for ( auto& current : GetComponents() ) { - DBG_LOG(DBG_PACKET_ANALYSIS, " %s (%s)", current->Name().c_str(), IsEnabled(current->Tag()) ? "enabled" : "disabled"); + DBG_LOG(DBG_PACKET_ANALYSIS, " %s", current->Name().c_str()); } DBG_LOG(DBG_PACKET_ANALYSIS, "ProtocolAnalyzerSet FSM:"); @@ -100,87 +100,6 @@ void Manager::DumpDebug() #endif } -bool Manager::EnableAnalyzer(const Tag& tag) - { - if ( Component* p = Lookup(tag) ) - { - DBG_LOG(DBG_PACKET_ANALYSIS, "Enabling analyzer %s", p->Name().c_str()); - p->SetEnabled(true); - return true; - } - - return false; - } - -bool Manager::EnableAnalyzer(EnumVal* val) - { - if ( Component* p = Lookup(val) ) - { - DBG_LOG(DBG_PACKET_ANALYSIS, "Enabling analyzer %s", p->Name().c_str()); - p->SetEnabled(true); - return true; - } - - return false; - } - -bool Manager::DisableAnalyzer(const Tag& tag) - { - if ( Component* p = Lookup(tag) ) - { - DBG_LOG(DBG_PACKET_ANALYSIS, "Disabling analyzer %s", p->Name().c_str()); - p->SetEnabled(false); - return true; - } - - return false; - } - -bool Manager::DisableAnalyzer(EnumVal* val) - { - if ( Component* p = Lookup(val) ) - { - DBG_LOG(DBG_PACKET_ANALYSIS, "Disabling analyzer %s", p->Name().c_str()); - p->SetEnabled(false); - return true; - } - - return false; - } - -void Manager::DisableAllAnalyzers() - { - DBG_LOG(DBG_PACKET_ANALYSIS, "Disabling all analyzers"); - - std::list all_analyzers = GetComponents(); - for ( const auto& analyzer : all_analyzers ) - analyzer->SetEnabled(false); - } - -zeek::packet_analysis::Tag Manager::GetAnalyzerTag(const char* name) - { - return GetComponentTag(name); - } - -bool Manager::IsEnabled(Tag tag) - { - if ( ! tag ) - return false; - - if ( Component* p = Lookup(tag) ) - return p->Enabled(); - - return false; - } - -bool Manager::IsEnabled(EnumVal* val) - { - if ( Component* p = Lookup(val) ) - return p->Enabled(); - - return false; - } - AnalyzerPtr Manager::InstantiateAnalyzer(const Tag& tag) { Component* c = Lookup(tag); @@ -191,9 +110,6 @@ AnalyzerPtr Manager::InstantiateAnalyzer(const Tag& tag) return nullptr; } - if ( ! c->Enabled() ) - return nullptr; - if ( ! c->Factory() ) { reporter->InternalWarning("analyzer %s cannot be instantiated dynamically", GetComponentName(tag).c_str()); diff --git a/src/packet_analysis/Manager.h b/src/packet_analysis/Manager.h index 7e6c767c7b..b1a4638ee9 100644 --- a/src/packet_analysis/Manager.h +++ b/src/packet_analysis/Manager.h @@ -50,53 +50,6 @@ public: */ void DumpDebug(); // Called after zeek_init() events. - /** - * Enables an analyzer type. Only enabled analyzers will be - * instantiated for new connections. - * - * @param tag The analyzer's tag. - * - * @return True if successful. - */ - bool EnableAnalyzer(const Tag& tag); - - /** - * Enables an analyzer type. Only enabled analyzers will be - * instantiated for new connections. - * - * @param tag The analyzer's tag as an enum of script type \c - * Analyzer::Tag. - * - * @return True if successful. - */ - bool EnableAnalyzer(EnumVal* tag); - - /** - * Enables an analyzer type. Disabled analyzers will not be - * instantiated for new connections. - * - * @param tag The analyzer's tag. - * - * @return True if successful. - */ - bool DisableAnalyzer(const Tag& tag); - - /** - * Disables an analyzer type. Disabled analyzers will not be - * instantiated for new connections. - * - * @param tag The analyzer's tag as an enum of script type \c - * Analyzer::Tag. - * - * @return True if successful. - */ - bool DisableAnalyzer(EnumVal* tag); - - /** - * Disables all currently registered analyzers. - */ - void DisableAllAnalyzers(); - /** * Returns the tag associated with an analyer name, or the tag * associated with an error if no such analyzer exists. @@ -105,21 +58,6 @@ public: */ Tag GetAnalyzerTag(const char* name); - /** - * Returns true if an analyzer is enabled. - * - * @param tag The analyzer's tag. - */ - bool IsEnabled(Tag tag); - - /** - * Returns true if an analyzer is enabled. - * - * @param tag The analyzer's tag as an enum of script type \c - * Analyzer::Tag. - */ - bool IsEnabled(EnumVal* tag); - /** * Instantiates a new analyzer instance. * diff --git a/testing/btest/Baseline/plugins.packet-protocol/output b/testing/btest/Baseline/plugins.packet-protocol/output index 42fd1cea42..ce4796e58b 100644 --- a/testing/btest/Baseline/plugins.packet-protocol/output +++ b/testing/btest/Baseline/plugins.packet-protocol/output @@ -1,5 +1,5 @@ PacketDemo::Bar - A Bar packet analyzer. (dynamic, version 1.0.0) - [Packet Analyzer] Bar (ANALYZER_BAR, enabled) + [Packet Analyzer] Bar (ANALYZER_BAR) [Event] bar_message === diff --git a/testing/btest/plugins/packet-protocol-plugin/src/Plugin.cc b/testing/btest/plugins/packet-protocol-plugin/src/Plugin.cc index 80032ea5f5..b90436a9ee 100644 --- a/testing/btest/plugins/packet-protocol-plugin/src/Plugin.cc +++ b/testing/btest/plugins/packet-protocol-plugin/src/Plugin.cc @@ -1,4 +1,3 @@ - #include "Plugin.h" #include "packet_analysis/Component.h"