from typing import Literal
from octopoes.models import OOI, Reference
from octopoes.models.persistence import ReferenceField
[docs]
class Software(OOI):
object_type: Literal["Software"] = "Software"
name: str
version: str | None = None
cpe: str | None = None
_natural_key_attrs = ["name", "version", "cpe"]
_information_value = ["name"]
_traversable = False
[docs]
class SoftwareInstance(OOI):
object_type: Literal["SoftwareInstance"] = "SoftwareInstance"
ooi: Reference = ReferenceField(OOI, max_issue_scan_level=0, max_inherit_scan_level=1)
software: Reference = ReferenceField(Software, max_issue_scan_level=1, max_inherit_scan_level=0)
_natural_key_attrs = ["ooi", "software"]
_reverse_relation_names = {"ooi": "software_instances", "software": "instances"}
# PK example: SoftwareInstance|IPAddressV4|internet|1.1.1.1|Software|apache|1.0|apache:/a.2.1./asd/
@property
def natural_key(self) -> str:
return f"{self.ooi}|{self.software}"