Merge remote-tracking branch 'origin/topic/timw/remove-tag-types'

* origin/topic/timw/remove-tag-types:
  Remove separate Tag types, note breaking change in NEWS
This commit is contained in:
Tim Wojtulewicz 2021-12-06 11:29:32 -07:00
commit f44ea32df8
13 changed files with 21 additions and 766 deletions

View file

@ -1,3 +1,7 @@
4.2.0-dev.410 | 2021-12-06 11:29:32 -0700
* Remove separate Tag types, note breaking change in NEWS (Tim Wojtulewicz, Corelight)
4.2.0-dev.408 | 2021-12-06 09:15:24 -0700
* GH-1768: Properly cleanup existing log stream when recreated on with the same ID (Tim Wojtulewicz, Corelight)

11
NEWS
View file

@ -6,6 +6,17 @@ release. For an exhaustive list of changes, see the ``CHANGES`` file
Zeek 4.2.0
==========
Breaking Changes
----------------
- The existing ``Tag`` types in C++ (``zeek::Analyzer::Tag``, etc) have been merged
into a single type called ``zeek::Tag``. This is a breaking change, and may result
in plugins failing to build where they were relying on those types being different
for function overloading and such. We attempted to include deprecated versions of
the old types, but were unable to do so because of changes to return types from a
number of methods. With this change, any uses of the `zeek::*::Tag` types will
need to be replaced by `zeek::Tag`.
New Functionality
-----------------

View file

@ -1 +1 @@
4.2.0-dev.408
4.2.0-dev.410

View file

@ -3,7 +3,7 @@
#include <sys/types.h> // for u_char
#include <string>
#include "zeek/analyzer/Tag.h"
#include "zeek/Tag.h"
namespace zeek::detail
{

View file

@ -11,8 +11,8 @@
#include "zeek/EventHandler.h"
#include "zeek/IntrusivePtr.h"
#include "zeek/Obj.h"
#include "zeek/Tag.h"
#include "zeek/Timer.h"
#include "zeek/analyzer/Tag.h"
namespace zeek
{

View file

@ -1,152 +0,0 @@
// See the file "COPYING" in the main distribution directory for copyright.
#pragma once
#include "zeek/zeek-config.h"
#include <string>
#include "zeek/Tag.h"
#include "zeek/Val.h"
namespace zeek::analyzer
{
/**
* This class implements a wrapper around zeek::Tag , presenting the same interface as that
* member object. It previously implemented a full tag object for this type of plugin
* component, but that functionality was merged into zeek::Tag and the separate tag types were
* deprecated. This class will eventually be removed per the Zeek deprecation policy.
*/
class [[deprecated("Remove in v5.1. Use zeek::Tag.")]] Tag
{
public:
/**
* Type for the component's main type.
*/
using type_t = zeek::Tag::type_t;
/**
* Type for the component's subtype.
*/
using subtype_t = zeek::Tag::subtype_t;
/**
* Returns the tag's main type.
*/
zeek::Tag::type_t Type() const { return tag.Type(); }
/**
* Returns the tag's subtype.
*/
zeek::Tag::subtype_t Subtype() const { return tag.Subtype(); }
/**
* Default constructor. This initializes the tag with an error value
* that will make \c operator \c bool return false.
*/
Tag() : tag() { }
/**
* Constructor.
*
* @param etype the script-layer enum type associated with the tag.
*
* @param type The main type. Note that the manager class manages the
* the value space internally, so noone else should assign main types.
*
* @param subtype The sub type, which is left to a component for
* interpretation. By default it's set to zero.
*/
Tag(const EnumTypePtr& etype, zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0)
: tag(etype, type, subtype)
{
}
/**
* Constructor.
*
* @param type The main type. Note that the component's Manager
* manages the value space internally, so noone else should assign
* any main types.
*
* @param subtype The sub type, which is left to a component for
* interpretation. By default it's set to zero.
*/
explicit Tag(zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) : tag(type, subtype) { }
/**
* Constructor.
*
* @param val An enum value of script type \c Analyzer::Tag.
*/
explicit Tag(EnumValPtr val) : tag(val) { }
/*
* Copy constructor.
*/
Tag(const Tag& other) : tag(other.tag) { }
/**
* Destructor.
*/
~Tag() { }
/**
* Assignment operator.
*/
Tag& operator=(const Tag& other)
{
tag = other.tag;
return *this;
}
/**
* Move assignment operator.
*/
Tag& operator=(Tag&& other) noexcept
{
tag = other.tag;
return *this;
}
/**
* Compares two tags for equality.
*/
bool operator==(const Tag& other) const { return tag == other.tag; }
/**
* Compares two tags for inequality.
*/
bool operator!=(const Tag& other) const { return tag != other.tag; }
/**
* Compares two tags for less-than relationship.
*/
bool operator<(const Tag& other) const { return tag < other.tag; }
/**
* Returns the numerical values for main and subtype inside a string
* suitable for printing. This is primarily for debugging.
*/
std::string AsString() const { return tag.AsString(); }
/**
* Returns the script-layer 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 { return tag.AsVal(); }
/**
* Returns false if the tag represents an error value rather than a
* legal component type.
*/
explicit operator bool() const { return static_cast<bool>(tag); }
private:
zeek::Tag tag;
};
} // namespace zeek::analyzer

View file

@ -6,11 +6,11 @@
#include <string>
#include <utility>
#include "zeek/Tag.h"
#include "zeek/WeirdState.h"
#include "zeek/ZeekArgs.h"
#include "zeek/ZeekList.h" // for ValPList
#include "zeek/ZeekString.h"
#include "zeek/analyzer/Tag.h"
#include "zeek/file_analysis/AnalyzerSet.h"
namespace zeek

View file

@ -1,152 +0,0 @@
// See the file "COPYING" in the main distribution directory for copyright.
#pragma once
#include "zeek/zeek-config.h"
#include <string>
#include "zeek/Tag.h"
#include "zeek/Val.h"
namespace zeek::file_analysis
{
/**
* This class implements a wrapper around zeek::Tag , presenting the same interface as that
* member object. It previously implemented a full tag object for this type of plugin
* component, but that functionality was merged into zeek::Tag and the separate tag types were
* deprecated. This class will eventually be removed per the Zeek deprecation policy.
*/
class [[deprecated("Remove in v5.1. Use zeek::Tag.")]] Tag
{
public:
/**
* Type for the component's main type.
*/
using type_t = zeek::Tag::type_t;
/**
* Type for the component's subtype.
*/
using subtype_t = zeek::Tag::subtype_t;
/**
* Returns the tag's main type.
*/
zeek::Tag::type_t Type() const { return tag.Type(); }
/**
* Returns the tag's subtype.
*/
zeek::Tag::subtype_t Subtype() const { return tag.Subtype(); }
/**
* Default constructor. This initializes the tag with an error value
* that will make \c operator \c bool return false.
*/
Tag() : tag() { }
/**
* Constructor.
*
* @param etype the script-layer enum type associated with the tag.
*
* @param type The main type. Note that the manager class manages the
* the value space internally, so noone else should assign main types.
*
* @param subtype The sub type, which is left to a component for
* interpretation. By default it's set to zero.
*/
Tag(const EnumTypePtr& etype, zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0)
: tag(etype, type, subtype)
{
}
/**
* Constructor.
*
* @param type The main type. Note that the component's Manager
* manages the value space internally, so noone else should assign
* any main types.
*
* @param subtype The sub type, which is left to a component for
* interpretation. By default it's set to zero.
*/
explicit Tag(zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) : tag(type, subtype) { }
/**
* Constructor.
*
* @param val An enum value of script type \c Files::Tag.
*/
explicit Tag(EnumValPtr val) : tag(val) { }
/*
* Copy constructor.
*/
Tag(const Tag& other) : tag(other.tag) { }
/**
* Destructor.
*/
~Tag() { }
/**
* Assignment operator.
*/
Tag& operator=(const Tag& other)
{
tag = other.tag;
return *this;
}
/**
* Move assignment operator.
*/
Tag& operator=(Tag&& other) noexcept
{
tag = other.tag;
return *this;
}
/**
* Compares two tags for equality.
*/
bool operator==(const Tag& other) const { return tag == other.tag; }
/**
* Compares two tags for inequality.
*/
bool operator!=(const Tag& other) const { return tag != other.tag; }
/**
* Compares two tags for less-than relationship.
*/
bool operator<(const Tag& other) const { return tag < other.tag; }
/**
* Returns the numerical values for main and subtype inside a string
* suitable for printing. This is primarily for debugging.
*/
std::string AsString() const { return tag.AsString(); }
/**
* Returns the script-layer 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 { return tag.AsVal(); }
/**
* Returns false if the tag represents an error value rather than a
* legal component type.
*/
explicit operator bool() const { return static_cast<bool>(tag); }
private:
zeek::Tag tag;
};
} // namespace zeek::file_analysis

View file

@ -7,8 +7,8 @@
#include <map>
#include "zeek/EventHandler.h"
#include "zeek/Tag.h"
#include "zeek/input/Component.h"
#include "zeek/input/Tag.h"
#include "zeek/plugin/ComponentManager.h"
#include "zeek/threading/SerialTypes.h"

View file

@ -1,152 +0,0 @@
// See the file "COPYING" in the main distribution directory for copyright.
#pragma once
#include "zeek/zeek-config.h"
#include <string>
#include "zeek/Tag.h"
#include "zeek/Val.h"
namespace zeek::input
{
/**
* This class implements a wrapper around zeek::Tag , presenting the same interface as that
* member object. It previously implemented a full tag object for this type of plugin
* component, but that functionality was merged into zeek::Tag and the separate tag types were
* deprecated. This class will eventually be removed per the Zeek deprecation policy.
*/
class [[deprecated("Remove in v5.1. Use zeek::Tag.")]] Tag
{
public:
/**
* Type for the component's main type.
*/
using type_t = zeek::Tag::type_t;
/**
* Type for the component's subtype.
*/
using subtype_t = zeek::Tag::subtype_t;
/**
* Returns the tag's main type.
*/
zeek::Tag::type_t Type() const { return tag.Type(); }
/**
* Returns the tag's subtype.
*/
zeek::Tag::subtype_t Subtype() const { return tag.Subtype(); }
/**
* Default constructor. This initializes the tag with an error value
* that will make \c operator \c bool return false.
*/
Tag() : tag() { }
/**
* Constructor.
*
* @param etype the script-layer enum type associated with the tag.
*
* @param type The main type. Note that the manager class manages the
* the value space internally, so noone else should assign main types.
*
* @param subtype The sub type, which is left to a component for
* interpretation. By default it's set to zero.
*/
Tag(const EnumTypePtr& etype, zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0)
: tag(etype, type, subtype)
{
}
/**
* Constructor.
*
* @param type The main type. Note that the component's Manager
* manages the value space internally, so noone else should assign
* any main types.
*
* @param subtype The sub type, which is left to a component for
* interpretation. By default it's set to zero.
*/
explicit Tag(zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) : tag(type, subtype) { }
/**
* Constructor.
*
* @param val An enum value of script type \c Input::Tag.
*/
explicit Tag(EnumValPtr val) : tag(val) { }
/*
* Copy constructor.
*/
Tag(const Tag& other) : tag(other.tag) { }
/**
* Destructor.
*/
~Tag() { }
/**
* Assignment operator.
*/
Tag& operator=(const Tag& other)
{
tag = other.tag;
return *this;
}
/**
* Move assignment operator.
*/
Tag& operator=(Tag&& other) noexcept
{
tag = other.tag;
return *this;
}
/**
* Compares two tags for equality.
*/
bool operator==(const Tag& other) const { return tag == other.tag; }
/**
* Compares two tags for inequality.
*/
bool operator!=(const Tag& other) const { return tag != other.tag; }
/**
* Compares two tags for less-than relationship.
*/
bool operator<(const Tag& other) const { return tag < other.tag; }
/**
* Returns the numerical values for main and subtype inside a string
* suitable for printing. This is primarily for debugging.
*/
std::string AsString() const { return tag.AsString(); }
/**
* Returns the script-layer 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 { return tag.AsVal(); }
/**
* Returns false if the tag represents an error value rather than a
* legal component type.
*/
explicit operator bool() const { return static_cast<bool>(tag); }
private:
zeek::Tag tag;
};
} // namespace zeek::input

View file

@ -1,152 +0,0 @@
// See the file "COPYING" in the main distribution directory for copyright.
#pragma once
#include "zeek/zeek-config.h"
#include <string>
#include "zeek/Tag.h"
#include "zeek/Val.h"
namespace zeek::logging
{
/**
* This class implements a wrapper around zeek::Tag , presenting the same interface as that
* member object. It previously implemented a full tag object for this type of plugin
* component, but that functionality was merged into zeek::Tag and the separate tag types were
* deprecated. This class will eventually be removed per the Zeek deprecation policy.
*/
class [[deprecated("Remove in v5.1. Use zeek::Tag.")]] Tag
{
public:
/**
* Type for the component's main type.
*/
using type_t = zeek::Tag::type_t;
/**
* Type for the component's subtype.
*/
using subtype_t = zeek::Tag::subtype_t;
/**
* Returns the tag's main type.
*/
zeek::Tag::type_t Type() const { return tag.Type(); }
/**
* Returns the tag's subtype.
*/
zeek::Tag::subtype_t Subtype() const { return tag.Subtype(); }
/**
* Default constructor. This initializes the tag with an error value
* that will make \c operator \c bool return false.
*/
Tag() : tag() { }
/**
* Constructor.
*
* @param etype the script-layer enum type associated with the tag.
*
* @param type The main type. Note that the manager class manages the
* the value space internally, so noone else should assign main types.
*
* @param subtype The sub type, which is left to a component for
* interpretation. By default it's set to zero.
*/
Tag(const EnumTypePtr& etype, zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0)
: tag(etype, type, subtype)
{
}
/**
* Constructor.
*
* @param type The main type. Note that the \a logging::Manager
* manages the value space internally, so noone else should assign
* any main types.
*
* @param subtype The sub type, which is left to a component for
* interpretation. By default it's set to zero.
*/
explicit Tag(zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) : tag(type, subtype) { }
/**
* Constructor.
*
* @param val An enum value of script type \c Logger::Tag.
*/
explicit Tag(EnumValPtr val) : tag(val) { }
/*
* Copy constructor.
*/
Tag(const Tag& other) : tag(other.tag) { }
/**
* Destructor.
*/
~Tag() { }
/**
* Assignment operator.
*/
Tag& operator=(const Tag& other)
{
tag = other.tag;
return *this;
}
/**
* Move assignment operator.
*/
Tag& operator=(Tag&& other) noexcept
{
tag = other.tag;
return *this;
}
/**
* Compares two tags for equality.
*/
bool operator==(const Tag& other) const { return tag == other.tag; }
/**
* Compares two tags for inequality.
*/
bool operator!=(const Tag& other) const { return tag != other.tag; }
/**
* Compares two tags for less-than relationship.
*/
bool operator<(const Tag& other) const { return tag < other.tag; }
/**
* Returns the numerical values for main and subtype inside a string
* suitable for printing. This is primarily for debugging.
*/
std::string AsString() const { return tag.AsString(); }
/**
* Returns the script-layer 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 { return tag.AsVal(); }
/**
* Returns false if the tag represents an error value rather than a
* legal component type.
*/
explicit operator bool() const { return static_cast<bool>(tag); }
private:
zeek::Tag tag;
};
} // namespace zeek::logging

View file

@ -1,152 +0,0 @@
// See the file "COPYING" in the main distribution directory for copyright.
#pragma once
#include "zeek/zeek-config.h"
#include <string>
#include "zeek/Tag.h"
#include "zeek/Val.h"
namespace zeek::packet_analysis
{
/**
* This class implements a wrapper around zeek::Tag , presenting the same interface as that
* member object. It previously implemented a full tag object for this type of plugin
* component, but that functionality was merged into zeek::Tag and the separate tag types were
* deprecated. This class will eventually be removed per the Zeek deprecation policy.
*/
class [[deprecated("Remove in v5.1. Use zeek::Tag.")]] Tag
{
public:
/**
* Type for the component's main type.
*/
using type_t = zeek::Tag::type_t;
/**
* Type for the component's subtype.
*/
using subtype_t = zeek::Tag::subtype_t;
/**
* Returns the tag's main type.
*/
zeek::Tag::type_t Type() const { return tag.Type(); }
/**
* Returns the tag's subtype.
*/
zeek::Tag::subtype_t Subtype() const { return tag.Subtype(); }
/**
* Default constructor. This initializes the tag with an error value
* that will make \c operator \c bool return false.
*/
Tag() : tag() { }
/**
* Constructor.
*
* @param etype the script-layer enum type associated with the tag.
*
* @param type The main type. Note that the manager class manages the
* the value space internally, so noone else should assign main types.
*
* @param subtype The sub type, which is left to a component for
* interpretation. By default it's set to zero.
*/
Tag(const EnumTypePtr& etype, zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0)
: tag(etype, type, subtype)
{
}
/**
* Constructor.
*
* @param type The main type. Note that the component's Manager
* manages the value space internally, so noone else should assign
* any main types.
*
* @param subtype The sub type, which is left to a component for
* interpretation. By default it's set to zero.
*/
explicit Tag(zeek::Tag::type_t type, zeek::Tag::subtype_t subtype = 0) : tag(type, subtype) { }
/**
* Constructor.
*
* @param val An enum value of script type \c PacketAnalyzer::Tag.
*/
explicit Tag(EnumValPtr val) : tag(val) { }
/*
* Copy constructor.
*/
Tag(const Tag& other) : tag(other.tag) { }
/**
* Destructor.
*/
~Tag() { }
/**
* Assignment operator.
*/
Tag& operator=(const Tag& other)
{
tag = other.tag;
return *this;
}
/**
* Move assignment operator.
*/
Tag& operator=(Tag&& other) noexcept
{
tag = other.tag;
return *this;
}
/**
* Compares two tags for equality.
*/
bool operator==(const Tag& other) const { return tag == other.tag; }
/**
* Compares two tags for inequality.
*/
bool operator!=(const Tag& other) const { return tag != other.tag; }
/**
* Compares two tags for less-than relationship.
*/
bool operator<(const Tag& other) const { return tag < other.tag; }
/**
* Returns the numerical values for main and subtype inside a string
* suitable for printing. This is primarily for debugging.
*/
std::string AsString() const { return tag.AsString(); }
/**
* Returns the script-layer 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 { return tag.AsVal(); }
/**
* Returns false if the tag represents an error value rather than a
* legal component type.
*/
explicit operator bool() const { return static_cast<bool>(tag); }
private:
zeek::Tag tag;
};
} // namespace zeek::packet_analysis

View file

@ -41,12 +41,12 @@
#include "zeek/ScriptCoverageManager.h"
#include "zeek/Stats.h"
#include "zeek/Stmt.h"
#include "zeek/Tag.h"
#include "zeek/Timer.h"
#include "zeek/Traverse.h"
#include "zeek/Trigger.h"
#include "zeek/Var.h"
#include "zeek/analyzer/Manager.h"
#include "zeek/analyzer/Tag.h"
#include "zeek/binpac_zeek.h"
#include "zeek/broker/Manager.h"
#include "zeek/file_analysis/Manager.h"