mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00

The different analyzers types all had their own methods for enabling/disabling their availability. This change abstracts that into a new API inside their base class (`plugin::Component`) so that they can be toggled in a unified way. In principle, other types of components could/should use this as well now, so that, e.g., an input reader's availability could be toggled at runtime. The code doesn't make that broader change for now because it would requires a series of changes wherever these other component types are being used. However, that means that one now could try toggling some other component through the new API without that having any effect. To catch that, there's a runtime check in place that turns any such attempt into an internal error.
32 lines
876 B
C++
32 lines
876 B
C++
// See the file "COPYING" in the main distribution directory for copyright.
|
|
|
|
#include "zeek/file_analysis/Component.h"
|
|
|
|
#include "zeek/Desc.h"
|
|
#include "zeek/file_analysis/Manager.h"
|
|
#include "zeek/util.h"
|
|
|
|
namespace zeek::file_analysis {
|
|
|
|
Component::Component(const std::string& name, factory_function arg_factory, Tag::subtype_t subtype, bool arg_enabled)
|
|
: plugin::Component(plugin::component::FILE_ANALYZER, name, subtype, file_mgr->GetTagType()) {
|
|
factory_func = arg_factory;
|
|
SetEnabled(arg_enabled);
|
|
}
|
|
|
|
void Component::Initialize() {
|
|
InitializeTag();
|
|
file_mgr->RegisterComponent(this, "ANALYZER_");
|
|
}
|
|
|
|
void Component::DoDescribe(ODesc* d) const {
|
|
if ( factory_func ) {
|
|
d->Add("ANALYZER_");
|
|
d->Add(CanonicalName());
|
|
d->Add(", ");
|
|
}
|
|
|
|
d->Add(Enabled() ? "enabled" : "disabled");
|
|
}
|
|
|
|
} // namespace zeek::file_analysis
|