colander_data_converter.formats.threatr package
colander_data_converter.formats.threatr.models module
- pydantic model colander_data_converter.formats.threatr.models.Entity[source]
Bases:
ThreatrType
Represents an entity in the Threatr data model.
Show JSON schema
{ "title": "Entity", "description": "Represents an entity in the Threatr data model.", "type": "object", "properties": { "id": { "format": "uuid4", "title": "Id", "type": "string" }, "created_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Created At" }, "updated_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Updated At" }, "name": { "maxLength": 512, "minLength": 1, "title": "Name", "type": "string" }, "type": { "$ref": "#/$defs/CommonEntityType" }, "super_type": { "$ref": "#/$defs/CommonEntitySuperType" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "pap": { "$ref": "#/$defs/TlpPapLevel", "default": "WHITE" }, "source_url": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Source Url" }, "tlp": { "$ref": "#/$defs/TlpPapLevel", "default": "WHITE" }, "attributes": { "anyOf": [ { "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Attributes" } }, "$defs": { "CommonEntitySuperType": { "description": "CommonEntitySuperType defines metadata for a super type of entities in the Colander data model.\n\nThis class is used to represent high-level categories of entities (such as Actor, Artifact, Device, etc.)\nand provides fields for the short name, display name, associated types, and the Python class implementing the entity.", "properties": { "short_name": { "maxLength": 32, "title": "Short Name", "type": "string" }, "name": { "maxLength": 512, "title": "Name", "type": "string" }, "types": { "anyOf": [ { "items": {}, "type": "array" }, { "type": "null" } ], "default": null, "title": "Types" } }, "required": [ "short_name", "name" ], "title": "CommonEntitySuperType", "type": "object" }, "CommonEntityType": { "description": "CommonEntityType is an abstract base class for defining shared attributes across various entity data types.\n\nThis class provides fields for identifiers, names, descriptions, and other metadata.", "properties": { "short_name": { "maxLength": 32, "title": "Short Name", "type": "string" }, "name": { "maxLength": 512, "title": "Name", "type": "string" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "svg_icon": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Svg Icon" }, "nf_icon": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Nf Icon" }, "stix2_type": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Type" }, "stix2_value_field_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Value Field Name" }, "stix2_pattern": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Pattern" }, "stix2_pattern_type": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Pattern Type" }, "default_attributes": { "anyOf": [ { "additionalProperties": { "type": "string" }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Default Attributes" }, "type_hints": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "default": null, "title": "Type Hints" } }, "required": [ "short_name", "name" ], "title": "CommonEntityType", "type": "object" }, "TlpPapLevel": { "description": "TlpPapLevel represents the Traffic Light Protocol (TLP) and Permissible Actions Protocol (PAP) levels.\n\nThese levels are used to classify the sensitivity of information and its sharing restrictions.\n\nExample:\n >>> level = TlpPapLevel.RED\n >>> print(level)\n RED", "enum": [ "RED", "AMBER", "GREEN", "WHITE" ], "title": "TlpPapLevel", "type": "string" } }, "required": [ "name", "type", "super_type" ] }
- Config:
str_strip_whitespace: bool = True
arbitrary_types_allowed: bool = True
- Fields:
- field attributes: Dict[str, str | None] | None = None
Optional dictionary of additional attributes.
- field created_at: datetime | None = None
The timestamp when the entity was created.
- field description: str | None = None
A description of the entity.
- field id: Annotated[UUID, UuidVersion(uuid_version=4)] [Optional]
The unique identifier for the entity.
- Constraints:
uuid_version = 4
- field name: str [Required]
The name of the entity.
- Constraints:
min_length = 1
max_length = 512
- field pap: TlpPapLevel = TlpPapLevel.WHITE
The PAP (Permissible Actions Protocol) level for the entity.
- field source_url: str | None = None
Optional source URL for the entity.
- field super_type: CommonEntitySuperType [Required]
The super type of the entity such as observable or event.
- field tlp: TlpPapLevel = TlpPapLevel.WHITE
The TLP (Traffic Light Protocol) level for the entity.
- field type: CommonEntityType [Required]
The type of the entity such as IP v4 address.
- field updated_at: datetime | None = None
The timestamp when the entity was last updated.
- pydantic model colander_data_converter.formats.threatr.models.EntityRelation[source]
Bases:
ThreatrType
Represents a relation between two entities in the Threatr data model.
Show JSON schema
{ "title": "EntityRelation", "description": "Represents a relation between two entities in the Threatr data model.", "type": "object", "properties": { "id": { "format": "uuid4", "title": "Id", "type": "string" }, "created_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Created At" }, "updated_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Updated At" }, "name": { "maxLength": 512, "minLength": 1, "title": "Name", "type": "string" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "attributes": { "anyOf": [ { "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Attributes" }, "obj_from": { "anyOf": [ { "$ref": "#/$defs/Entity" }, { "$ref": "#/$defs/ObjectReference" } ], "title": "Obj From" }, "obj_to": { "anyOf": [ { "$ref": "#/$defs/Entity" }, { "$ref": "#/$defs/ObjectReference" } ], "title": "Obj To" } }, "$defs": { "CommonEntitySuperType": { "description": "CommonEntitySuperType defines metadata for a super type of entities in the Colander data model.\n\nThis class is used to represent high-level categories of entities (such as Actor, Artifact, Device, etc.)\nand provides fields for the short name, display name, associated types, and the Python class implementing the entity.", "properties": { "short_name": { "maxLength": 32, "title": "Short Name", "type": "string" }, "name": { "maxLength": 512, "title": "Name", "type": "string" }, "types": { "anyOf": [ { "items": {}, "type": "array" }, { "type": "null" } ], "default": null, "title": "Types" } }, "required": [ "short_name", "name" ], "title": "CommonEntitySuperType", "type": "object" }, "CommonEntityType": { "description": "CommonEntityType is an abstract base class for defining shared attributes across various entity data types.\n\nThis class provides fields for identifiers, names, descriptions, and other metadata.", "properties": { "short_name": { "maxLength": 32, "title": "Short Name", "type": "string" }, "name": { "maxLength": 512, "title": "Name", "type": "string" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "svg_icon": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Svg Icon" }, "nf_icon": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Nf Icon" }, "stix2_type": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Type" }, "stix2_value_field_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Value Field Name" }, "stix2_pattern": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Pattern" }, "stix2_pattern_type": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Pattern Type" }, "default_attributes": { "anyOf": [ { "additionalProperties": { "type": "string" }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Default Attributes" }, "type_hints": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "default": null, "title": "Type Hints" } }, "required": [ "short_name", "name" ], "title": "CommonEntityType", "type": "object" }, "Entity": { "description": "Represents an entity in the Threatr data model.", "properties": { "id": { "format": "uuid4", "title": "Id", "type": "string" }, "created_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Created At" }, "updated_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Updated At" }, "name": { "maxLength": 512, "minLength": 1, "title": "Name", "type": "string" }, "type": { "$ref": "#/$defs/CommonEntityType" }, "super_type": { "$ref": "#/$defs/CommonEntitySuperType" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "pap": { "$ref": "#/$defs/TlpPapLevel", "default": "WHITE" }, "source_url": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Source Url" }, "tlp": { "$ref": "#/$defs/TlpPapLevel", "default": "WHITE" }, "attributes": { "anyOf": [ { "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Attributes" } }, "required": [ "name", "type", "super_type" ], "title": "Entity", "type": "object" }, "ObjectReference": { "format": "uuid4", "type": "string" }, "TlpPapLevel": { "description": "TlpPapLevel represents the Traffic Light Protocol (TLP) and Permissible Actions Protocol (PAP) levels.\n\nThese levels are used to classify the sensitivity of information and its sharing restrictions.\n\nExample:\n >>> level = TlpPapLevel.RED\n >>> print(level)\n RED", "enum": [ "RED", "AMBER", "GREEN", "WHITE" ], "title": "TlpPapLevel", "type": "string" } }, "required": [ "name", "obj_from", "obj_to" ] }
- Config:
str_strip_whitespace: bool = True
arbitrary_types_allowed: bool = True
- Fields:
- field attributes: Dict[str, str | None] | None = None
Optional dictionary of additional attributes for the relation.
- field created_at: datetime | None = None
The timestamp when the entity relation was created.
- field description: str | None = None
A description of the entity.
- field id: Annotated[UUID, UuidVersion(uuid_version=4)] [Optional]
The unique identifier for the entity relation.
- Constraints:
uuid_version = 4
- field name: str [Required]
The name of the entity relation.
- Constraints:
min_length = 1
max_length = 512
- field obj_from: Entity | ObjectReference [Required]
The source entity or reference in the relation.
- field updated_at: datetime | None = None
The timestamp when the entity relation was last updated.
- pydantic model colander_data_converter.formats.threatr.models.Event[source]
Bases:
ThreatrType
Represents an event in the Threatr data model.
Show JSON schema
{ "title": "Event", "description": "Represents an event in the Threatr data model.", "type": "object", "properties": { "id": { "format": "uuid4", "title": "Id", "type": "string" }, "created_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Created At" }, "updated_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Updated At" }, "name": { "maxLength": 512, "minLength": 1, "title": "Name", "type": "string" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "attributes": { "anyOf": [ { "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Attributes" }, "first_seen": { "default": "2025-07-15T16:35:28.900945Z", "format": "date-time", "title": "First Seen", "type": "string" }, "last_seen": { "default": "2025-07-15T16:35:28.900948Z", "format": "date-time", "title": "Last Seen", "type": "string" }, "count": { "default": 1, "exclusiveMinimum": 0, "title": "Count", "type": "integer" }, "involved_entity": { "anyOf": [ { "$ref": "#/$defs/Entity" }, { "$ref": "#/$defs/ObjectReference" }, { "type": "null" } ], "default": null, "title": "Involved Entity" } }, "$defs": { "CommonEntitySuperType": { "description": "CommonEntitySuperType defines metadata for a super type of entities in the Colander data model.\n\nThis class is used to represent high-level categories of entities (such as Actor, Artifact, Device, etc.)\nand provides fields for the short name, display name, associated types, and the Python class implementing the entity.", "properties": { "short_name": { "maxLength": 32, "title": "Short Name", "type": "string" }, "name": { "maxLength": 512, "title": "Name", "type": "string" }, "types": { "anyOf": [ { "items": {}, "type": "array" }, { "type": "null" } ], "default": null, "title": "Types" } }, "required": [ "short_name", "name" ], "title": "CommonEntitySuperType", "type": "object" }, "CommonEntityType": { "description": "CommonEntityType is an abstract base class for defining shared attributes across various entity data types.\n\nThis class provides fields for identifiers, names, descriptions, and other metadata.", "properties": { "short_name": { "maxLength": 32, "title": "Short Name", "type": "string" }, "name": { "maxLength": 512, "title": "Name", "type": "string" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "svg_icon": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Svg Icon" }, "nf_icon": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Nf Icon" }, "stix2_type": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Type" }, "stix2_value_field_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Value Field Name" }, "stix2_pattern": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Pattern" }, "stix2_pattern_type": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Pattern Type" }, "default_attributes": { "anyOf": [ { "additionalProperties": { "type": "string" }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Default Attributes" }, "type_hints": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "default": null, "title": "Type Hints" } }, "required": [ "short_name", "name" ], "title": "CommonEntityType", "type": "object" }, "Entity": { "description": "Represents an entity in the Threatr data model.", "properties": { "id": { "format": "uuid4", "title": "Id", "type": "string" }, "created_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Created At" }, "updated_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Updated At" }, "name": { "maxLength": 512, "minLength": 1, "title": "Name", "type": "string" }, "type": { "$ref": "#/$defs/CommonEntityType" }, "super_type": { "$ref": "#/$defs/CommonEntitySuperType" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "pap": { "$ref": "#/$defs/TlpPapLevel", "default": "WHITE" }, "source_url": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Source Url" }, "tlp": { "$ref": "#/$defs/TlpPapLevel", "default": "WHITE" }, "attributes": { "anyOf": [ { "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Attributes" } }, "required": [ "name", "type", "super_type" ], "title": "Entity", "type": "object" }, "ObjectReference": { "format": "uuid4", "type": "string" }, "TlpPapLevel": { "description": "TlpPapLevel represents the Traffic Light Protocol (TLP) and Permissible Actions Protocol (PAP) levels.\n\nThese levels are used to classify the sensitivity of information and its sharing restrictions.\n\nExample:\n >>> level = TlpPapLevel.RED\n >>> print(level)\n RED", "enum": [ "RED", "AMBER", "GREEN", "WHITE" ], "title": "TlpPapLevel", "type": "string" } }, "required": [ "name" ] }
- Config:
str_strip_whitespace: bool = True
arbitrary_types_allowed: bool = True
- Fields:
- Validators:
_check_dates
»all fields
- field attributes: Dict[str, str | None] | None = None
Optional dictionary of additional attributes for the relation.
- Validated by:
_check_dates
- field count: Annotated[int, Gt(gt=0)] = 1
The number of times this event was observed.
- Constraints:
gt = 0
- Validated by:
_check_dates
- field created_at: datetime | None = None
The timestamp when the entity relation was created.
- Validated by:
_check_dates
- field description: str | None = None
A description of the entity.
- Validated by:
_check_dates
- field first_seen: datetime = datetime.datetime(2025, 7, 15, 16, 35, 28, 900945, tzinfo=datetime.timezone.utc)
The timestamp when the event was first observed.
- Validated by:
_check_dates
- field id: Annotated[UUID, UuidVersion(uuid_version=4)] [Optional]
The unique identifier for the entity relation.
- Constraints:
uuid_version = 4
- Validated by:
_check_dates
- field involved_entity: Entity | None | ObjectReference = None
List of entities or references involved in this event.
- Validated by:
_check_dates
- field last_seen: datetime = datetime.datetime(2025, 7, 15, 16, 35, 28, 900948, tzinfo=datetime.timezone.utc)
The timestamp when the event was last observed.
- Validated by:
_check_dates
- field name: str [Required]
The name of the entity relation.
- Constraints:
min_length = 1
max_length = 512
- Validated by:
_check_dates
- field updated_at: datetime | None = None
The timestamp when the entity relation was last updated.
- Validated by:
_check_dates
- pydantic model colander_data_converter.formats.threatr.models.ThreatrFeed[source]
Bases:
ThreatrType
Represents a feed of Threatr data, including entities, relations, and events.
Show JSON schema
{ "title": "ThreatrFeed", "description": "Represents a feed of Threatr data, including entities, relations, and events.", "type": "object", "properties": { "root_entity": { "$ref": "#/$defs/Entity" }, "entities": { "anyOf": [ { "items": { "$ref": "#/$defs/Entity" }, "type": "array" }, { "type": "null" } ], "default": [], "title": "Entities" }, "relations": { "anyOf": [ { "items": { "$ref": "#/$defs/EntityRelation" }, "type": "array" }, { "type": "null" } ], "default": [], "title": "Relations" }, "events": { "anyOf": [ { "items": { "$ref": "#/$defs/Event" }, "type": "array" }, { "type": "null" } ], "default": [], "title": "Events" } }, "$defs": { "CommonEntitySuperType": { "description": "CommonEntitySuperType defines metadata for a super type of entities in the Colander data model.\n\nThis class is used to represent high-level categories of entities (such as Actor, Artifact, Device, etc.)\nand provides fields for the short name, display name, associated types, and the Python class implementing the entity.", "properties": { "short_name": { "maxLength": 32, "title": "Short Name", "type": "string" }, "name": { "maxLength": 512, "title": "Name", "type": "string" }, "types": { "anyOf": [ { "items": {}, "type": "array" }, { "type": "null" } ], "default": null, "title": "Types" } }, "required": [ "short_name", "name" ], "title": "CommonEntitySuperType", "type": "object" }, "CommonEntityType": { "description": "CommonEntityType is an abstract base class for defining shared attributes across various entity data types.\n\nThis class provides fields for identifiers, names, descriptions, and other metadata.", "properties": { "short_name": { "maxLength": 32, "title": "Short Name", "type": "string" }, "name": { "maxLength": 512, "title": "Name", "type": "string" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "svg_icon": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Svg Icon" }, "nf_icon": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Nf Icon" }, "stix2_type": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Type" }, "stix2_value_field_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Value Field Name" }, "stix2_pattern": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Pattern" }, "stix2_pattern_type": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stix2 Pattern Type" }, "default_attributes": { "anyOf": [ { "additionalProperties": { "type": "string" }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Default Attributes" }, "type_hints": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "default": null, "title": "Type Hints" } }, "required": [ "short_name", "name" ], "title": "CommonEntityType", "type": "object" }, "Entity": { "description": "Represents an entity in the Threatr data model.", "properties": { "id": { "format": "uuid4", "title": "Id", "type": "string" }, "created_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Created At" }, "updated_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Updated At" }, "name": { "maxLength": 512, "minLength": 1, "title": "Name", "type": "string" }, "type": { "$ref": "#/$defs/CommonEntityType" }, "super_type": { "$ref": "#/$defs/CommonEntitySuperType" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "pap": { "$ref": "#/$defs/TlpPapLevel", "default": "WHITE" }, "source_url": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Source Url" }, "tlp": { "$ref": "#/$defs/TlpPapLevel", "default": "WHITE" }, "attributes": { "anyOf": [ { "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Attributes" } }, "required": [ "name", "type", "super_type" ], "title": "Entity", "type": "object" }, "EntityRelation": { "description": "Represents a relation between two entities in the Threatr data model.", "properties": { "id": { "format": "uuid4", "title": "Id", "type": "string" }, "created_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Created At" }, "updated_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Updated At" }, "name": { "maxLength": 512, "minLength": 1, "title": "Name", "type": "string" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "attributes": { "anyOf": [ { "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Attributes" }, "obj_from": { "anyOf": [ { "$ref": "#/$defs/Entity" }, { "$ref": "#/$defs/ObjectReference" } ], "title": "Obj From" }, "obj_to": { "anyOf": [ { "$ref": "#/$defs/Entity" }, { "$ref": "#/$defs/ObjectReference" } ], "title": "Obj To" } }, "required": [ "name", "obj_from", "obj_to" ], "title": "EntityRelation", "type": "object" }, "Event": { "description": "Represents an event in the Threatr data model.", "properties": { "id": { "format": "uuid4", "title": "Id", "type": "string" }, "created_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Created At" }, "updated_at": { "anyOf": [ { "format": "date-time", "type": "string" }, { "type": "null" } ], "default": null, "title": "Updated At" }, "name": { "maxLength": 512, "minLength": 1, "title": "Name", "type": "string" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "attributes": { "anyOf": [ { "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }, "type": "object" }, { "type": "null" } ], "default": null, "title": "Attributes" }, "first_seen": { "default": "2025-07-15T16:35:28.900945Z", "format": "date-time", "title": "First Seen", "type": "string" }, "last_seen": { "default": "2025-07-15T16:35:28.900948Z", "format": "date-time", "title": "Last Seen", "type": "string" }, "count": { "default": 1, "exclusiveMinimum": 0, "title": "Count", "type": "integer" }, "involved_entity": { "anyOf": [ { "$ref": "#/$defs/Entity" }, { "$ref": "#/$defs/ObjectReference" }, { "type": "null" } ], "default": null, "title": "Involved Entity" } }, "required": [ "name" ], "title": "Event", "type": "object" }, "ObjectReference": { "format": "uuid4", "type": "string" }, "TlpPapLevel": { "description": "TlpPapLevel represents the Traffic Light Protocol (TLP) and Permissible Actions Protocol (PAP) levels.\n\nThese levels are used to classify the sensitivity of information and its sharing restrictions.\n\nExample:\n >>> level = TlpPapLevel.RED\n >>> print(level)\n RED", "enum": [ "RED", "AMBER", "GREEN", "WHITE" ], "title": "TlpPapLevel", "type": "string" } }, "required": [ "root_entity" ] }
- Config:
str_strip_whitespace: bool = True
arbitrary_types_allowed: bool = True
- Fields:
entities (List[colander_data_converter.formats.threatr.models.Entity] | None)
events (List[colander_data_converter.formats.threatr.models.Event] | None)
relations (List[colander_data_converter.formats.threatr.models.EntityRelation] | None)
root_entity (colander_data_converter.formats.threatr.models.Entity)
- field relations: List[EntityRelation] | None = []
List of entity relations objects.
- field root_entity: Entity [Required]
The root entity of the feed. It corresponds to the entity that has been requested.
- static load(raw_object: Dict[str, Entity | Event | EntityRelation], strict: bool = False) ThreatrFeed [source]
Loads a ThreatrFeed from a raw object dictionary, resolving references.
- Parameters:
raw_object (Dict[str, Union[Entity, Event, EntityRelation]]) – The raw data to validate and load.
strict (bool) – If True, raises a ValueError when a UUID reference cannot be resolved. If False, unresolved references remain as UUIDs.
- Returns:
The loaded and reference-resolved feed.
- Return type:
- resolve_references(strict=False)[source]
Resolves references within entities, relations, and events.
Iterates over each entity, relation, and event within the respective collections, calling their resolve_references method to update them with any referenced data. This helps in synchronizing internal state with external dependencies or updates.
- Parameters:
strict (bool) – If True, raises a ValueError when a UUID reference cannot be resolved. If False, unresolved references remain as UUIDs.
- unlink_references() None [source]
Unlinks references from all entities, relations, and events within the current context.
This method iterates through each entity, event, and relation in the respective lists, invoking their unlink_references() methods to replace object references with UUIDs. This operation is useful for breaking dependencies or preparing data for serialization.
- class colander_data_converter.formats.threatr.models.ThreatrRepository(*args, **kwargs)[source]
Bases:
object
Singleton repository for managing and storing Entity, Event, and EntityRelation objects.
This class provides centralized storage and reference management for all model instances, supporting insertion, lookup, and reference resolution/unlinking.
- relations: Dict[str, EntityRelation]
- pydantic model colander_data_converter.formats.threatr.models.ThreatrType[source]
Bases:
BaseModel
Base model for Threatr objects, providing repository registration and reference management.
This class ensures that all subclasses are registered in the ThreatrRepository and provides methods to unlink and resolve object references for serialization and deserialization.
Show JSON schema
{ "title": "ThreatrType", "description": "Base model for Threatr objects, providing repository registration and reference management.\n\nThis class ensures that all subclasses are registered in the ThreatrRepository and provides\nmethods to unlink and resolve object references for serialization and deserialization.", "type": "object", "properties": {} }
- Config:
str_strip_whitespace: bool = True
arbitrary_types_allowed: bool = True
- model_post_init(_ThreatrType__context)[source]
Executes post-initialization logic for the model, ensuring the repository registers the current subclass instance.
- Parameters:
__context (Any) – Additional context provided for post-initialization handling.
- resolve_references(strict=False)[source]
Resolves references for the fields in the object’s model. Fields annotated with ObjectReference or List[ObjectReference] are processed to fetch and replace their UUID references with respective entities using the ThreatrRepository.
This method updates the object in-place.
- Parameters:
strict (bool) – If True, raises a ValueError when a UUID reference cannot be resolved. If False, unresolved references remain as UUIDs.
- Raises:
ValueError – If strict is True and a UUID reference cannot be resolved.
- unlink_references()[source]
Unlinks object references by replacing them with their respective UUIDs.
This method updates the model fields of the class instance where fields annotated as ObjectReference or List[ObjectReference] exist. It replaces the references (of type objects) with their UUIDs if they exist.
For fields of type ObjectReference, the method retrieves the field’s value and replaces it with its id (UUID) if the current value is not already a UUID.
For fields of type List[ObjectReference], the method iterates through the list and replaces each object reference with its id (UUID) if the current value is not already a UUID. The field value is updated only if at least one replacement occurs.
- Raises:
AttributeError – If the class instance does not have the expected field or attribute.