Skip to content

local_network.py

Configuration objects built around the networks.cfg

To import...

from dynamite_nsm.services.base.config_objects.zeek import local_network as zeek_config_local_network

LocalNetwork

__init__(self, ip_and_cidr, description=None) special

A local network denoted by a IP/CIDR

Parameters:

Name Type Description Default
ip_and_cidr str

An IP/CIDR string representing a local network.

required
description Optional[str]

A description of that network's purpose

None
Source code in dynamite_nsm/services/base/config_objects/zeek/local_network.py
def __init__(self, ip_and_cidr: str, description: Optional[str] = None):
    """A local network denoted by a IP/CIDR
    Args:
        ip_and_cidr: An IP/CIDR string representing a local network.
        description: A description of that network's purpose
    """
    self.ip_and_cidr = ip_and_cidr
    self.description = description

get_raw(self)

Get a raw representation of this LocalNetwork

Returns:

Type Description
str

An assignment statement that can be inserted directly into Zeek's networks.cfg

Source code in dynamite_nsm/services/base/config_objects/zeek/local_network.py
def get_raw(self) -> str:
    """Get a raw representation of this LocalNetwork
    Returns:
        An assignment statement that can be inserted directly into Zeek's networks.cfg
    """
    if self.description:
        return '{0: <64} {1}\n'.format(self.ip_and_cidr, self.description)
    return '{0: <64} {1}\n'.format(self.ip_and_cidr, 'Undocumented Network')

LocalNetworks

__init__(self, local_networks=None) special

A collection of LocalNetworks

Parameters:

Name Type Description Default
local_networks Optional[List[dynamite_nsm.services.base.config_objects.zeek.local_network.LocalNetwork]]

A collection of LocalNetwork objects

None
Source code in dynamite_nsm/services/base/config_objects/zeek/local_network.py
def __init__(self, local_networks: Optional[List[LocalNetwork]] = None):
    """A collection of LocalNetworks
    Args:
        local_networks: A collection of LocalNetwork objects
    """
    super().__init__('ip_and_cidr', local_networks)
    self.local_networks = self.items
    self._idx = 0

get_raw(self)

Get a list of LocalNetworks that can be inserted directly into the network.cfg file

Returns:

Type Description
List[str]

A list of local network assignments

Source code in dynamite_nsm/services/base/config_objects/zeek/local_network.py
def get_raw(self) -> List[str]:
    """Get a list of LocalNetworks that can be inserted directly into the network.cfg file
    Returns:
        A list of local network assignments
    """
    return [local_network.get_raw() for local_network in self.local_networks]