Data Types¶
Bro/Zeek Types¶
Boolean¶
- class zlogging.types.BoolType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
bool
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
Numeric Types¶
- class zlogging.types.CountType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
count
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
- class zlogging.types.IntType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
int
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
- class zlogging.types.DoubleType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
double
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
Time Types¶
- class zlogging.types.TimeType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
time
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
- class zlogging.types.IntervalType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
interval
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
- Variables:
String¶
- class zlogging.types.StringType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
string
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
Network Types¶
- class zlogging.types.PortType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
port
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
- class zlogging.types.AddrType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
addr
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
- parse(data)[source]¶
Parse
data
from string.- Parameters:
data (
Union
[str
,bytes
,IPv4Address
,IPv6Address
]) – raw data- Return type:
- Returns:
The parsed IP address. If
data
is unset,None
will be returned.
- tojson(data)[source]¶
Serialize
data
as JSON log format.- Parameters:
data (
Union
[IPv4Address
,IPv6Address
,None
]) – raw data- Returns:
The JSON serialisable IP address string.
- Return type:
- toascii(data)[source]¶
Serialize
data
as ASCII log format.- Parameters:
data (
Union
[IPv4Address
,IPv6Address
,None
]) – raw data- Returns:
The ASCII representation of the IP address.
- Return type:
- class zlogging.types.SubnetType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
subnet
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
- parse(data)[source]¶
Parse
data
from string.- Parameters:
data (
Union
[str
,bytes
,IPv4Network
,IPv6Network
]) – raw data- Return type:
- Returns:
The parsed IP network. If
data
is unset,None
will be returned.
- tojson(data)[source]¶
Serialize
data
as JSON log format.- Parameters:
data (
Union
[IPv4Network
,IPv6Network
,None
]) – raw data- Returns:
The JSON serialisable IP network string.
- Return type:
- toascii(data)[source]¶
Serialize
data
as ASCII log format.- Parameters:
data (
Union
[IPv4Network
,IPv6Network
,None
]) – raw data- Returns:
The ASCII representation of the IP network.
- Return type:
Enumeration¶
- class zlogging.types.EnumType(empty_field=None, unset_field=None, set_separator=None, namespaces=None, bare=False, enum_hook=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
enum
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.bare (
bool
) – IfTrue
, do not loadzeek
namespace by default.enum_hook (
Optional
[dict
[str
,Enum
]]) – Additional enum to be included in the namespace.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
Container Types¶
- class zlogging.types.SetType(empty_field=None, unset_field=None, set_separator=None, element_type=None, *args, **kwargs)[source]¶
Bases:
_GenericType
,Generic
[_S
]Bro/Zeek
set
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.element_type (
Union
[TypeVar
(_S
, bound= _SimpleType),Type
[TypeVar
(_S
, bound= _SimpleType)],None
]) – Data type of container’s elements.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
- Raises:
ZeekTypeError – If
element_type
is not supplied.ZeekValueError – If
element_type
is 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_type
should be a simple data type, i.e. a subclass of_SimpleType
.
- class zlogging.types.VectorType(empty_field=None, unset_field=None, set_separator=None, element_type=None, *args, **kwargs)[source]¶
Bases:
_GenericType
,Generic
[_S
]Bro/Zeek
vector
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.element_type (
Union
[TypeVar
(_S
, bound= _SimpleType),Type
[TypeVar
(_S
, bound= _SimpleType)],None
]) – Data type of container’s elements.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
- Raises:
ZeekTypeError – If
element_type
is not supplied.ZeekValueError – If
element_type
is 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_type
should be a simple data type, i.e. a subclass of_SimpleType
.
- class zlogging.types.RecordType(empty_field=None, unset_field=None, set_separator=None, *args, **element_mapping)[source]¶
Bases:
_VariadicType
Bro/Zeek
record
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.element_mapping (
Union
[Type
[_SimpleType
],_SimpleType
,_GenericType
]) – Data type of container’s elements.*args (Any) – Arbitrary positional arguments.
**kwargs (Any) – Arbitrary keyword arguments.
- Raises:
ZeekTypeError – If
element_mapping
is not supplied.ZeekValueError – If
element_mapping
is not a valid Bro/Zeek data type; or in case of inconsistency fromempty_field
,unset_field
andset_separator
of each field.
- Return type:
Note
A valid
element_mapping
should be a simple or generic data type, i.e. a subclass of_SimpleType
or_GenericType
.See also
See
_aux_expand_typing()
for more information about processing the fields.
Any type¶
- class zlogging.types.AnyType(empty_field=None, unset_field=None, set_separator=None, json_encoder=None, *args, **kwargs)[source]¶
Bases:
_SimpleType
Bro/Zeek
any
data type.- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.json_encoder (
Optional
[Type
[JSONEncoder
]]) – JSON encoder class fortojson()
method calls.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
Note
The
AnyType
is only used for arbitrary typing as required inJSONParser
. It is NOT a valid type of Bro/Zeek logging framework.
Abstract Base Types¶
- class zlogging.types.BaseType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
object
Base Bro/Zeek data type.
- Parameters:
empty_field (
Union
[str
,bytes
,None
]) – Placeholder for empty field.unset_field (
Union
[str
,bytes
,None
]) – Placeholder for unset field.set_separator (
Union
[str
,bytes
,None
]) – Separator forset
/vector
fields.*args (
Any
) – Arbitrary positional arguments.**kwargs (
Any
) – Arbitrary keyword arguments.
- __call__(data)[source]¶
Parse
data
from string.This is a proxy method which calls to
parse()
of the type implementation.
- class zlogging.types._SimpleType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
BaseType
Simple data type.
In Bro/Zeek script language, such simple type includes
bool
,count
,int
,double
,time
,interval
,string
,addr
,port
,subnet
andenum
.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]¶
-
Generic data type.
In Bro/Zeek script language, such generic type includes
set
andvector
, which are also known as container types.
- class zlogging.types._VariadicType(empty_field=None, unset_field=None, set_separator=None, *args, **kwargs)[source]¶
Bases:
BaseType
Variadic 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
]]¶ Data type of container’s elements.
-
element_mapping: