mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 00:28:21 +00:00
Unify all of the Tag types into one type
- Remove tag types for each component type (analyzer, etc) - Add deprecated versions of the old types - Remove unnecessary tag element from templates for TaggedComponent and ComponentManager - Enable TaggedComponent to pass an EnumType when initializing Tag objects - Update some tests that are affected by the tag enum values changing order
This commit is contained in:
parent
4f9f46a0c4
commit
331161138a
46 changed files with 352 additions and 955 deletions
|
@ -15,7 +15,6 @@ set(file_analysis_SRCS
|
|||
Analyzer.cc
|
||||
AnalyzerSet.cc
|
||||
Component.cc
|
||||
Tag.cc
|
||||
)
|
||||
|
||||
bif_target(file_analysis.bif)
|
||||
|
|
|
@ -11,8 +11,9 @@ 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),
|
||||
plugin::TaggedComponent<file_analysis::Tag>(subtype)
|
||||
: plugin::Component(plugin::component::FILE_ANALYZER, name), plugin::TaggedComponent(
|
||||
subtype,
|
||||
file_mgr->GetTagType())
|
||||
{
|
||||
factory_func = arg_factory;
|
||||
enabled = arg_enabled;
|
||||
|
|
|
@ -27,7 +27,7 @@ class Manager;
|
|||
* A plugin can provide a specific file analyzer by registering this
|
||||
* analyzer component, describing the analyzer.
|
||||
*/
|
||||
class Component : public plugin::Component, public plugin::TaggedComponent<file_analysis::Tag>
|
||||
class Component : public plugin::Component, public plugin::TaggedComponent
|
||||
{
|
||||
public:
|
||||
using factory_function = Analyzer* (*)(RecordValPtr args, File* file);
|
||||
|
|
|
@ -27,7 +27,6 @@ namespace file_analysis
|
|||
{
|
||||
|
||||
class FileReassembler;
|
||||
class Tag;
|
||||
|
||||
/**
|
||||
* Wrapper class around \c fa_file record values from script layer.
|
||||
|
|
|
@ -19,8 +19,8 @@ namespace zeek::file_analysis
|
|||
{
|
||||
|
||||
Manager::Manager()
|
||||
: plugin::ComponentManager<file_analysis::Tag, file_analysis::Component>("Files", "Tag"),
|
||||
current_file_id(), magic_state(), cumulative_files(0), max_files(0)
|
||||
: plugin::ComponentManager<file_analysis::Component>("Files", "Tag"), current_file_id(),
|
||||
magic_state(), cumulative_files(0), max_files(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace analyzer
|
|||
{
|
||||
|
||||
class Analyzer;
|
||||
class Tag;
|
||||
|
||||
} // namespace analyzer
|
||||
|
||||
|
@ -31,12 +30,11 @@ namespace file_analysis
|
|||
{
|
||||
|
||||
class File;
|
||||
class Tag;
|
||||
|
||||
/**
|
||||
* Main entry point for interacting with file analysis.
|
||||
*/
|
||||
class Manager : public plugin::ComponentManager<Tag, Component>
|
||||
class Manager : public plugin::ComponentManager<Component>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#include "zeek/file_analysis/Tag.h"
|
||||
|
||||
#include "zeek/file_analysis/Manager.h"
|
||||
|
||||
namespace zeek::file_analysis
|
||||
{
|
||||
|
||||
const Tag Tag::Error;
|
||||
|
||||
Tag::Tag(type_t type, subtype_t subtype) : zeek::Tag(file_mgr->GetTagType(), type, subtype) { }
|
||||
|
||||
Tag& Tag::operator=(const Tag& other)
|
||||
{
|
||||
zeek::Tag::operator=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const EnumValPtr& Tag::AsVal() const
|
||||
{
|
||||
return zeek::Tag::AsVal(file_mgr->GetTagType());
|
||||
}
|
||||
|
||||
Tag::Tag(EnumValPtr val) : zeek::Tag(std::move(val)) { }
|
||||
|
||||
} // namespace zeek::file_analysis
|
|
@ -6,105 +6,9 @@
|
|||
|
||||
#include "zeek/Tag.h"
|
||||
|
||||
namespace zeek::plugin
|
||||
{
|
||||
template <class T> class TaggedComponent;
|
||||
template <class T, class C> class ComponentManager;
|
||||
}
|
||||
|
||||
namespace zeek
|
||||
namespace zeek::file_analysis
|
||||
{
|
||||
|
||||
class EnumVal;
|
||||
using Tag [[deprecated("Remove in v5.1. Use zeek::Tag.")]] = zeek::Tag;
|
||||
|
||||
namespace file_analysis
|
||||
{
|
||||
|
||||
class Component;
|
||||
|
||||
/**
|
||||
* Class to identify a file analyzer type.
|
||||
*
|
||||
* The script-layer analogue is Files::Tag.
|
||||
*/
|
||||
class Tag : public zeek::Tag
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* Copy constructor.
|
||||
*/
|
||||
Tag(const Tag& other) : zeek::Tag(other) { }
|
||||
|
||||
/**
|
||||
* Default constructor. This initializes the tag with an error value
|
||||
* that will make \c operator \c bool return false.
|
||||
*/
|
||||
Tag() : zeek::Tag() { }
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~Tag() { }
|
||||
|
||||
/**
|
||||
* Returns false if the tag represents an error value rather than a
|
||||
* legal analyzer type.
|
||||
*/
|
||||
explicit operator bool() const { return *this != Error; }
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
*/
|
||||
Tag& operator=(const Tag& other);
|
||||
|
||||
/**
|
||||
* Compares two tags for equality.
|
||||
*/
|
||||
bool operator==(const Tag& other) const { return zeek::Tag::operator==(other); }
|
||||
|
||||
/**
|
||||
* Compares two tags for inequality.
|
||||
*/
|
||||
bool operator!=(const Tag& other) const { return zeek::Tag::operator!=(other); }
|
||||
|
||||
/**
|
||||
* Compares two tags for less-than relationship.
|
||||
*/
|
||||
bool operator<(const Tag& other) const { return zeek::Tag::operator<(other); }
|
||||
|
||||
/**
|
||||
* Returns the \c Files::Tag enum that corresponds to this tag.
|
||||
* The returned value does not have its ref-count increased.
|
||||
*
|
||||
* @param etype the script-layer enum type associated with the tag.
|
||||
*/
|
||||
const EnumValPtr& AsVal() const;
|
||||
|
||||
static const Tag Error;
|
||||
|
||||
protected:
|
||||
friend class plugin::ComponentManager<Tag, Component>;
|
||||
friend class plugin::TaggedComponent<Tag>;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param type The main type. Note that the \a file_analysis::Manager
|
||||
* manages the value space internally, so noone else should assign
|
||||
* main types.
|
||||
*
|
||||
* @param subtype The sub type, which is left to an analyzer for
|
||||
* interpretation. By default it's set to zero.
|
||||
*/
|
||||
explicit Tag(type_t type, subtype_t subtype = 0);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param val An enum value of script type \c Files::Tag.
|
||||
*/
|
||||
explicit Tag(EnumValPtr val);
|
||||
};
|
||||
|
||||
} // namespace file_analysis
|
||||
} // namespace zeek
|
||||
} // namespace zeek::file_analysis
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace file_analysis
|
|||
{
|
||||
|
||||
class File;
|
||||
class Tag;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue