colander_data_converter.converters.threatr.mapping
- class colander_data_converter.converters.threatr.mapping.ThreatrMapper[source]
Bases:
object
Base class for mapping between Threatr and Colander data using the mapping file.
This abstract base class provides common functionality for all Threatr to Colander mappers. It initializes the mapping loader and provides access to the mapping data that defines how different data formats should be converted between the two systems.
- mapping_loader
Instance of ThreatrMappingLoader for accessing mapping data
- Type:
Note
This is a base class that should be subclassed by specific mapper implementations. The mapping data is loaded once and shared across all mapper instances.
Example
>>> class CustomMapper(ThreatrMapper): ... def __init__(self): ... super().__init__() ... >>> mapper = CustomMapper() >>> hasattr(mapper, 'mapping_loader') True
- class colander_data_converter.converters.threatr.mapping.ThreatrMappingLoader[source]
Bases:
object
Loads and provides access to the Threatr to Colander mapping data.
This class is responsible for loading the mapping configuration from a JSON file that defines how Threatr entities, events, and relations should be converted to their Colander equivalents. The mapping data includes field mappings, type conversions, and relationship definitions.
Note
The mapping data is loaded once during initialization and cached for subsequent use.
- mapping_data
The loaded mapping data
- Type:
List[Dict[str
,Any]]
Example
>>> loader = ThreatrMappingLoader() >>> mappings = loader.mapping_data >>> isinstance(mappings, list) True
- __init__()[source]
Initialize the mapping loader and load the mapping data.
- Raises:
ValueError – If the mapping file cannot be found or parsed