openc2lib.types.targets.file
1from openc2lib.types.base import Map 2from openc2lib.types.data import Hashes 3from openc2lib.core.target import target 4 5@target('file') 6class File(Map): 7 """ OpenC2 File 8 9 Implements the `file` target (Section 3.4.1.6). 10 Properties of a file. A "File" Target MUST contain at least one property. 11 12 """ 13 fields = {'name': str, 'path': str, 'hashes': Hashes} 14 """ 15 Internal class members are just provided as reference for valid fields and to map their name 16 to the expected type. They shall not be instantiated or used directly. 17 `name`: The name of the file as defined in the file system 18 `path`: The absolute path to the location of the file in the file system 19 `hashes`: One or more cryptographic hash codes of the file contents 20 """ 21 22 def __init__(self, file: dict): 23 super().__init__(file) 24 # Explicit control on each field is carried out to manage the possibility of wrong 25 # inputs or inputs defined by extensions 26 for x in self.keys(): 27 if x in self.fields: 28 return 29 raise ValueError("A 'File' Target MUST contain at least one property.")
6@target('file') 7class File(Map): 8 """ OpenC2 File 9 10 Implements the `file` target (Section 3.4.1.6). 11 Properties of a file. A "File" Target MUST contain at least one property. 12 13 """ 14 fields = {'name': str, 'path': str, 'hashes': Hashes} 15 """ 16 Internal class members are just provided as reference for valid fields and to map their name 17 to the expected type. They shall not be instantiated or used directly. 18 `name`: The name of the file as defined in the file system 19 `path`: The absolute path to the location of the file in the file system 20 `hashes`: One or more cryptographic hash codes of the file contents 21 """ 22 23 def __init__(self, file: dict): 24 super().__init__(file) 25 # Explicit control on each field is carried out to manage the possibility of wrong 26 # inputs or inputs defined by extensions 27 for x in self.keys(): 28 if x in self.fields: 29 return 30 raise ValueError("A 'File' Target MUST contain at least one property.")
OpenC2 File
Implements the file target (Section 3.4.1.6).
Properties of a file. A "File" Target MUST contain at least one property.
fields =
{'name': <class 'str'>, 'path': <class 'str'>, 'hashes': <class 'openc2lib.types.data.hashes.Hashes'>}
Internal class members are just provided as reference for valid fields and to map their name
to the expected type. They shall not be instantiated or used directly.
name: The name of the file as defined in the file system
path: The absolute path to the location of the file in the file system
hashes: One or more cryptographic hash codes of the file contents
Inherited Members
- builtins.dict
- get
- setdefault
- pop
- popitem
- keys
- items
- values
- update
- fromkeys
- clear
- copy