openc2lib.profiles.slpf.profile

StateLess Packet Filter profile

This modules contains the definition of the slpf profile. It is mostly used as a container for the namespace identifier.

 1""" StateLess Packet Filter profile
 2
 3	This modules contains the definition of the `slpf` profile. It is mostly used as a container
 4	for the namespace identifier.
 5"""
 6from openc2lib import Profile, Map
 7
 8from openc2lib.profiles.slpf.nsid import nsid, name
 9
10""" SLPF profile
11
12	Creates the `slpf` profile. This structure follows the definition of the Actuator in
13	the Command message. 
14"""
15class slpf(Profile, Map):
16	fieldtypes = dict(hostname=str, named_group=str, asset_id=str, asset_tuple = [str])
17	""" Selectors for Actuator
18
19		Fields that may be specified to select the specific Actuator implementation.
20		Usage of these fields is described by the SLPF Specification (Sec. 2.1.4), but their actual
21		meaning and usage is up the the `Actuator` implementation.
22
23		The extension mechanism is described in the 
24		[Developing extensions](https://github.com/mattereppe/openc2lib/blob/main/docs/developingextensions.md#developing-extensions) Section of the main documentation.
25
26		:param hostname: [RFC1123] hostname (can be a domain name or IP address) 
27			for a particular device with SLPF functionality.
28		:param named_group: User defined collection of devices with SLPF functionality.
29		:param asset_id: Unique identifier for a particular SLPF.
30		:param asset_tuple: Unique tuple identifier for a particular SLPF consisting 
31			of a list of up to 10 strings.
32	"""
33
34	def __init__(self, dic):
35		""" Initialize the profile
36
37			The profile can be initialized by passing the internal fields explicitely 
38			(i.e., by giving them as ***key=value*** pair.
39			:param dic: A list of ***key=value*** pair which allowed values are given
40				by `fieldtype`.
41		"""
42		Profile.__init__(self, nsid, name)
43		Map.__init__(self, dic)
44	
45	def __str__(self):
46		id = self.nsid + '('
47		for k,v in self.items():
48			id += str(k) + ':' + str(v) + ','
49		id = id.strip(',')
50		id += ')'
51		return id
16class slpf(Profile, Map):
17	fieldtypes = dict(hostname=str, named_group=str, asset_id=str, asset_tuple = [str])
18	""" Selectors for Actuator
19
20		Fields that may be specified to select the specific Actuator implementation.
21		Usage of these fields is described by the SLPF Specification (Sec. 2.1.4), but their actual
22		meaning and usage is up the the `Actuator` implementation.
23
24		The extension mechanism is described in the 
25		[Developing extensions](https://github.com/mattereppe/openc2lib/blob/main/docs/developingextensions.md#developing-extensions) Section of the main documentation.
26
27		:param hostname: [RFC1123] hostname (can be a domain name or IP address) 
28			for a particular device with SLPF functionality.
29		:param named_group: User defined collection of devices with SLPF functionality.
30		:param asset_id: Unique identifier for a particular SLPF.
31		:param asset_tuple: Unique tuple identifier for a particular SLPF consisting 
32			of a list of up to 10 strings.
33	"""
34
35	def __init__(self, dic):
36		""" Initialize the profile
37
38			The profile can be initialized by passing the internal fields explicitely 
39			(i.e., by giving them as ***key=value*** pair.
40			:param dic: A list of ***key=value*** pair which allowed values are given
41				by `fieldtype`.
42		"""
43		Profile.__init__(self, nsid, name)
44		Map.__init__(self, dic)
45	
46	def __str__(self):
47		id = self.nsid + '('
48		for k,v in self.items():
49			id += str(k) + ':' + str(v) + ','
50		id = id.strip(',')
51		id += ')'
52		return id

OpenC2 Profile

This is the openc2lib interpretation of the Profile concept. It basically defines a Profile namespace and the language extensions that are defined for that namespace.

A Profile is fully transparent to concrete implementation for controlling specific security functions, which in openc2lib terminology is named Actuator.

Each Profile defined for openc2lib must inherit from this class.

slpf(dic)
35	def __init__(self, dic):
36		""" Initialize the profile
37
38			The profile can be initialized by passing the internal fields explicitely 
39			(i.e., by giving them as ***key=value*** pair.
40			:param dic: A list of ***key=value*** pair which allowed values are given
41				by `fieldtype`.
42		"""
43		Profile.__init__(self, nsid, name)
44		Map.__init__(self, dic)

Initialize the profile

The profile can be initialized by passing the internal fields explicitely (i.e., by giving them as key=value pair.

Parameters
  • dic: A list of key=value pair which allowed values are given by fieldtype.
fieldtypes = {'hostname': <class 'str'>, 'named_group': <class 'str'>, 'asset_id': <class 'str'>, 'asset_tuple': [<class 'str'>]}

Selectors for Actuator

Fields that may be specified to select the specific Actuator implementation. Usage of these fields is described by the SLPF Specification (Sec. 2.1.4), but their actual meaning and usage is up the the Actuator implementation.

The extension mechanism is described in the Developing extensions Section of the main documentation.

Parameters
  • hostname: [RFC1123] hostname (can be a domain name or IP address) for a particular device with SLPF functionality.
  • named_group: User defined collection of devices with SLPF functionality.
  • asset_id: Unique identifier for a particular SLPF.
  • asset_tuple: Unique tuple identifier for a particular SLPF consisting of a list of up to 10 strings.
Inherited Members
openc2lib.core.profile.Profile
nsid
name
openc2lib.types.basetypes.Map
extend
regext
todict
fromdict
builtins.dict
get
setdefault
pop
popitem
keys
items
values
update
fromkeys
clear
copy