Data Types¶
Bro/Zeek Types¶
Bro/Zeek data types.
-
class
zlogging.types.AddrType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._SimpleTypeBro/Zeek
addrdata type.- Parameters
- Variables
-
parse(data)[source]¶ Parse
datafrom string.- Parameters
data (Union[AnyStr, IPAddress]) – raw data
- Return type
Optional[IPAddress]
- Returns
The parsed IP address. If
datais unset,Nonewill be returned.
-
class
zlogging.types.BoolType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._SimpleTypeBro/Zeek
booldata type.- Parameters
- Variables
-
class
zlogging.types.CountType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._SimpleTypeBro/Zeek
countdata type.- Parameters
- Variables
-
property
python_type¶ Corresponding Python type annotation.
- Type
Any
- Return type
Type[uint64]
-
parse(data)[source]¶ Parse
datafrom string.- Parameters
data (Union[AnyStr, uint64]) – raw data
- Return type
Optional[uint64]
- Returns
The parsed numeral data. If
datais unset,Nonewill be returned.
-
class
zlogging.types.DoubleType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._SimpleTypeBro/Zeek
doubledata type.- Parameters
- Variables
-
property
python_type¶ Corresponding Python type annotation.
- Type
Any
- Return type
Type[Decimal]
-
parse(data)[source]¶ Parse
datafrom string.- Parameters
data (Union[AnyStr, Decimal]) – raw data
- Return type
Optional[Decimal]
- Returns
The parsed numeral data. If
datais unset,Nonewill be returned.
-
class
zlogging.types.EnumType(empty_field=None, unset_field=None, set_separator=None, namespaces=None, bare=False, enum_hook=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._SimpleTypeBro/Zeek
enumdata type.- Parameters
empty_field (
bytesorstr, optional) – Placeholder for empty field.unset_field (
bytesorstr, optional) – Placeholder for unset field.set_separator (
bytesorstr, optional) – Separator forset/vectorfields.namespaces (
List[str], optional) – Namespaces to be loaded.bare (
bool, optional) – IfTrue, do not loadzeeknamespace by default.enum_hook (
dictmapping ofstrandenum.Enum, optional) – Additional enum to be included in the namespace.*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
- Variables
-
parse(data)[source]¶ Parse
datafrom string.- Parameters
data (Union[AnyStr, Enum]) – raw data
- Return type
Optional[Enum]
- Returns
The parsed enum data. If
datais unset,Nonewill be returned.- Warns
ZeekValueWarning – If
dateis not defined in the enum namespace.
-
class
zlogging.types.IntervalType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._SimpleTypeBro/Zeek
intervaldata type.- Parameters
- Variables
-
property
python_type¶ Corresponding Python type annotation.
- Type
Any
- Return type
Type[TimeDeltaType]
-
parse(data)[source]¶ Parse
datafrom string.- Parameters
data (Union[AnyStr, TimeDeltaType]) – raw data
- Return type
Optional[TimeDeltaType]
- Returns
The parsed numeral data. If
datais unset,Nonewill be returned.
-
class
zlogging.types.IntType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._SimpleTypeBro/Zeek
intdata type.- Parameters
- Variables
-
property
python_type¶ Corresponding Python type annotation.
- Type
Any
- Return type
Type[int64]
-
parse(data)[source]¶ Parse
datafrom string.- Parameters
data (Union[AnyStr, int64]) – raw data
- Return type
Optional[int64]
- Returns
The parsed numeral data. If
datais unset,Nonewill be returned.
-
class
zlogging.types.PortType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._SimpleTypeBro/Zeek
portdata type.- Parameters
- Variables
-
property
python_type¶ Corresponding Python type annotation.
- Type
Any
- Return type
Type[uint16]
-
parse(data)[source]¶ Parse
datafrom string.- Parameters
data (Union[AnyStr, uint16]) – raw data
- Return type
Optional[uint16]
- Returns
The parsed port number. If
datais unset,Nonewill be returned.
-
class
zlogging.types.RecordType(empty_field=None, unset_field=None, set_separator=None, *args, **element_mapping)[source]¶ Bases:
zlogging.types._VariadicTypeBro/Zeek
recorddata type.- Parameters
empty_field (
bytesorstr, optional) – Placeholder for empty field.unset_field (
bytesorstr, optional) – Placeholder for unset field.set_separator (
bytesorstr, optional) – Separator forset/vectorfields.*args – Variable length argument list.
**kwargs – element_mapping (
dictmappingstrandBaseTypeinstance): Data type of container’s elements.
- Variables
- Raises
ZeekTypeError – If
element_mappingis not supplied.ZeekValueError – If
element_mappingis not a valid Bro/Zeek data type; or in case of inconsistency fromempty_field,unset_fieldandset_separatorof each field.
Note
A valid
element_mappingshould be a simple or generic data type, i.e. a subclass of_SimpleTypeor_GenericType.See also
See
_aux_expand_typing()for more information about processing the fields.-
element_mapping: OrderedDict[str, Union[_SimpleType, _GenericType]]¶
-
class
zlogging.types.SetType(empty_field=None, unset_field=None, set_separator=None, element_type=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._GenericType,Generic[zlogging.types._S]Bro/Zeek
setdata type.- Parameters
empty_field (
bytesorstr, optional) – Placeholder for empty field.unset_field (
bytesorstr, optional) – Placeholder for unset field.set_separator (
bytesorstr, optional) – Separator forset/vectorfields.element_type (
BaseTypeinstance) – Data type of container’s elements.*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
- Variables
- Raises
ZeekTypeError – If
element_typeis not supplied.ZeekValueError – If
element_typeis not a valid Bro/Zeek data type.
Example
As a generic data type, the class supports the typing proxy as introduced PEP 484:
>>> SetType[StringType]
which is the same at runtime as following:
>>> SetType(element_type=StringType())
Note
A valid
element_typeshould be a simple data type, i.e. a subclass of_SimpleType.-
parse(data)[source]¶ Parse
datafrom string.- Parameters
data (Union[AnyStr, Set[_S]]) – raw data
- Return type
Optional[Set[_S]]
- Returns
The parsed set data. If
datais unset,Nonewill be returned.
-
class
zlogging.types.StringType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._SimpleTypeBro/Zeek
stringdata type.- Parameters
- Variables
-
class
zlogging.types.SubnetType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._SimpleTypeBro/Zeek
subnetdata type.- Parameters
- Variables
-
parse(data)[source]¶ Parse
datafrom string.- Parameters
data (Union[AnyStr, IPNetwork]) – raw data
- Return type
Optional[IPNetwork]
- Returns
The parsed IP network. If
datais unset,Nonewill be returned.
-
class
zlogging.types.TimeType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._SimpleTypeBro/Zeek
timedata type.- Parameters
- Variables
-
property
python_type¶ Corresponding Python type annotation.
- Type
Any
- Return type
Type[DateTimeType]
-
parse(data)[source]¶ Parse
datafrom string.- Parameters
data (Union[AnyStr, DateTimeType]) – raw data
- Return type
Optional[DateTimeType]
- Returns
The parsed numeral data. If
datais unset,Nonewill be returned.
-
class
zlogging.types.VectorType(empty_field=None, unset_field=None, set_separator=None, element_type=None, *args, **kwargs)[source]¶ Bases:
zlogging.types._GenericType,Generic[zlogging.types._S]Bro/Zeek
vectordata type.- Parameters
empty_field (
bytesorstr, optional) – Placeholder for empty field.unset_field (
bytesorstr, optional) – Placeholder for unset field.set_separator (
bytesorstr, optional) – Separator forset/vectorfields.element_type (
BaseTypeinstance) – Data type of container’s elements.*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
- Variables
- Raises
ZeekTypeError – If
element_typeis not supplied.ZeekValueError – If
element_typeis not a valid Bro/Zeek data type.
Example
As a generic data type, the class supports the typing proxy as introduced PEP 484:
>>> VectorType[StringType]
which is the same at runtime as following:
>>> VectorType(element_type=StringType())
Note
A valid
element_typeshould be a simple data type, i.e. a subclass of_SimpleType.-
parse(data)[source]¶ Parse
datafrom string.- Parameters
data (Union[AnyStr, List[_S]]) – raw data
- Return type
Optional[List[_S]]
- Returns
The parsed list data. If
datais unset,Nonewill be returned.
-
class
zlogging.types._GenericType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types.BaseTypeGeneric data type.
In Bro/Zeek script language, such generic type includes
setandvector, which are also known as container types.
-
class
zlogging.types._SimpleType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types.BaseTypeSimple data type.
In Bro/Zeek script language, such simple type includes
bool,count,int,double,time,interval,string,addr,port,subnetandenum.To support arbitrary typing as required in
JSONParser,any, the arbitrary date type is also included.
-
class
zlogging.types._VariadicType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types.BaseTypeVariadic data type.
In Bro/Zeek script language, such variadic type refers to
record, which is also a container type.-
element_mapping: OrderedDict[str, Union[_SimpleType, _GenericType]]¶
-
parse(data)[source]¶ Not supported for a variadic data type.
- Parameters
data (Any) – data to process
- Raises
ZeekNotImplemented – If try to call such method.
- Return type
NoReturn
-
tojson(data)[source]¶ Not supported for a variadic data type.
- Parameters
data (Any) – data to process
- Raises
ZeekNotImplemented – If try to call such method.
- Return type
NoReturn
-
toascii(data)[source]¶ Not supported for a variadic data type.
- Parameters
data (Any) – data to process
- Raises
ZeekNotImplemented – If try to call such method.
- Return type
NoReturn
-
Abstract Base Types¶
-
class
zlogging.types.BaseType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
objectBase Bro/Zeek data type.
- Parameters
- Variables
-
__call__(data)[source]¶ Parse
datafrom string.This is a proxy method which calls to
parse()of the type implementation.- Return type
- Parameters
data (Any) –
-
class
zlogging.types._SimpleType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types.BaseTypeSimple data type.
In Bro/Zeek script language, such simple type includes
bool,count,int,double,time,interval,string,addr,port,subnetandenum.To support arbitrary typing as required in
JSONParser,any, the arbitrary date type is also included.
-
class
zlogging.types._GenericType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types.BaseTypeGeneric data type.
In Bro/Zeek script language, such generic type includes
setandvector, which are also known as container types.
-
class
zlogging.types._VariadicType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶ Bases:
zlogging.types.BaseTypeVariadic data type.
In Bro/Zeek script language, such variadic type refers to
record, which is also a container type.-
element_mapping: OrderedDict[str, Union[_SimpleType, _GenericType]]¶
-
parse(data)[source]¶ Not supported for a variadic data type.
- Parameters
data (Any) – data to process
- Raises
ZeekNotImplemented – If try to call such method.
- Return type
NoReturn
-
tojson(data)[source]¶ Not supported for a variadic data type.
- Parameters
data (Any) – data to process
- Raises
ZeekNotImplemented – If try to call such method.
- Return type
NoReturn
-
toascii(data)[source]¶ Not supported for a variadic data type.
- Parameters
data (Any) – data to process
- Raises
ZeekNotImplemented – If try to call such method.
- Return type
NoReturn
-