#! /usr/bin/env python3
#
-# Generated Python bindings from a SHACL model
-#
-# This file was automatically generated by shacl2code. DO NOT MANUALLY MODIFY IT
+# This file was auto-generated by shacl2code 1.0.0. DO NOT MANUALLY MODIFY IT
#
# SPDX-License-Identifier: MIT
+"""Generated Python bindings from a SHACL model"""
+
+from __future__ import annotations
+import decimal
import functools
import hashlib
import json
import sys
import threading
import time
+import warnings
+from abc import ABC, abstractmethod
from contextlib import contextmanager
-from datetime import datetime, timezone, timedelta
+from dataclasses import dataclass
+from datetime import datetime, timedelta, timezone
from enum import Enum
-from abc import ABC, abstractmethod
-
-
-def check_type(obj, types):
+from typing import Generic, TYPE_CHECKING, TypeVar, Union, cast, overload
+
+if TYPE_CHECKING:
+ from typing import (
+ Any,
+ BinaryIO,
+ Callable,
+ Dict,
+ Iterable,
+ Iterator,
+ List,
+ Optional,
+ Set,
+ Tuple,
+ Type,
+ )
+
+T_PropV = TypeVar("T_PropV")
+
+
+def check_type(obj: Any, types: Union[Type[Any], Tuple[Type[Any], ...]]) -> None:
+ """Check if an object is an instance of a type or one of types.
+ Raise a TypeError if not."""
if not isinstance(obj, types):
if isinstance(types, (list, tuple)):
raise TypeError(
- f"Value must be one of type: {', '.join(t.__name__ for t in types)}. Got {type(obj)}"
+ f"Value must be one of type: {', '.join(t.__name__ for t in types)}. Got {type(obj).__name__}"
)
- raise TypeError(f"Value must be of type {types.__name__}. Got {type(obj)}")
+ raise TypeError(
+ f"Value must be of type {types.__name__}. Got {type(obj).__name__}"
+ )
-class Property(ABC):
+class Property(ABC, Generic[T_PropV]):
"""
A generic SHACL object property. The different types will derive from this
class
"""
- def __init__(self, *, pattern=None):
+ VALID_TYPES: Union[Type[Any], Tuple[Type[Any], ...]] = ()
+
+ __slots__ = ("pattern",)
+
+ def __init__(self, *, pattern: Optional[str] = None) -> None:
self.pattern = pattern
- def init(self):
+ def init(self) -> Optional[T_PropV]:
return None
- def validate(self, value):
+ def validate(self, value: Any) -> None:
check_type(value, self.VALID_TYPES)
if self.pattern is not None and not re.search(
self.pattern, self.to_string(value)
f"Value is not correctly formatted. Got '{self.to_string(value)}'"
)
- def set(self, value):
- return value
+ def set(self, value: Any) -> T_PropV:
+ return cast(T_PropV, value)
- def check_min_count(self, value, min_count):
+ def check_min_count(self, value: T_PropV, min_count: int) -> bool:
return min_count == 1
- def check_max_count(self, value, max_count):
+ def check_max_count(self, value: T_PropV, max_count: int) -> bool:
return max_count == 1
- def elide(self, value):
+ def elide(self, value: T_PropV) -> bool:
return value is None
- def walk(self, value, callback, path):
+ def walk(
+ self,
+ value: T_PropV,
+ callback: Callable[[Any, List[str]], bool],
+ path: List[str],
+ ) -> None:
callback(value, path)
- def iter_objects(self, value, recursive, visited):
+ def iter_objects(
+ self, value: Optional[T_PropV], recursive: bool, visited: Set["SHACLObject"]
+ ) -> Iterable["SHACLObject"]:
return []
- def link_prop(self, value, objectset, missing, visited):
+ def link_prop(
+ self,
+ value: Optional[T_PropV],
+ objectset: "SHACLObjectSet",
+ missing: Optional[Set[str]],
+ visited: Set["SHACLObject"],
+ ) -> Optional[T_PropV]:
return value
- def to_string(self, value):
+ def to_string(self, value: T_PropV) -> str:
return str(value)
@abstractmethod
- def encode(self, encoder, value, state):
- pass
+ def encode(self, encoder: "Encoder", value: T_PropV, state: "EncodeState") -> None:
+ raise NotImplementedError("Subclasses must implement encode method")
@abstractmethod
- def decode(self, decoder, *, objectset=None):
- pass
+ def decode(self, decoder: "Decoder", state: "DecodeState") -> Optional[T_PropV]:
+ raise NotImplementedError("Subclasses must implement decode method")
-class StringProp(Property):
+class StringProp(Property[str]):
"""
A scalar string property for an SHACL object
"""
VALID_TYPES = str
- def set(self, value):
+ def set(self, value: Any) -> str:
return str(value)
- def encode(self, encoder, value, state):
+ def encode(self, encoder: Encoder, value: str, state: EncodeState) -> None:
encoder.write_string(value)
- def decode(self, decoder, *, objectset=None):
+ def decode(self, decoder: Decoder, state: DecodeState) -> Optional[str]:
return decoder.read_string()
class AnyURIProp(StringProp):
- def encode(self, encoder, value, state):
+ """A string property whose value is encoded as an IRI rather than a plain string."""
+
+ def encode(self, encoder: Encoder, value: str, state: EncodeState) -> None:
encoder.write_iri(value)
- def decode(self, decoder, *, objectset=None):
+ def decode(self, decoder: Decoder, state: DecodeState) -> Optional[str]:
return decoder.read_iri()
-class DateTimeProp(Property):
+class DateTimeProp(Property[datetime]):
"""
A Date/Time Object with optional timezone
"""
UTC_FORMAT_STR = "%Y-%m-%dT%H:%M:%SZ"
REGEX = r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|[+-]\d{2}:\d{2})?$"
- def set(self, value):
+ __slots__ = ()
+
+ def set(self, value: datetime) -> datetime:
return self._normalize(value)
- def encode(self, encoder, value, state):
+ def encode(self, encoder: Encoder, value: datetime, state: EncodeState) -> None:
encoder.write_datetime(self.to_string(value))
- def decode(self, decoder, *, objectset=None):
+ def decode(self, decoder: Decoder, state: DecodeState) -> Optional[datetime]:
s = decoder.read_datetime()
if s is None:
return None
+ if isinstance(s, datetime):
+ return self._normalize(s)
v = self.from_string(s)
return self._normalize(v)
- def _normalize(self, value):
+ def _normalize(self, value: datetime) -> datetime:
if value.utcoffset() is None:
value = value.astimezone()
+
+ # Remove seconds from timezone offset
+ offset = value.utcoffset()
+ if offset is not None:
+ seconds = offset % timedelta(
+ minutes=-1 if offset.total_seconds() < 0 else 1
+ )
+ if seconds:
+ offset = offset - seconds
+ value = value.replace(tzinfo=timezone(offset))
+
+ # Convert 00:00 timezone offset to UTC
offset = value.utcoffset()
- seconds = offset % timedelta(minutes=-1 if offset.total_seconds() < 0 else 1)
- if seconds:
- offset = offset - seconds
- value = value.replace(tzinfo=timezone(offset))
+ if offset is not None and offset.seconds == 0:
+ value = value.astimezone(timezone.utc)
+
value = value.replace(microsecond=0)
return value
- def to_string(self, value):
+ def to_string(self, value: datetime) -> str:
value = self._normalize(value)
if value.tzinfo == timezone.utc:
return value.strftime(self.UTC_FORMAT_STR)
return value.isoformat()
- def from_string(self, value):
+ def from_string(self, value: str) -> datetime:
if not re.match(self.REGEX, value):
raise ValueError(f"'{value}' is not a correctly formatted datetime")
if "Z" in value:
REGEX = r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|[+-]\d{2}:\d{2})$"
+ __slots__ = ()
+
+
+class IntegerProp(Property[int]):
+ """A scalar integer property for a SHACL object."""
-class IntegerProp(Property):
VALID_TYPES = int
- def set(self, value):
+ __slots__ = ()
+
+ def set(self, value: Any) -> int:
return int(value)
- def encode(self, encoder, value, state):
+ def encode(self, encoder: Encoder, value: int, state: EncodeState) -> None:
encoder.write_integer(value)
- def decode(self, decoder, *, objectset=None):
+ def decode(self, decoder: Decoder, state: DecodeState) -> Optional[int]:
return decoder.read_integer()
class PositiveIntegerProp(IntegerProp):
- def validate(self, value):
+ """An integer property that enforces a minimum value of 1."""
+
+ __slots__ = ()
+
+ def validate(self, value: Any) -> None:
super().validate(value)
if value < 1:
- raise ValueError(f"Value must be >=1. Got {value}")
+ raise ValueError(f"Value must be >= 1. Got {value}")
class NonNegativeIntegerProp(IntegerProp):
- def validate(self, value):
+ """An integer property that enforces a minimum value of 0."""
+
+ __slots__ = ()
+
+ def validate(self, value: Any) -> None:
super().validate(value)
if value < 0:
raise ValueError(f"Value must be >= 0. Got {value}")
-class BooleanProp(Property):
+class BooleanProp(Property[bool]):
+ """A scalar boolean property for a SHACL object."""
+
VALID_TYPES = bool
- def set(self, value):
+ __slots__ = ()
+
+ def set(self, value: Any) -> bool:
return bool(value)
- def encode(self, encoder, value, state):
+ def encode(self, encoder: Encoder, value: bool, state: EncodeState) -> None:
encoder.write_bool(value)
- def decode(self, decoder, *, objectset=None):
+ def decode(self, decoder: Decoder, state: DecodeState) -> Optional[bool]:
return decoder.read_bool()
-class FloatProp(Property):
+class FloatProp(Property[float]):
+ """A scalar floating-point property for a SHACL object."""
+
VALID_TYPES = (float, int)
- def set(self, value):
+ __slots__ = ()
+
+ def set(self, value: Any) -> float:
return float(value)
- def encode(self, encoder, value, state):
+ def encode(
+ self, encoder: Encoder, value: Union[float, int], state: EncodeState
+ ) -> None:
encoder.write_float(value)
- def decode(self, decoder, *, objectset=None):
+ def decode(self, decoder: Decoder, state: DecodeState) -> Optional[float]:
return decoder.read_float()
-class IRIProp(Property):
- def __init__(self, context=[], *, pattern=None):
+class IRIProp(Property[T_PropV]):
+ """A property that holds IRI values with an optional context for compaction and expansion."""
+
+ __slots__ = ("context",)
+
+ def __init__(
+ self,
+ context: Optional[Tuple[Tuple[str, str], ...]] = None,
+ *,
+ pattern: Optional[str] = None,
+ ) -> None:
+ if context is None:
+ context = ()
super().__init__(pattern=pattern)
self.context = context
- def compact(self, value):
+ def compact(self, value: str, dflt: Optional[str] = None) -> Optional[str]:
+ """Return the compact alias for the given IRI, or dflt if not found in context."""
for iri, compact in self.context:
if value == iri:
return compact
- return None
+ return dflt
- def expand(self, value):
+ def expand(self, value: str, dflt: Optional[str] = None) -> Optional[str]:
+ """Return the full IRI for the given compact alias, or dflt if not found in context."""
for iri, compact in self.context:
if value == compact:
return iri
- return None
+ return dflt
- def iri_values(self):
+ def iri_values(self) -> Iterator[str]:
+ """Iterate over all full IRI values defined in the context."""
return (iri for iri, _ in self.context)
-class ObjectProp(IRIProp):
+class ObjectProp(IRIProp[Union[str, "SHACLObject"]]):
"""
A scalar SHACL object property of a SHACL object
"""
- def __init__(self, cls, required, context=[]):
+ __slots__ = ("cls", "required")
+
+ def __init__(
+ self,
+ cls: Type["SHACLObject"],
+ required: bool,
+ context: Optional[Tuple[Tuple[str, str], ...]] = None,
+ ):
super().__init__(context)
self.cls = cls
self.required = required
- def init(self):
- if self.required and not self.cls.IS_ABSTRACT:
- return self.cls()
- return None
-
- def validate(self, value):
+ def validate(self, value: Any) -> None:
check_type(value, (self.cls, str))
- def walk(self, value, callback, path):
+ def set(self, value: Any) -> Union[str, "SHACLObject"]:
+ if isinstance(value, SHACLObject):
+ return value
+ return str(value)
+
+ def walk(
+ self,
+ value: Optional[Union[str, "SHACLObject"]],
+ callback: Callable[[Any, List[str]], bool],
+ path: List[str],
+ ) -> None:
if value is None:
return
else:
callback(value, path)
- def iter_objects(self, value, recursive, visited):
+ def iter_objects(
+ self,
+ value: Optional[Union[str, "SHACLObject"]],
+ recursive: bool,
+ visited: Set["SHACLObject"],
+ ) -> Iterable["SHACLObject"]:
if value is None or isinstance(value, str):
return
for c in value.iter_objects(recursive=True, visited=visited):
yield c
- def encode(self, encoder, value, state):
+ def encode(
+ self, encoder: Encoder, value: Union[str, "SHACLObject"], state: EncodeState
+ ) -> None:
if value is None:
raise ValueError("Object cannot be None")
if isinstance(value, str):
- encoder.write_iri(value, self.compact(value))
+ encoder.write_iri(value, self.compact(value) or state.compact_iri(value))
return
return value.encode(encoder, state)
- def decode(self, decoder, *, objectset=None):
+ def decode(self, decoder: Decoder, state: DecodeState) -> Union[str, "SHACLObject"]:
+ if decoder.is_object():
+ return self.cls.decode(decoder, state)
+
iri = decoder.read_iri()
if iri is None:
- return self.cls.decode(decoder, objectset=objectset)
+ raise TypeError("IRI cannot be None")
- iri = self.expand(iri) or iri
+ iri = self.expand(iri) or state.expand_iri(iri) or iri
- if objectset is None:
+ if state.objectset is None:
return iri
- obj = objectset.find_by_id(iri)
+ obj = state.objectset.find_by_id(iri)
if obj is None:
return iri
self.validate(obj)
return obj
- def link_prop(self, value, objectset, missing, visited):
+ def link_prop(
+ self,
+ value: Optional[Union[str, "SHACLObject"]],
+ objectset: "SHACLObjectSet",
+ missing: Optional[Set[str]],
+ visited: Set["SHACLObject"],
+ ) -> Optional[Union[str, "SHACLObject"]]:
if value is None:
return value
# De-duplicate IDs
if value._id:
- value = objectset.find_by_id(value._id, value)
+ # Since value must be a SHACLObject at this point,
+ # find_by_id will always return a SHACLObject because we pass value as default.
+ # So we can safely cast here to allow subsequent value.link_helper call to work.
+ value = cast("SHACLObject", objectset.find_by_id(value._id, value))
self.validate(value)
value.link_helper(objectset, missing, visited)
return value
-class ListProxy(object):
- def __init__(self, prop, data=None):
+class ListProxy(Generic[T_PropV]):
+ """A type-checked, property-aware list wrapper for multi-valued SHACL properties."""
+
+ __slots__ = ("_data", "_prop")
+
+ def __init__(
+ self, prop: Property[T_PropV], data: Optional[List[T_PropV]] = None
+ ) -> None:
if data is None:
- self.__data = []
+ self._data: List[T_PropV] = []
else:
- self.__data = data
- self.__prop = prop
+ self._data = data
+ self._prop: Property[T_PropV] = prop
- def append(self, value):
- self.__prop.validate(value)
- self.__data.append(self.__prop.set(value))
+ def append(self, value: T_PropV) -> None:
+ self._prop.validate(value)
+ self._data.append(self._prop.set(value))
- def insert(self, idx, value):
- self.__prop.validate(value)
- self.__data.insert(idx, self.__prop.set(value))
+ def insert(self, idx: int, value: T_PropV) -> None:
+ self._prop.validate(value)
+ self._data.insert(idx, self._prop.set(value))
- def extend(self, items):
+ def extend(self, items: Iterable[T_PropV]) -> None:
for i in items:
self.append(i)
- def sort(self, *args, **kwargs):
- self.__data.sort(*args, **kwargs)
+ def sort(self, *args: Any, **kwargs: Any) -> None:
+ self._data.sort(*args, **kwargs)
+
+ @overload
+ def __getitem__(self, key: int) -> T_PropV: ...
+
+ @overload
+ def __getitem__(self, key: slice) -> List[T_PropV]: ...
- def __getitem__(self, key):
- return self.__data[key]
+ def __getitem__(self, key: Union[int, slice]) -> Union[T_PropV, List[T_PropV]]:
+ return self._data[key]
- def __setitem__(self, key, value):
+ @overload
+ def __setitem__(self, key: int, value: T_PropV) -> None: ...
+
+ @overload
+ def __setitem__(self, key: slice, value: Iterable[T_PropV]) -> None: ...
+
+ def __setitem__(
+ self, key: Union[int, slice], value: Union[T_PropV, Iterable[T_PropV]]
+ ) -> None:
if isinstance(key, slice):
- for v in value:
- self.__prop.validate(v)
- self.__data[key] = [self.__prop.set(v) for v in value]
+ val_iter = cast(Iterable[T_PropV], value)
+ for v in val_iter:
+ self._prop.validate(v)
+ self._data[key] = [self._prop.set(v) for v in val_iter]
+ elif isinstance(key, int):
+ self._prop.validate(value)
+ self._data[key] = self._prop.set(value)
else:
- self.__prop.validate(value)
- self.__data[key] = self.__prop.set(value)
+ raise TypeError(
+ f"ListProxy indices must be integers or slices. Got {type(key).__name__}"
+ )
- def __delitem__(self, key):
- del self.__data[key]
+ def __delitem__(self, key: Union[int, slice]) -> None:
+ del self._data[key]
- def __contains__(self, item):
- return item in self.__data
+ def __contains__(self, item: Any) -> bool:
+ return item in self._data
- def __iter__(self):
- return iter(self.__data)
+ def __iter__(self) -> Iterator[T_PropV]:
+ return iter(self._data)
- def __len__(self):
- return len(self.__data)
+ def __len__(self) -> int:
+ return len(self._data)
- def __str__(self):
- return str(self.__data)
+ def __str__(self) -> str:
+ return str(self._data)
- def __repr__(self):
- return repr(self.__data)
+ def __repr__(self) -> str:
+ return repr(self._data)
- def __eq__(self, other):
+ def __eq__(self, other: Any) -> bool:
if isinstance(other, ListProxy):
- return self.__data == other.__data
+ return self._data == other._data
- return self.__data == other
+ return self._data == other
-class ListProp(Property):
+class ListProp(Property[ListProxy[T_PropV]]):
"""
A list of SHACL properties
"""
VALID_TYPES = (list, ListProxy)
- def __init__(self, prop):
+ __slots__ = ("prop",)
+
+ def __init__(self, prop: Property[T_PropV]) -> None:
super().__init__()
self.prop = prop
- def init(self):
+ def init(self) -> ListProxy[T_PropV]:
return ListProxy(self.prop)
- def validate(self, value):
+ def validate(self, value: Any) -> None:
super().validate(value)
for i in value:
self.prop.validate(i)
- def set(self, value):
+ def set(
+ self,
+ value: Union[ListProxy[T_PropV], Iterable[T_PropV]],
+ ) -> ListProxy[T_PropV]:
if isinstance(value, ListProxy):
return value
return ListProxy(self.prop, [self.prop.set(d) for d in value])
- def check_min_count(self, value, min_count):
+ def check_min_count(self, value: ListProxy[T_PropV], min_count: int) -> bool:
check_type(value, ListProxy)
return len(value) >= min_count
- def check_max_count(self, value, max_count):
+ def check_max_count(self, value: ListProxy[T_PropV], max_count: int) -> bool:
check_type(value, ListProxy)
return len(value) <= max_count
- def elide(self, value):
+ def elide(self, value: ListProxy[T_PropV]) -> bool:
check_type(value, ListProxy)
return len(value) == 0
- def walk(self, value, callback, path):
+ def walk(
+ self,
+ value: ListProxy[T_PropV],
+ callback: Callable[[Any, List[str]], bool],
+ path: List[str],
+ ) -> None:
+ if value is None:
+ return
callback(value, path)
for idx, v in enumerate(value):
self.prop.walk(v, callback, path + [f"[{idx}]"])
- def iter_objects(self, value, recursive, visited):
+ def iter_objects(
+ self,
+ value: Optional[ListProxy[T_PropV]],
+ recursive: bool,
+ visited: Set["SHACLObject"],
+ ) -> Iterable[Any]:
+ if value is None:
+ return
for v in value:
for c in self.prop.iter_objects(v, recursive, visited):
yield c
- def link_prop(self, value, objectset, missing, visited):
- if isinstance(value, ListProxy):
- data = [self.prop.link_prop(v, objectset, missing, visited) for v in value]
- else:
- data = [self.prop.link_prop(v, objectset, missing, visited) for v in value]
+ def link_prop(
+ self,
+ value: Optional[ListProxy[T_PropV]],
+ objectset: "SHACLObjectSet",
+ missing: Optional[Set[str]],
+ visited: Set["SHACLObject"],
+ ) -> ListProxy[T_PropV]:
+ if value is None:
+ return ListProxy(self.prop)
+
+ data: List[T_PropV] = [
+ cast(T_PropV, self.prop.link_prop(v, objectset, missing, visited))
+ for v in value
+ ]
return ListProxy(self.prop, data=data)
- def encode(self, encoder, value, state):
+ def encode(
+ self, encoder: Encoder, value: ListProxy[T_PropV], state: EncodeState
+ ) -> None:
check_type(value, ListProxy)
with encoder.write_list() as list_s:
with list_s.write_list_item() as item_s:
self.prop.encode(item_s, v, state)
- def decode(self, decoder, *, objectset=None):
- data = []
+ def decode(self, decoder: Decoder, state: DecodeState) -> ListProxy[T_PropV]:
+ data: List[T_PropV] = []
for val_d in decoder.read_list():
- v = self.prop.decode(val_d, objectset=objectset)
- self.prop.validate(v)
- data.append(v)
+ v = self.prop.decode(val_d, state)
+ if v is not None:
+ self.prop.validate(v)
+ data.append(v)
return ListProxy(self.prop, data=data)
-class EnumProp(IRIProp):
+class EnumProp(IRIProp[str]):
+ """An IRI property restricted to a fixed set of named individual values."""
+
VALID_TYPES = str
- def __init__(self, values, *, pattern=None):
+ __slots__ = ()
+
+ def __init__(
+ self,
+ values: Optional[Tuple[Tuple[str, str], ...]] = None,
+ *,
+ pattern: Optional[str] = None,
+ ) -> None:
super().__init__(values, pattern=pattern)
- def validate(self, value):
+ def validate(self, value: Any) -> None:
super().validate(value)
- valid_values = self.iri_values()
- if value not in valid_values:
+ if value not in self.iri_values():
raise ValueError(
- f"'{value}' is not a valid value. Choose one of {' '.join(valid_values)}"
+ f"'{value}' is not a valid value. Choose one of {' '.join(self.iri_values())}"
)
- def encode(self, encoder, value, state):
+ def encode(self, encoder: Encoder, value: str, state: EncodeState) -> None:
encoder.write_enum(value, self, self.compact(value))
- def decode(self, decoder, *, objectset=None):
+ def decode(self, decoder: Decoder, state: DecodeState) -> str:
v = decoder.read_enum(self)
+ if v is None:
+ raise TypeError("Enum IRI cannot be None")
return self.expand(v) or v
class NodeKind(Enum):
+ """The allowed identifier kind for a SHACL node (blank node, IRI, or either)."""
+
BlankNode = 1
IRI = 2
BlankNodeOrIRI = 3
-def is_IRI(s):
+def is_IRI(s: Any) -> bool:
if not isinstance(s, str):
return False
if s.startswith("_:"):
return True
-def is_blank_node(s):
+def is_blank_node(s: Any) -> bool:
if not isinstance(s, str):
return False
if not s.startswith("_:"):
return True
-def register(type_iri, *, compact_type=None, abstract=False):
- def add_class(key, c):
- assert (
- key not in SHACLObject.CLASSES
- ), f"{key} already registered to {SHACLObject.CLASSES[key].__name__}"
- SHACLObject.CLASSES[key] = c
+# fmt: off
+"""Format Guard"""
+_USE_SLOTS = True
+"""Format Guard"""
+# fmt: on
+
+# After Python 3.10, use slots=True to save a little space
+_DC_KWARGS = {"slots": True} if _USE_SLOTS and sys.version_info >= (3, 10) else {}
+
+
+@dataclass(**_DC_KWARGS)
+class ClassProp:
+ """Descriptor for a single property on a SHACLObject class, holding its IRI, Python name, and constraints."""
+
+ pyname: str
+ reg: Optional[Callable[..., Any]]
+ iri: str
+ min_count: Optional[int] = None
+ max_count: Optional[int] = None
+ compact: Optional[str] = None
+ deprecated: bool = False
+ # For efficiency reasons this should be of type Property (only) but
+ # initialized to None
+ prop: Property = None # type: ignore
+
+
+class SHACLObjectMeta(type):
+ """Metaclass for SHACLObject that processes PROPERTIES, slots, and named individuals at class creation time."""
+
+ def __new__(cls, name, bases, attrs):
+ def check_base_prop(name):
+ return any(hasattr(b, name) or name in b._EXTRA_SLOTS for b in bases)
+
+ is_base = name == "SHACLObject"
+
+ attrs.setdefault("IS_ABSTRACT", False)
+ attrs.setdefault("IS_DEPRECATED", False)
+ attrs.setdefault("NAMED_INDIVIDUALS", {})
+ attrs.setdefault("NODE_KIND", NodeKind.BlankNodeOrIRI)
+ attrs.setdefault("_EXTRA_SLOTS", set())
+ attrs["_EXTRA_SLOTS"] = set(attrs["_EXTRA_SLOTS"])
+
+ py_properties = {}
+ iri_properties = {}
+ compact_properties = {}
+ for p in attrs.get("PROPERTIES", []):
+ if not is_base:
+ for b in bases:
+ if p.pyname in b._OBJ_PY_PROPS or p.pyname in b._EXTRA_SLOTS:
+ raise KeyError(
+ f"'{p.pyname}' is already defined for '{b.__name__}'"
+ )
+ if p.iri in b._OBJ_IRI_PROPS:
+ raise KeyError(
+ f"'{p.iri}' is already defined for '{b.__name__}'"
+ )
+ if p.compact and p.compact in b._OBJ_COMPACT_PROPS:
+ raise KeyError(
+ f"'{p.compact}' is already defined for '{b.__name__}'"
+ )
+
+ if p.pyname in py_properties:
+ raise KeyError(f"'{p.pyname}' is already defined for '{name}'")
+
+ if p.iri in iri_properties:
+ raise KeyError(f"'{p.iri}' is already defined for '{name}'")
+
+ if p.compact and p.compact in compact_properties:
+ raise KeyError(f"'{p.compact}' is already defined for '{name}'")
+
+ while (
+ p.pyname in attrs
+ or p.pyname in attrs["_EXTRA_SLOTS"]
+ or check_base_prop(p.pyname)
+ ):
+ p.pyname = p.pyname + "_"
+
+ if not callable(p.reg):
+ raise ValueError(
+ f"Registration of {name}.{p.pyname} must be a callable to allow deferred class typing. Try: `lambda: ...`"
+ )
+
+ py_properties[p.pyname] = p
+ iri_properties[p.iri] = p
+
+ if p.compact:
+ p.compact = p.compact
+ compact_properties[p.compact] = p
+
+ if _USE_SLOTS:
+ # Assign slots. Note that __slots__ automatically inherits from the
+ # parent, so there is no need to merge in from the parent
+ attrs["__slots__"] = tuple(
+ sorted(
+ set(py_properties.keys())
+ | attrs["_EXTRA_SLOTS"]
+ | set(attrs.get("__slots__", ()))
+ )
+ )
- def decorator(c):
- global NAMED_INDIVIDUALS
+ # Merge in the parent slots so that __setattr__ works properly
+ for b in bases:
+ attrs["_EXTRA_SLOTS"] |= b._EXTRA_SLOTS
+
+ if "PROPERTIES" in attrs:
+ del attrs["PROPERTIES"]
+
+ attrs["_OBJ_PY_PROPS"] = py_properties
+ attrs["_OBJ_IRI_PROPS"] = iri_properties
+ attrs["_OBJ_COMPACT_PROPS"] = compact_properties
+ if not is_base:
+ for b in bases:
+ for k, v in b._OBJ_PY_PROPS.items():
+ attrs["_OBJ_PY_PROPS"][k] = v
+
+ for k, v in b._OBJ_IRI_PROPS.items():
+ attrs["_OBJ_IRI_PROPS"][k] = v
+
+ for k, v in b._OBJ_COMPACT_PROPS.items():
+ attrs["_OBJ_COMPACT_PROPS"][k] = v
+
+ attrs["_IRI"] = {p.pyname: p.iri for p in attrs["_OBJ_PY_PROPS"].values()}
+
+ auto_ni = True
+ if "AUTO_NAMED_INDIVIDUALS" in attrs:
+ auto_ni = attrs["AUTO_NAMED_INDIVIDUALS"]
+ del attrs["AUTO_NAMED_INDIVIDUALS"]
+
+ for k, v in attrs["NAMED_INDIVIDUALS"].items():
+ if auto_ni:
+ if (
+ k in attrs
+ or k in attrs["_EXTRA_SLOTS"]
+ or check_base_prop(k)
+ or k in py_properties
+ ):
+ raise KeyError(
+ f"Named Individual with name '{k}' conflicts with existing property"
+ )
+ attrs[k] = v
- assert issubclass(
- c, SHACLObject
- ), f"{c.__name__} is not derived from SHACLObject"
+ NAMED_INDIVIDUALS.add(v)
- c._OBJ_TYPE = type_iri
- c.IS_ABSTRACT = abstract
- add_class(type_iri, c)
+ attrs["_NEEDS_REG"] = True
- c._OBJ_COMPACT_TYPE = compact_type
- if compact_type:
- add_class(compact_type, c)
+ attrs["_TYPE"] = attrs.pop("TYPE", None)
- NAMED_INDIVIDUALS |= set(c.NAMED_INDIVIDUALS.values())
+ attrs["_COMPACT_TYPE"] = attrs.pop("COMPACT_TYPE", None)
- # Registration is deferred until the first instance of class is created
- # so that it has access to any other defined class
- c._NEEDS_REG = True
- return c
+ return super().__new__(cls, name, bases, attrs)
- return decorator
+ @staticmethod
+ def _add_class(key: str, c: Type[SHACLObject]) -> None:
+ if key in SHACLObject.CLASSES:
+ raise KeyError(
+ f"{key} already registered to {SHACLObject.CLASSES[key].__name__}"
+ )
+ SHACLObject.CLASSES[key] = c
register_lock = threading.Lock()
-NAMED_INDIVIDUALS = set()
+NAMED_INDIVIDUALS: Set[str] = set()
+T_SHACLObject = TypeVar("T_SHACLObject", bound="SHACLObject")
@functools.total_ordering
-class SHACLObject(object):
- CLASSES = {}
+class SHACLObject(metaclass=SHACLObjectMeta):
+ """Base class for all SHACL-defined objects, providing property access, encoding, and decoding."""
+
+ CLASSES: Dict[str, Type] = {}
+
+ # Class properties that can be set in derived classes:
+
+ # A dictionary of Named Individuals. The key is the python name of the
+ # individual and the value is the IRI of the individual (not inherited)
+ NAMED_INDIVIDUALS: Dict[str, str] = {}
+
+ # If True, class member variables will be automatically created for the class
+ # from the NAMED_INDIVIDUALS dictionary
+ # NOTE: This variable is not present in the class
+ AUTO_NAMED_INDIVIDUALS: bool = True
+
+ # The type of ID the object is allowed to have (inherited from parent)
NODE_KIND = NodeKind.BlankNodeOrIRI
- ID_ALIAS = None
- IS_ABSTRACT = True
- def __init__(self, **kwargs):
+ # An alternate IRI for the ID property, besides "@id" (inherited from
+ # parent)
+ ID_ALIAS: Optional[str] = None
+
+ # If True, this class is abstract and cannot be implemented (not inherited
+ # from parent)
+ IS_ABSTRACT: bool = True
+
+ # If True, this class is deprecated and will raise a warning when created
+ # (not inherited from parent)
+ IS_DEPRECATED: bool = False
+
+ # The fully qualified Type IRI for the object. Required
+ # NOTE: This variable is not present in the class. Use get_type() instead
+ TYPE: str = ""
+
+ # The compacted Type IRI of the object. Must match how the TYPE property
+ # would be compacted by the context. Not inherited from parent
+ # NOTE: This variable is not present in the class. Use get_compact_type()
+ # instead
+ COMPACT_TYPE: Optional[str] = None
+
+ # A list of properties for this object. Each entry must be a ClassProp
+ # object. Properties are automatically inherited from parent classes and do
+ # not need to be re-listed here.
+ # NOTE: The variable is not present in the class
+ PROPERTIES = [
+ ClassProp("_id", lambda: StringProp(), "@id"),
+ ]
+
+ # Internal variables
+ _EXTRA_SLOTS: Union[Set[str], Tuple[str, ...]] = (
+ "_extensible",
+ "_metadata",
+ "_birth_index",
+ )
+ _OBJ_PY_PROPS: Dict[str, ClassProp] = {}
+ _OBJ_IRI_PROPS: Dict[str, ClassProp] = {}
+ _OBJ_COMPACT_PROPS: Dict[str, ClassProp] = {}
+ _NEEDS_REG: bool = True
+ _next_birth_index: int = 0
+ _TYPE: str
+ _COMPACT_TYPE: Optional[str]
+ _extensible: Dict[str, Any]
+
+ # Instance variables
+ _id: Optional[str]
+ _metadata: Dict[str, Any]
+
+ def __init_subclass__(cls, **kwargs):
+ def add_class(key: str, c: Type[SHACLObject]) -> None:
+ if key in SHACLObject.CLASSES:
+ raise KeyError(
+ f"{key} already registered to {SHACLObject.CLASSES[key].__name__}"
+ )
+ SHACLObject.CLASSES[key] = c
+
+ super().__init_subclass__(**kwargs)
+ if cls._TYPE:
+ add_class(cls._TYPE, cls)
+
+ if cls._COMPACT_TYPE:
+ add_class(cls._COMPACT_TYPE, cls)
+
+ def __init__(self, **kwargs: Any) -> None:
if self._is_abstract():
raise NotImplementedError(
f"{self.__class__.__name__} is abstract and cannot be implemented"
)
+ if self.__class__.IS_DEPRECATED:
+ warnings.warn(
+ f"{self.__class__.__name__} is deprecated", DeprecationWarning
+ )
+
with register_lock:
cls = self.__class__
if cls._NEEDS_REG:
- cls._OBJ_PROPERTIES = {}
- cls._OBJ_IRIS = {}
- cls._register_props()
+ for p in cls._OBJ_PY_PROPS.values():
+ # Note that since classes share their ClassProp objects
+ # with their parents, the property might have already been
+ # initialized.
+ if p.prop is None and p.reg is not None:
+ reg_callable = p.reg
+ try:
+ p.prop = reg_callable()
+ p.reg = None # type: ignore[assignment]
+ except Exception as e:
+ raise ValueError(
+ f"Registration of {cls.__name__}.{p.pyname} failed: {e}"
+ ) from e
cls._NEEDS_REG = False
- self.__dict__["_obj_data"] = {}
- self.__dict__["_obj_metadata"] = {}
+ self._metadata = {}
+ self._birth_index = SHACLObject._next_birth_index
+ SHACLObject._next_birth_index += 1
- for iri, prop, _, _, _, _ in self.__iter_props():
- self.__dict__["_obj_data"][iri] = prop.init()
+ for p in self._OBJ_PY_PROPS.values():
+ object.__setattr__(self, p.pyname, p.prop.init())
for k, v in kwargs.items():
setattr(self, k, v)
- def _is_abstract(self):
- return self.__class__.IS_ABSTRACT
+ def get_type(self) -> str:
+ """Return the fully qualified IRI type of this object."""
+ return self._TYPE
- @classmethod
- def _register_props(cls):
- cls._add_property("_id", StringProp(), iri="@id")
+ def get_compact_type(self) -> Optional[str]:
+ """Return the compacted type IRI of this object, or None if not defined."""
+ return self._COMPACT_TYPE
- @classmethod
- def _add_property(
- cls,
- pyname,
- prop,
- iri,
- min_count=None,
- max_count=None,
- compact=None,
- ):
- if pyname in cls._OBJ_IRIS:
- raise KeyError(f"'{pyname}' is already defined for '{cls.__name__}'")
- if iri in cls._OBJ_PROPERTIES:
- raise KeyError(f"'{iri}' is already defined for '{cls.__name__}'")
+ def _is_abstract(self) -> bool:
+ return self.__class__.IS_ABSTRACT
- while hasattr(cls, pyname):
- pyname = pyname + "_"
+ def __set(self, p: ClassProp, value: Any) -> None:
+ if p.iri == "@id":
+ if self.NODE_KIND == NodeKind.BlankNode:
+ if not is_blank_node(value):
+ raise ValueError(
+ f"{self.__class__.__name__} ({id(self)}) can only have local reference. Property '{p.iri}' cannot be set to {value!r} and must start with '_:'"
+ )
+ elif self.NODE_KIND == NodeKind.IRI:
+ if not is_IRI(value):
+ raise ValueError(
+ f"{self.__class__.__name__} ({id(self)}) can only have an IRI value. Property '{p.iri}' cannot be set to {value!r}"
+ )
+ else:
+ if not is_blank_node(value) and not is_IRI(value):
+ raise ValueError(
+ f"{self.__class__.__name__} ({id(self)}) Has invalid Property '{p.iri}' {value!r}. Must be a blank node or IRI"
+ )
- pyname = sys.intern(pyname)
- iri = sys.intern(iri)
+ p.prop.validate(value)
+ if p.deprecated:
+ warnings.warn(
+ f"{self.__class__.__name__}.{p.pyname} is deprecated",
+ DeprecationWarning,
+ )
+ object.__setattr__(self, p.pyname, p.prop.set(value))
- cls._OBJ_IRIS[pyname] = iri
- cls._OBJ_PROPERTIES[iri] = (prop, min_count, max_count, pyname, compact)
+ def __del(self, p: ClassProp):
+ object.__setattr__(self, p.pyname, p.prop.init())
- def __setattr__(self, name, value):
+ def __get_attr(self, name: str) -> ClassProp:
if name == self.ID_ALIAS:
- self["@id"] = value
- return
+ name = "_id"
try:
- iri = self._OBJ_IRIS[name]
- self[iri] = value
+ return self._OBJ_PY_PROPS[name]
except KeyError:
raise AttributeError(
f"'{name}' is not a valid property of {self.__class__.__name__}"
)
- def __getattr__(self, name):
- if name in self._OBJ_IRIS:
- return self.__dict__["_obj_data"][self._OBJ_IRIS[name]]
-
- if name == self.ID_ALIAS:
- return self.__dict__["_obj_data"]["@id"]
-
- if name == "_metadata":
- return self.__dict__["_obj_metadata"]
-
- if name == "_IRI":
- return self._OBJ_IRIS
+ def __setattr__(self, name: str, value: Any) -> None:
+ if name in self._EXTRA_SLOTS:
+ object.__setattr__(self, name, value)
+ return
- if name == "TYPE":
- return self.__class__._OBJ_TYPE
+ self.__set(self.__get_attr(name), value)
- if name == "COMPACT_TYPE":
- return self.__class__._OBJ_COMPACT_TYPE
+ def __getattr__(self, name: str) -> Any:
+ if name == self.ID_ALIAS:
+ return self._id
raise AttributeError(
f"'{name}' is not a valid property of {self.__class__.__name__}"
)
- def __delattr__(self, name):
- if name == self.ID_ALIAS:
- del self["@id"]
+ def __delattr__(self, name: str) -> None:
+ if name in self._EXTRA_SLOTS:
+ object.__delattr__(self, name)
return
- try:
- iri = self._OBJ_IRIS[name]
- del self[iri]
- except KeyError:
- raise AttributeError(
- f"'{name}' is not a valid property of {self.__class__.__name__}"
- )
-
- def __get_prop(self, iri):
- if iri not in self._OBJ_PROPERTIES:
- raise KeyError(
- f"'{iri}' is not a valid property of {self.__class__.__name__}"
- )
-
- return self._OBJ_PROPERTIES[iri]
+ self.__del(self.__get_attr(name))
- def __iter_props(self):
- for iri, v in self._OBJ_PROPERTIES.items():
- yield iri, *v
+ def __get_key(self, iri: str) -> ClassProp:
+ return self._OBJ_IRI_PROPS[iri]
- def __getitem__(self, iri):
- return self.__dict__["_obj_data"][iri]
-
- def __setitem__(self, iri, value):
- if iri == "@id":
- if self.NODE_KIND == NodeKind.BlankNode:
- if not is_blank_node(value):
- raise ValueError(
- f"{self.__class__.__name__} ({id(self)}) can only have local reference. Property '{iri}' cannot be set to '{value}' and must start with '_:'"
- )
- elif self.NODE_KIND == NodeKind.IRI:
- if not is_IRI(value):
- raise ValueError(
- f"{self.__class__.__name__} ({id(self)}) can only have an IRI value. Property '{iri}' cannot be set to '{value}'"
- )
- else:
- if not is_blank_node(value) and not is_IRI(value):
- raise ValueError(
- f"{self.__class__.__name__} ({id(self)}) Has invalid Property '{iri}' '{value}'. Must be a blank node or IRI"
- )
+ def __getitem__(self, iri: str) -> Any:
+ return getattr(self, self.__get_key(iri).pyname)
- prop, _, _, _, _ = self.__get_prop(iri)
- prop.validate(value)
- self.__dict__["_obj_data"][iri] = prop.set(value)
+ def __setitem__(self, iri: str, value: Any) -> None:
+ self.__set(self.__get_key(iri), value)
- def __delitem__(self, iri):
- prop, _, _, _, _ = self.__get_prop(iri)
- self.__dict__["_obj_data"][iri] = prop.init()
+ def __delitem__(self, iri: str) -> None:
+ self.__del(self.__get_key(iri))
- def __iter__(self):
- return iter(self._OBJ_PROPERTIES.keys())
+ def __iter__(self) -> Iterator[str]:
+ return iter(self._OBJ_IRI_PROPS.keys())
- def walk(self, callback, path=None):
+ def walk(
+ self,
+ callback: Callable[[Any, List[str]], bool],
+ path: Optional[List[str]] = None,
+ ) -> None:
"""
Walk object tree, invoking the callback for each item
Callback has the form:
- def callback(object, path):
+ def walk_callback(object: Any, path: List[str]) -> bool:
+ ...
"""
if path is None:
path = ["."]
if callback(self, path):
- for iri, prop, _, _, _, _ in self.__iter_props():
- prop.walk(self.__dict__["_obj_data"][iri], callback, path + [f".{iri}"])
+ for p in self._OBJ_PY_PROPS.values():
+ p.prop.walk(getattr(self, p.pyname), callback, path + [f".{p.iri}"])
- def property_keys(self):
- for iri, _, _, _, pyname, compact in self.__iter_props():
- if iri == "@id":
+ def property_keys(self) -> Iterator[Tuple[Optional[str], str, Optional[str]]]:
+ """Yield (python_name, iri, compact_iri) tuples for each property defined on this object."""
+ for p in self._OBJ_PY_PROPS.values():
+ if p.iri == "@id":
compact = self.ID_ALIAS
- yield pyname, iri, compact
+ else:
+ compact = p.compact
+ yield p.pyname, p.iri, compact
- def iter_objects(self, *, recursive=False, visited=None):
+ def iter_objects(
+ self, *, recursive: bool = False, visited: Optional[Set["SHACLObject"]] = None
+ ) -> Iterable["SHACLObject"]:
"""
- Iterate of all objects that are a child of this one
+ Iterate over all objects that are a child of this one
"""
if visited is None:
visited = set()
- for iri, prop, _, _, _, _ in self.__iter_props():
- for c in prop.iter_objects(
- self.__dict__["_obj_data"][iri], recursive=recursive, visited=visited
+ for p in self._OBJ_PY_PROPS.values():
+ for c in p.prop.iter_objects(
+ getattr(self, p.pyname), recursive=recursive, visited=visited
):
yield c
- def encode(self, encoder, state):
- idname = self.ID_ALIAS or self._OBJ_IRIS["_id"]
+ def encode(self, encoder: Encoder, state: EncodeState) -> None:
+ """Encode this object to the given encoder, writing its type, ID, and properties."""
+ idname = self.ID_ALIAS or "@id"
if not self._id and self.NODE_KIND == NodeKind.IRI:
raise ValueError(
f"{self.__class__.__name__} ({id(self)}) must have a IRI for property '{idname}'"
)
+ _id = state.get_object_id(self)
+
if state.is_written(self):
- encoder.write_iri(state.get_object_id(self))
+ encoder.write_iri(_id, state.compact_iri(_id))
return
state.add_written(self)
with encoder.write_object(
- self,
- state.get_object_id(self),
+ self.get_type(),
+ self.get_compact_type() or state.compact_iri(self.get_type()),
+ self.ID_ALIAS,
+ _id,
+ state.compact_iri(_id),
bool(self._id) or state.is_refed(self),
) as obj_s:
self._encode_properties(obj_s, state)
- def _encode_properties(self, encoder, state):
- for iri, prop, min_count, max_count, pyname, compact in self.__iter_props():
- value = self.__dict__["_obj_data"][iri]
- if prop.elide(value):
- if min_count:
+ def _encode_properties(self, encoder: Encoder, state: EncodeState) -> None:
+ for p in self._OBJ_PY_PROPS.values():
+ value = getattr(self, p.pyname)
+ if p.prop.elide(value):
+ if p.min_count:
raise ValueError(
- f"Property '{pyname}' in {self.__class__.__name__} ({id(self)}) is required (currently {value!r})"
+ f"Property '{p.pyname}' in {self.__class__.__name__} ({id(self)}) is required (currently {value!r})"
)
continue
- if min_count is not None:
- if not prop.check_min_count(value, min_count):
+ if p.min_count is not None:
+ if not p.prop.check_min_count(value, p.min_count):
raise ValueError(
- f"Property '{pyname}' in {self.__class__.__name__} ({id(self)}) requires a minimum of {min_count} elements"
+ f"Property '{p.pyname}' in {self.__class__.__name__} ({id(self)}) requires a minimum of {p.min_count} elements"
)
- if max_count is not None:
- if not prop.check_max_count(value, max_count):
+ if p.max_count is not None:
+ if not p.prop.check_max_count(value, p.max_count):
raise ValueError(
- f"Property '{pyname}' in {self.__class__.__name__} ({id(self)}) requires a maximum of {max_count} elements"
+ f"Property '{p.pyname}' in {self.__class__.__name__} ({id(self)}) requires a maximum of {p.max_count} elements"
)
- if iri == self._OBJ_IRIS["_id"]:
+ if p.iri == "@id":
continue
- with encoder.write_property(iri, compact) as prop_s:
- prop.encode(prop_s, value, state)
+ with encoder.write_property(
+ p.iri, p.compact or state.compact_iri(p.iri)
+ ) as prop_s:
+ p.prop.encode(prop_s, value, state)
@classmethod
- def _make_object(cls, typ):
+ def _make_object(cls: Type["SHACLObject"], typ: str) -> "SHACLObject":
if typ not in cls.CLASSES:
raise TypeError(f"Unknown type {typ}")
return cls.CLASSES[typ]()
@classmethod
- def decode(cls, decoder, *, objectset=None):
+ def decode(
+ cls: Type[T_SHACLObject], decoder: Decoder, state: DecodeState
+ ) -> "SHACLObject":
typ, obj_d = decoder.read_object()
if typ is None:
raise TypeError("Unable to determine type for object")
+ typ = state.objectset.expand_iri(typ) or typ
obj = cls._make_object(typ)
- for key in (obj.ID_ALIAS, obj._OBJ_IRIS["_id"]):
- with obj_d.read_property(key) as prop_d:
- if prop_d is None:
- continue
-
- _id = prop_d.read_iri()
- if _id is None:
- raise TypeError(f"Object key '{key}' is the wrong type")
-
- obj._id = _id
- break
+ _id = obj_d.read_object_id(obj.ID_ALIAS)
+ if _id is not None:
+ obj._id = state.expand_iri(_id) or _id
if obj.NODE_KIND == NodeKind.IRI and not obj._id:
raise ValueError("Object is missing required IRI")
- if objectset is not None:
- if obj._id:
- v = objectset.find_by_id(_id)
- if v is not None:
- return v
+ if obj._id:
+ if obj._id in state.read_objs:
+ return state.read_objs[obj._id]
+ state.read_objs[obj._id] = obj
- obj._decode_properties(obj_d, objectset=objectset)
+ obj._decode_properties(obj_d, state)
+
+ if state.objectset is not None:
+ state.objectset.add_index(obj)
- if objectset is not None:
- objectset.add_index(obj)
return obj
- def _decode_properties(self, decoder, objectset=None):
+ def _decode_properties(self, decoder: Decoder, state: DecodeState) -> None:
for key in decoder.object_keys():
- if not self._decode_prop(decoder, key, objectset=objectset):
+ if not self._decode_prop(decoder, key, state):
raise KeyError(f"Unknown property '{key}'")
- def _decode_prop(self, decoder, key, objectset=None):
- if key in (self._OBJ_IRIS["_id"], self.ID_ALIAS):
+ def _decode_prop(self, decoder: Decoder, key: str, state: DecodeState) -> bool:
+ if key in ("@id", self.ID_ALIAS):
return True
- for iri, prop, _, _, _, compact in self.__iter_props():
- if compact == key:
- read_key = compact
- elif iri == key:
- read_key = iri
- else:
- continue
-
- with decoder.read_property(read_key) as prop_d:
- v = prop.decode(prop_d, objectset=objectset)
- prop.validate(v)
- self.__dict__["_obj_data"][iri] = v
- return True
+ expanded_key = state.expand_iri(key)
+ if expanded_key and expanded_key in self._OBJ_IRI_PROPS:
+ p = self._OBJ_IRI_PROPS[expanded_key]
+ elif key in self._OBJ_IRI_PROPS:
+ p = self._OBJ_IRI_PROPS[key]
+ elif key in self._OBJ_COMPACT_PROPS:
+ p = self._OBJ_COMPACT_PROPS[key]
+ else:
+ return False
- return False
+ with decoder.read_property(key) as prop_d:
+ if prop_d is None:
+ raise TypeError(f"Property decoder for key '{key}' cannot be None")
+ v = p.prop.decode(prop_d, state)
+ self.__set(p, v)
+ return True
- def link_helper(self, objectset, missing, visited):
+ def link_helper(
+ self,
+ objectset: SHACLObjectSet,
+ missing: Optional[Set[str]],
+ visited: Set["SHACLObject"],
+ ) -> None:
+ """Resolve string IRI references in this object's properties to actual SHACLObject instances."""
if self in visited:
return
visited.add(self)
- for iri, prop, _, _, _, _ in self.__iter_props():
- self.__dict__["_obj_data"][iri] = prop.link_prop(
- self.__dict__["_obj_data"][iri],
- objectset,
- missing,
- visited,
+ for p in self._OBJ_PY_PROPS.values():
+ object.__setattr__(
+ self,
+ p.pyname,
+ p.prop.link_prop(
+ getattr(self, p.pyname),
+ objectset,
+ missing,
+ visited,
+ ),
)
def __str__(self):
def __eq__(self, other):
return super().__eq__(other)
- def __lt__(self, other):
- def sort_key(obj):
- if isinstance(obj, str):
- return (obj, "", "", "")
- return (
- obj._id or "",
- obj.TYPE,
- getattr(obj, "name", None) or "",
- id(obj),
- )
+ @staticmethod
+ def _sort_key(obj: Any) -> Tuple[str, str, str, int]:
+ if isinstance(obj, str):
+ return (obj, "", "", 0)
+ return (
+ obj._id or "",
+ obj.get_type(),
+ getattr(obj, "name", None) or "",
+ obj._birth_index,
+ )
- return sort_key(self) < sort_key(other)
+ def __lt__(self, other: Any) -> bool:
+ return SHACLObject._sort_key(self) < SHACLObject._sort_key(other)
-class SHACLExtensibleObject(object):
+class SHACLExtensibleObject(SHACLObject):
+ """A SHACLObject that accepts and round-trips arbitrary IRI-keyed extension properties."""
+
CLOSED = False
- def __init__(self, typ=None, **kwargs):
- if typ:
- self.__dict__["_obj_TYPE"] = (typ, None)
- else:
- self.__dict__["_obj_TYPE"] = (self._OBJ_TYPE, self._OBJ_COMPACT_TYPE)
+ def __init__(self, typ: Optional[str] = None, **kwargs: Any) -> None:
+ self._extensible = {
+ "type": typ if typ else self._TYPE,
+ "compact_type": None if typ else self._COMPACT_TYPE,
+ "data": {},
+ }
+
super().__init__(**kwargs)
- def _is_abstract(self):
+ def get_type(self) -> str:
+ """Return the type IRI stored in the extensible data, which may differ from the class TYPE."""
+ return self._extensible["type"]
+
+ def get_compact_type(self) -> Optional[str]:
+ """Return the compacted type IRI from the extensible data, or None if not set."""
+ return self._extensible["compact_type"]
+
+ def _is_abstract(self) -> bool:
# Unknown classes are assumed to not be abstract so that they can be
# deserialized
- typ = self.__dict__["_obj_TYPE"][0]
- if typ in self.__class__.CLASSES:
- return self.__class__.CLASSES[typ].IS_ABSTRACT
+ typ = self.get_type()
+ if typ in SHACLObject.CLASSES:
+ return SHACLObject.CLASSES[typ].IS_ABSTRACT
return False
+ @property
+ def _ext_data(self) -> Dict[str, Any]:
+ return self._extensible["data"]
+
@classmethod
- def _make_object(cls, typ):
+ def _make_object(cls: Type["SHACLExtensibleObject"], typ: str) -> "SHACLObject":
# Check for a known type, and if so, deserialize as that instead
if typ in cls.CLASSES:
return cls.CLASSES[typ]()
obj = cls(typ)
return obj
- def _decode_properties(self, decoder, objectset=None):
+ def _decode_properties(self, decoder: Decoder, state: DecodeState) -> None:
def decode_value(d):
if not d.is_list():
return d.read_value()
return [decode_value(val_d) for val_d in d.read_list()]
if self.CLOSED:
- super()._decode_properties(decoder, objectset=objectset)
+ super()._decode_properties(decoder, state)
return
for key in decoder.object_keys():
- if self._decode_prop(decoder, key, objectset=objectset):
+ if self._decode_prop(decoder, key, state):
continue
- if not is_IRI(key):
+ if key is None:
+ raise KeyError("Property key cannot be None")
+
+ expanded_key = state.expand_iri(key) or key
+
+ if not is_IRI(expanded_key):
raise KeyError(
- f"Extensible object properties must be IRIs. Got '{key}'"
+ f"Extensible object properties must be IRIs. Got '{key}' (expanded to '{expanded_key}')"
)
with decoder.read_property(key) as prop_d:
- self.__dict__["_obj_data"][key] = decode_value(prop_d)
-
- def _encode_properties(self, encoder, state):
- def encode_value(encoder, v):
- if isinstance(v, bool):
- encoder.write_bool(v)
- elif isinstance(v, str):
- encoder.write_string(v)
- elif isinstance(v, int):
- encoder.write_integer(v)
- elif isinstance(v, float):
- encoder.write_float(v)
- elif isinstance(v, list):
- with encoder.write_list() as list_s:
- for i in v:
- with list_s.write_list_item() as item_s:
- encode_value(item_s, i)
- else:
- raise TypeError(
- f"Unsupported serialized type {type(v)} with value '{v}'"
- )
+ self._ext_data[expanded_key] = decode_value(prop_d)
+ def _encode_properties(self, encoder: Encoder, state: EncodeState) -> None:
super()._encode_properties(encoder, state)
if self.CLOSED:
return
- for iri, value in self.__dict__["_obj_data"].items():
- if iri in self._OBJ_PROPERTIES:
+ for iri, value in self._ext_data.items():
+ if iri in self._OBJ_IRI_PROPS:
continue
- with encoder.write_property(iri) as prop_s:
- encode_value(prop_s, value)
+ with encoder.write_property(iri, state.compact_iri(iri)) as prop_s:
+ if isinstance(value, list):
+ v = value
+ else:
+ v = [value]
+ with prop_s.write_list() as list_s:
+ for i in v:
+ with list_s.write_list_item() as item_s:
+ if isinstance(i, bool):
+ item_s.write_bool(i)
+ elif isinstance(i, str):
+ item_s.write_string(i)
+ elif isinstance(i, int):
+ item_s.write_integer(i)
+ elif isinstance(i, float):
+ item_s.write_float(i)
+ else:
+ raise TypeError(
+ f"Unsupported serialized type {type(i)} with value {i!r}"
+ )
+
+ def __getitem__(self, iri: str) -> Any:
+ try:
+ return super().__getitem__(iri)
+ except KeyError:
+ if self.CLOSED:
+ raise
+
+ if not is_IRI(iri):
+ raise KeyError(f"Key '{iri}' must be an IRI")
+ return self._ext_data[iri]
- def __setitem__(self, iri, value):
+ def __setitem__(self, iri: str, value: Any) -> None:
try:
super().__setitem__(iri, value)
+ return
except KeyError:
if self.CLOSED:
raise
- if not is_IRI(iri):
- raise KeyError(f"Key '{iri}' must be an IRI")
- self.__dict__["_obj_data"][iri] = value
+ if not is_IRI(iri):
+ raise KeyError(f"Key '{iri}' must be an IRI")
+ self._ext_data[iri] = value
- def __delitem__(self, iri):
+ def __delitem__(self, iri: str) -> None:
try:
super().__delitem__(iri)
+ return
except KeyError:
if self.CLOSED:
raise
- if not is_IRI(iri):
- raise KeyError(f"Key '{iri}' must be an IRI")
- del self.__dict__["_obj_data"][iri]
-
- def __getattr__(self, name):
- if name == "TYPE":
- return self.__dict__["_obj_TYPE"][0]
- if name == "COMPACT_TYPE":
- return self.__dict__["_obj_TYPE"][1]
- return super().__getattr__(name)
+ if not is_IRI(iri):
+ raise KeyError(f"Key '{iri}' must be an IRI")
+ del self._ext_data[iri]
- def property_keys(self):
- iris = set()
+ def property_keys(self) -> Iterator[Tuple[Optional[str], str, Optional[str]]]:
+ iris: Set[str] = set()
for pyname, iri, compact in super().property_keys():
iris.add(iri)
yield pyname, iri, compact
if self.CLOSED:
return
- for iri in self.__dict__["_obj_data"].keys():
+ for iri in self._ext_data.keys():
if iri not in iris:
yield None, iri, None
class SHACLObjectSet(object):
- def __init__(self, objects=[], *, link=False):
- self.objects = set()
- self.missing_ids = set()
- for o in objects:
- self.objects.add(o)
+ """A collection of SHACLObject instances with indexing, linking, serialization, and query support."""
+
+ def __init__(
+ self, objects: Optional[Iterable[SHACLObject]] = None, *, link: bool = False
+ ) -> None:
+ if objects is None:
+ objects = []
+ self.objects: Set[SHACLObject] = set(objects)
+ self.missing_ids: Set[str] = set()
+ self.obj_by_id: Dict[str, SHACLObject] = {}
+ self.obj_by_type: Dict[str, Set[Tuple[bool, SHACLObject]]] = {}
self.create_index()
+ self.context: Dict[str, str] = {}
if link:
self._link()
- def create_index(self):
+ def create_index(self) -> None:
"""
(re)Create object index
for o in self.foreach():
self.add_index(o)
- def add_index(self, obj):
+ def add_index(self, obj: SHACLObject) -> None:
"""
Add object to index
Adds the object to all appropriate indices
"""
- def reg_type(typ, compact, o, exact):
+ def reg_type(
+ typ: str,
+ compact: Optional[str],
+ o: SHACLObject,
+ exact: bool,
+ ) -> None:
self.obj_by_type.setdefault(typ, set()).add((exact, o))
if compact:
self.obj_by_type.setdefault(compact, set()).add((exact, o))
for typ in SHACLObject.CLASSES.values():
if isinstance(obj, typ):
- reg_type(
- typ._OBJ_TYPE, typ._OBJ_COMPACT_TYPE, obj, obj.__class__ is typ
- )
+ reg_type(typ._TYPE, typ._COMPACT_TYPE, obj, obj.__class__ is typ)
# This covers custom extensions
- reg_type(obj.TYPE, obj.COMPACT_TYPE, obj, True)
+ reg_type(obj.get_type(), obj.get_compact_type(), obj, True)
if not obj._id:
return
self.obj_by_id[obj._id] = obj
- def add(self, obj):
+ def add(self, obj: SHACLObject) -> SHACLObject:
"""
Add object to object set
self.add_index(obj)
return obj
- def update(self, *others):
+ def update(self, *others: Iterable[SHACLObject]) -> None:
"""
Update object set adding all objects in each other iterable
"""
for obj in o:
self.add(obj)
- def __contains__(self, item):
+ def __contains__(self, item: SHACLObject) -> bool:
"""
Returns True if the item is in the object set
"""
return item in self.objects
- def link(self):
+ def link(self) -> Set[str]:
"""
Link object set
self.create_index()
return self._link()
- def _link(self):
- global NAMED_INDIVIDUALS
-
+ def _link(self) -> Set[str]:
self.missing_ids = set()
- visited = set()
-
- new_objects = set()
+ visited: Set[SHACLObject] = set()
+ new_objects: Set[SHACLObject] = set()
for o in self.objects:
if o._id:
- o = self.find_by_id(o._id, o)
+ o = cast(SHACLObject, self.find_by_id(o._id, o))
o.link_helper(self, self.missing_ids, visited)
new_objects.add(o)
self.objects = new_objects
# Remove blank nodes
- obj_by_id = {}
+ obj_by_id: Dict[str, SHACLObject] = {}
for _id, obj in self.obj_by_id.items():
if _id.startswith("_:"):
del obj._id
return self.missing_ids
- def find_by_id(self, _id, default=None):
+ def find_by_id(
+ self, _id: str, default: Optional[SHACLObject] = None
+ ) -> Optional[SHACLObject]:
"""
Find object by ID
return default
return self.obj_by_id[_id]
- def foreach(self):
+ def foreach(self) -> Iterable[SHACLObject]:
"""
Iterate over every object in the object set, and all child objects
"""
for child in o.iter_objects(recursive=True, visited=visited):
yield child
- def foreach_type(self, typ, *, match_subclass=True):
+ @overload
+ def foreach_type(
+ self, typ: str, *, match_subclass: bool = True
+ ) -> Iterator[SHACLObject]: ...
+
+ @overload
+ def foreach_type(
+ self, typ: Type[T_SHACLObject], *, match_subclass: bool = True
+ ) -> Iterator[T_SHACLObject]: ...
+
+ def foreach_type(
+ self, typ: Union[str, Type[T_SHACLObject]], *, match_subclass: bool = True
+ ) -> Iterable[SHACLObject]:
"""
Iterate over each object of a specified type (or subclass there of)
returned
"""
if not isinstance(typ, str):
- if not issubclass(typ, SHACLObject):
+ if not isinstance(typ, type) or not issubclass(typ, SHACLObject):
raise TypeError(f"Type must be derived from SHACLObject, got {typ}")
- typ = typ._OBJ_TYPE
+ # This intermediate step is necessary for pyrefly...
+ typ_class: Type[SHACLObject] = typ
+ typ = typ_class._TYPE
if typ not in self.obj_by_type:
return
for exact, o in self.obj_by_type[typ]:
if match_subclass or exact:
- yield o
+ yield cast(T_SHACLObject, o)
- def merge(self, *objectsets):
+ def merge(self, *objectsets: "SHACLObjectSet") -> "SHACLObjectSet":
"""
Merge object sets
Returns a new object set that is the combination of this object set and
all provided arguments
"""
- new_objects = set()
+ new_objects: Set[SHACLObject] = set()
new_objects |= self.objects
for d in objectsets:
new_objects |= d.objects
return SHACLObjectSet(new_objects, link=True)
- def encode(self, encoder, force_list=False, *, key=None):
+ def inline_blank_nodes(self) -> None:
+ """
+ Removes (inlines) blank node objects from the root object set if they
+ are referenced in only one other location besides the root.
+
+ Deserializers that do not preserve the tree-like structure of the
+ objects (e.g. RDF) should call this to ensure that blank nodes are
+ inline correctly
+ """
+ ref_counts: Dict[SHACLObject, int] = {}
+
+ def walk_callback(value: SHACLObject, path: List[str]) -> bool:
+ if not isinstance(value, SHACLObject):
+ return True
+
+ ref_counts.setdefault(value, 0)
+ ref_counts[value] += 1
+ if ref_counts[value] > 1:
+ return False
+
+ return True
+
+ for o in self.objects:
+ # Note that every object in the root object set gets at least one
+ # reference
+ o.walk(walk_callback)
+
+ new_objects: Set[SHACLObject] = set()
+ for o in self.objects:
+ if is_IRI(o._id):
+ new_objects.add(o)
+ # If the object is a blank node and is only referenced by this
+ # root list and one other location, remove it from the root list
+ #
+ # A count of 1 means the object is only referenced by the root, and
+ # therefore must be kept
+ elif ref_counts[o] != 2:
+ new_objects.add(o)
+
+ self.objects = new_objects
+
+ def encode(
+ self,
+ encoder: Encoder,
+ state: EncodeState,
+ force_list: bool = False,
+ *,
+ key: Optional[Callable[[SHACLObject], Any]] = None,
+ ) -> None:
"""
Serialize a list of objects to a serialization encoder
If force_list is true, a list will always be written using the encoder.
"""
- ref_counts = {}
- state = EncodeState()
-
- def walk_callback(value, path):
- nonlocal state
- nonlocal ref_counts
+ ref_counts: Dict[SHACLObject, int] = {}
+ def walk_callback(value: SHACLObject, path: List[str]) -> bool:
if not isinstance(value, SHACLObject):
return True
# Remove blank node ID for re-assignment
- if value._id and value._id.startswith("_:"):
+ if is_blank_node(value._id):
del value._id
if value._id:
for o in objects:
state.written_objects.add(o)
- with encoder.write_list() as list_s:
+ with encoder.write_object_list() as list_s:
for o in objects:
# Allow this specific object to be written now
state.written_objects.remove(o)
elif objects:
objects[0].encode(encoder, state)
- def decode(self, decoder):
+ def decode(self, decoder: Decoder, state: DecodeState):
+ """Decode objects from the decoder and add them to this set, then link all references."""
self.create_index()
-
for obj_d in decoder.read_list():
- o = SHACLObject.decode(obj_d, objectset=self)
+ o = SHACLExtensibleObject.decode(obj_d, state)
self.objects.add(o)
self._link()
+ def expand_iri(self, iri: str, default: Optional[str] = None) -> Optional[str]:
+ """Expand a compact IRI to a full IRI using the object set's context, or return default."""
+ for k, v in self.context.items():
+ if iri == k:
+ return self.expand_iri(v, v)
+ if iri.startswith(k + ":"):
+ new_iri = v + iri[len(k) + 1 :]
+ return self.expand_iri(new_iri, new_iri)
+ return default
+
+ def compact_iri(self, iri: str, default: Optional[str] = None) -> Optional[str]:
+ """Compact a full IRI to a prefixed short form using the object set's context, or return default."""
+ for k, v in self.context.items():
+ if iri == v:
+ return self.compact_iri(k, k)
+ if iri.startswith(v):
+ new_iri = k + ":" + iri[len(v) :]
+ return self.compact_iri(new_iri, new_iri)
+ return default
+
class EncodeState(object):
- def __init__(self):
- self.ref_objects = set()
- self.written_objects = set()
- self.blank_objects = {}
+ """Tracks per-serialization state: object IDs, reference counts, and write order."""
+
+ def __init__(self, objectset: SHACLObjectSet):
+ self.ref_objects: Set[SHACLObject] = set()
+ self.written_objects: Set[SHACLObject] = set()
+ self.blank_objects: Dict[SHACLObject, str] = {}
+ self.objectset = objectset
- def get_object_id(self, o):
+ def get_object_id(self, o: SHACLObject) -> str:
if o._id:
return o._id
return self.blank_objects[o]
- def is_refed(self, o):
+ def is_refed(self, o: SHACLObject) -> bool:
return o in self.ref_objects
- def add_refed(self, o):
+ def add_refed(self, o: SHACLObject) -> None:
self.ref_objects.add(o)
- def is_written(self, o):
+ def is_written(self, o: SHACLObject) -> bool:
return o in self.written_objects
- def add_written(self, o):
+ def add_written(self, o: SHACLObject) -> None:
self.written_objects.add(o)
+ def expand_iri(self, iri: str, default: Optional[str] = None) -> Optional[str]:
+ if self.objectset:
+ return self.objectset.expand_iri(iri, default)
+ return default
+
+ def compact_iri(self, iri: str, default: Optional[str] = None) -> Optional[str]:
+ if self.objectset:
+ return self.objectset.compact_iri(iri, default)
+ return default
+
+
+class DecodeState(object):
+ """Carries the target SHACLObjectSet and context during a deserialization pass."""
+
+ def __init__(self, objectset: SHACLObjectSet):
+ self.objectset = objectset
+ self.read_objs: Dict[str, SHACLObject] = {}
+
+ def expand_iri(self, iri: str, default: Optional[str] = None) -> Optional[str]:
+ if self.objectset:
+ return self.objectset.expand_iri(iri, default)
+ return default
+
+ def compact_iri(self, iri: str, default: Optional[str] = None) -> Optional[str]:
+ if self.objectset:
+ return self.objectset.compact_iri(iri, default)
+ return default
+
class Decoder(ABC):
+ """Abstract interface for reading typed values and objects from a serialized source."""
+
@abstractmethod
- def read_value(self):
+ def read_value(self) -> Any:
"""
Consume next item
Consumes the next item of any type
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_value method")
@abstractmethod
- def read_string(self):
+ def read_string(self) -> Optional[str]:
"""
Consume the next item as a string.
Returns the string value of the next item, or `None` if the next item
is not a string
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_string method")
@abstractmethod
- def read_datetime(self):
+ def read_datetime(self) -> Optional[str]:
"""
Consumes the next item as a date & time string
implementation can just check if the next item is a string without
worrying about the format
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_datetime method")
@abstractmethod
- def read_integer(self):
+ def read_integer(self) -> Optional[int]:
"""
Consumes the next item as an integer
Returns the integer value of the next item, or `None` if the next item
is not an integer
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_integer method")
@abstractmethod
- def read_iri(self):
+ def read_iri(self) -> Optional[str]:
"""
Consumes the next item as an IRI string
The returned string should be either a fully-qualified IRI, or a blank
node ID
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_iri method")
@abstractmethod
- def read_enum(self, e):
+ def read_enum(self, e) -> Optional[str]:
"""
Consumes the next item as an Enum value string
actually a member of the specified Enum, so the `Decoder` does not need
to check that, but can if it wishes
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_enum method")
@abstractmethod
- def read_bool(self):
+ def read_bool(self) -> Optional[bool]:
"""
Consume the next item as a boolean value
Returns the boolean value of the next item, or `None` if the next item
is not a boolean
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_bool method")
@abstractmethod
- def read_float(self):
+ def read_float(self) -> Optional[float]:
"""
Consume the next item as a float value
Returns the float value of the next item, or `None` if the next item is
not a float
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_float method")
@abstractmethod
- def read_list(self):
+ def read_list(self) -> Iterator["Decoder"]:
"""
Consume the next item as a list generator
generated `Decoder` can be used to read the corresponding item from the
list
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_list method")
@abstractmethod
- def is_list(self):
+ def is_list(self) -> bool:
"""
Checks if the next item is a list
Returns True if the next item is a list, or False if it is a scalar
"""
- pass
+ raise NotImplementedError("Subclasses must implement is_list method")
@abstractmethod
- def read_object(self):
+ def read_object(self) -> Tuple[Any, "Decoder"]:
"""
Consume next item as an object
Properties will be read out of the object using `read_property` and
`read_object_id`
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_object method")
@abstractmethod
@contextmanager
- def read_property(self, key):
+ def read_property(self, key: str) -> Iterator[Optional["Decoder"]]:
"""
Read property from object
value of the property with the given key in current object, or `None`
if the property does not exist in the current object.
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_property method")
+
+ @abstractmethod
+ def is_object(self) -> bool:
+ """
+ Checks if the item is an object
+
+ Returns True if the item is an object, or False if is not
+ """
+ raise NotImplementedError("Subclasses must implement is_object method")
@abstractmethod
- def object_keys(self):
+ def object_keys(self) -> Iterator[str]:
"""
Read property keys from an object
Iterates over all the serialized keys for the current object
"""
- pass
+ raise NotImplementedError("Subclasses must implement object_keys method")
@abstractmethod
- def read_object_id(self, alias=None):
+ def read_object_id(self, alias: Optional[str] = None) -> Optional[Any]:
"""
Read current object ID property
If `alias` is provided, is is a hint as to another name by which the ID
might be found, if the `Decoder` supports aliases for an ID
"""
- pass
+ raise NotImplementedError("Subclasses must implement read_object_id method")
class JSONLDDecoder(Decoder):
- def __init__(self, data, root=False):
+ """Decoder implementation that reads SHACL objects from a parsed JSON-LD data structure."""
+
+ def __init__(self, data: Any, root: bool = False) -> None:
self.data = data
self.root = root
- def read_value(self):
+ def read_value(self) -> Optional[Any]:
if isinstance(self.data, str):
try:
return float(self.data)
pass
return self.data
- def read_string(self):
+ def read_string(self) -> Optional[str]:
if isinstance(self.data, str):
return self.data
return None
- def read_datetime(self):
+ def read_datetime(self) -> Optional[str]:
return self.read_string()
- def read_integer(self):
+ def read_integer(self) -> Optional[int]:
if isinstance(self.data, int):
return self.data
return None
- def read_bool(self):
+ def read_bool(self) -> Optional[bool]:
if isinstance(self.data, bool):
return self.data
return None
- def read_float(self):
+ def read_float(self) -> Optional[float]:
if isinstance(self.data, (int, float, str)):
return float(self.data)
return None
- def read_iri(self):
+ def read_iri(self) -> Optional[str]:
if isinstance(self.data, str):
return self.data
return None
- def read_enum(self, e):
+ def read_enum(self, e) -> Optional[str]:
if isinstance(self.data, str):
return self.data
return None
- def read_list(self):
+ def read_list(self) -> Iterator["JSONLDDecoder"]:
if self.is_list():
for v in self.data:
yield self.__class__(v)
else:
yield self
- def is_list(self):
+ def is_list(self) -> bool:
return isinstance(self.data, (list, tuple, set))
- def __get_value(self, *keys):
+ def __get_value(self, *keys: Optional[str]) -> Optional[Any]:
for k in keys:
if k and k in self.data:
return self.data[k]
return None
@contextmanager
- def read_property(self, key):
+ def read_property(self, key: str) -> Iterator[Optional["JSONLDDecoder"]]:
v = self.__get_value(key)
if v is not None:
yield self.__class__(v)
else:
yield None
- def object_keys(self):
+ def is_object(self) -> bool:
+ return isinstance(self.data, dict)
+
+ def object_keys(self) -> Iterator[str]:
for key in self.data.keys():
if key in ("@type", "type"):
continue
continue
yield key
- def read_object(self):
+ def read_object(self) -> Tuple[Any, "JSONLDDecoder"]:
typ = self.__get_value("@type", "type")
if typ is not None:
return typ, self
return None, self
- def read_object_id(self, alias=None):
+ def read_object_id(self, alias: Optional[str] = None) -> Optional[Any]:
return self.__get_value(alias, "@id")
class JSONLDDeserializer(object):
- def deserialize_data(self, data, objectset: SHACLObjectSet):
- if "@graph" in data:
- h = JSONLDDecoder(data["@graph"], True)
- else:
- h = JSONLDDecoder(data, True)
+ """Deserializes SHACL objects from JSON-LD data or files into a SHACLObjectSet."""
- objectset.decode(h)
+ def deserialize_data(self, data: Any, objectset: SHACLObjectSet) -> None:
+ """Decode SHACL objects from a pre-parsed JSON-LD data structure into the given object set."""
+ h = JSONLDDecoder(data, True)
- def read(self, f, objectset: SHACLObjectSet):
+ with h.read_property("@context") as context_prop:
+ if context_prop:
+ decode_context(context_prop, objectset)
+
+ state = DecodeState(objectset)
+ with h.read_property("@graph") as graph_prop:
+ objectset.decode(graph_prop if graph_prop else h, state)
+
+ def read(self, f: BinaryIO, objectset: SHACLObjectSet) -> None:
+ """Parse a JSON-LD file and deserialize its objects into the given object set."""
data = json.load(f)
self.deserialize_data(data, objectset)
class Encoder(ABC):
+ """Abstract interface for writing typed values and objects to a serialized output."""
+
@abstractmethod
- def write_string(self, v):
+ def write_string(self, v: str) -> None:
"""
Write a string value
Encodes the value as a string in the output
"""
- pass
+ raise NotImplementedError("Subclasses must implement write_string method")
@abstractmethod
- def write_datetime(self, v):
+ def write_datetime(self, v: str) -> None:
"""
Write a date & time string
Note: The provided string is already correctly encoded as an ISO datetime
"""
- pass
+ raise NotImplementedError("Subclasses must implement write_datetime method")
@abstractmethod
- def write_integer(self, v):
+ def write_integer(self, v: int) -> None:
"""
Write an integer value
Encodes the value as an integer in the output
"""
- pass
+ raise NotImplementedError("Subclasses must implement write_integer method")
@abstractmethod
- def write_iri(self, v, compact=None):
+ def write_iri(self, v: str, compact: Optional[str] = None) -> None:
"""
Write IRI
the serialization supports compacted IRIs, it should be preferred to
the full IRI
"""
- pass
+ raise NotImplementedError("Subclasses must implement write_iri method")
@abstractmethod
- def write_enum(self, v, e, compact=None):
+ def write_enum(
+ self, v: str, e: Property[Any], compact: Optional[str] = None
+ ) -> None:
"""
Write enum value IRI
qualified IRI. If `compact` is provided and the serialization supports
compacted IRIs, it should be preferred to the full IRI.
"""
- pass
+ raise NotImplementedError("Subclasses must implement write_enum method")
@abstractmethod
- def write_bool(self, v):
+ def write_bool(self, v: bool) -> None:
"""
Write boolean
Encodes the value as a boolean in the output
"""
- pass
+ raise NotImplementedError("Subclasses must implement write_bool method")
@abstractmethod
- def write_float(self, v):
+ def write_float(self, v: float) -> None:
"""
Write float
Encodes the value as a floating point number in the output
"""
- pass
+ raise NotImplementedError("Subclasses must implement write_float method")
@abstractmethod
@contextmanager
- def write_object(self, o, _id, needs_id):
+ def write_object(
+ self,
+ typ: str,
+ compact_type: Optional[str],
+ id_alias: Optional[str],
+ _id: str,
+ compact_id: Optional[str],
+ needs_id: bool,
+ ) -> Iterator["Encoder"]:
"""
Write object
Properties will be written the object using `write_property`
"""
- pass
+ raise NotImplementedError("Subclasses must implement write_object method")
@abstractmethod
@contextmanager
- def write_property(self, iri, compact=None):
+ def write_property(
+ self, iri: str, compact: Optional[str] = None
+ ) -> Iterator["Encoder"]:
"""
Write object property
the serialization supports compacted IRIs, it should be preferred to
the full IRI.
"""
- pass
+ raise NotImplementedError("Subclasses must implement write_property method")
@abstractmethod
@contextmanager
- def write_list(self):
+ def write_list(self) -> Iterator["Encoder"]:
"""
Write list
Each item of the list will be added using `write_list_item`
"""
- pass
+ raise NotImplementedError("Subclasses must implement write_list method")
@abstractmethod
@contextmanager
- def write_list_item(self):
+ def write_list_item(self) -> Iterator["Encoder"]:
"""
Write list item
A context manager that yields an `Encoder` that can be used to encode
the value for a list item
"""
- pass
+ raise NotImplementedError("Subclasses must implement write_list_item method")
+
+ @abstractmethod
+ @contextmanager
+ def write_object_list(self) -> Iterator["Encoder"]:
+ """
+ Write top level object list
+
+ A context manager that yields an `Encoder` that encodes the top level
+ list of objects.
+
+ Each object in the list will be added using `write_list_item`
+ """
+ raise NotImplementedError("Subclasses must implement write_object_list method")
+
+ @abstractmethod
+ @contextmanager
+ def write_dict(self) -> Iterator["Encoder"]:
+ """
+ Write dict
+
+ A context manager that yields an `Encoder` that can be used to encode a
+ dictionary.
+ """
+ raise NotImplementedError("Subclasses must implement write_dict method")
class JSONLDEncoder(Encoder):
- def __init__(self, data=None):
- self.data = data
+ """Encoder that builds a JSON-LD Python data structure (dicts/lists) for later JSON serialization."""
+
+ def __init__(self, data: Optional[Any] = None) -> None:
+ self.data: Any = data
- def write_string(self, v):
+ def write_string(self, v: str) -> None:
self.data = v
- def write_datetime(self, v):
+ def write_datetime(self, v: str) -> None:
self.data = v
- def write_integer(self, v):
+ def write_integer(self, v: int) -> None:
self.data = v
- def write_iri(self, v, compact=None):
+ def write_iri(self, v: str, compact: Optional[str] = None) -> None:
self.write_string(compact or v)
- def write_enum(self, v, e, compact=None):
+ def write_enum(self, v: str, e: Any, compact: Optional[str] = None) -> None:
self.write_string(compact or v)
- def write_bool(self, v):
+ def write_bool(self, v: bool) -> None:
self.data = v
- def write_float(self, v):
+ def write_float(self, v: float) -> None:
self.data = str(v)
@contextmanager
- def write_property(self, iri, compact=None):
+ def write_property(
+ self, iri: str, compact: Optional[str] = None
+ ) -> Iterator["JSONLDEncoder"]:
s = self.__class__(None)
yield s
if s.data is not None:
+ # within write_object() context, self.data is expected to be a dict
+ if not isinstance(self.data, dict):
+ raise TypeError(
+ "Encoder.write_property used outside of write_object context; encoder.data is not a dict"
+ )
self.data[compact or iri] = s.data
@contextmanager
- def write_object(self, o, _id, needs_id):
- self.data = {
- "type": o.COMPACT_TYPE or o.TYPE,
- }
- if needs_id:
- self.data[o.ID_ALIAS or "@id"] = _id
+ def write_dict(self) -> Iterator["JSONLDEncoder"]:
+ if not self.data:
+ self.data = {}
yield self
@contextmanager
- def write_list(self):
+ def write_object(
+ self,
+ typ: str,
+ compact_type: Optional[str],
+ id_alias: Optional[str],
+ _id: str,
+ compact_id: Optional[str],
+ needs_id: bool,
+ ) -> Iterator["JSONLDEncoder"]:
+ with self.write_dict() as obj_dict:
+ obj_dict.data["type"] = compact_type or typ
+ if needs_id:
+ obj_dict.data[id_alias or "@id"] = compact_id or _id
+ yield obj_dict
+
+ @contextmanager
+ def write_list(self) -> Iterator["JSONLDEncoder"]:
self.data = []
yield self
if not self.data:
self.data = None
@contextmanager
- def write_list_item(self):
+ def write_list_item(self) -> Iterator["JSONLDEncoder"]:
s = self.__class__(None)
yield s
if s.data is not None:
+ if not isinstance(self.data, list):
+ raise TypeError(
+ "Encoder.write_list_item used outside of write_list context; encoder.data is not a list"
+ )
self.data.append(s.data)
+ @contextmanager
+ def write_object_list(self) -> Iterator["JSONLDEncoder"]:
+ with self.write_property("@graph") as graph_prop:
+ with graph_prop.write_list() as graph_list:
+ yield graph_list
+
class JSONLDSerializer(object):
- def __init__(self, **args):
+ """Serializes a SHACLObjectSet to a JSON-LD file or in-memory data structure."""
+
+ def __init__(self, **args: Any) -> None:
self.args = args
def serialize_data(
self,
objectset: SHACLObjectSet,
- force_at_graph=False,
- ):
+ force_at_graph: bool = False,
+ ) -> Any:
+ """Encode the object set to a JSON-LD Python data structure and return it."""
h = JSONLDEncoder()
- objectset.encode(h, force_at_graph)
- data = {}
- if len(CONTEXT_URLS) == 1:
- data["@context"] = CONTEXT_URLS[0]
- elif CONTEXT_URLS:
- data["@context"] = CONTEXT_URLS
-
- if isinstance(h.data, list):
- data["@graph"] = h.data
- else:
- for k, v in h.data.items():
- data[k] = v
-
- return data
+ state = EncodeState(objectset)
+ with h.write_dict() as doc_s:
+ encode_context(doc_s, objectset)
+ objectset.encode(doc_s, state, force_at_graph)
+ return h.data
def write(
self,
objectset: SHACLObjectSet,
- f,
- force_at_graph=False,
+ f: BinaryIO,
+ force_at_graph: bool = False,
**kwargs,
- ):
+ ) -> str:
"""
Write a SHACLObjectSet to a JSON LD file
If force_at_graph is True, a @graph node will always be written
+
+ Note that f should be a file-like object that supports the `write`
+ method, and that opens in binary mode (e.g. `open("file.json", "wb")`).
"""
data = self.serialize_data(objectset, force_at_graph)
sha1 = hashlib.sha1()
for chunk in json.JSONEncoder(**args).iterencode(data):
- chunk = chunk.encode("utf-8")
- f.write(chunk)
- sha1.update(chunk)
+ chunk_bytes = chunk.encode("utf-8")
+ f.write(chunk_bytes)
+ sha1.update(chunk_bytes)
return sha1.hexdigest()
class JSONLDInlineEncoder(Encoder):
- def __init__(self, f, sha1):
- self.f = f
- self.comma = False
- self.sha1 = sha1
+ """Encoder that writes JSON-LD output directly to a binary file stream, computing a SHA-1 hash."""
- def write(self, s):
- s = s.encode("utf-8")
- self.f.write(s)
- self.sha1.update(s)
+ def __init__(self, f: BinaryIO, sha1: Any, in_dict: bool = False) -> None:
+ self.f: BinaryIO = f
+ self.comma: bool = False
+ self.sha1: Any = sha1
+ self.in_dict: bool = in_dict
- def _write_comma(self):
+ def write(self, s: str) -> None:
+ """Write a raw string to the output stream and update the SHA-1 hash."""
+ b = s.encode("utf-8")
+ self.f.write(b)
+ self.sha1.update(b)
+
+ def _write_comma(self) -> None:
if self.comma:
self.write(",")
self.comma = False
- def write_string(self, v):
+ def write_string(self, v: str) -> None:
self.write(json.dumps(v))
- def write_datetime(self, v):
+ def write_datetime(self, v: str) -> None:
self.write_string(v)
- def write_integer(self, v):
+ def write_integer(self, v: int) -> None:
self.write(f"{v}")
- def write_iri(self, v, compact=None):
+ def write_iri(self, v: str, compact: Optional[str] = None) -> None:
self.write_string(compact or v)
- def write_enum(self, v, e, compact=None):
+ def write_enum(self, v: str, e: Any, compact: Optional[str] = None) -> None:
self.write_iri(v, compact)
- def write_bool(self, v):
+ def write_bool(self, v: bool) -> None:
if v:
self.write("true")
else:
self.write("false")
- def write_float(self, v):
+ def write_float(self, v: float) -> None:
self.write(json.dumps(str(v)))
@contextmanager
- def write_property(self, iri, compact=None):
+ def write_property(
+ self, iri: str, compact: Optional[str] = None
+ ) -> Iterator["JSONLDInlineEncoder"]:
self._write_comma()
self.write_string(compact or iri)
self.write(":")
- yield self
+ yield self.__class__(self.f, self.sha1)
self.comma = True
@contextmanager
- def write_object(self, o, _id, needs_id):
+ def write_dict(self) -> Iterator["JSONLDInlineEncoder"]:
self._write_comma()
+ if self.in_dict:
+ yield self
+ return
self.write("{")
- self.write_string("type")
- self.write(":")
- self.write_string(o.COMPACT_TYPE or o.TYPE)
- self.comma = True
-
- if needs_id:
- self._write_comma()
- self.write_string(o.ID_ALIAS or "@id")
- self.write(":")
- self.write_string(_id)
- self.comma = True
-
- self.comma = True
- yield self
-
+ yield self.__class__(self.f, self.sha1, True)
self.write("}")
self.comma = True
@contextmanager
- def write_list(self):
+ def write_object(
+ self,
+ typ: str,
+ compact_type: Optional[str],
+ id_alias: Optional[str],
+ _id: str,
+ compact_id: Optional[str],
+ needs_id: bool,
+ ) -> Iterator["JSONLDInlineEncoder"]:
+ with self.write_dict() as obj_dict:
+ with obj_dict.write_property(
+ "type"
+ ) as type_prop:
+ type_prop.write_string(compact_type or typ)
+
+ if needs_id:
+ with obj_dict.write_property(id_alias or "@id") as id_prop:
+ id_prop.write_string(compact_id or _id)
+
+ yield obj_dict
+
+ @contextmanager
+ def write_list(self) -> Iterator["JSONLDInlineEncoder"]:
self._write_comma()
self.write("[")
yield self.__class__(self.f, self.sha1)
self.comma = True
@contextmanager
- def write_list_item(self):
+ def write_list_item(self) -> Iterator["JSONLDInlineEncoder"]:
self._write_comma()
yield self.__class__(self.f, self.sha1)
self.comma = True
+ @contextmanager
+ def write_object_list(self) -> Iterator["JSONLDInlineEncoder"]:
+ with self.write_property("@graph") as graph_prop:
+ with graph_prop.write_list() as graph_list:
+ yield graph_list
+
class JSONLDInlineSerializer(object):
+ """Serializes a SHACLObjectSet directly to a binary stream, returning a SHA-1 digest."""
+
def write(
self,
objectset: SHACLObjectSet,
- f,
- force_at_graph=False,
+ f: BinaryIO,
+ force_at_graph: bool = False,
):
"""
Write a SHACLObjectSet to a JSON LD file
"""
sha1 = hashlib.sha1()
h = JSONLDInlineEncoder(f, sha1)
- h.write('{"@context":')
- if len(CONTEXT_URLS) == 1:
- h.write(f'"{CONTEXT_URLS[0]}"')
- elif CONTEXT_URLS:
- h.write('["')
- h.write('","'.join(CONTEXT_URLS))
- h.write('"]')
- h.write(",")
-
- h.write('"@graph":')
-
- objectset.encode(h, True)
- h.write("}")
+ state = EncodeState(objectset)
+ with h.write_dict() as doc_s:
+ encode_context(doc_s, objectset)
+ objectset.encode(doc_s, state, True)
+
return sha1.hexdigest()
-def print_tree(objects, all_fields=False):
- """
- Print object tree
- """
- seen = set()
+def encode_context(encoder: Encoder, objectset: SHACLObjectSet) -> None:
+ context: List[Union[str, Dict[str, str]]] = list(CONTEXT_URLS)
+ if objectset.context:
+ context.append(objectset.context)
- def callback(value, path):
- nonlocal seen
+ if not context:
+ return
- s = (" " * (len(path) - 1)) + f"{path[-1]}"
- if isinstance(value, SHACLObject):
- s += f" {value} ({id(value)})"
- is_empty = False
- elif isinstance(value, ListProxy):
- is_empty = len(value) == 0
- if is_empty:
- s += " []"
+ def write_context(e, ctx):
+ if isinstance(ctx, str):
+ e.write_string(ctx)
else:
- s += f" {value!r}"
- is_empty = value is None
+ with e.write_dict() as dict_s:
+ for k, v in ctx.items():
+ with dict_s.write_property(k) as ctx_prop:
+ ctx_prop.write_string(v)
+
+ with encoder.write_property("@context") as context_prop:
+ if len(context) == 1:
+ write_context(context_prop, context[0])
+ else:
+ with context_prop.write_list() as context_list:
+ for ctx in context:
+ with context_list.write_list_item() as context_list_item:
+ write_context(context_list_item, ctx)
- if all_fields or not is_empty:
- print(s)
- if isinstance(value, SHACLObject):
- if value in seen:
+def decode_context(decoder: Decoder, objectset: SHACLObjectSet) -> None:
+ def _decode_ctx(d: Decoder):
+ if not d.is_object():
+ return
+
+ for k in d.object_keys():
+ with d.read_property(k) as prop_d:
+ if prop_d:
+ if s := prop_d.read_string():
+ objectset.context[k] = s
+
+ if decoder.is_list():
+ for ctx_d in decoder.read_list():
+ _decode_ctx(ctx_d)
+ else:
+ _decode_ctx(decoder)
+
+
+try:
+ from rdflib import BNode, Literal, URIRef
+ from rdflib.namespace import RDF
+ from rdflib.term import IdentifiedNode
+
+ if TYPE_CHECKING:
+ from rdflib import Graph
+ from rdflib.term import Node
+
+ class RDFDecoder(Decoder):
+ def __init__(
+ self,
+ graph: Graph,
+ subject: Optional[Node] = None,
+ predicate: Optional[Node] = None,
+ value: Optional[Node] = None,
+ ) -> None:
+ self.graph: Graph = graph
+ self.subject: Optional[Node] = subject
+ self.predicate: Optional[Node] = predicate
+ self.value: Optional[Node] = value
+
+ def __read_node(self) -> Optional[Node]:
+ if self.value is not None:
+ return self.value
+ if self.predicate is None:
+ return None
+ return self.graph.value(self.subject, self.predicate)
+
+ def read_value(self) -> Optional[Any]:
+ v = self.__read_node()
+ if isinstance(v, Literal):
+ return v.toPython()
+ return None
+
+ def read_string(self) -> Optional[str]:
+ v = self.read_value()
+ if isinstance(v, str):
+ return v
+ return None
+
+ def read_datetime(self) -> Optional[str]:
+ return self.read_value()
+
+ def read_integer(self) -> Optional[int]:
+ v = self.read_value()
+ if isinstance(v, (int, decimal.Decimal)):
+ return int(v)
+ return None
+
+ def read_bool(self) -> Optional[bool]:
+ v = self.read_value()
+ if isinstance(v, bool):
+ return v
+ return None
+
+ def read_float(self) -> Optional[float]:
+ v = self.read_value()
+ if isinstance(v, (int, float, str, decimal.Decimal)):
+ return float(v)
+ return None
+
+ def read_iri(self) -> Optional[str]:
+ v = self.__read_node()
+ if isinstance(v, URIRef):
+ return v.toPython()
+ elif isinstance(v, Literal):
+ v = v.toPython()
+ if isinstance(v, str):
+ return v
+ elif isinstance(v, BNode):
+ return v.n3()
+ return None
+
+ def read_enum(self, e) -> Optional[str]:
+ v = self.__read_node()
+ if isinstance(v, URIRef):
+ return v.toPython()
+ return None
+
+ def read_list(self) -> Iterator["RDFDecoder"]:
+ if not self.subject:
+ blank_nodes = set()
+ for s in self.graph.subjects(unique=True):
+ if (s, RDF.type, None) not in self.graph:
+ continue
+
+ if isinstance(s, BNode):
+ blank_nodes.add(s)
+ continue
+ yield self.__class__(self.graph, s)
+
+ for s in blank_nodes:
+ yield self.__class__(self.graph, s)
+ else:
+ for o in self.graph.objects(self.subject, self.predicate):
+ if (o, RDF.type, None) in self.graph:
+ yield self.__class__(self.graph, o)
+ else:
+ yield self.__class__(
+ self.graph,
+ self.subject,
+ self.predicate,
+ o,
+ )
+
+ def is_list(self) -> bool:
+ if not self.subject:
+ return True
+ if self.value is not None:
return False
- seen.add(value)
- return True
+ return len(list(self.graph.objects(self.subject, self.predicate))) > 1
- return True
+ @contextmanager
+ def read_property(self, key: str) -> Iterator[Optional["RDFDecoder"]]:
+ if key == "@id":
+ yield self.__class__(self.graph, value=self.subject)
+ else:
+ yield self.__class__(self.graph, self.subject, URIRef(key))
- for o in objects:
- o.walk(callback)
+ def is_object(self) -> bool:
+ n = self.__read_node() or self.subject
+ return (n, RDF.type, None) in self.graph
+ def object_keys(self) -> Iterator[str]:
+ for p in self.graph.predicates(self.subject, unique=True):
+ if p == RDF.type:
+ continue
-# fmt: off
-"""Format Guard"""
+ if not isinstance(p, IdentifiedNode):
+ raise TypeError(f"Predicate is of unknown type {type(p)}")
+
+ yield p.toPython()
+ def read_object(self) -> Tuple[Any, "RDFDecoder"]:
+ s = self.__read_node()
+ if s is None:
+ s = self.subject
-CONTEXT_URLS = [
+ typ = self.graph.value(s, RDF.type)
+ if typ is None:
+ return None, self
+
+ if not isinstance(typ, IdentifiedNode):
+ raise TypeError(f"Type value is of unknown type {type(typ)}")
+
+ return typ.toPython(), self.__class__(self.graph, s)
+
+ def read_object_id(self, alias=None) -> Optional[Any]:
+ if isinstance(self.subject, BNode):
+ return self.subject.n3()
+ if not isinstance(self.subject, IdentifiedNode):
+ raise TypeError(f"Subject is of unknown type {type(self.subject)}")
+ return self.subject.toPython()
+
+ class RDFDeserializer(object):
+ """Deserializes SHACL objects from an rdflib Graph into a SHACLObjectSet."""
+
+ def read(self, graph: Graph, objset: SHACLObjectSet) -> None:
+ """Decode all typed subjects from the rdflib Graph into the given object set."""
+ d = RDFDecoder(graph)
+ state = DecodeState(objset)
+ objset.decode(d, state)
+ objset.inline_blank_nodes()
+
+ class RDFEncoder(Encoder):
+ def __init__(
+ self,
+ graph: Graph,
+ subject: Optional[Node] = None,
+ predicate: Optional[Node] = None,
+ ) -> None:
+ self.graph: Graph = graph
+ self.subject: Optional[Node] = subject
+ self.predicate: Optional[Node] = predicate
+
+ def __add_literal(self, v: Any) -> None:
+ if self.subject is None or self.predicate is None:
+ raise TypeError("Subject and predicate of literal value cannot be None")
+ self.graph.add((self.subject, self.predicate, Literal(v)))
+
+ def __add_uriref(self, v: str) -> None:
+ if self.subject is None or self.predicate is None:
+ raise TypeError("Subject and predicate of URIRef value cannot be None")
+ self.graph.add((self.subject, self.predicate, URIRef(v)))
+
+ def write_string(self, v):
+ self.__add_literal(v)
+
+ def write_datetime(self, v):
+ self.__add_literal(v)
+
+ def write_integer(self, v):
+ self.__add_literal(v)
+
+ def write_iri(self, v, compact=None):
+ self.__add_uriref(v)
+
+ def write_enum(self, v, e, compact=None):
+ self.__add_uriref(v)
+
+ def write_bool(self, v):
+ self.__add_literal(v)
+
+ def write_float(self, v):
+ self.__add_literal(v)
+
+ @contextmanager
+ def write_property(self, iri: str, compact: Optional[str] = None):
+ yield self.__class__(self.graph, self.subject, URIRef(iri))
+
+ @contextmanager
+ def write_object(
+ self,
+ typ: str,
+ compact_type: Optional[str],
+ id_alias: Optional[str],
+ _id: str,
+ compact_id: Optional[str],
+ needs_id: bool,
+ ):
+ obj: Node
+ if _id.startswith("_:"):
+ obj = BNode(_id[2:])
+ else:
+ obj = URIRef(_id)
+
+ if self.subject is not None:
+ if self.predicate is None:
+ raise TypeError("Predicate cannot be None when subject is not None")
+ self.graph.add((self.subject, self.predicate, obj))
+ self.graph.add((obj, RDF.type, URIRef(typ)))
+ yield self.__class__(self.graph, obj)
+
+ @contextmanager
+ def write_list(self):
+ yield self
+
+ @contextmanager
+ def write_list_item(self):
+ yield self
+
+ @contextmanager
+ def write_object_list(self):
+ yield self
+
+ @contextmanager
+ def write_dict(self):
+ yield self
+
+ class RDFSerializer(object):
+ """Serializes a SHACLObjectSet into an rdflib Graph."""
+
+ def write(self, objset: SHACLObjectSet, g: Graph) -> None:
+ """
+ Write a SHACLObjectSet to an rdflib Graph
+ """
+ e = RDFEncoder(g)
+ state = EncodeState(objset)
+ objset.encode(e, state)
+
+except ImportError:
+ pass
+
+
+# fmt: off
+"""Format Guard"""
+CONTEXT_URLS: List[str] = [
"https://spdx.org/rdf/3.0.1/spdx-context.jsonld",
]
# CLASSES
-# A class for describing the energy consumption incurred by an AI model in
-# different stages of its lifecycle.
-@register("https://spdx.org/rdf/3.0.1/terms/AI/EnergyConsumption", compact_type="ai_EnergyConsumption", abstract=False)
class ai_EnergyConsumption(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ A class for describing the energy consumption incurred by an AI model in
+ different stages of its lifecycle.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyConsumption"
+ COMPACT_TYPE = "ai_EnergyConsumption"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Specifies the amount of energy consumed when finetuning the AI model that is
# being used in the AI system.
- cls._add_property(
+ ClassProp(
"ai_finetuningEnergyConsumption",
+ lambda:
ListProp(ObjectProp(ai_EnergyConsumptionDescription, False)),
iri="https://spdx.org/rdf/3.0.1/terms/AI/finetuningEnergyConsumption",
compact="ai_finetuningEnergyConsumption",
- )
+ deprecated=False,
+ ),
# Specifies the amount of energy consumed during inference time by an AI model
# that is being used in the AI system.
- cls._add_property(
+ ClassProp(
"ai_inferenceEnergyConsumption",
+ lambda:
ListProp(ObjectProp(ai_EnergyConsumptionDescription, False)),
iri="https://spdx.org/rdf/3.0.1/terms/AI/inferenceEnergyConsumption",
compact="ai_inferenceEnergyConsumption",
- )
+ deprecated=False,
+ ),
# Specifies the amount of energy consumed when training the AI model that is
# being used in the AI system.
- cls._add_property(
+ ClassProp(
"ai_trainingEnergyConsumption",
+ lambda:
ListProp(ObjectProp(ai_EnergyConsumptionDescription, False)),
iri="https://spdx.org/rdf/3.0.1/terms/AI/trainingEnergyConsumption",
compact="ai_trainingEnergyConsumption",
- )
+ deprecated=False,
+ ),
+ ]
-# The class that helps note down the quantity of energy consumption and the unit
-# used for measurement.
-@register("https://spdx.org/rdf/3.0.1/terms/AI/EnergyConsumptionDescription", compact_type="ai_EnergyConsumptionDescription", abstract=False)
class ai_EnergyConsumptionDescription(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ The class that helps note down the quantity of energy consumption and the unit
+ used for measurement.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyConsumptionDescription"
+ COMPACT_TYPE = "ai_EnergyConsumptionDescription"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Represents the energy quantity.
- cls._add_property(
+ ClassProp(
"ai_energyQuantity",
+ lambda:
FloatProp(),
iri="https://spdx.org/rdf/3.0.1/terms/AI/energyQuantity",
min_count=1,
compact="ai_energyQuantity",
- )
+ deprecated=False,
+ ),
# Specifies the unit in which energy is measured.
- cls._add_property(
+ ClassProp(
"ai_energyUnit",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/kilowattHour", "kilowattHour"),
("https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/megajoule", "megajoule"),
("https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/other", "other"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/AI/energyUnit",
min_count=1,
compact="ai_energyUnit",
- )
+ deprecated=False,
+ ),
+ ]
-# Specifies the unit of energy consumption.
-@register("https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType", compact_type="ai_EnergyUnitType", abstract=False)
class ai_EnergyUnitType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Specifies the unit of energy consumption.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType"
+ COMPACT_TYPE = "ai_EnergyUnitType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # Kilowatt-hour.
"kilowattHour": "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/kilowattHour",
+ # Megajoule.
"megajoule": "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/megajoule",
+ # Any other units of energy measurement.
"other": "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/other",
}
- # Kilowatt-hour.
- kilowattHour = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/kilowattHour"
- # Megajoule.
- megajoule = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/megajoule"
- # Any other units of energy measurement.
- other = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/other"
-# Specifies the safety risk level.
-@register("https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType", compact_type="ai_SafetyRiskAssessmentType", abstract=False)
class ai_SafetyRiskAssessmentType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Specifies the safety risk level.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType"
+ COMPACT_TYPE = "ai_SafetyRiskAssessmentType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # The second-highest level of risk posed by an AI system.
"high": "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/high",
+ # Low/no risk is posed by an AI system.
"low": "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/low",
+ # The third-highest level of risk posed by an AI system.
"medium": "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/medium",
+ # The highest level of risk posed by an AI system.
"serious": "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/serious",
}
- # The second-highest level of risk posed by an AI system.
- high = "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/high"
- # Low/no risk is posed by an AI system.
- low = "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/low"
- # The third-highest level of risk posed by an AI system.
- medium = "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/medium"
- # The highest level of risk posed by an AI system.
- serious = "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/serious"
-
-
-# Specifies the type of an annotation.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType", compact_type="AnnotationType", abstract=False)
+
+
class AnnotationType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Specifies the type of an annotation.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType"
+ COMPACT_TYPE = "AnnotationType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # Used to store extra information about an Element which is not part of a review (e.g. extra information provided during the creation of the Element).
"other": "https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/other",
+ # Used when someone reviews the Element.
"review": "https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/review",
}
- # Used to store extra information about an Element which is not part of a review (e.g. extra information provided during the creation of the Element).
- other = "https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/other"
- # Used when someone reviews the Element.
- review = "https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/review"
-# Provides information about the creation of the Element.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/CreationInfo", compact_type="CreationInfo", abstract=False)
class CreationInfo(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ Provides information about the creation of the Element.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/CreationInfo"
+ COMPACT_TYPE = "CreationInfo"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Provide consumers with comments by the creator of the Element about the
# Element.
- cls._add_property(
+ ClassProp(
"comment",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/comment",
compact="comment",
- )
+ deprecated=False,
+ ),
# Identifies when the Element was originally created.
- cls._add_property(
+ ClassProp(
"created",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Core/created",
min_count=1,
compact="created",
- )
+ deprecated=False,
+ ),
# Identifies who or what created the Element.
- cls._add_property(
+ ClassProp(
"createdBy",
- ListProp(ObjectProp(Agent, False, context=[
+ lambda:
+ ListProp(ObjectProp(Agent, False, context=(
("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
- ],)),
+ ),)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/createdBy",
min_count=1,
compact="createdBy",
- )
+ deprecated=False,
+ ),
# Identifies the tooling that was used during the creation of the Element.
- cls._add_property(
+ ClassProp(
"createdUsing",
+ lambda:
ListProp(ObjectProp(Tool, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/createdUsing",
compact="createdUsing",
- )
+ deprecated=False,
+ ),
# Provides a reference number that can be used to understand how to parse and
# interpret an Element.
- cls._add_property(
+ ClassProp(
"specVersion",
- StringProp(pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$",),
+ lambda:
+ StringProp(pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"),
iri="https://spdx.org/rdf/3.0.1/terms/Core/specVersion",
min_count=1,
compact="specVersion",
- )
+ deprecated=False,
+ ),
+ ]
-# A key with an associated value.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/DictionaryEntry", compact_type="DictionaryEntry", abstract=False)
class DictionaryEntry(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ A key with an associated value.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/DictionaryEntry"
+ COMPACT_TYPE = "DictionaryEntry"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# A key used in a generic key-value pair.
- cls._add_property(
+ ClassProp(
"key",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/key",
min_count=1,
compact="key",
- )
+ deprecated=False,
+ ),
# A value used in a generic key-value pair.
- cls._add_property(
+ ClassProp(
"value",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/value",
compact="value",
- )
+ deprecated=False,
+ ),
+ ]
-# Base domain class from which all other SPDX-3.0 domain classes derive.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/Element", compact_type="Element", abstract=True)
class Element(SHACLObject):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Base domain class from which all other SPDX-3.0 domain classes derive.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Element"
+ COMPACT_TYPE = "Element"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ IS_ABSTRACT: bool = True
+ PROPERTIES = [
# Provide consumers with comments by the creator of the Element about the
# Element.
- cls._add_property(
+ ClassProp(
"comment",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/comment",
compact="comment",
- )
+ deprecated=False,
+ ),
# Provides information about the creation of the Element.
- cls._add_property(
+ ClassProp(
"creationInfo",
+ lambda:
ObjectProp(CreationInfo, True),
iri="https://spdx.org/rdf/3.0.1/terms/Core/creationInfo",
min_count=1,
compact="creationInfo",
- )
+ deprecated=False,
+ ),
# Provides a detailed description of the Element.
- cls._add_property(
+ ClassProp(
"description",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/description",
compact="description",
- )
+ deprecated=False,
+ ),
# Specifies an Extension characterization of some aspect of an Element.
- cls._add_property(
+ ClassProp(
"extension",
+ lambda:
ListProp(ObjectProp(extension_Extension, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/extension",
compact="extension",
- )
+ deprecated=False,
+ ),
# Provides a reference to a resource outside the scope of SPDX-3.0 content
# that uniquely identifies an Element.
- cls._add_property(
+ ClassProp(
"externalIdentifier",
+ lambda:
ListProp(ObjectProp(ExternalIdentifier, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/externalIdentifier",
compact="externalIdentifier",
- )
+ deprecated=False,
+ ),
# Points to a resource outside the scope of the SPDX-3.0 content
# that provides additional characteristics of an Element.
- cls._add_property(
+ ClassProp(
"externalRef",
+ lambda:
ListProp(ObjectProp(ExternalRef, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/externalRef",
compact="externalRef",
- )
+ deprecated=False,
+ ),
# Identifies the name of an Element as designated by the creator.
- cls._add_property(
+ ClassProp(
"name",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/name",
compact="name",
- )
+ deprecated=False,
+ ),
# A short description of an Element.
- cls._add_property(
+ ClassProp(
"summary",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/summary",
compact="summary",
- )
+ deprecated=False,
+ ),
# Provides an IntegrityMethod with which the integrity of an Element can be
# asserted.
- cls._add_property(
+ ClassProp(
"verifiedUsing",
+ lambda:
ListProp(ObjectProp(IntegrityMethod, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/verifiedUsing",
compact="verifiedUsing",
- )
+ deprecated=False,
+ ),
+ ]
-# A collection of Elements, not necessarily with unifying context.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/ElementCollection", compact_type="ElementCollection", abstract=True)
class ElementCollection(Element):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A collection of Elements, not necessarily with unifying context.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ElementCollection"
+ COMPACT_TYPE = "ElementCollection"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ IS_ABSTRACT: bool = True
+ PROPERTIES = [
# Refers to one or more Elements that are part of an ElementCollection.
- cls._add_property(
+ ClassProp(
"element",
- ListProp(ObjectProp(Element, False, context=[
+ lambda:
+ ListProp(ObjectProp(Element, False, context=(
+ ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
("https://spdx.org/rdf/3.0.1/terms/Core/NoneElement", "NoneElement"),
+ ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
- ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
- ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
- ],)),
+ ),)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/element",
compact="element",
- )
+ deprecated=False,
+ ),
# Describes one a profile which the creator of this ElementCollection intends to
# conform to.
- cls._add_property(
+ ClassProp(
"profileConformance",
- ListProp(EnumProp([
+ lambda:
+ ListProp(EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/ai", "ai"),
("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/build", "build"),
("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/core", "core"),
("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/security", "security"),
("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/simpleLicensing", "simpleLicensing"),
("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/software", "software"),
- ])),
+ ))),
iri="https://spdx.org/rdf/3.0.1/terms/Core/profileConformance",
compact="profileConformance",
- )
+ deprecated=False,
+ ),
# This property is used to denote the root Element(s) of a tree of elements contained in a BOM.
- cls._add_property(
+ ClassProp(
"rootElement",
- ListProp(ObjectProp(Element, False, context=[
+ lambda:
+ ListProp(ObjectProp(Element, False, context=(
+ ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
("https://spdx.org/rdf/3.0.1/terms/Core/NoneElement", "NoneElement"),
+ ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
- ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
- ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
- ],)),
+ ),)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/rootElement",
compact="rootElement",
- )
+ deprecated=False,
+ ),
+ ]
-# A reference to a resource identifier defined outside the scope of SPDX-3.0 content that uniquely identifies an Element.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifier", compact_type="ExternalIdentifier", abstract=False)
class ExternalIdentifier(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ A reference to a resource identifier defined outside the scope of SPDX-3.0 content that uniquely identifies an Element.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifier"
+ COMPACT_TYPE = "ExternalIdentifier"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Provide consumers with comments by the creator of the Element about the
# Element.
- cls._add_property(
+ ClassProp(
"comment",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/comment",
compact="comment",
- )
+ deprecated=False,
+ ),
# Specifies the type of the external identifier.
- cls._add_property(
+ ClassProp(
"externalIdentifierType",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe22", "cpe22"),
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe23", "cpe23"),
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cve", "cve"),
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swhid", "swhid"),
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swid", "swid"),
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/urlScheme", "urlScheme"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Core/externalIdentifierType",
min_count=1,
compact="externalIdentifierType",
- )
+ deprecated=False,
+ ),
# Uniquely identifies an external element.
- cls._add_property(
+ ClassProp(
"identifier",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/identifier",
min_count=1,
compact="identifier",
- )
+ deprecated=False,
+ ),
# Provides the location for more information regarding an external identifier.
- cls._add_property(
+ ClassProp(
"identifierLocator",
+ lambda:
ListProp(AnyURIProp()),
iri="https://spdx.org/rdf/3.0.1/terms/Core/identifierLocator",
compact="identifierLocator",
- )
+ deprecated=False,
+ ),
# An entity that is authorized to issue identification credentials.
- cls._add_property(
+ ClassProp(
"issuingAuthority",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/issuingAuthority",
compact="issuingAuthority",
- )
+ deprecated=False,
+ ),
+ ]
-# Specifies the type of an external identifier.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType", compact_type="ExternalIdentifierType", abstract=False)
class ExternalIdentifierType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Specifies the type of an external identifier.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType"
+ COMPACT_TYPE = "ExternalIdentifierType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # [Common Platform Enumeration Specification 2.2](https://cpe.mitre.org/files/cpe-specification_2.2.pdf)
"cpe22": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe22",
+ # [Common Platform Enumeration: Naming Specification Version 2.3](https://csrc.nist.gov/publications/detail/nistir/7695/final)
"cpe23": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe23",
+ # Common Vulnerabilities and Exposures identifiers, an identifier for a specific software flaw defined within the official CVE Dictionary and that conforms to the [CVE specification](https://csrc.nist.gov/glossary/term/cve_id).
"cve": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cve",
+ # Email address, as defined in [RFC 3696](https://datatracker.ietf.org/doc/rfc3986/) Section 3.
"email": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/email",
+ # [Gitoid](https://www.iana.org/assignments/uri-schemes/prov/gitoid), stands for [Git Object ID](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects). A gitoid of type blob is a unique hash of a binary artifact. A gitoid may represent either an [Artifact Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-identifier-types) for the software artifact or an [Input Manifest Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#input-manifest-identifier) for the software artifact's associated [Artifact Input Manifest](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-input-manifest); this ambiguity exists because the Artifact Input Manifest is itself an artifact, and the gitoid of that artifact is its valid identifier. Gitoids calculated on software artifacts (Snippet, File, or Package Elements) should be recorded in the SPDX 3.0 SoftwareArtifact's contentIdentifier property. Gitoids calculated on the Artifact Input Manifest (Input Manifest Identifier) should be recorded in the SPDX 3.0 Element's externalIdentifier property. See [OmniBOR Specification](https://github.com/omnibor/spec/), a minimalistic specification for describing software [Artifact Dependency Graphs](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-dependency-graph-adg).
"gitoid": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/gitoid",
+ # Used when the type does not match any of the other options.
"other": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/other",
+ # Package URL, as defined in the corresponding [Annex](../../../annexes/pkg-url-specification.md) of this specification.
"packageUrl": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/packageUrl",
+ # Used when there is a security related identifier of unspecified type.
"securityOther": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/securityOther",
+ # SoftWare Hash IDentifier, a persistent intrinsic identifier for digital artifacts, such as files, trees (also known as directories or folders), commits, and other objects typically found in version control systems. The format of the identifiers is defined in the [SWHID specification](https://www.swhid.org/specification/v1.1/4.Syntax) (ISO/IEC DIS 18670). They typically look like `swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2`.
"swhid": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swhid",
+ # Concise Software Identification (CoSWID) tag, as defined in [RFC 9393](https://datatracker.ietf.org/doc/rfc9393/) Section 2.3.
"swid": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swid",
+ # [Uniform Resource Identifier (URI) Schemes](https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml). The scheme used in order to locate a resource.
"urlScheme": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/urlScheme",
}
- # [Common Platform Enumeration Specification 2.2](https://cpe.mitre.org/files/cpe-specification_2.2.pdf)
- cpe22 = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe22"
- # [Common Platform Enumeration: Naming Specification Version 2.3](https://csrc.nist.gov/publications/detail/nistir/7695/final)
- cpe23 = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe23"
- # Common Vulnerabilities and Exposures identifiers, an identifier for a specific software flaw defined within the official CVE Dictionary and that conforms to the [CVE specification](https://csrc.nist.gov/glossary/term/cve_id).
- cve = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cve"
- # Email address, as defined in [RFC 3696](https://datatracker.ietf.org/doc/rfc3986/) Section 3.
- email = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/email"
- # [Gitoid](https://www.iana.org/assignments/uri-schemes/prov/gitoid), stands for [Git Object ID](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects). A gitoid of type blob is a unique hash of a binary artifact. A gitoid may represent either an [Artifact Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-identifier-types) for the software artifact or an [Input Manifest Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#input-manifest-identifier) for the software artifact's associated [Artifact Input Manifest](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-input-manifest); this ambiguity exists because the Artifact Input Manifest is itself an artifact, and the gitoid of that artifact is its valid identifier. Gitoids calculated on software artifacts (Snippet, File, or Package Elements) should be recorded in the SPDX 3.0 SoftwareArtifact's contentIdentifier property. Gitoids calculated on the Artifact Input Manifest (Input Manifest Identifier) should be recorded in the SPDX 3.0 Element's externalIdentifier property. See [OmniBOR Specification](https://github.com/omnibor/spec/), a minimalistic specification for describing software [Artifact Dependency Graphs](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-dependency-graph-adg).
- gitoid = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/gitoid"
- # Used when the type does not match any of the other options.
- other = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/other"
- # Package URL, as defined in the corresponding [Annex](../../../annexes/pkg-url-specification.md) of this specification.
- packageUrl = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/packageUrl"
- # Used when there is a security related identifier of unspecified type.
- securityOther = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/securityOther"
- # SoftWare Hash IDentifier, a persistent intrinsic identifier for digital artifacts, such as files, trees (also known as directories or folders), commits, and other objects typically found in version control systems. The format of the identifiers is defined in the [SWHID specification](https://www.swhid.org/specification/v1.1/4.Syntax) (ISO/IEC DIS 18670). They typically look like `swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2`.
- swhid = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swhid"
- # Concise Software Identification (CoSWID) tag, as defined in [RFC 9393](https://datatracker.ietf.org/doc/rfc9393/) Section 2.3.
- swid = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swid"
- # [Uniform Resource Identifier (URI) Schemes](https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml). The scheme used in order to locate a resource.
- urlScheme = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/urlScheme"
-
-
-# A map of Element identifiers that are used within an SpdxDocument but defined
-# external to that SpdxDocument.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/ExternalMap", compact_type="ExternalMap", abstract=False)
+
+
class ExternalMap(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ A map of Element identifiers that are used within an SpdxDocument but defined
+ external to that SpdxDocument.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalMap"
+ COMPACT_TYPE = "ExternalMap"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Artifact representing a serialization instance of SPDX data containing the
# definition of a particular Element.
- cls._add_property(
+ ClassProp(
"definingArtifact",
+ lambda:
ObjectProp(Artifact, False),
iri="https://spdx.org/rdf/3.0.1/terms/Core/definingArtifact",
compact="definingArtifact",
- )
+ deprecated=False,
+ ),
# Identifies an external Element used within an SpdxDocument but defined
# external to that SpdxDocument.
- cls._add_property(
+ ClassProp(
"externalSpdxId",
+ lambda:
AnyURIProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/externalSpdxId",
min_count=1,
compact="externalSpdxId",
- )
+ deprecated=False,
+ ),
# Provides an indication of where to retrieve an external Element.
- cls._add_property(
+ ClassProp(
"locationHint",
+ lambda:
AnyURIProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/locationHint",
compact="locationHint",
- )
+ deprecated=False,
+ ),
# Provides an IntegrityMethod with which the integrity of an Element can be
# asserted.
- cls._add_property(
+ ClassProp(
"verifiedUsing",
+ lambda:
ListProp(ObjectProp(IntegrityMethod, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/verifiedUsing",
compact="verifiedUsing",
- )
+ deprecated=False,
+ ),
+ ]
-# A reference to a resource outside the scope of SPDX-3.0 content related to an Element.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRef", compact_type="ExternalRef", abstract=False)
class ExternalRef(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ A reference to a resource outside the scope of SPDX-3.0 content related to an Element.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRef"
+ COMPACT_TYPE = "ExternalRef"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Provide consumers with comments by the creator of the Element about the
# Element.
- cls._add_property(
+ ClassProp(
"comment",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/comment",
compact="comment",
- )
+ deprecated=False,
+ ),
# Provides information about the content type of an Element or a Property.
- cls._add_property(
+ ClassProp(
"contentType",
- StringProp(pattern=r"^[^\/]+\/[^\/]+$",),
+ lambda:
+ StringProp(pattern=r"^[^\/]+\/[^\/]+$"),
iri="https://spdx.org/rdf/3.0.1/terms/Core/contentType",
compact="contentType",
- )
+ deprecated=False,
+ ),
# Specifies the type of the external reference.
- cls._add_property(
+ ClassProp(
"externalRefType",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altDownloadLocation", "altDownloadLocation"),
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altWebPage", "altWebPage"),
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/binaryArtifact", "binaryArtifact"),
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vcs", "vcs"),
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityDisclosureReport", "vulnerabilityDisclosureReport"),
("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityExploitabilityAssessment", "vulnerabilityExploitabilityAssessment"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Core/externalRefType",
compact="externalRefType",
- )
+ deprecated=False,
+ ),
# Provides the location of an external reference.
- cls._add_property(
+ ClassProp(
"locator",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/Core/locator",
compact="locator",
- )
+ deprecated=False,
+ ),
+ ]
-# Specifies the type of an external reference.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType", compact_type="ExternalRefType", abstract=False)
class ExternalRefType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Specifies the type of an external reference.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType"
+ COMPACT_TYPE = "ExternalRefType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # A reference to an alternative download location.
"altDownloadLocation": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altDownloadLocation",
+ # A reference to an alternative web page.
"altWebPage": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altWebPage",
+ # A reference to binary artifacts related to a package.
"binaryArtifact": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/binaryArtifact",
+ # A reference to a Bower package. The package locator format, looks like `package#version`, is defined in the "install" section of [Bower API documentation](https://bower.io/docs/api/#install).
"bower": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/bower",
+ # A reference build metadata related to a published package.
"buildMeta": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/buildMeta",
+ # A reference build system used to create or publish the package.
"buildSystem": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/buildSystem",
+ # A reference to a certification report for a package from an accredited/independent body.
"certificationReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/certificationReport",
+ # A reference to the instant messaging system used by the maintainer for a package.
"chat": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/chat",
+ # A reference to a Software Composition Analysis (SCA) report.
"componentAnalysisReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/componentAnalysisReport",
+ # [Common Weakness Enumeration](https://csrc.nist.gov/glossary/term/common_weakness_enumeration). A reference to a source of software flaw defined within the official [CWE List](https://cwe.mitre.org/data/) that conforms to the [CWE specification](https://cwe.mitre.org/).
"cwe": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/cwe",
+ # A reference to the documentation for a package.
"documentation": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/documentation",
+ # A reference to a dynamic analysis report for a package.
"dynamicAnalysisReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/dynamicAnalysisReport",
+ # A reference to the End Of Sale (EOS) and/or End Of Life (EOL) information related to a package.
"eolNotice": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/eolNotice",
+ # A reference to a export control assessment for a package.
"exportControlAssessment": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/exportControlAssessment",
+ # A reference to funding information related to a package.
"funding": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/funding",
+ # A reference to the issue tracker for a package.
"issueTracker": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/issueTracker",
+ # A reference to additional license information related to an artifact.
"license": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/license",
+ # A reference to the mailing list used by the maintainer for a package.
"mailingList": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/mailingList",
+ # A reference to a Maven repository artifact. The artifact locator format is defined in the [Maven documentation](https://maven.apache.org/guides/mini/guide-naming-conventions.html) and looks like `groupId:artifactId[:version]`.
"mavenCentral": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/mavenCentral",
+ # A reference to metrics related to package such as OpenSSF scorecards.
"metrics": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/metrics",
+ # A reference to an npm package. The package locator format is defined in the [npm documentation](https://docs.npmjs.com/cli/v10/configuring-npm/package-json) and looks like `package@version`.
"npm": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/npm",
+ # A reference to a NuGet package. The package locator format is defined in the [NuGet documentation](https://docs.nuget.org) and looks like `package/version`.
"nuget": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/nuget",
+ # Used when the type does not match any of the other options.
"other": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/other",
+ # A reference to a privacy assessment for a package.
"privacyAssessment": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/privacyAssessment",
+ # A reference to additional product metadata such as reference within organization's product catalog.
"productMetadata": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/productMetadata",
+ # A reference to a purchase order for a package.
"purchaseOrder": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/purchaseOrder",
+ # A reference to a quality assessment for a package.
"qualityAssessmentReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/qualityAssessmentReport",
+ # A reference to a published list of releases for a package.
"releaseHistory": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/releaseHistory",
+ # A reference to the release notes for a package.
"releaseNotes": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/releaseNotes",
+ # A reference to a risk assessment for a package.
"riskAssessment": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/riskAssessment",
+ # A reference to a runtime analysis report for a package.
"runtimeAnalysisReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/runtimeAnalysisReport",
+ # A reference to information assuring that the software is developed using security practices as defined by [NIST SP 800-218 Secure Software Development Framework (SSDF) Version 1.1](https://csrc.nist.gov/pubs/sp/800/218/final) or [CISA Secure Software Development Attestation Form](https://www.cisa.gov/resources-tools/resources/secure-software-development-attestation-form).
"secureSoftwareAttestation": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/secureSoftwareAttestation",
+ # A reference to the security adversary model for a package.
"securityAdversaryModel": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityAdversaryModel",
+ # A reference to a published security advisory (where advisory as defined per [ISO 29147:2018](https://www.iso.org/standard/72311.html)) that may affect one or more elements, e.g., vendor advisories or specific NVD entries.
"securityAdvisory": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityAdvisory",
+ # A reference to the patch or source code that fixes a vulnerability.
"securityFix": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityFix",
+ # A reference to related security information of unspecified type.
"securityOther": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityOther",
+ # A reference to a [penetration test](https://en.wikipedia.org/wiki/Penetration_test) report for a package.
"securityPenTestReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityPenTestReport",
+ # A reference to instructions for reporting newly discovered security vulnerabilities for a package.
"securityPolicy": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityPolicy",
+ # A reference the [security threat model](https://en.wikipedia.org/wiki/Threat_model) for a package.
"securityThreatModel": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityThreatModel",
+ # A reference to a social media channel for a package.
"socialMedia": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/socialMedia",
+ # A reference to an artifact containing the sources for a package.
"sourceArtifact": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/sourceArtifact",
+ # A reference to a static analysis report for a package.
"staticAnalysisReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/staticAnalysisReport",
+ # A reference to the software support channel or other support information for a package.
"support": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/support",
+ # A reference to a version control system related to a software artifact.
"vcs": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vcs",
+ # A reference to a Vulnerability Disclosure Report (VDR) which provides the software supplier's analysis and findings describing the impact (or lack of impact) that reported vulnerabilities have on packages or products in the supplier's SBOM as defined in [NIST SP 800-161 Cybersecurity Supply Chain Risk Management Practices for Systems and Organizations](https://csrc.nist.gov/pubs/sp/800/161/r1/final).
"vulnerabilityDisclosureReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityDisclosureReport",
+ # A reference to a Vulnerability Exploitability eXchange (VEX) statement which provides information on whether a product is impacted by a specific vulnerability in an included package and, if affected, whether there are actions recommended to remediate. See also [NTIA VEX one-page summary](https://ntia.gov/files/ntia/publications/vex_one-page_summary.pdf).
"vulnerabilityExploitabilityAssessment": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityExploitabilityAssessment",
}
- # A reference to an alternative download location.
- altDownloadLocation = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altDownloadLocation"
- # A reference to an alternative web page.
- altWebPage = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altWebPage"
- # A reference to binary artifacts related to a package.
- binaryArtifact = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/binaryArtifact"
- # A reference to a Bower package. The package locator format, looks like `package#version`, is defined in the "install" section of [Bower API documentation](https://bower.io/docs/api/#install).
- bower = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/bower"
- # A reference build metadata related to a published package.
- buildMeta = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/buildMeta"
- # A reference build system used to create or publish the package.
- buildSystem = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/buildSystem"
- # A reference to a certification report for a package from an accredited/independent body.
- certificationReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/certificationReport"
- # A reference to the instant messaging system used by the maintainer for a package.
- chat = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/chat"
- # A reference to a Software Composition Analysis (SCA) report.
- componentAnalysisReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/componentAnalysisReport"
- # [Common Weakness Enumeration](https://csrc.nist.gov/glossary/term/common_weakness_enumeration). A reference to a source of software flaw defined within the official [CWE List](https://cwe.mitre.org/data/) that conforms to the [CWE specification](https://cwe.mitre.org/).
- cwe = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/cwe"
- # A reference to the documentation for a package.
- documentation = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/documentation"
- # A reference to a dynamic analysis report for a package.
- dynamicAnalysisReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/dynamicAnalysisReport"
- # A reference to the End Of Sale (EOS) and/or End Of Life (EOL) information related to a package.
- eolNotice = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/eolNotice"
- # A reference to a export control assessment for a package.
- exportControlAssessment = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/exportControlAssessment"
- # A reference to funding information related to a package.
- funding = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/funding"
- # A reference to the issue tracker for a package.
- issueTracker = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/issueTracker"
- # A reference to additional license information related to an artifact.
- license = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/license"
- # A reference to the mailing list used by the maintainer for a package.
- mailingList = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/mailingList"
- # A reference to a Maven repository artifact. The artifact locator format is defined in the [Maven documentation](https://maven.apache.org/guides/mini/guide-naming-conventions.html) and looks like `groupId:artifactId[:version]`.
- mavenCentral = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/mavenCentral"
- # A reference to metrics related to package such as OpenSSF scorecards.
- metrics = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/metrics"
- # A reference to an npm package. The package locator format is defined in the [npm documentation](https://docs.npmjs.com/cli/v10/configuring-npm/package-json) and looks like `package@version`.
- npm = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/npm"
- # A reference to a NuGet package. The package locator format is defined in the [NuGet documentation](https://docs.nuget.org) and looks like `package/version`.
- nuget = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/nuget"
- # Used when the type does not match any of the other options.
- other = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/other"
- # A reference to a privacy assessment for a package.
- privacyAssessment = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/privacyAssessment"
- # A reference to additional product metadata such as reference within organization's product catalog.
- productMetadata = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/productMetadata"
- # A reference to a purchase order for a package.
- purchaseOrder = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/purchaseOrder"
- # A reference to a quality assessment for a package.
- qualityAssessmentReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/qualityAssessmentReport"
- # A reference to a published list of releases for a package.
- releaseHistory = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/releaseHistory"
- # A reference to the release notes for a package.
- releaseNotes = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/releaseNotes"
- # A reference to a risk assessment for a package.
- riskAssessment = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/riskAssessment"
- # A reference to a runtime analysis report for a package.
- runtimeAnalysisReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/runtimeAnalysisReport"
- # A reference to information assuring that the software is developed using security practices as defined by [NIST SP 800-218 Secure Software Development Framework (SSDF) Version 1.1](https://csrc.nist.gov/pubs/sp/800/218/final) or [CISA Secure Software Development Attestation Form](https://www.cisa.gov/resources-tools/resources/secure-software-development-attestation-form).
- secureSoftwareAttestation = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/secureSoftwareAttestation"
- # A reference to the security adversary model for a package.
- securityAdversaryModel = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityAdversaryModel"
- # A reference to a published security advisory (where advisory as defined per [ISO 29147:2018](https://www.iso.org/standard/72311.html)) that may affect one or more elements, e.g., vendor advisories or specific NVD entries.
- securityAdvisory = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityAdvisory"
- # A reference to the patch or source code that fixes a vulnerability.
- securityFix = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityFix"
- # A reference to related security information of unspecified type.
- securityOther = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityOther"
- # A reference to a [penetration test](https://en.wikipedia.org/wiki/Penetration_test) report for a package.
- securityPenTestReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityPenTestReport"
- # A reference to instructions for reporting newly discovered security vulnerabilities for a package.
- securityPolicy = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityPolicy"
- # A reference the [security threat model](https://en.wikipedia.org/wiki/Threat_model) for a package.
- securityThreatModel = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityThreatModel"
- # A reference to a social media channel for a package.
- socialMedia = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/socialMedia"
- # A reference to an artifact containing the sources for a package.
- sourceArtifact = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/sourceArtifact"
- # A reference to a static analysis report for a package.
- staticAnalysisReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/staticAnalysisReport"
- # A reference to the software support channel or other support information for a package.
- support = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/support"
- # A reference to a version control system related to a software artifact.
- vcs = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vcs"
- # A reference to a Vulnerability Disclosure Report (VDR) which provides the software supplier's analysis and findings describing the impact (or lack of impact) that reported vulnerabilities have on packages or products in the supplier's SBOM as defined in [NIST SP 800-161 Cybersecurity Supply Chain Risk Management Practices for Systems and Organizations](https://csrc.nist.gov/pubs/sp/800/161/r1/final).
- vulnerabilityDisclosureReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityDisclosureReport"
- # A reference to a Vulnerability Exploitability eXchange (VEX) statement which provides information on whether a product is impacted by a specific vulnerability in an included package and, if affected, whether there are actions recommended to remediate. See also [NTIA VEX one-page summary](https://ntia.gov/files/ntia/publications/vex_one-page_summary.pdf).
- vulnerabilityExploitabilityAssessment = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityExploitabilityAssessment"
-
-
-# A mathematical algorithm that maps data of arbitrary size to a bit string.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm", compact_type="HashAlgorithm", abstract=False)
+
+
class HashAlgorithm(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ A mathematical algorithm that maps data of arbitrary size to a bit string.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm"
+ COMPACT_TYPE = "HashAlgorithm"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # Adler-32 checksum is part of the widely used zlib compression library as defined in [RFC 1950](https://datatracker.ietf.org/doc/rfc1950/) Section 2.3.
"adler32": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/adler32",
+ # BLAKE2b algorithm with a digest size of 256, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
"blake2b256": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b256",
+ # BLAKE2b algorithm with a digest size of 384, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
"blake2b384": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b384",
+ # BLAKE2b algorithm with a digest size of 512, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
"blake2b512": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b512",
+ # [BLAKE3](https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf)
"blake3": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake3",
+ # [Dilithium](https://pq-crystals.org/dilithium/)
"crystalsDilithium": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsDilithium",
+ # [Kyber](https://pq-crystals.org/kyber/)
"crystalsKyber": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsKyber",
+ # [FALCON](https://falcon-sign.info/falcon.pdf)
"falcon": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/falcon",
+ # MD2 message-digest algorithm, as defined in [RFC 1319](https://datatracker.ietf.org/doc/rfc1319/).
"md2": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md2",
+ # MD4 message-digest algorithm, as defined in [RFC 1186](https://datatracker.ietf.org/doc/rfc1186/).
"md4": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md4",
+ # MD5 message-digest algorithm, as defined in [RFC 1321](https://datatracker.ietf.org/doc/rfc1321/).
"md5": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md5",
+ # [MD6 hash function](https://people.csail.mit.edu/rivest/pubs/RABCx08.pdf)
"md6": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md6",
+ # any hashing algorithm that does not exist in this list of entries
"other": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/other",
+ # SHA-1, a secure hashing algorithm, as defined in [RFC 3174](https://datatracker.ietf.org/doc/rfc3174/).
"sha1": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha1",
+ # SHA-2 with a digest length of 224, as defined in [RFC 3874](https://datatracker.ietf.org/doc/rfc3874/).
"sha224": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha224",
+ # SHA-2 with a digest length of 256, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
"sha256": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha256",
+ # SHA-2 with a digest length of 384, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
"sha384": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha384",
+ # SHA-3 with a digest length of 224, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
"sha3_224": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_224",
+ # SHA-3 with a digest length of 256, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
"sha3_256": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_256",
+ # SHA-3 with a digest length of 384, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
"sha3_384": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_384",
+ # SHA-3 with a digest length of 512, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
"sha3_512": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_512",
+ # SHA-2 with a digest length of 512, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
"sha512": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha512",
}
- # Adler-32 checksum is part of the widely used zlib compression library as defined in [RFC 1950](https://datatracker.ietf.org/doc/rfc1950/) Section 2.3.
- adler32 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/adler32"
- # BLAKE2b algorithm with a digest size of 256, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
- blake2b256 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b256"
- # BLAKE2b algorithm with a digest size of 384, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
- blake2b384 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b384"
- # BLAKE2b algorithm with a digest size of 512, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
- blake2b512 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b512"
- # [BLAKE3](https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf)
- blake3 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake3"
- # [Dilithium](https://pq-crystals.org/dilithium/)
- crystalsDilithium = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsDilithium"
- # [Kyber](https://pq-crystals.org/kyber/)
- crystalsKyber = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsKyber"
- # [FALCON](https://falcon-sign.info/falcon.pdf)
- falcon = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/falcon"
- # MD2 message-digest algorithm, as defined in [RFC 1319](https://datatracker.ietf.org/doc/rfc1319/).
- md2 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md2"
- # MD4 message-digest algorithm, as defined in [RFC 1186](https://datatracker.ietf.org/doc/rfc1186/).
- md4 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md4"
- # MD5 message-digest algorithm, as defined in [RFC 1321](https://datatracker.ietf.org/doc/rfc1321/).
- md5 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md5"
- # [MD6 hash function](https://people.csail.mit.edu/rivest/pubs/RABCx08.pdf)
- md6 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md6"
- # any hashing algorithm that does not exist in this list of entries
- other = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/other"
- # SHA-1, a secure hashing algorithm, as defined in [RFC 3174](https://datatracker.ietf.org/doc/rfc3174/).
- sha1 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha1"
- # SHA-2 with a digest length of 224, as defined in [RFC 3874](https://datatracker.ietf.org/doc/rfc3874/).
- sha224 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha224"
- # SHA-2 with a digest length of 256, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
- sha256 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha256"
- # SHA-2 with a digest length of 384, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
- sha384 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha384"
- # SHA-3 with a digest length of 224, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
- sha3_224 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_224"
- # SHA-3 with a digest length of 256, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
- sha3_256 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_256"
- # SHA-3 with a digest length of 384, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
- sha3_384 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_384"
- # SHA-3 with a digest length of 512, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
- sha3_512 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_512"
- # SHA-2 with a digest length of 512, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
- sha512 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha512"
-
-
-# A concrete subclass of Element used by Individuals in the
-# Core profile.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/IndividualElement", compact_type="IndividualElement", abstract=False)
+
+
class IndividualElement(Element):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
+ """
+ A concrete subclass of Element used by Individuals in the
+ Core profile.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/IndividualElement"
+ COMPACT_TYPE = "IndividualElement"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # An Individual Value for Element representing a set of Elements of unknown
+ # identify or cardinality (number).
"NoAssertionElement": "https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement",
+ # An Individual Value for Element representing a set of Elements with
+ # cardinality (number/count) of zero.
"NoneElement": "https://spdx.org/rdf/3.0.1/terms/Core/NoneElement",
}
- # An Individual Value for Element representing a set of Elements of unknown
- # identify or cardinality (number).
- NoAssertionElement = "https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement"
- # An Individual Value for Element representing a set of Elements with
- # cardinality (number/count) of zero.
- NoneElement = "https://spdx.org/rdf/3.0.1/terms/Core/NoneElement"
-# Provides an independently reproducible mechanism that permits verification of a specific Element.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/IntegrityMethod", compact_type="IntegrityMethod", abstract=True)
class IntegrityMethod(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ Provides an independently reproducible mechanism that permits verification of a specific Element.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/IntegrityMethod"
+ COMPACT_TYPE = "IntegrityMethod"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ IS_ABSTRACT: bool = True
+ PROPERTIES = [
# Provide consumers with comments by the creator of the Element about the
# Element.
- cls._add_property(
+ ClassProp(
"comment",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/comment",
compact="comment",
- )
+ deprecated=False,
+ ),
+ ]
-# Provide an enumerated set of lifecycle phases that can provide context to relationships.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType", compact_type="LifecycleScopeType", abstract=False)
class LifecycleScopeType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Provide an enumerated set of lifecycle phases that can provide context to relationships.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType"
+ COMPACT_TYPE = "LifecycleScopeType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # A relationship has specific context implications during an element's build phase, during development.
"build": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/build",
+ # A relationship has specific context implications during an element's design.
"design": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/design",
+ # A relationship has specific context implications during development phase of an element.
"development": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/development",
+ # A relationship has other specific context information necessary to capture that the above set of enumerations does not handle.
"other": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/other",
+ # A relationship has specific context implications during the execution phase of an element.
"runtime": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/runtime",
+ # A relationship has specific context implications during an element's testing phase, during development.
"test": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/test",
}
- # A relationship has specific context implications during an element's build phase, during development.
- build = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/build"
- # A relationship has specific context implications during an element's design.
- design = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/design"
- # A relationship has specific context implications during development phase of an element.
- development = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/development"
- # A relationship has other specific context information necessary to capture that the above set of enumerations does not handle.
- other = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/other"
- # A relationship has specific context implications during the execution phase of an element.
- runtime = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/runtime"
- # A relationship has specific context implications during an element's testing phase, during development.
- test = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/test"
-
-
-# A mapping between prefixes and namespace partial URIs.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/NamespaceMap", compact_type="NamespaceMap", abstract=False)
+
+
class NamespaceMap(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ A mapping between prefixes and namespace partial URIs.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/NamespaceMap"
+ COMPACT_TYPE = "NamespaceMap"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Provides an unambiguous mechanism for conveying a URI fragment portion of an
# Element ID.
- cls._add_property(
+ ClassProp(
"namespace",
+ lambda:
AnyURIProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/namespace",
min_count=1,
compact="namespace",
- )
+ deprecated=False,
+ ),
# A substitute for a URI.
- cls._add_property(
+ ClassProp(
"prefix",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/prefix",
min_count=1,
compact="prefix",
- )
+ deprecated=False,
+ ),
+ ]
-# An SPDX version 2.X compatible verification method for software packages.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/PackageVerificationCode", compact_type="PackageVerificationCode", abstract=False)
class PackageVerificationCode(IntegrityMethod):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ An SPDX version 2.X compatible verification method for software packages.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/PackageVerificationCode"
+ COMPACT_TYPE = "PackageVerificationCode"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Specifies the algorithm used for calculating the hash value.
- cls._add_property(
+ ClassProp(
"algorithm",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/adler32", "adler32"),
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b256", "blake2b256"),
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b384", "blake2b384"),
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_384", "sha3_384"),
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_512", "sha3_512"),
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha512", "sha512"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Core/algorithm",
min_count=1,
compact="algorithm",
- )
+ deprecated=False,
+ ),
# The result of applying a hash algorithm to an Element.
- cls._add_property(
+ ClassProp(
"hashValue",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/hashValue",
min_count=1,
compact="hashValue",
- )
+ deprecated=False,
+ ),
# The relative file name of a file to be excluded from the
# `PackageVerificationCode`.
- cls._add_property(
+ ClassProp(
"packageVerificationCodeExcludedFile",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/Core/packageVerificationCodeExcludedFile",
compact="packageVerificationCodeExcludedFile",
- )
+ deprecated=False,
+ ),
+ ]
-# A tuple of two positive integers that define a range.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/PositiveIntegerRange", compact_type="PositiveIntegerRange", abstract=False)
class PositiveIntegerRange(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ A tuple of two positive integers that define a range.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/PositiveIntegerRange"
+ COMPACT_TYPE = "PositiveIntegerRange"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Defines the beginning of a range.
- cls._add_property(
+ ClassProp(
"beginIntegerRange",
+ lambda:
PositiveIntegerProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/beginIntegerRange",
min_count=1,
compact="beginIntegerRange",
- )
+ deprecated=False,
+ ),
# Defines the end of a range.
- cls._add_property(
+ ClassProp(
"endIntegerRange",
+ lambda:
PositiveIntegerProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/endIntegerRange",
min_count=1,
compact="endIntegerRange",
- )
+ deprecated=False,
+ ),
+ ]
-# Categories of presence or absence.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType", compact_type="PresenceType", abstract=False)
class PresenceType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Categories of presence or absence.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType"
+ COMPACT_TYPE = "PresenceType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # Indicates absence of the field.
"no": "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/no",
+ # Makes no assertion about the field.
"noAssertion": "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/noAssertion",
+ # Indicates presence of the field.
"yes": "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/yes",
}
- # Indicates absence of the field.
- no = "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/no"
- # Makes no assertion about the field.
- noAssertion = "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/noAssertion"
- # Indicates presence of the field.
- yes = "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/yes"
-# Enumeration of the valid profiles.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType", compact_type="ProfileIdentifierType", abstract=False)
class ProfileIdentifierType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Enumeration of the valid profiles.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType"
+ COMPACT_TYPE = "ProfileIdentifierType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # the element follows the AI profile specification
"ai": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/ai",
+ # the element follows the Build profile specification
"build": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/build",
+ # the element follows the Core profile specification
"core": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/core",
+ # the element follows the Dataset profile specification
"dataset": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/dataset",
+ # the element follows the ExpandedLicensing profile specification
"expandedLicensing": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/expandedLicensing",
+ # the element follows the Extension profile specification
"extension": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/extension",
+ # the element follows the Lite profile specification
"lite": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/lite",
+ # the element follows the Security profile specification
"security": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/security",
+ # the element follows the SimpleLicensing profile specification
"simpleLicensing": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/simpleLicensing",
+ # the element follows the Software profile specification
"software": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/software",
}
- # the element follows the AI profile specification
- ai = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/ai"
- # the element follows the Build profile specification
- build = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/build"
- # the element follows the Core profile specification
- core = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/core"
- # the element follows the Dataset profile specification
- dataset = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/dataset"
- # the element follows the ExpandedLicensing profile specification
- expandedLicensing = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/expandedLicensing"
- # the element follows the Extension profile specification
- extension = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/extension"
- # the element follows the Lite profile specification
- lite = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/lite"
- # the element follows the Security profile specification
- security = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/security"
- # the element follows the SimpleLicensing profile specification
- simpleLicensing = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/simpleLicensing"
- # the element follows the Software profile specification
- software = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/software"
-
-
-# Describes a relationship between one or more elements.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/Relationship", compact_type="Relationship", abstract=False)
+
+
class Relationship(Element):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Describes a relationship between one or more elements.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Relationship"
+ COMPACT_TYPE = "Relationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Provides information about the completeness of relationships.
- cls._add_property(
+ ClassProp(
"completeness",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/complete", "complete"),
("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/incomplete", "incomplete"),
("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/noAssertion", "noAssertion"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Core/completeness",
compact="completeness",
- )
+ deprecated=False,
+ ),
# Specifies the time from which an element is no longer applicable / valid.
- cls._add_property(
+ ClassProp(
"endTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Core/endTime",
compact="endTime",
- )
+ deprecated=False,
+ ),
# References the Element on the left-hand side of a relationship.
- cls._add_property(
+ ClassProp(
"from_",
- ObjectProp(Element, True, context=[
+ lambda:
+ ObjectProp(Element, True, context=(
+ ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
("https://spdx.org/rdf/3.0.1/terms/Core/NoneElement", "NoneElement"),
+ ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
- ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
- ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
- ],),
+ ),),
iri="https://spdx.org/rdf/3.0.1/terms/Core/from",
min_count=1,
compact="from",
- )
+ deprecated=False,
+ ),
# Information about the relationship between two Elements.
- cls._add_property(
+ ClassProp(
"relationshipType",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/affects", "affects"),
("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/amendedBy", "amendedBy"),
("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/ancestorOf", "ancestorOf"),
("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/trainedOn", "trainedOn"),
("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/underInvestigationFor", "underInvestigationFor"),
("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/usesTool", "usesTool"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Core/relationshipType",
min_count=1,
compact="relationshipType",
- )
+ deprecated=False,
+ ),
# Specifies the time from which an element is applicable / valid.
- cls._add_property(
+ ClassProp(
"startTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Core/startTime",
compact="startTime",
- )
+ deprecated=False,
+ ),
# References an Element on the right-hand side of a relationship.
- cls._add_property(
+ ClassProp(
"to",
- ListProp(ObjectProp(Element, False, context=[
+ lambda:
+ ListProp(ObjectProp(Element, False, context=(
+ ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
("https://spdx.org/rdf/3.0.1/terms/Core/NoneElement", "NoneElement"),
+ ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
- ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
- ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
- ],)),
+ ),)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/to",
min_count=1,
compact="to",
- )
+ deprecated=False,
+ ),
+ ]
-# Indicates whether a relationship is known to be complete, incomplete, or if no assertion is made with respect to relationship completeness.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness", compact_type="RelationshipCompleteness", abstract=False)
class RelationshipCompleteness(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Indicates whether a relationship is known to be complete, incomplete, or if no assertion is made with respect to relationship completeness.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness"
+ COMPACT_TYPE = "RelationshipCompleteness"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # The relationship is known to be exhaustive.
"complete": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/complete",
+ # The relationship is known not to be exhaustive.
"incomplete": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/incomplete",
+ # No assertion can be made about the completeness of the relationship.
"noAssertion": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/noAssertion",
}
- # The relationship is known to be exhaustive.
- complete = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/complete"
- # The relationship is known not to be exhaustive.
- incomplete = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/incomplete"
- # No assertion can be made about the completeness of the relationship.
- noAssertion = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/noAssertion"
-# Information about the relationship between two Elements.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType", compact_type="RelationshipType", abstract=False)
class RelationshipType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Information about the relationship between two Elements.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType"
+ COMPACT_TYPE = "RelationshipType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # The `from` Vulnerability affects each `to` Element. The use of the `affects` type is constrained to `VexAffectedVulnAssessmentRelationship` classed relationships.
"affects": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/affects",
+ # The `from` Element is amended by each `to` Element.
"amendedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/amendedBy",
+ # The `from` Element is an ancestor of each `to` Element.
"ancestorOf": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/ancestorOf",
+ # The `from` Element is available from the additional supplier described by each `to` Element.
"availableFrom": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/availableFrom",
+ # The `from` Element is a configuration applied to each `to` Element, during a LifecycleScopeType period.
"configures": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/configures",
+ # The `from` Element contains each `to` Element.
"contains": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/contains",
+ # The `from` Vulnerability is coordinatedBy the `to` Agent(s) (vendor, researcher, or consumer agent).
"coordinatedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/coordinatedBy",
+ # The `from` Element has been copied to each `to` Element.
"copiedTo": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/copiedTo",
+ # The `from` Agent is delegating an action to the Agent of the `to` Relationship (which must be of type invokedBy), during a LifecycleScopeType (e.g. the `to` invokedBy Relationship is being done on behalf of `from`).
"delegatedTo": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/delegatedTo",
+ # The `from` Element depends on each `to` Element, during a LifecycleScopeType period.
"dependsOn": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/dependsOn",
+ # The `from` Element is a descendant of each `to` Element.
"descendantOf": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/descendantOf",
+ # The `from` Element describes each `to` Element. To denote the root(s) of a tree of elements in a collection, the rootElement property should be used.
"describes": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/describes",
+ # The `from` Vulnerability has no impact on each `to` Element. The use of the `doesNotAffect` is constrained to `VexNotAffectedVulnAssessmentRelationship` classed relationships.
"doesNotAffect": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/doesNotAffect",
+ # The `from` archive expands out as an artifact described by each `to` Element.
"expandsTo": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/expandsTo",
+ # The `from` Vulnerability has had an exploit created against it by each `to` Agent.
"exploitCreatedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/exploitCreatedBy",
+ # Designates a `from` Vulnerability has been fixed by the `to` Agent(s).
"fixedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/fixedBy",
+ # A `from` Vulnerability has been fixed in each `to` Element. The use of the `fixedIn` type is constrained to `VexFixedVulnAssessmentRelationship` classed relationships.
"fixedIn": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/fixedIn",
+ # Designates a `from` Vulnerability was originally discovered by the `to` Agent(s).
"foundBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/foundBy",
+ # The `from` Element generates each `to` Element.
"generates": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/generates",
+ # Every `to` Element is a file added to the `from` Element (`from` hasAddedFile `to`).
"hasAddedFile": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAddedFile",
+ # Relates a `from` Vulnerability and each `to` Element with a security assessment. To be used with `VulnAssessmentRelationship` types.
"hasAssessmentFor": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAssessmentFor",
+ # Used to associate a `from` Artifact with each `to` Vulnerability.
"hasAssociatedVulnerability": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAssociatedVulnerability",
+ # The `from` SoftwareArtifact is concluded by the SPDX data creator to be governed by each `to` license.
"hasConcludedLicense": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasConcludedLicense",
+ # The `from` Element treats each `to` Element as a data file. A data file is an artifact that stores data required or optional for the `from` Element's functionality. A data file can be a database file, an index file, a log file, an AI model file, a calibration data file, a temporary file, a backup file, and more. For AI training dataset, test dataset, test artifact, configuration data, build input data, and build output data, please consider using the more specific relationship types: `trainedOn`, `testedOn`, `hasTest`, `configures`, `hasInput`, and `hasOutput`, respectively. This relationship does not imply dependency.
"hasDataFile": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDataFile",
+ # The `from` SoftwareArtifact was discovered to actually contain each `to` license, for example as detected by use of automated tooling.
"hasDeclaredLicense": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDeclaredLicense",
+ # Every `to` Element is a file deleted from the `from` Element (`from` hasDeletedFile `to`).
"hasDeletedFile": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDeletedFile",
+ # The `from` Element has manifest files that contain dependency information in each `to` Element.
"hasDependencyManifest": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDependencyManifest",
+ # The `from` Element is distributed as an artifact in each `to` Element (e.g. an RPM or archive file).
"hasDistributionArtifact": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDistributionArtifact",
+ # The `from` Element is documented by each `to` Element.
"hasDocumentation": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDocumentation",
+ # The `from` Element dynamically links in each `to` Element, during a LifecycleScopeType period.
"hasDynamicLink": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDynamicLink",
+ # Every `to` Element is considered as evidence for the `from` Element (`from` hasEvidence `to`).
"hasEvidence": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasEvidence",
+ # Every `to` Element is an example for the `from` Element (`from` hasExample `to`).
"hasExample": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasExample",
+ # The `from` Build was run on the `to` Element during a LifecycleScopeType period (e.g. the host that the build runs on).
"hasHost": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasHost",
+ # The `from` Build has each `to` Element as an input, during a LifecycleScopeType period.
"hasInput": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasInput",
+ # Every `to` Element is metadata about the `from` Element (`from` hasMetadata `to`).
"hasMetadata": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasMetadata",
+ # Every `to` Element is an optional component of the `from` Element (`from` hasOptionalComponent `to`).
"hasOptionalComponent": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOptionalComponent",
+ # The `from` Element optionally depends on each `to` Element, during a LifecycleScopeType period.
"hasOptionalDependency": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOptionalDependency",
+ # The `from` Build element generates each `to` Element as an output, during a LifecycleScopeType period.
"hasOutput": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOutput",
+ # The `from` Element has a prerequisite on each `to` Element, during a LifecycleScopeType period.
"hasPrerequisite": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasPrerequisite",
+ # The `from` Element has a dependency on each `to` Element, dependency is not in the distributed artifact, but assumed to be provided, during a LifecycleScopeType period.
"hasProvidedDependency": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasProvidedDependency",
+ # The `from` Element has a requirement on each `to` Element, during a LifecycleScopeType period.
"hasRequirement": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasRequirement",
+ # Every `to` Element is a specification for the `from` Element (`from` hasSpecification `to`), during a LifecycleScopeType period.
"hasSpecification": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasSpecification",
+ # The `from` Element statically links in each `to` Element, during a LifecycleScopeType period.
"hasStaticLink": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasStaticLink",
+ # Every `to` Element is a test artifact for the `from` Element (`from` hasTest `to`), during a LifecycleScopeType period.
"hasTest": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasTest",
+ # Every `to` Element is a test case for the `from` Element (`from` hasTestCase `to`).
"hasTestCase": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasTestCase",
+ # Every `to` Element is a variant the `from` Element (`from` hasVariant `to`).
"hasVariant": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasVariant",
+ # The `from` Element was invoked by the `to` Agent, during a LifecycleScopeType period (for example, a Build element that describes a build step).
"invokedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/invokedBy",
+ # The `from` Element is modified by each `to` Element.
"modifiedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/modifiedBy",
+ # Every `to` Element is related to the `from` Element where the relationship type is not described by any of the SPDX relationship types (this relationship is directionless).
"other": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/other",
+ # Every `to` Element is a packaged instance of the `from` Element (`from` packagedBy `to`).
"packagedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/packagedBy",
+ # Every `to` Element is a patch for the `from` Element (`from` patchedBy `to`).
"patchedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/patchedBy",
+ # Designates a `from` Vulnerability was made available for public use or reference by each `to` Agent.
"publishedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/publishedBy",
+ # Designates a `from` Vulnerability was first reported to a project, vendor, or tracking database for formal identification by each `to` Agent.
"reportedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/reportedBy",
+ # Designates a `from` Vulnerability's details were tracked, aggregated, and/or enriched to improve context (i.e. NVD) by each `to` Agent.
"republishedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/republishedBy",
+ # The `from` SpdxDocument can be found in a serialized form in each `to` Artifact.
"serializedInArtifact": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/serializedInArtifact",
+ # The `from` Element has been tested on the `to` Element(s).
"testedOn": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/testedOn",
+ # The `from` Element has been trained on the `to` Element(s).
"trainedOn": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/trainedOn",
+ # The `from` Vulnerability impact is being investigated for each `to` Element. The use of the `underInvestigationFor` type is constrained to `VexUnderInvestigationVulnAssessmentRelationship` classed relationships.
"underInvestigationFor": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/underInvestigationFor",
+ # The `from` Element uses each `to` Element as a tool, during a LifecycleScopeType period.
"usesTool": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/usesTool",
}
- # The `from` Vulnerability affects each `to` Element. The use of the `affects` type is constrained to `VexAffectedVulnAssessmentRelationship` classed relationships.
- affects = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/affects"
- # The `from` Element is amended by each `to` Element.
- amendedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/amendedBy"
- # The `from` Element is an ancestor of each `to` Element.
- ancestorOf = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/ancestorOf"
- # The `from` Element is available from the additional supplier described by each `to` Element.
- availableFrom = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/availableFrom"
- # The `from` Element is a configuration applied to each `to` Element, during a LifecycleScopeType period.
- configures = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/configures"
- # The `from` Element contains each `to` Element.
- contains = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/contains"
- # The `from` Vulnerability is coordinatedBy the `to` Agent(s) (vendor, researcher, or consumer agent).
- coordinatedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/coordinatedBy"
- # The `from` Element has been copied to each `to` Element.
- copiedTo = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/copiedTo"
- # The `from` Agent is delegating an action to the Agent of the `to` Relationship (which must be of type invokedBy), during a LifecycleScopeType (e.g. the `to` invokedBy Relationship is being done on behalf of `from`).
- delegatedTo = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/delegatedTo"
- # The `from` Element depends on each `to` Element, during a LifecycleScopeType period.
- dependsOn = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/dependsOn"
- # The `from` Element is a descendant of each `to` Element.
- descendantOf = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/descendantOf"
- # The `from` Element describes each `to` Element. To denote the root(s) of a tree of elements in a collection, the rootElement property should be used.
- describes = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/describes"
- # The `from` Vulnerability has no impact on each `to` Element. The use of the `doesNotAffect` is constrained to `VexNotAffectedVulnAssessmentRelationship` classed relationships.
- doesNotAffect = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/doesNotAffect"
- # The `from` archive expands out as an artifact described by each `to` Element.
- expandsTo = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/expandsTo"
- # The `from` Vulnerability has had an exploit created against it by each `to` Agent.
- exploitCreatedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/exploitCreatedBy"
- # Designates a `from` Vulnerability has been fixed by the `to` Agent(s).
- fixedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/fixedBy"
- # A `from` Vulnerability has been fixed in each `to` Element. The use of the `fixedIn` type is constrained to `VexFixedVulnAssessmentRelationship` classed relationships.
- fixedIn = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/fixedIn"
- # Designates a `from` Vulnerability was originally discovered by the `to` Agent(s).
- foundBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/foundBy"
- # The `from` Element generates each `to` Element.
- generates = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/generates"
- # Every `to` Element is a file added to the `from` Element (`from` hasAddedFile `to`).
- hasAddedFile = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAddedFile"
- # Relates a `from` Vulnerability and each `to` Element with a security assessment. To be used with `VulnAssessmentRelationship` types.
- hasAssessmentFor = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAssessmentFor"
- # Used to associate a `from` Artifact with each `to` Vulnerability.
- hasAssociatedVulnerability = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAssociatedVulnerability"
- # The `from` SoftwareArtifact is concluded by the SPDX data creator to be governed by each `to` license.
- hasConcludedLicense = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasConcludedLicense"
- # The `from` Element treats each `to` Element as a data file. A data file is an artifact that stores data required or optional for the `from` Element's functionality. A data file can be a database file, an index file, a log file, an AI model file, a calibration data file, a temporary file, a backup file, and more. For AI training dataset, test dataset, test artifact, configuration data, build input data, and build output data, please consider using the more specific relationship types: `trainedOn`, `testedOn`, `hasTest`, `configures`, `hasInput`, and `hasOutput`, respectively. This relationship does not imply dependency.
- hasDataFile = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDataFile"
- # The `from` SoftwareArtifact was discovered to actually contain each `to` license, for example as detected by use of automated tooling.
- hasDeclaredLicense = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDeclaredLicense"
- # Every `to` Element is a file deleted from the `from` Element (`from` hasDeletedFile `to`).
- hasDeletedFile = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDeletedFile"
- # The `from` Element has manifest files that contain dependency information in each `to` Element.
- hasDependencyManifest = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDependencyManifest"
- # The `from` Element is distributed as an artifact in each `to` Element (e.g. an RPM or archive file).
- hasDistributionArtifact = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDistributionArtifact"
- # The `from` Element is documented by each `to` Element.
- hasDocumentation = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDocumentation"
- # The `from` Element dynamically links in each `to` Element, during a LifecycleScopeType period.
- hasDynamicLink = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDynamicLink"
- # Every `to` Element is considered as evidence for the `from` Element (`from` hasEvidence `to`).
- hasEvidence = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasEvidence"
- # Every `to` Element is an example for the `from` Element (`from` hasExample `to`).
- hasExample = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasExample"
- # The `from` Build was run on the `to` Element during a LifecycleScopeType period (e.g. the host that the build runs on).
- hasHost = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasHost"
- # The `from` Build has each `to` Element as an input, during a LifecycleScopeType period.
- hasInput = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasInput"
- # Every `to` Element is metadata about the `from` Element (`from` hasMetadata `to`).
- hasMetadata = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasMetadata"
- # Every `to` Element is an optional component of the `from` Element (`from` hasOptionalComponent `to`).
- hasOptionalComponent = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOptionalComponent"
- # The `from` Element optionally depends on each `to` Element, during a LifecycleScopeType period.
- hasOptionalDependency = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOptionalDependency"
- # The `from` Build element generates each `to` Element as an output, during a LifecycleScopeType period.
- hasOutput = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOutput"
- # The `from` Element has a prerequisite on each `to` Element, during a LifecycleScopeType period.
- hasPrerequisite = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasPrerequisite"
- # The `from` Element has a dependency on each `to` Element, dependency is not in the distributed artifact, but assumed to be provided, during a LifecycleScopeType period.
- hasProvidedDependency = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasProvidedDependency"
- # The `from` Element has a requirement on each `to` Element, during a LifecycleScopeType period.
- hasRequirement = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasRequirement"
- # Every `to` Element is a specification for the `from` Element (`from` hasSpecification `to`), during a LifecycleScopeType period.
- hasSpecification = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasSpecification"
- # The `from` Element statically links in each `to` Element, during a LifecycleScopeType period.
- hasStaticLink = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasStaticLink"
- # Every `to` Element is a test artifact for the `from` Element (`from` hasTest `to`), during a LifecycleScopeType period.
- hasTest = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasTest"
- # Every `to` Element is a test case for the `from` Element (`from` hasTestCase `to`).
- hasTestCase = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasTestCase"
- # Every `to` Element is a variant the `from` Element (`from` hasVariant `to`).
- hasVariant = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasVariant"
- # The `from` Element was invoked by the `to` Agent, during a LifecycleScopeType period (for example, a Build element that describes a build step).
- invokedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/invokedBy"
- # The `from` Element is modified by each `to` Element.
- modifiedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/modifiedBy"
- # Every `to` Element is related to the `from` Element where the relationship type is not described by any of the SPDX relationship types (this relationship is directionless).
- other = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/other"
- # Every `to` Element is a packaged instance of the `from` Element (`from` packagedBy `to`).
- packagedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/packagedBy"
- # Every `to` Element is a patch for the `from` Element (`from` patchedBy `to`).
- patchedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/patchedBy"
- # Designates a `from` Vulnerability was made available for public use or reference by each `to` Agent.
- publishedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/publishedBy"
- # Designates a `from` Vulnerability was first reported to a project, vendor, or tracking database for formal identification by each `to` Agent.
- reportedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/reportedBy"
- # Designates a `from` Vulnerability's details were tracked, aggregated, and/or enriched to improve context (i.e. NVD) by each `to` Agent.
- republishedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/republishedBy"
- # The `from` SpdxDocument can be found in a serialized form in each `to` Artifact.
- serializedInArtifact = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/serializedInArtifact"
- # The `from` Element has been tested on the `to` Element(s).
- testedOn = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/testedOn"
- # The `from` Element has been trained on the `to` Element(s).
- trainedOn = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/trainedOn"
- # The `from` Vulnerability impact is being investigated for each `to` Element. The use of the `underInvestigationFor` type is constrained to `VexUnderInvestigationVulnAssessmentRelationship` classed relationships.
- underInvestigationFor = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/underInvestigationFor"
- # The `from` Element uses each `to` Element as a tool, during a LifecycleScopeType period.
- usesTool = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/usesTool"
-
-
-# A collection of SPDX Elements that could potentially be serialized.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/SpdxDocument", compact_type="SpdxDocument", abstract=False)
+
+
class SpdxDocument(ElementCollection):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A collection of SPDX Elements that could potentially be serialized.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/SpdxDocument"
+ COMPACT_TYPE = "SpdxDocument"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Provides the license under which the SPDX documentation of the Element can be
# used.
- cls._add_property(
+ ClassProp(
"dataLicense",
- ObjectProp(simplelicensing_AnyLicenseInfo, False, context=[
+ lambda:
+ ObjectProp(simplelicensing_AnyLicenseInfo, False, context=(
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
- ],),
+ ),),
iri="https://spdx.org/rdf/3.0.1/terms/Core/dataLicense",
compact="dataLicense",
- )
+ deprecated=False,
+ ),
# Provides an ExternalMap of Element identifiers.
- cls._add_property(
+ ClassProp(
"import_",
+ lambda:
ListProp(ObjectProp(ExternalMap, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/import",
compact="import",
- )
+ deprecated=False,
+ ),
# Provides a NamespaceMap of prefixes and associated namespace partial URIs applicable to an SpdxDocument and independent of any specific serialization format or instance.
- cls._add_property(
+ ClassProp(
"namespaceMap",
+ lambda:
ListProp(ObjectProp(NamespaceMap, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/namespaceMap",
compact="namespaceMap",
- )
+ deprecated=False,
+ ),
+ ]
-# Indicates the type of support that is associated with an artifact.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/SupportType", compact_type="SupportType", abstract=False)
class SupportType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Indicates the type of support that is associated with an artifact.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType"
+ COMPACT_TYPE = "SupportType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # in addition to being supported by the supplier, the software is known to have been deployed and is in use. For a software as a service provider, this implies the software is now available as a service.
"deployed": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/deployed",
+ # the artifact is in active development and is not considered ready for formal support from the supplier.
"development": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/development",
+ # there is a defined end of support for the artifact from the supplier. This may also be referred to as end of life. There is a validUntilDate that can be used to signal when support ends for the artifact.
"endOfSupport": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/endOfSupport",
+ # the artifact has been released, and there is limited support available from the supplier. There is a validUntilDate that can provide additional information about the duration of support.
"limitedSupport": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/limitedSupport",
+ # no assertion about the type of support is made. This is considered the default if no other support type is used.
"noAssertion": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noAssertion",
+ # there is no support for the artifact from the supplier, consumer assumes any support obligations.
"noSupport": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noSupport",
+ # the artifact has been released, and is supported from the supplier. There is a validUntilDate that can provide additional information about the duration of support.
"support": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/support",
}
- # in addition to being supported by the supplier, the software is known to have been deployed and is in use. For a software as a service provider, this implies the software is now available as a service.
- deployed = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/deployed"
- # the artifact is in active development and is not considered ready for formal support from the supplier.
- development = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/development"
- # there is a defined end of support for the artifact from the supplier. This may also be referred to as end of life. There is a validUntilDate that can be used to signal when support ends for the artifact.
- endOfSupport = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/endOfSupport"
- # the artifact has been released, and there is limited support available from the supplier. There is a validUntilDate that can provide additional information about the duration of support.
- limitedSupport = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/limitedSupport"
- # no assertion about the type of support is made. This is considered the default if no other support type is used.
- noAssertion = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noAssertion"
- # there is no support for the artifact from the supplier, consumer assumes any support obligations.
- noSupport = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noSupport"
- # the artifact has been released, and is supported from the supplier. There is a validUntilDate that can provide additional information about the duration of support.
- support = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/support"
-
-
-# An element of hardware and/or software utilized to carry out a particular function.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/Tool", compact_type="Tool", abstract=False)
+
+
class Tool(Element):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ An element of hardware and/or software utilized to carry out a particular function.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Tool"
+ COMPACT_TYPE = "Tool"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
-# Categories of confidentiality level.
-@register("https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType", compact_type="dataset_ConfidentialityLevelType", abstract=False)
class dataset_ConfidentialityLevelType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Categories of confidentiality level.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType"
+ COMPACT_TYPE = "dataset_ConfidentialityLevelType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # Data points in the dataset can be shared only with specific organizations and their clients on a need to know basis.
"amber": "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/amber",
+ # Dataset may be distributed freely, without restriction.
"clear": "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/clear",
+ # Dataset can be shared within a community of peers and partners.
"green": "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/green",
+ # Data points in the dataset are highly confidential and can only be shared with named recipients.
"red": "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/red",
}
- # Data points in the dataset can be shared only with specific organizations and their clients on a need to know basis.
- amber = "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/amber"
- # Dataset may be distributed freely, without restriction.
- clear = "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/clear"
- # Dataset can be shared within a community of peers and partners.
- green = "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/green"
- # Data points in the dataset are highly confidential and can only be shared with named recipients.
- red = "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/red"
-
-
-# Availability of dataset.
-@register("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType", compact_type="dataset_DatasetAvailabilityType", abstract=False)
+
+
class dataset_DatasetAvailabilityType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Availability of dataset.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType"
+ COMPACT_TYPE = "dataset_DatasetAvailabilityType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # the dataset is not publicly available and can only be accessed after affirmatively accepting terms on a clickthrough webpage.
"clickthrough": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/clickthrough",
+ # the dataset is publicly available and can be downloaded directly.
"directDownload": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/directDownload",
+ # the dataset is publicly available, but not all at once, and can only be accessed through queries which return parts of the dataset.
"query": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/query",
+ # the dataset is not publicly available and an email registration is required before accessing the dataset, although without an affirmative acceptance of terms.
"registration": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/registration",
+ # the dataset provider is not making available the underlying data and the dataset must be reassembled, typically using the provided script for scraping the data.
"scrapingScript": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/scrapingScript",
}
- # the dataset is not publicly available and can only be accessed after affirmatively accepting terms on a clickthrough webpage.
- clickthrough = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/clickthrough"
- # the dataset is publicly available and can be downloaded directly.
- directDownload = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/directDownload"
- # the dataset is publicly available, but not all at once, and can only be accessed through queries which return parts of the dataset.
- query = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/query"
- # the dataset is not publicly available and an email registration is required before accessing the dataset, although without an affirmative acceptance of terms.
- registration = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/registration"
- # the dataset provider is not making available the underlying data and the dataset must be reassembled, typically using the provided script for scraping the data.
- scrapingScript = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/scrapingScript"
-
-
-# Enumeration of dataset types.
-@register("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType", compact_type="dataset_DatasetType", abstract=False)
+
+
class dataset_DatasetType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Enumeration of dataset types.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType"
+ COMPACT_TYPE = "dataset_DatasetType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # data is audio based, such as a collection of music from the 80s.
"audio": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/audio",
+ # data that is classified into a discrete number of categories, such as the eye color of a population of people.
"categorical": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/categorical",
+ # data is in the form of a graph where entries are somehow related to each other through edges, such a social network of friends.
"graph": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/graph",
+ # data is a collection of images such as pictures of animals.
"image": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/image",
+ # data type is not known.
"noAssertion": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/noAssertion",
+ # data consists only of numeric entries.
"numeric": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/numeric",
+ # data is of a type not included in this list.
"other": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/other",
+ # data is recorded from a physical sensor, such as a thermometer reading or biometric device.
"sensor": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/sensor",
+ # data is stored in tabular format or retrieved from a relational database.
"structured": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/structured",
+ # data describes the syntax or semantics of a language or text, such as a parse tree used for natural language processing.
"syntactic": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/syntactic",
+ # data consists of unstructured text, such as a book, Wikipedia article (without images), or transcript.
"text": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/text",
+ # data is recorded in an ordered sequence of timestamped entries, such as the price of a stock over the course of a day.
"timeseries": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timeseries",
+ # data is recorded with a timestamp for each entry, but not necessarily ordered or at specific intervals, such as when a taxi ride starts and ends.
"timestamp": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timestamp",
+ # data is video based, such as a collection of movie clips featuring Tom Hanks.
"video": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/video",
}
- # data is audio based, such as a collection of music from the 80s.
- audio = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/audio"
- # data that is classified into a discrete number of categories, such as the eye color of a population of people.
- categorical = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/categorical"
- # data is in the form of a graph where entries are somehow related to each other through edges, such a social network of friends.
- graph = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/graph"
- # data is a collection of images such as pictures of animals.
- image = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/image"
- # data type is not known.
- noAssertion = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/noAssertion"
- # data consists only of numeric entries.
- numeric = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/numeric"
- # data is of a type not included in this list.
- other = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/other"
- # data is recorded from a physical sensor, such as a thermometer reading or biometric device.
- sensor = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/sensor"
- # data is stored in tabular format or retrieved from a relational database.
- structured = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/structured"
- # data describes the syntax or semantics of a language or text, such as a parse tree used for natural language processing.
- syntactic = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/syntactic"
- # data consists of unstructured text, such as a book, Wikipedia article (without images), or transcript.
- text = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/text"
- # data is recorded in an ordered sequence of timestamped entries, such as the price of a stock over the course of a day.
- timeseries = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timeseries"
- # data is recorded with a timestamp for each entry, but not necessarily ordered or at specific intervals, such as when a taxi ride starts and ends.
- timestamp = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timestamp"
- # data is video based, such as a collection of movie clips featuring Tom Hanks.
- video = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/video"
-
-
-# Abstract class for additional text intended to be added to a License, but
-# which is not itself a standalone License.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/LicenseAddition", compact_type="expandedlicensing_LicenseAddition", abstract=True)
+
+
class expandedlicensing_LicenseAddition(Element):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Abstract class for additional text intended to be added to a License, but
+ which is not itself a standalone License.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/LicenseAddition"
+ COMPACT_TYPE = "expandedlicensing_LicenseAddition"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ IS_ABSTRACT: bool = True
+ PROPERTIES = [
# Identifies the full text of a LicenseAddition.
- cls._add_property(
+ ClassProp(
"expandedlicensing_additionText",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/additionText",
min_count=1,
compact="expandedlicensing_additionText",
- )
+ deprecated=False,
+ ),
# Specifies whether an additional text identifier has been marked as deprecated.
- cls._add_property(
+ ClassProp(
"expandedlicensing_isDeprecatedAdditionId",
+ lambda:
BooleanProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/isDeprecatedAdditionId",
compact="expandedlicensing_isDeprecatedAdditionId",
- )
+ deprecated=False,
+ ),
# Identifies all the text and metadata associated with a license in the license
# XML format.
- cls._add_property(
+ ClassProp(
"expandedlicensing_licenseXml",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/licenseXml",
compact="expandedlicensing_licenseXml",
- )
+ deprecated=False,
+ ),
# Specifies the licenseId that is preferred to be used in place of a deprecated
# License or LicenseAddition.
- cls._add_property(
+ ClassProp(
"expandedlicensing_obsoletedBy",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/obsoletedBy",
compact="expandedlicensing_obsoletedBy",
- )
+ deprecated=False,
+ ),
# Contains a URL where the License or LicenseAddition can be found in use.
- cls._add_property(
+ ClassProp(
"expandedlicensing_seeAlso",
+ lambda:
ListProp(AnyURIProp()),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/seeAlso",
compact="expandedlicensing_seeAlso",
- )
+ deprecated=False,
+ ),
# Identifies the full text of a LicenseAddition, in SPDX templating format.
- cls._add_property(
+ ClassProp(
"expandedlicensing_standardAdditionTemplate",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/standardAdditionTemplate",
compact="expandedlicensing_standardAdditionTemplate",
- )
+ deprecated=False,
+ ),
+ ]
-# A license exception that is listed on the SPDX Exceptions list.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ListedLicenseException", compact_type="expandedlicensing_ListedLicenseException", abstract=False)
class expandedlicensing_ListedLicenseException(expandedlicensing_LicenseAddition):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A license exception that is listed on the SPDX Exceptions list.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ListedLicenseException"
+ COMPACT_TYPE = "expandedlicensing_ListedLicenseException"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Specifies the SPDX License List version in which this license or exception
# identifier was deprecated.
- cls._add_property(
+ ClassProp(
"expandedlicensing_deprecatedVersion",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/deprecatedVersion",
compact="expandedlicensing_deprecatedVersion",
- )
+ deprecated=False,
+ ),
# Specifies the SPDX License List version in which this ListedLicense or
# ListedLicenseException identifier was first added.
- cls._add_property(
+ ClassProp(
"expandedlicensing_listVersionAdded",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/listVersionAdded",
compact="expandedlicensing_listVersionAdded",
- )
+ deprecated=False,
+ ),
+ ]
-# A property name with an associated value.
-@register("https://spdx.org/rdf/3.0.1/terms/Extension/CdxPropertyEntry", compact_type="extension_CdxPropertyEntry", abstract=False)
class extension_CdxPropertyEntry(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ A property name with an associated value.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Extension/CdxPropertyEntry"
+ COMPACT_TYPE = "extension_CdxPropertyEntry"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# A name used in a CdxPropertyEntry name-value pair.
- cls._add_property(
+ ClassProp(
"extension_cdxPropName",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Extension/cdxPropName",
min_count=1,
compact="extension_cdxPropName",
- )
+ deprecated=False,
+ ),
# A value used in a CdxPropertyEntry name-value pair.
- cls._add_property(
+ ClassProp(
"extension_cdxPropValue",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Extension/cdxPropValue",
compact="extension_cdxPropValue",
- )
+ deprecated=False,
+ ),
+ ]
-# A characterization of some aspect of an Element that is associated with the Element in a generalized fashion.
-@register("https://spdx.org/rdf/3.0.1/terms/Extension/Extension", compact_type="extension_Extension", abstract=True)
-class extension_Extension(SHACLExtensibleObject, SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+class extension_Extension(SHACLExtensibleObject):
+ """
+ A characterization of some aspect of an Element that is associated with the Element in a generalized fashion.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Extension/Extension"
+ COMPACT_TYPE = "extension_Extension"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ IS_ABSTRACT: bool = True
-# Specifies the CVSS base, temporal, threat, or environmental severity type.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType", compact_type="security_CvssSeverityType", abstract=False)
class security_CvssSeverityType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Specifies the CVSS base, temporal, threat, or environmental severity type.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType"
+ COMPACT_TYPE = "security_CvssSeverityType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # When a CVSS score is between 9.0 - 10.0
"critical": "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/critical",
+ # When a CVSS score is between 7.0 - 8.9
"high": "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/high",
+ # When a CVSS score is between 0.1 - 3.9
"low": "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/low",
+ # When a CVSS score is between 4.0 - 6.9
"medium": "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/medium",
+ # When a CVSS score is 0.0
"none": "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/none",
}
- # When a CVSS score is between 9.0 - 10.0
- critical = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/critical"
- # When a CVSS score is between 7.0 - 8.9
- high = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/high"
- # When a CVSS score is between 0.1 - 3.9
- low = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/low"
- # When a CVSS score is between 4.0 - 6.9
- medium = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/medium"
- # When a CVSS score is 0.0
- none = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/none"
-
-
-# Specifies the exploit catalog type.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType", compact_type="security_ExploitCatalogType", abstract=False)
+
+
class security_ExploitCatalogType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Specifies the exploit catalog type.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType"
+ COMPACT_TYPE = "security_ExploitCatalogType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # CISA's Known Exploited Vulnerability (KEV) Catalog
"kev": "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/kev",
+ # Other exploit catalogs
"other": "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/other",
}
- # CISA's Known Exploited Vulnerability (KEV) Catalog
- kev = "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/kev"
- # Other exploit catalogs
- other = "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/other"
-# Specifies the SSVC decision type.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType", compact_type="security_SsvcDecisionType", abstract=False)
class security_SsvcDecisionType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Specifies the SSVC decision type.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType"
+ COMPACT_TYPE = "security_SsvcDecisionType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # The vulnerability requires attention from the organization's internal, supervisory-level and leadership-level individuals. Necessary actions include requesting assistance or information about the vulnerability, as well as publishing a notification either internally and/or externally. Typically, internal groups would meet to determine the overall response and then execute agreed upon actions. CISA recommends remediating Act vulnerabilities as soon as possible.
"act": "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/act",
+ # The vulnerability requires attention from the organization's internal, supervisory-level individuals. Necessary actions include requesting assistance or information about the vulnerability, and may involve publishing a notification either internally and/or externally. CISA recommends remediating Attend vulnerabilities sooner than standard update timelines.
"attend": "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/attend",
+ # The vulnerability does not require action at this time. The organization would continue to track the vulnerability and reassess it if new information becomes available. CISA recommends remediating Track vulnerabilities within standard update timelines.
"track": "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/track",
+ # ("Track\*" in the SSVC spec) The vulnerability contains specific characteristics that may require closer monitoring for changes. CISA recommends remediating Track\* vulnerabilities within standard update timelines.
"trackStar": "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/trackStar",
}
- # The vulnerability requires attention from the organization's internal, supervisory-level and leadership-level individuals. Necessary actions include requesting assistance or information about the vulnerability, as well as publishing a notification either internally and/or externally. Typically, internal groups would meet to determine the overall response and then execute agreed upon actions. CISA recommends remediating Act vulnerabilities as soon as possible.
- act = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/act"
- # The vulnerability requires attention from the organization's internal, supervisory-level individuals. Necessary actions include requesting assistance or information about the vulnerability, and may involve publishing a notification either internally and/or externally. CISA recommends remediating Attend vulnerabilities sooner than standard update timelines.
- attend = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/attend"
- # The vulnerability does not require action at this time. The organization would continue to track the vulnerability and reassess it if new information becomes available. CISA recommends remediating Track vulnerabilities within standard update timelines.
- track = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/track"
- # ("Track\*" in the SSVC spec) The vulnerability contains specific characteristics that may require closer monitoring for changes. CISA recommends remediating Track\* vulnerabilities within standard update timelines.
- trackStar = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/trackStar"
-
-
-# Specifies the VEX justification type.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType", compact_type="security_VexJustificationType", abstract=False)
+
+
class security_VexJustificationType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Specifies the VEX justification type.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType"
+ COMPACT_TYPE = "security_VexJustificationType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # The software is not affected because the vulnerable component is not in the product.
"componentNotPresent": "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/componentNotPresent",
+ # Built-in inline controls or mitigations prevent an adversary from leveraging the vulnerability.
"inlineMitigationsAlreadyExist": "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/inlineMitigationsAlreadyExist",
+ # The vulnerable component is present, and the component contains the vulnerable code. However, vulnerable code is used in such a way that an attacker cannot mount any anticipated attack.
"vulnerableCodeCannotBeControlledByAdversary": "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeCannotBeControlledByAdversary",
+ # The affected code is not reachable through the execution of the code, including non-anticipated states of the product.
"vulnerableCodeNotInExecutePath": "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotInExecutePath",
+ # The product is not affected because the code underlying the vulnerability is not present in the product.
"vulnerableCodeNotPresent": "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotPresent",
}
- # The software is not affected because the vulnerable component is not in the product.
- componentNotPresent = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/componentNotPresent"
- # Built-in inline controls or mitigations prevent an adversary from leveraging the vulnerability.
- inlineMitigationsAlreadyExist = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/inlineMitigationsAlreadyExist"
- # The vulnerable component is present, and the component contains the vulnerable code. However, vulnerable code is used in such a way that an attacker cannot mount any anticipated attack.
- vulnerableCodeCannotBeControlledByAdversary = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeCannotBeControlledByAdversary"
- # The affected code is not reachable through the execution of the code, including non-anticipated states of the product.
- vulnerableCodeNotInExecutePath = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotInExecutePath"
- # The product is not affected because the code underlying the vulnerability is not present in the product.
- vulnerableCodeNotPresent = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotPresent"
-
-
-# Abstract ancestor class for all vulnerability assessments
-@register("https://spdx.org/rdf/3.0.1/terms/Security/VulnAssessmentRelationship", compact_type="security_VulnAssessmentRelationship", abstract=True)
+
+
class security_VulnAssessmentRelationship(Relationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Abstract ancestor class for all vulnerability assessments
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ IS_ABSTRACT: bool = True
+ PROPERTIES = [
# Identifies who or what supplied the artifact or VulnAssessmentRelationship
# referenced by the Element.
- cls._add_property(
+ ClassProp(
"suppliedBy",
- ObjectProp(Agent, False, context=[
+ lambda:
+ ObjectProp(Agent, False, context=(
("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
- ],),
+ ),),
iri="https://spdx.org/rdf/3.0.1/terms/Core/suppliedBy",
compact="suppliedBy",
- )
+ deprecated=False,
+ ),
# Specifies an Element contained in a piece of software where a vulnerability was
# found.
- cls._add_property(
+ ClassProp(
"security_assessedElement",
+ lambda:
ObjectProp(software_SoftwareArtifact, False),
iri="https://spdx.org/rdf/3.0.1/terms/Security/assessedElement",
compact="security_assessedElement",
- )
+ deprecated=False,
+ ),
# Specifies a time when a vulnerability assessment was modified
- cls._add_property(
+ ClassProp(
"security_modifiedTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Security/modifiedTime",
compact="security_modifiedTime",
- )
+ deprecated=False,
+ ),
# Specifies the time when a vulnerability was published.
- cls._add_property(
+ ClassProp(
"security_publishedTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Security/publishedTime",
compact="security_publishedTime",
- )
+ deprecated=False,
+ ),
# Specified the time and date when a vulnerability was withdrawn.
- cls._add_property(
+ ClassProp(
"security_withdrawnTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Security/withdrawnTime",
compact="security_withdrawnTime",
- )
+ deprecated=False,
+ ),
+ ]
-# Abstract class representing a license combination consisting of one or more licenses.
-@register("https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/AnyLicenseInfo", compact_type="simplelicensing_AnyLicenseInfo", abstract=True)
class simplelicensing_AnyLicenseInfo(Element):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Abstract class representing a license combination consisting of one or more licenses.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/AnyLicenseInfo"
+ COMPACT_TYPE = "simplelicensing_AnyLicenseInfo"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ IS_ABSTRACT: bool = True
-# An SPDX Element containing an SPDX license expression string.
-@register("https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/LicenseExpression", compact_type="simplelicensing_LicenseExpression", abstract=False)
class simplelicensing_LicenseExpression(simplelicensing_AnyLicenseInfo):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ An SPDX Element containing an SPDX license expression string.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/LicenseExpression"
+ COMPACT_TYPE = "simplelicensing_LicenseExpression"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Maps a LicenseRef or AdditionRef string for a Custom License or a Custom
# License Addition to its URI ID.
- cls._add_property(
+ ClassProp(
"simplelicensing_customIdToUri",
+ lambda:
ListProp(ObjectProp(DictionaryEntry, False)),
iri="https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/customIdToUri",
compact="simplelicensing_customIdToUri",
- )
+ deprecated=False,
+ ),
# A string in the license expression format.
- cls._add_property(
+ ClassProp(
"simplelicensing_licenseExpression",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/licenseExpression",
min_count=1,
compact="simplelicensing_licenseExpression",
- )
+ deprecated=False,
+ ),
# The version of the SPDX License List used in the license expression.
- cls._add_property(
+ ClassProp(
"simplelicensing_licenseListVersion",
- StringProp(pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$",),
+ lambda:
+ StringProp(pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"),
iri="https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/licenseListVersion",
compact="simplelicensing_licenseListVersion",
- )
+ deprecated=False,
+ ),
+ ]
-# A license or addition that is not listed on the SPDX License List.
-@register("https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/SimpleLicensingText", compact_type="simplelicensing_SimpleLicensingText", abstract=False)
class simplelicensing_SimpleLicensingText(Element):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A license or addition that is not listed on the SPDX License List.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/SimpleLicensingText"
+ COMPACT_TYPE = "simplelicensing_SimpleLicensingText"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Identifies the full text of a License or Addition.
- cls._add_property(
+ ClassProp(
"simplelicensing_licenseText",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/licenseText",
min_count=1,
compact="simplelicensing_licenseText",
- )
+ deprecated=False,
+ ),
+ ]
-# A canonical, unique, immutable identifier
-@register("https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifier", compact_type="software_ContentIdentifier", abstract=False)
class software_ContentIdentifier(IntegrityMethod):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ A canonical, unique, immutable identifier
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifier"
+ COMPACT_TYPE = "software_ContentIdentifier"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Specifies the type of the content identifier.
- cls._add_property(
+ ClassProp(
"software_contentIdentifierType",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/gitoid", "gitoid"),
("https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/swhid", "swhid"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Software/contentIdentifierType",
min_count=1,
compact="software_contentIdentifierType",
- )
+ deprecated=False,
+ ),
# Specifies the value of the content identifier.
- cls._add_property(
+ ClassProp(
"software_contentIdentifierValue",
+ lambda:
AnyURIProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Software/contentIdentifierValue",
min_count=1,
compact="software_contentIdentifierValue",
- )
+ deprecated=False,
+ ),
+ ]
-# Specifies the type of a content identifier.
-@register("https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType", compact_type="software_ContentIdentifierType", abstract=False)
class software_ContentIdentifierType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Specifies the type of a content identifier.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType"
+ COMPACT_TYPE = "software_ContentIdentifierType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # [Gitoid](https://www.iana.org/assignments/uri-schemes/prov/gitoid), stands for [Git Object ID](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects). A gitoid of type blob is a unique hash of a binary artifact. A gitoid may represent either an [Artifact Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-identifier-types) for the software artifact or an [Input Manifest Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#input-manifest-identifier) for the software artifact's associated [Artifact Input Manifest](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-input-manifest); this ambiguity exists because the Artifact Input Manifest is itself an artifact, and the gitoid of that artifact is its valid identifier. Gitoids calculated on software artifacts (Snippet, File, or Package Elements) should be recorded in the SPDX 3.0 SoftwareArtifact's contentIdentifier property. Gitoids calculated on the Artifact Input Manifest (Input Manifest Identifier) should be recorded in the SPDX 3.0 Element's externalIdentifier property. See [OmniBOR Specification](https://github.com/omnibor/spec/), a minimalistic specification for describing software [Artifact Dependency Graphs](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-dependency-graph-adg).
"gitoid": "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/gitoid",
+ # SoftWare Hash IDentifier, a persistent intrinsic identifier for digital artifacts, such as files, trees (also known as directories or folders), commits, and other objects typically found in version control systems. The format of the identifiers is defined in the [SWHID specification](https://www.swhid.org/specification/v1.1/4.Syntax) (ISO/IEC DIS 18670). They typically look like `swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2`.
"swhid": "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/swhid",
}
- # [Gitoid](https://www.iana.org/assignments/uri-schemes/prov/gitoid), stands for [Git Object ID](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects). A gitoid of type blob is a unique hash of a binary artifact. A gitoid may represent either an [Artifact Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-identifier-types) for the software artifact or an [Input Manifest Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#input-manifest-identifier) for the software artifact's associated [Artifact Input Manifest](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-input-manifest); this ambiguity exists because the Artifact Input Manifest is itself an artifact, and the gitoid of that artifact is its valid identifier. Gitoids calculated on software artifacts (Snippet, File, or Package Elements) should be recorded in the SPDX 3.0 SoftwareArtifact's contentIdentifier property. Gitoids calculated on the Artifact Input Manifest (Input Manifest Identifier) should be recorded in the SPDX 3.0 Element's externalIdentifier property. See [OmniBOR Specification](https://github.com/omnibor/spec/), a minimalistic specification for describing software [Artifact Dependency Graphs](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-dependency-graph-adg).
- gitoid = "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/gitoid"
- # SoftWare Hash IDentifier, a persistent intrinsic identifier for digital artifacts, such as files, trees (also known as directories or folders), commits, and other objects typically found in version control systems. The format of the identifiers is defined in the [SWHID specification](https://www.swhid.org/specification/v1.1/4.Syntax) (ISO/IEC DIS 18670). They typically look like `swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2`.
- swhid = "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/swhid"
-# Enumeration of the different kinds of SPDX file.
-@register("https://spdx.org/rdf/3.0.1/terms/Software/FileKindType", compact_type="software_FileKindType", abstract=False)
class software_FileKindType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Enumeration of the different kinds of SPDX file.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/FileKindType"
+ COMPACT_TYPE = "software_FileKindType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # The file represents a directory and all content stored in that directory.
"directory": "https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/directory",
+ # The file represents a single file (default).
"file": "https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/file",
}
- # The file represents a directory and all content stored in that directory.
- directory = "https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/directory"
- # The file represents a single file (default).
- file = "https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/file"
-# Provides a set of values to be used to describe the common types of SBOMs that
-# tools may create.
-@register("https://spdx.org/rdf/3.0.1/terms/Software/SbomType", compact_type="software_SbomType", abstract=False)
class software_SbomType(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Provides a set of values to be used to describe the common types of SBOMs that
+ tools may create.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType"
+ COMPACT_TYPE = "software_SbomType"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # SBOM generated through analysis of artifacts (e.g., executables, packages, containers, and virtual machine images) after its build. Such analysis generally requires a variety of heuristics. In some contexts, this may also be referred to as a "3rd party" SBOM.
"analyzed": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/analyzed",
+ # SBOM generated as part of the process of building the software to create a releasable artifact (e.g., executable or package) from data such as source files, dependencies, built components, build process ephemeral data, and other SBOMs.
"build": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/build",
+ # SBOM provides an inventory of software that is present on a system. This may be an assembly of other SBOMs that combines analysis of configuration options, and examination of execution behavior in a (potentially simulated) deployment environment.
"deployed": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/deployed",
+ # SBOM of intended, planned software project or product with included components (some of which may not yet exist) for a new software artifact.
"design": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/design",
+ # SBOM generated through instrumenting the system running the software, to capture only components present in the system, as well as external call-outs or dynamically loaded components. In some contexts, this may also be referred to as an "Instrumented" or "Dynamic" SBOM.
"runtime": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/runtime",
+ # SBOM created directly from the development environment, source files, and included dependencies used to build an product artifact.
"source": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/source",
}
- # SBOM generated through analysis of artifacts (e.g., executables, packages, containers, and virtual machine images) after its build. Such analysis generally requires a variety of heuristics. In some contexts, this may also be referred to as a "3rd party" SBOM.
- analyzed = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/analyzed"
- # SBOM generated as part of the process of building the software to create a releasable artifact (e.g., executable or package) from data such as source files, dependencies, built components, build process ephemeral data, and other SBOMs.
- build = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/build"
- # SBOM provides an inventory of software that is present on a system. This may be an assembly of other SBOMs that combines analysis of configuration options, and examination of execution behavior in a (potentially simulated) deployment environment.
- deployed = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/deployed"
- # SBOM of intended, planned software project or product with included components (some of which may not yet exist) for a new software artifact.
- design = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/design"
- # SBOM generated through instrumenting the system running the software, to capture only components present in the system, as well as external call-outs or dynamically loaded components. In some contexts, this may also be referred to as an "Instrumented" or "Dynamic" SBOM.
- runtime = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/runtime"
- # SBOM created directly from the development environment, source files, and included dependencies used to build an product artifact.
- source = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/source"
-
-
-# Provides information about the primary purpose of an Element.
-@register("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose", compact_type="software_SoftwarePurpose", abstract=False)
+
+
class software_SoftwarePurpose(SHACLObject):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
+ """
+ Provides information about the primary purpose of an Element.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose"
+ COMPACT_TYPE = "software_SoftwarePurpose"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # The Element is a software application.
"application": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/application",
+ # The Element is an archived collection of one or more files (.tar, .zip, etc.).
"archive": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/archive",
+ # The Element is a bill of materials.
"bom": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/bom",
+ # The Element is configuration data.
"configuration": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/configuration",
+ # The Element is a container image which can be used by a container runtime application.
"container": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/container",
+ # The Element is data.
"data": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/data",
+ # The Element refers to a chipset, processor, or electronic board.
"device": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/device",
+ # The Element represents software that controls hardware devices.
"deviceDriver": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/deviceDriver",
+ # The Element refers to a disk image that can be written to a disk, booted in a VM, etc. A disk image typically contains most or all of the components necessary to boot, such as bootloaders, kernels, firmware, userspace, etc.
"diskImage": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/diskImage",
+ # The Element is documentation.
"documentation": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/documentation",
+ # The Element is the evidence that a specification or requirement has been fulfilled.
"evidence": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/evidence",
+ # The Element is an Artifact that can be run on a computer.
"executable": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/executable",
+ # The Element is a single file which can be independently distributed (configuration file, statically linked binary, Kubernetes deployment, etc.).
"file": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/file",
+ # The Element is a file system image that can be written to a disk (or virtual) partition.
"filesystemImage": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/filesystemImage",
+ # The Element provides low level control over a device's hardware.
"firmware": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/firmware",
+ # The Element is a software framework.
"framework": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/framework",
+ # The Element is used to install software on disk.
"install": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/install",
+ # The Element is a software library.
"library": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/library",
+ # The Element is a software manifest.
"manifest": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/manifest",
+ # The Element is a machine learning or artificial intelligence model.
"model": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/model",
+ # The Element is a module of a piece of software.
"module": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/module",
+ # The Element is an operating system.
"operatingSystem": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/operatingSystem",
+ # The Element doesn't fit into any of the other categories.
"other": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/other",
+ # The Element contains a set of changes to update, fix, or improve another Element.
"patch": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/patch",
+ # The Element represents a runtime environment.
"platform": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/platform",
+ # The Element provides a requirement needed as input for another Element.
"requirement": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/requirement",
+ # The Element is a single or a collection of source files.
"source": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/source",
+ # The Element is a plan, guideline or strategy how to create, perform or analyze an application.
"specification": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/specification",
+ # The Element is a test used to verify functionality on an software element.
"test": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/test",
}
- # The Element is a software application.
- application = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/application"
- # The Element is an archived collection of one or more files (.tar, .zip, etc.).
- archive = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/archive"
- # The Element is a bill of materials.
- bom = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/bom"
- # The Element is configuration data.
- configuration = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/configuration"
- # The Element is a container image which can be used by a container runtime application.
- container = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/container"
- # The Element is data.
- data = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/data"
- # The Element refers to a chipset, processor, or electronic board.
- device = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/device"
- # The Element represents software that controls hardware devices.
- deviceDriver = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/deviceDriver"
- # The Element refers to a disk image that can be written to a disk, booted in a VM, etc. A disk image typically contains most or all of the components necessary to boot, such as bootloaders, kernels, firmware, userspace, etc.
- diskImage = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/diskImage"
- # The Element is documentation.
- documentation = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/documentation"
- # The Element is the evidence that a specification or requirement has been fulfilled.
- evidence = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/evidence"
- # The Element is an Artifact that can be run on a computer.
- executable = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/executable"
- # The Element is a single file which can be independently distributed (configuration file, statically linked binary, Kubernetes deployment, etc.).
- file = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/file"
- # The Element is a file system image that can be written to a disk (or virtual) partition.
- filesystemImage = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/filesystemImage"
- # The Element provides low level control over a device's hardware.
- firmware = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/firmware"
- # The Element is a software framework.
- framework = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/framework"
- # The Element is used to install software on disk.
- install = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/install"
- # The Element is a software library.
- library = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/library"
- # The Element is a software manifest.
- manifest = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/manifest"
- # The Element is a machine learning or artificial intelligence model.
- model = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/model"
- # The Element is a module of a piece of software.
- module = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/module"
- # The Element is an operating system.
- operatingSystem = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/operatingSystem"
- # The Element doesn't fit into any of the other categories.
- other = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/other"
- # The Element contains a set of changes to update, fix, or improve another Element.
- patch = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/patch"
- # The Element represents a runtime environment.
- platform = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/platform"
- # The Element provides a requirement needed as input for another Element.
- requirement = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/requirement"
- # The Element is a single or a collection of source files.
- source = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/source"
- # The Element is a plan, guideline or strategy how to create, perform or analyze an application.
- specification = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/specification"
- # The Element is a test used to verify functionality on an software element.
- test = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/test"
-
-
-# Class that describes a build instance of software/artifacts.
-@register("https://spdx.org/rdf/3.0.1/terms/Build/Build", compact_type="build_Build", abstract=False)
+
+
class build_Build(Element):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Class that describes a build instance of software/artifacts.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Build/Build"
+ COMPACT_TYPE = "build_Build"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Property that describes the time at which a build stops.
- cls._add_property(
+ ClassProp(
"build_buildEndTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Build/buildEndTime",
compact="build_buildEndTime",
- )
+ deprecated=False,
+ ),
# A buildId is a locally unique identifier used by a builder to identify a unique
# instance of a build produced by it.
- cls._add_property(
+ ClassProp(
"build_buildId",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Build/buildId",
compact="build_buildId",
- )
+ deprecated=False,
+ ),
# Property describing the start time of a build.
- cls._add_property(
+ ClassProp(
"build_buildStartTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Build/buildStartTime",
compact="build_buildStartTime",
- )
+ deprecated=False,
+ ),
# A buildType is a hint that is used to indicate the toolchain, platform, or
# infrastructure that the build was invoked on.
- cls._add_property(
+ ClassProp(
"build_buildType",
+ lambda:
AnyURIProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Build/buildType",
min_count=1,
compact="build_buildType",
- )
+ deprecated=False,
+ ),
# Property that describes the digest of the build configuration file used to
# invoke a build.
- cls._add_property(
+ ClassProp(
"build_configSourceDigest",
+ lambda:
ListProp(ObjectProp(Hash, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Build/configSourceDigest",
compact="build_configSourceDigest",
- )
+ deprecated=False,
+ ),
# Property describes the invocation entrypoint of a build.
- cls._add_property(
+ ClassProp(
"build_configSourceEntrypoint",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/Build/configSourceEntrypoint",
compact="build_configSourceEntrypoint",
- )
+ deprecated=False,
+ ),
# Property that describes the URI of the build configuration source file.
- cls._add_property(
+ ClassProp(
"build_configSourceUri",
+ lambda:
ListProp(AnyURIProp()),
iri="https://spdx.org/rdf/3.0.1/terms/Build/configSourceUri",
compact="build_configSourceUri",
- )
+ deprecated=False,
+ ),
# Property describing the session in which a build is invoked.
- cls._add_property(
+ ClassProp(
"build_environment",
+ lambda:
ListProp(ObjectProp(DictionaryEntry, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Build/environment",
compact="build_environment",
- )
+ deprecated=False,
+ ),
# Property describing a parameter used in an instance of a build.
- cls._add_property(
+ ClassProp(
"build_parameter",
+ lambda:
ListProp(ObjectProp(DictionaryEntry, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Build/parameter",
compact="build_parameter",
- )
+ deprecated=False,
+ ),
+ ]
-# Agent represents anything with the potential to act on a system.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/Agent", compact_type="Agent", abstract=False)
class Agent(Element):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Agent represents anything with the potential to act on a system.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Agent"
+ COMPACT_TYPE = "Agent"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
-# An assertion made in relation to one or more elements.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/Annotation", compact_type="Annotation", abstract=False)
class Annotation(Element):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ An assertion made in relation to one or more elements.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Annotation"
+ COMPACT_TYPE = "Annotation"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Describes the type of annotation.
- cls._add_property(
+ ClassProp(
"annotationType",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/other", "other"),
("https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/review", "review"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Core/annotationType",
min_count=1,
compact="annotationType",
- )
+ deprecated=False,
+ ),
# Provides information about the content type of an Element or a Property.
- cls._add_property(
+ ClassProp(
"contentType",
- StringProp(pattern=r"^[^\/]+\/[^\/]+$",),
+ lambda:
+ StringProp(pattern=r"^[^\/]+\/[^\/]+$"),
iri="https://spdx.org/rdf/3.0.1/terms/Core/contentType",
compact="contentType",
- )
+ deprecated=False,
+ ),
# Commentary on an assertion that an annotator has made.
- cls._add_property(
+ ClassProp(
"statement",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/statement",
compact="statement",
- )
+ deprecated=False,
+ ),
# An Element an annotator has made an assertion about.
- cls._add_property(
+ ClassProp(
"subject",
- ObjectProp(Element, True, context=[
+ lambda:
+ ObjectProp(Element, True, context=(
+ ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
("https://spdx.org/rdf/3.0.1/terms/Core/NoneElement", "NoneElement"),
+ ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
- ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
- ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
- ],),
+ ),),
iri="https://spdx.org/rdf/3.0.1/terms/Core/subject",
min_count=1,
compact="subject",
- )
+ deprecated=False,
+ ),
+ ]
-# A distinct article or unit within the digital domain.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/Artifact", compact_type="Artifact", abstract=True)
class Artifact(Element):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A distinct article or unit within the digital domain.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Artifact"
+ COMPACT_TYPE = "Artifact"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ IS_ABSTRACT: bool = True
+ PROPERTIES = [
# Specifies the time an artifact was built.
- cls._add_property(
+ ClassProp(
"builtTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Core/builtTime",
compact="builtTime",
- )
+ deprecated=False,
+ ),
# Identifies from where or whom the Element originally came.
- cls._add_property(
+ ClassProp(
"originatedBy",
- ListProp(ObjectProp(Agent, False, context=[
+ lambda:
+ ListProp(ObjectProp(Agent, False, context=(
("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
- ],)),
+ ),)),
iri="https://spdx.org/rdf/3.0.1/terms/Core/originatedBy",
compact="originatedBy",
- )
+ deprecated=False,
+ ),
# Specifies the time an artifact was released.
- cls._add_property(
+ ClassProp(
"releaseTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Core/releaseTime",
compact="releaseTime",
- )
+ deprecated=False,
+ ),
# The name of a relevant standard that may apply to an artifact.
- cls._add_property(
+ ClassProp(
"standardName",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/Core/standardName",
compact="standardName",
- )
+ deprecated=False,
+ ),
# Identifies who or what supplied the artifact or VulnAssessmentRelationship
# referenced by the Element.
- cls._add_property(
+ ClassProp(
"suppliedBy",
- ObjectProp(Agent, False, context=[
+ lambda:
+ ObjectProp(Agent, False, context=(
("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
- ],),
+ ),),
iri="https://spdx.org/rdf/3.0.1/terms/Core/suppliedBy",
compact="suppliedBy",
- )
+ deprecated=False,
+ ),
# Specifies the level of support associated with an artifact.
- cls._add_property(
+ ClassProp(
"supportLevel",
- ListProp(EnumProp([
+ lambda:
+ ListProp(EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/deployed", "deployed"),
("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/development", "development"),
("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/endOfSupport", "endOfSupport"),
("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noAssertion", "noAssertion"),
("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noSupport", "noSupport"),
("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/support", "support"),
- ])),
+ ))),
iri="https://spdx.org/rdf/3.0.1/terms/Core/supportLevel",
compact="supportLevel",
- )
+ deprecated=False,
+ ),
# Specifies until when the artifact can be used before its usage needs to be
# reassessed.
- cls._add_property(
+ ClassProp(
"validUntilTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Core/validUntilTime",
compact="validUntilTime",
- )
+ deprecated=False,
+ ),
+ ]
-# A collection of Elements that have a shared context.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/Bundle", compact_type="Bundle", abstract=False)
class Bundle(ElementCollection):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A collection of Elements that have a shared context.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Bundle"
+ COMPACT_TYPE = "Bundle"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Gives information about the circumstances or unifying properties
# that Elements of the bundle have been assembled under.
- cls._add_property(
+ ClassProp(
"context",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/context",
compact="context",
- )
+ deprecated=False,
+ ),
+ ]
-# A mathematically calculated representation of a grouping of data.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/Hash", compact_type="Hash", abstract=False)
class Hash(IntegrityMethod):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ A mathematically calculated representation of a grouping of data.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Hash"
+ COMPACT_TYPE = "Hash"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Specifies the algorithm used for calculating the hash value.
- cls._add_property(
+ ClassProp(
"algorithm",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/adler32", "adler32"),
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b256", "blake2b256"),
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b384", "blake2b384"),
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_384", "sha3_384"),
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_512", "sha3_512"),
("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha512", "sha512"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Core/algorithm",
min_count=1,
compact="algorithm",
- )
+ deprecated=False,
+ ),
# The result of applying a hash algorithm to an Element.
- cls._add_property(
+ ClassProp(
"hashValue",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Core/hashValue",
min_count=1,
compact="hashValue",
- )
+ deprecated=False,
+ ),
+ ]
-# Provide context for a relationship that occurs in the lifecycle.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopedRelationship", compact_type="LifecycleScopedRelationship", abstract=False)
class LifecycleScopedRelationship(Relationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Provide context for a relationship that occurs in the lifecycle.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopedRelationship"
+ COMPACT_TYPE = "LifecycleScopedRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Capture the scope of information about a specific relationship between elements.
- cls._add_property(
+ ClassProp(
"scope",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/build", "build"),
("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/design", "design"),
("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/development", "development"),
("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/other", "other"),
("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/runtime", "runtime"),
("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/test", "test"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Core/scope",
compact="scope",
- )
+ deprecated=False,
+ ),
+ ]
-# A group of people who work together in an organized way for a shared purpose.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/Organization", compact_type="Organization", abstract=False)
class Organization(Agent):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
+ """
+ A group of people who work together in an organized way for a shared purpose.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Organization"
+ COMPACT_TYPE = "Organization"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # An Organization representing the SPDX Project.
"SpdxOrganization": "https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization",
}
- # An Organization representing the SPDX Project.
- SpdxOrganization = "https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization"
-# An individual human being.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/Person", compact_type="Person", abstract=False)
class Person(Agent):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ An individual human being.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Person"
+ COMPACT_TYPE = "Person"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
-# A software agent.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/SoftwareAgent", compact_type="SoftwareAgent", abstract=False)
class SoftwareAgent(Agent):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A software agent.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/SoftwareAgent"
+ COMPACT_TYPE = "SoftwareAgent"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
-# Portion of an AnyLicenseInfo representing a set of licensing information
-# where all elements apply.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ConjunctiveLicenseSet", compact_type="expandedlicensing_ConjunctiveLicenseSet", abstract=False)
class expandedlicensing_ConjunctiveLicenseSet(simplelicensing_AnyLicenseInfo):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Portion of an AnyLicenseInfo representing a set of licensing information
+ where all elements apply.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ConjunctiveLicenseSet"
+ COMPACT_TYPE = "expandedlicensing_ConjunctiveLicenseSet"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# A license expression participating in a license set.
- cls._add_property(
+ ClassProp(
"expandedlicensing_member",
- ListProp(ObjectProp(simplelicensing_AnyLicenseInfo, False, context=[
+ lambda:
+ ListProp(ObjectProp(simplelicensing_AnyLicenseInfo, False, context=(
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
- ],)),
+ ),)),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/member",
min_count=2,
compact="expandedlicensing_member",
- )
+ deprecated=False,
+ ),
+ ]
-# A license addition that is not listed on the SPDX Exceptions List.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/CustomLicenseAddition", compact_type="expandedlicensing_CustomLicenseAddition", abstract=False)
class expandedlicensing_CustomLicenseAddition(expandedlicensing_LicenseAddition):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A license addition that is not listed on the SPDX Exceptions List.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/CustomLicenseAddition"
+ COMPACT_TYPE = "expandedlicensing_CustomLicenseAddition"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
-# Portion of an AnyLicenseInfo representing a set of licensing information where
-# only one of the elements applies.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/DisjunctiveLicenseSet", compact_type="expandedlicensing_DisjunctiveLicenseSet", abstract=False)
class expandedlicensing_DisjunctiveLicenseSet(simplelicensing_AnyLicenseInfo):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Portion of an AnyLicenseInfo representing a set of licensing information where
+ only one of the elements applies.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/DisjunctiveLicenseSet"
+ COMPACT_TYPE = "expandedlicensing_DisjunctiveLicenseSet"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# A license expression participating in a license set.
- cls._add_property(
+ ClassProp(
"expandedlicensing_member",
- ListProp(ObjectProp(simplelicensing_AnyLicenseInfo, False, context=[
+ lambda:
+ ListProp(ObjectProp(simplelicensing_AnyLicenseInfo, False, context=(
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
- ],)),
+ ),)),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/member",
min_count=2,
compact="expandedlicensing_member",
- )
+ deprecated=False,
+ ),
+ ]
-# Abstract class representing a License or an OrLaterOperator.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ExtendableLicense", compact_type="expandedlicensing_ExtendableLicense", abstract=True)
class expandedlicensing_ExtendableLicense(simplelicensing_AnyLicenseInfo):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Abstract class representing a License or an OrLaterOperator.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ExtendableLicense"
+ COMPACT_TYPE = "expandedlicensing_ExtendableLicense"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ IS_ABSTRACT: bool = True
-# A concrete subclass of AnyLicenseInfo used by Individuals in the
-# ExpandedLicensing profile.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/IndividualLicensingInfo", compact_type="expandedlicensing_IndividualLicensingInfo", abstract=False)
class expandedlicensing_IndividualLicensingInfo(simplelicensing_AnyLicenseInfo):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
+ """
+ A concrete subclass of AnyLicenseInfo used by Individuals in the
+ ExpandedLicensing profile.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/IndividualLicensingInfo"
+ COMPACT_TYPE = "expandedlicensing_IndividualLicensingInfo"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ NAMED_INDIVIDUALS: Dict[str, str] = {
+ # An Individual Value for License when no assertion can be made about its actual
+ # value.
"NoAssertionLicense": "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense",
+ # An Individual Value for License where the SPDX data creator determines that no
+ # license is present.
"NoneLicense": "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense",
}
- # An Individual Value for License when no assertion can be made about its actual
- # value.
- NoAssertionLicense = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense"
- # An Individual Value for License where the SPDX data creator determines that no
- # license is present.
- NoneLicense = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense"
-# Abstract class for the portion of an AnyLicenseInfo representing a license.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/License", compact_type="expandedlicensing_License", abstract=True)
class expandedlicensing_License(expandedlicensing_ExtendableLicense):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Abstract class for the portion of an AnyLicenseInfo representing a license.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/License"
+ COMPACT_TYPE = "expandedlicensing_License"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ IS_ABSTRACT: bool = True
+ PROPERTIES = [
# Specifies whether a license or additional text identifier has been marked as
# deprecated.
- cls._add_property(
+ ClassProp(
"expandedlicensing_isDeprecatedLicenseId",
+ lambda:
BooleanProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/isDeprecatedLicenseId",
compact="expandedlicensing_isDeprecatedLicenseId",
- )
+ deprecated=False,
+ ),
# Specifies whether the License is listed as free by the
# Free Software Foundation (FSF).
- cls._add_property(
+ ClassProp(
"expandedlicensing_isFsfLibre",
+ lambda:
BooleanProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/isFsfLibre",
compact="expandedlicensing_isFsfLibre",
- )
+ deprecated=False,
+ ),
# Specifies whether the License is listed as approved by the
# Open Source Initiative (OSI).
- cls._add_property(
+ ClassProp(
"expandedlicensing_isOsiApproved",
+ lambda:
BooleanProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/isOsiApproved",
compact="expandedlicensing_isOsiApproved",
- )
+ deprecated=False,
+ ),
# Identifies all the text and metadata associated with a license in the license
# XML format.
- cls._add_property(
+ ClassProp(
"expandedlicensing_licenseXml",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/licenseXml",
compact="expandedlicensing_licenseXml",
- )
+ deprecated=False,
+ ),
# Specifies the licenseId that is preferred to be used in place of a deprecated
# License or LicenseAddition.
- cls._add_property(
+ ClassProp(
"expandedlicensing_obsoletedBy",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/obsoletedBy",
compact="expandedlicensing_obsoletedBy",
- )
+ deprecated=False,
+ ),
# Contains a URL where the License or LicenseAddition can be found in use.
- cls._add_property(
+ ClassProp(
"expandedlicensing_seeAlso",
+ lambda:
ListProp(AnyURIProp()),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/seeAlso",
compact="expandedlicensing_seeAlso",
- )
+ deprecated=False,
+ ),
# Provides a License author's preferred text to indicate that a file is covered
# by the License.
- cls._add_property(
+ ClassProp(
"expandedlicensing_standardLicenseHeader",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/standardLicenseHeader",
compact="expandedlicensing_standardLicenseHeader",
- )
+ deprecated=False,
+ ),
# Identifies the full text of a License, in SPDX templating format.
- cls._add_property(
+ ClassProp(
"expandedlicensing_standardLicenseTemplate",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/standardLicenseTemplate",
compact="expandedlicensing_standardLicenseTemplate",
- )
+ deprecated=False,
+ ),
# Identifies the full text of a License or Addition.
- cls._add_property(
+ ClassProp(
"simplelicensing_licenseText",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/licenseText",
min_count=1,
compact="simplelicensing_licenseText",
- )
+ deprecated=False,
+ ),
+ ]
-# A license that is listed on the SPDX License List.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ListedLicense", compact_type="expandedlicensing_ListedLicense", abstract=False)
class expandedlicensing_ListedLicense(expandedlicensing_License):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A license that is listed on the SPDX License List.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ListedLicense"
+ COMPACT_TYPE = "expandedlicensing_ListedLicense"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Specifies the SPDX License List version in which this license or exception
# identifier was deprecated.
- cls._add_property(
+ ClassProp(
"expandedlicensing_deprecatedVersion",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/deprecatedVersion",
compact="expandedlicensing_deprecatedVersion",
- )
+ deprecated=False,
+ ),
# Specifies the SPDX License List version in which this ListedLicense or
# ListedLicenseException identifier was first added.
- cls._add_property(
+ ClassProp(
"expandedlicensing_listVersionAdded",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/listVersionAdded",
compact="expandedlicensing_listVersionAdded",
- )
+ deprecated=False,
+ ),
+ ]
-# Portion of an AnyLicenseInfo representing this version, or any later version,
-# of the indicated License.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/OrLaterOperator", compact_type="expandedlicensing_OrLaterOperator", abstract=False)
class expandedlicensing_OrLaterOperator(expandedlicensing_ExtendableLicense):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Portion of an AnyLicenseInfo representing this version, or any later version,
+ of the indicated License.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/OrLaterOperator"
+ COMPACT_TYPE = "expandedlicensing_OrLaterOperator"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# A License participating in an 'or later' model.
- cls._add_property(
+ ClassProp(
"expandedlicensing_subjectLicense",
+ lambda:
ObjectProp(expandedlicensing_License, True),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/subjectLicense",
min_count=1,
compact="expandedlicensing_subjectLicense",
- )
+ deprecated=False,
+ ),
+ ]
-# Portion of an AnyLicenseInfo representing a License which has additional
-# text applied to it.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/WithAdditionOperator", compact_type="expandedlicensing_WithAdditionOperator", abstract=False)
class expandedlicensing_WithAdditionOperator(simplelicensing_AnyLicenseInfo):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Portion of an AnyLicenseInfo representing a License which has additional
+ text applied to it.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/WithAdditionOperator"
+ COMPACT_TYPE = "expandedlicensing_WithAdditionOperator"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# A LicenseAddition participating in a 'with addition' model.
- cls._add_property(
+ ClassProp(
"expandedlicensing_subjectAddition",
+ lambda:
ObjectProp(expandedlicensing_LicenseAddition, True),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/subjectAddition",
min_count=1,
compact="expandedlicensing_subjectAddition",
- )
+ deprecated=False,
+ ),
# A License participating in a 'with addition' model.
- cls._add_property(
+ ClassProp(
"expandedlicensing_subjectExtendableLicense",
+ lambda:
ObjectProp(expandedlicensing_ExtendableLicense, True),
iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/subjectExtendableLicense",
min_count=1,
compact="expandedlicensing_subjectExtendableLicense",
- )
+ deprecated=False,
+ ),
+ ]
-# A type of extension consisting of a list of name value pairs.
-@register("https://spdx.org/rdf/3.0.1/terms/Extension/CdxPropertiesExtension", compact_type="extension_CdxPropertiesExtension", abstract=False)
class extension_CdxPropertiesExtension(extension_Extension):
- NODE_KIND = NodeKind.BlankNodeOrIRI
- NAMED_INDIVIDUALS = {
- }
+ """
+ A type of extension consisting of a list of name value pairs.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Extension/CdxPropertiesExtension"
+ COMPACT_TYPE = "extension_CdxPropertiesExtension"
+ NODE_KIND: NodeKind = NodeKind.BlankNodeOrIRI
+ PROPERTIES = [
# Provides a map of a property names to a values.
- cls._add_property(
+ ClassProp(
"extension_cdxProperty",
+ lambda:
ListProp(ObjectProp(extension_CdxPropertyEntry, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Extension/cdxProperty",
min_count=1,
compact="extension_cdxProperty",
- )
+ deprecated=False,
+ ),
+ ]
-# Provides a CVSS version 2.0 assessment for a vulnerability.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/CvssV2VulnAssessmentRelationship", compact_type="security_CvssV2VulnAssessmentRelationship", abstract=False)
class security_CvssV2VulnAssessmentRelationship(security_VulnAssessmentRelationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Provides a CVSS version 2.0 assessment for a vulnerability.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/CvssV2VulnAssessmentRelationship"
+ COMPACT_TYPE = "security_CvssV2VulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Provides a numerical (0-10) representation of the severity of a vulnerability.
- cls._add_property(
+ ClassProp(
"security_score",
+ lambda:
FloatProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/score",
min_count=1,
compact="security_score",
- )
+ deprecated=False,
+ ),
# Specifies the CVSS vector string for a vulnerability.
- cls._add_property(
+ ClassProp(
"security_vectorString",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/vectorString",
min_count=1,
compact="security_vectorString",
- )
+ deprecated=False,
+ ),
+ ]
-# Provides a CVSS version 3 assessment for a vulnerability.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/CvssV3VulnAssessmentRelationship", compact_type="security_CvssV3VulnAssessmentRelationship", abstract=False)
class security_CvssV3VulnAssessmentRelationship(security_VulnAssessmentRelationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Provides a CVSS version 3 assessment for a vulnerability.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/CvssV3VulnAssessmentRelationship"
+ COMPACT_TYPE = "security_CvssV3VulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Provides a numerical (0-10) representation of the severity of a vulnerability.
- cls._add_property(
+ ClassProp(
"security_score",
+ lambda:
FloatProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/score",
min_count=1,
compact="security_score",
- )
+ deprecated=False,
+ ),
# Specifies the CVSS qualitative severity rating of a vulnerability in relation to a piece of software.
- cls._add_property(
+ ClassProp(
"security_severity",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/critical", "critical"),
("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/high", "high"),
("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/low", "low"),
("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/medium", "medium"),
("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/none", "none"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Security/severity",
min_count=1,
compact="security_severity",
- )
+ deprecated=False,
+ ),
# Specifies the CVSS vector string for a vulnerability.
- cls._add_property(
+ ClassProp(
"security_vectorString",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/vectorString",
min_count=1,
compact="security_vectorString",
- )
+ deprecated=False,
+ ),
+ ]
-# Provides a CVSS version 4 assessment for a vulnerability.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/CvssV4VulnAssessmentRelationship", compact_type="security_CvssV4VulnAssessmentRelationship", abstract=False)
class security_CvssV4VulnAssessmentRelationship(security_VulnAssessmentRelationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Provides a CVSS version 4 assessment for a vulnerability.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/CvssV4VulnAssessmentRelationship"
+ COMPACT_TYPE = "security_CvssV4VulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Provides a numerical (0-10) representation of the severity of a vulnerability.
- cls._add_property(
+ ClassProp(
"security_score",
+ lambda:
FloatProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/score",
min_count=1,
compact="security_score",
- )
+ deprecated=False,
+ ),
# Specifies the CVSS qualitative severity rating of a vulnerability in relation to a piece of software.
- cls._add_property(
+ ClassProp(
"security_severity",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/critical", "critical"),
("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/high", "high"),
("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/low", "low"),
("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/medium", "medium"),
("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/none", "none"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Security/severity",
min_count=1,
compact="security_severity",
- )
+ deprecated=False,
+ ),
# Specifies the CVSS vector string for a vulnerability.
- cls._add_property(
+ ClassProp(
"security_vectorString",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/vectorString",
min_count=1,
compact="security_vectorString",
- )
+ deprecated=False,
+ ),
+ ]
-# Provides an EPSS assessment for a vulnerability.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/EpssVulnAssessmentRelationship", compact_type="security_EpssVulnAssessmentRelationship", abstract=False)
class security_EpssVulnAssessmentRelationship(security_VulnAssessmentRelationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Provides an EPSS assessment for a vulnerability.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/EpssVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_EpssVulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# The percentile of the current probability score.
- cls._add_property(
+ ClassProp(
"security_percentile",
+ lambda:
FloatProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/percentile",
min_count=1,
compact="security_percentile",
- )
+ deprecated=False,
+ ),
# A probability score between 0 and 1 of a vulnerability being exploited.
- cls._add_property(
+ ClassProp(
"security_probability",
+ lambda:
FloatProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/probability",
min_count=1,
compact="security_probability",
- )
+ deprecated=False,
+ ),
+ ]
-# Provides an exploit assessment of a vulnerability.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogVulnAssessmentRelationship", compact_type="security_ExploitCatalogVulnAssessmentRelationship", abstract=False)
class security_ExploitCatalogVulnAssessmentRelationship(security_VulnAssessmentRelationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Provides an exploit assessment of a vulnerability.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_ExploitCatalogVulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Specifies the exploit catalog type.
- cls._add_property(
+ ClassProp(
"security_catalogType",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/kev", "kev"),
("https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/other", "other"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Security/catalogType",
min_count=1,
compact="security_catalogType",
- )
+ deprecated=False,
+ ),
# Describe that a CVE is known to have an exploit because it's been listed in an exploit catalog.
- cls._add_property(
+ ClassProp(
"security_exploited",
+ lambda:
BooleanProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/exploited",
min_count=1,
compact="security_exploited",
- )
+ deprecated=False,
+ ),
# Provides the location of an exploit catalog.
- cls._add_property(
+ ClassProp(
"security_locator",
+ lambda:
AnyURIProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/locator",
min_count=1,
compact="security_locator",
- )
+ deprecated=False,
+ ),
+ ]
-# Provides an SSVC assessment for a vulnerability.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/SsvcVulnAssessmentRelationship", compact_type="security_SsvcVulnAssessmentRelationship", abstract=False)
class security_SsvcVulnAssessmentRelationship(security_VulnAssessmentRelationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Provides an SSVC assessment for a vulnerability.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_SsvcVulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Provide the enumeration of possible decisions in the
# [Stakeholder-Specific Vulnerability Categorization (SSVC) decision tree](https://www.cisa.gov/stakeholder-specific-vulnerability-categorization-ssvc).
- cls._add_property(
+ ClassProp(
"security_decisionType",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/act", "act"),
("https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/attend", "attend"),
("https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/track", "track"),
("https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/trackStar", "trackStar"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Security/decisionType",
min_count=1,
compact="security_decisionType",
- )
+ deprecated=False,
+ ),
+ ]
-# Abstract ancestor class for all VEX relationships
-@register("https://spdx.org/rdf/3.0.1/terms/Security/VexVulnAssessmentRelationship", compact_type="security_VexVulnAssessmentRelationship", abstract=True)
class security_VexVulnAssessmentRelationship(security_VulnAssessmentRelationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Abstract ancestor class for all VEX relationships
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VexVulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ IS_ABSTRACT: bool = True
+ PROPERTIES = [
# Conveys information about how VEX status was determined.
- cls._add_property(
+ ClassProp(
"security_statusNotes",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/statusNotes",
compact="security_statusNotes",
- )
+ deprecated=False,
+ ),
# Specifies the version of a VEX statement.
- cls._add_property(
+ ClassProp(
"security_vexVersion",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/vexVersion",
compact="security_vexVersion",
- )
+ deprecated=False,
+ ),
+ ]
-# Specifies a vulnerability and its associated information.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/Vulnerability", compact_type="security_Vulnerability", abstract=False)
class security_Vulnerability(Artifact):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Specifies a vulnerability and its associated information.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/Vulnerability"
+ COMPACT_TYPE = "security_Vulnerability"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Specifies a time when a vulnerability assessment was modified
- cls._add_property(
+ ClassProp(
"security_modifiedTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Security/modifiedTime",
compact="security_modifiedTime",
- )
+ deprecated=False,
+ ),
# Specifies the time when a vulnerability was published.
- cls._add_property(
+ ClassProp(
"security_publishedTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Security/publishedTime",
compact="security_publishedTime",
- )
+ deprecated=False,
+ ),
# Specified the time and date when a vulnerability was withdrawn.
- cls._add_property(
+ ClassProp(
"security_withdrawnTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Security/withdrawnTime",
compact="security_withdrawnTime",
- )
+ deprecated=False,
+ ),
+ ]
-# A distinct article or unit related to Software.
-@register("https://spdx.org/rdf/3.0.1/terms/Software/SoftwareArtifact", compact_type="software_SoftwareArtifact", abstract=True)
class software_SoftwareArtifact(Artifact):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A distinct article or unit related to Software.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwareArtifact"
+ COMPACT_TYPE = "software_SoftwareArtifact"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ IS_ABSTRACT: bool = True
+ PROPERTIES = [
# Provides additional purpose information of the software artifact.
- cls._add_property(
+ ClassProp(
"software_additionalPurpose",
- ListProp(EnumProp([
+ lambda:
+ ListProp(EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/application", "application"),
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/archive", "archive"),
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/bom", "bom"),
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/source", "source"),
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/specification", "specification"),
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/test", "test"),
- ])),
+ ))),
iri="https://spdx.org/rdf/3.0.1/terms/Software/additionalPurpose",
compact="software_additionalPurpose",
- )
+ deprecated=False,
+ ),
# Provides a place for the SPDX data creator to record acknowledgement text for
# a software Package, File or Snippet.
- cls._add_property(
+ ClassProp(
"software_attributionText",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/Software/attributionText",
compact="software_attributionText",
- )
+ deprecated=False,
+ ),
# A canonical, unique, immutable identifier of the artifact content, that may be
# used for verifying its identity and/or integrity.
- cls._add_property(
+ ClassProp(
"software_contentIdentifier",
+ lambda:
ListProp(ObjectProp(software_ContentIdentifier, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Software/contentIdentifier",
compact="software_contentIdentifier",
- )
+ deprecated=False,
+ ),
# Identifies the text of one or more copyright notices for a software Package,
# File or Snippet, if any.
- cls._add_property(
+ ClassProp(
"software_copyrightText",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Software/copyrightText",
compact="software_copyrightText",
- )
+ deprecated=False,
+ ),
# Provides information about the primary purpose of the software artifact.
- cls._add_property(
+ ClassProp(
"software_primaryPurpose",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/application", "application"),
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/archive", "archive"),
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/bom", "bom"),
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/source", "source"),
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/specification", "specification"),
("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/test", "test"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Software/primaryPurpose",
compact="software_primaryPurpose",
- )
+ deprecated=False,
+ ),
+ ]
-# A container for a grouping of SPDX-3.0 content characterizing details
-# (provenence, composition, licensing, etc.) about a product.
-@register("https://spdx.org/rdf/3.0.1/terms/Core/Bom", compact_type="Bom", abstract=False)
class Bom(Bundle):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A container for a grouping of SPDX-3.0 content characterizing details
+ (provenence, composition, licensing, etc.) about a product.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Bom"
+ COMPACT_TYPE = "Bom"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
-# A license that is not listed on the SPDX License List.
-@register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/CustomLicense", compact_type="expandedlicensing_CustomLicense", abstract=False)
class expandedlicensing_CustomLicense(expandedlicensing_License):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A license that is not listed on the SPDX License List.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/CustomLicense"
+ COMPACT_TYPE = "expandedlicensing_CustomLicense"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
-# Connects a vulnerability and an element designating the element as a product
-# affected by the vulnerability.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/VexAffectedVulnAssessmentRelationship", compact_type="security_VexAffectedVulnAssessmentRelationship", abstract=False)
class security_VexAffectedVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Connects a vulnerability and an element designating the element as a product
+ affected by the vulnerability.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexAffectedVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VexAffectedVulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Provides advise on how to mitigate or remediate a vulnerability when a VEX product
# is affected by it.
- cls._add_property(
+ ClassProp(
"security_actionStatement",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/actionStatement",
min_count=1,
compact="security_actionStatement",
- )
+ deprecated=False,
+ ),
# Records the time when a recommended action was communicated in a VEX statement
# to mitigate a vulnerability.
- cls._add_property(
+ ClassProp(
"security_actionStatementTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Security/actionStatementTime",
compact="security_actionStatementTime",
- )
+ deprecated=False,
+ ),
+ ]
-# Links a vulnerability and elements representing products (in the VEX sense) where
-# a fix has been applied and are no longer affected.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/VexFixedVulnAssessmentRelationship", compact_type="security_VexFixedVulnAssessmentRelationship", abstract=False)
class security_VexFixedVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Links a vulnerability and elements representing products (in the VEX sense) where
+ a fix has been applied and are no longer affected.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexFixedVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VexFixedVulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
-# Links a vulnerability and one or more elements designating the latter as products
-# not affected by the vulnerability.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/VexNotAffectedVulnAssessmentRelationship", compact_type="security_VexNotAffectedVulnAssessmentRelationship", abstract=False)
class security_VexNotAffectedVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Links a vulnerability and one or more elements designating the latter as products
+ not affected by the vulnerability.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexNotAffectedVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VexNotAffectedVulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Explains why a VEX product is not affected by a vulnerability. It is an
# alternative in VexNotAffectedVulnAssessmentRelationship to the machine-readable
# justification label.
- cls._add_property(
+ ClassProp(
"security_impactStatement",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Security/impactStatement",
compact="security_impactStatement",
- )
+ deprecated=False,
+ ),
# Timestamp of impact statement.
- cls._add_property(
+ ClassProp(
"security_impactStatementTime",
- DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
+ lambda:
+ DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$"),
iri="https://spdx.org/rdf/3.0.1/terms/Security/impactStatementTime",
compact="security_impactStatementTime",
- )
+ deprecated=False,
+ ),
# Impact justification label to be used when linking a vulnerability to an element
# representing a VEX product with a VexNotAffectedVulnAssessmentRelationship
# relationship.
- cls._add_property(
+ ClassProp(
"security_justificationType",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/componentNotPresent", "componentNotPresent"),
("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/inlineMitigationsAlreadyExist", "inlineMitigationsAlreadyExist"),
("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeCannotBeControlledByAdversary", "vulnerableCodeCannotBeControlledByAdversary"),
("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotInExecutePath", "vulnerableCodeNotInExecutePath"),
("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotPresent", "vulnerableCodeNotPresent"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Security/justificationType",
compact="security_justificationType",
- )
+ deprecated=False,
+ ),
+ ]
-# Designates elements as products where the impact of a vulnerability is being
-# investigated.
-@register("https://spdx.org/rdf/3.0.1/terms/Security/VexUnderInvestigationVulnAssessmentRelationship", compact_type="security_VexUnderInvestigationVulnAssessmentRelationship", abstract=False)
class security_VexUnderInvestigationVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Designates elements as products where the impact of a vulnerability is being
+ investigated.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexUnderInvestigationVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VexUnderInvestigationVulnAssessmentRelationship"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
-# Refers to any object that stores content on a computer.
-@register("https://spdx.org/rdf/3.0.1/terms/Software/File", compact_type="software_File", abstract=False)
class software_File(software_SoftwareArtifact):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Refers to any object that stores content on a computer.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/File"
+ COMPACT_TYPE = "software_File"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Provides information about the content type of an Element or a Property.
- cls._add_property(
+ ClassProp(
"contentType",
- StringProp(pattern=r"^[^\/]+\/[^\/]+$",),
+ lambda:
+ StringProp(pattern=r"^[^\/]+\/[^\/]+$"),
iri="https://spdx.org/rdf/3.0.1/terms/Core/contentType",
compact="contentType",
- )
+ deprecated=False,
+ ),
# Describes if a given file is a directory or non-directory kind of file.
- cls._add_property(
+ ClassProp(
"software_fileKind",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/directory", "directory"),
("https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/file", "file"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Software/fileKind",
compact="software_fileKind",
- )
+ deprecated=False,
+ ),
+ ]
-# Refers to any unit of content that can be associated with a distribution of
-# software.
-@register("https://spdx.org/rdf/3.0.1/terms/Software/Package", compact_type="software_Package", abstract=False)
class software_Package(software_SoftwareArtifact):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Refers to any unit of content that can be associated with a distribution of
+ software.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/Package"
+ COMPACT_TYPE = "software_Package"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Identifies the download Uniform Resource Identifier for the package at the time
# that the document was created.
- cls._add_property(
+ ClassProp(
"software_downloadLocation",
+ lambda:
AnyURIProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Software/downloadLocation",
compact="software_downloadLocation",
- )
+ deprecated=False,
+ ),
# A place for the SPDX document creator to record a website that serves as the
# package's home page.
- cls._add_property(
+ ClassProp(
"software_homePage",
+ lambda:
AnyURIProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Software/homePage",
compact="software_homePage",
- )
+ deprecated=False,
+ ),
# Provides a place for the SPDX data creator to record the package URL string
# (in accordance with the Package URL specification) for a software Package.
- cls._add_property(
+ ClassProp(
"software_packageUrl",
+ lambda:
AnyURIProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Software/packageUrl",
compact="software_packageUrl",
- )
+ deprecated=False,
+ ),
# Identify the version of a package.
- cls._add_property(
+ ClassProp(
"software_packageVersion",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Software/packageVersion",
compact="software_packageVersion",
- )
+ deprecated=False,
+ ),
# Records any relevant background information or additional comments
# about the origin of the package.
- cls._add_property(
+ ClassProp(
"software_sourceInfo",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Software/sourceInfo",
compact="software_sourceInfo",
- )
+ deprecated=False,
+ ),
+ ]
-# A collection of SPDX Elements describing a single package.
-@register("https://spdx.org/rdf/3.0.1/terms/Software/Sbom", compact_type="software_Sbom", abstract=False)
class software_Sbom(Bom):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ A collection of SPDX Elements describing a single package.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/Sbom"
+ COMPACT_TYPE = "software_Sbom"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Provides information about the type of an SBOM.
- cls._add_property(
+ ClassProp(
"software_sbomType",
- ListProp(EnumProp([
+ lambda:
+ ListProp(EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/analyzed", "analyzed"),
("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/build", "build"),
("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/deployed", "deployed"),
("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/design", "design"),
("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/runtime", "runtime"),
("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/source", "source"),
- ])),
+ ))),
iri="https://spdx.org/rdf/3.0.1/terms/Software/sbomType",
compact="software_sbomType",
- )
+ deprecated=False,
+ ),
+ ]
-# Describes a certain part of a file.
-@register("https://spdx.org/rdf/3.0.1/terms/Software/Snippet", compact_type="software_Snippet", abstract=False)
class software_Snippet(software_SoftwareArtifact):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Describes a certain part of a file.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/Snippet"
+ COMPACT_TYPE = "software_Snippet"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Defines the byte range in the original host file that the snippet information
# applies to.
- cls._add_property(
+ ClassProp(
"software_byteRange",
+ lambda:
ObjectProp(PositiveIntegerRange, False),
iri="https://spdx.org/rdf/3.0.1/terms/Software/byteRange",
compact="software_byteRange",
- )
+ deprecated=False,
+ ),
# Defines the line range in the original host file that the snippet information
# applies to.
- cls._add_property(
+ ClassProp(
"software_lineRange",
+ lambda:
ObjectProp(PositiveIntegerRange, False),
iri="https://spdx.org/rdf/3.0.1/terms/Software/lineRange",
compact="software_lineRange",
- )
+ deprecated=False,
+ ),
# Defines the original host file that the snippet information applies to.
- cls._add_property(
+ ClassProp(
"software_snippetFromFile",
+ lambda:
ObjectProp(software_File, True),
iri="https://spdx.org/rdf/3.0.1/terms/Software/snippetFromFile",
min_count=1,
compact="software_snippetFromFile",
- )
+ deprecated=False,
+ ),
+ ]
-# Specifies an AI package and its associated information.
-@register("https://spdx.org/rdf/3.0.1/terms/AI/AIPackage", compact_type="ai_AIPackage", abstract=False)
class ai_AIPackage(software_Package):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Specifies an AI package and its associated information.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/AI/AIPackage"
+ COMPACT_TYPE = "ai_AIPackage"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Indicates whether the system can perform a decision or action without human
# involvement or guidance.
- cls._add_property(
+ ClassProp(
"ai_autonomyType",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/no", "no"),
("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/noAssertion", "noAssertion"),
("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/yes", "yes"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/AI/autonomyType",
compact="ai_autonomyType",
- )
+ deprecated=False,
+ ),
# Captures the domain in which the AI package can be used.
- cls._add_property(
+ ClassProp(
"ai_domain",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/AI/domain",
compact="ai_domain",
- )
+ deprecated=False,
+ ),
# Indicates the amount of energy consumption incurred by an AI model.
- cls._add_property(
+ ClassProp(
"ai_energyConsumption",
+ lambda:
ObjectProp(ai_EnergyConsumption, False),
iri="https://spdx.org/rdf/3.0.1/terms/AI/energyConsumption",
compact="ai_energyConsumption",
- )
+ deprecated=False,
+ ),
# Records a hyperparameter used to build the AI model contained in the AI
# package.
- cls._add_property(
+ ClassProp(
"ai_hyperparameter",
+ lambda:
ListProp(ObjectProp(DictionaryEntry, False)),
iri="https://spdx.org/rdf/3.0.1/terms/AI/hyperparameter",
compact="ai_hyperparameter",
- )
+ deprecated=False,
+ ),
# Provides relevant information about the AI software, not including the model
# description.
- cls._add_property(
+ ClassProp(
"ai_informationAboutApplication",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/AI/informationAboutApplication",
compact="ai_informationAboutApplication",
- )
+ deprecated=False,
+ ),
# Describes relevant information about different steps of the training process.
- cls._add_property(
+ ClassProp(
"ai_informationAboutTraining",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/AI/informationAboutTraining",
compact="ai_informationAboutTraining",
- )
+ deprecated=False,
+ ),
# Captures a limitation of the AI software.
- cls._add_property(
+ ClassProp(
"ai_limitation",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/AI/limitation",
compact="ai_limitation",
- )
+ deprecated=False,
+ ),
# Records the measurement of prediction quality of the AI model.
- cls._add_property(
+ ClassProp(
"ai_metric",
+ lambda:
ListProp(ObjectProp(DictionaryEntry, False)),
iri="https://spdx.org/rdf/3.0.1/terms/AI/metric",
compact="ai_metric",
- )
+ deprecated=False,
+ ),
# Captures the threshold that was used for computation of a metric described in
# the metric field.
- cls._add_property(
+ ClassProp(
"ai_metricDecisionThreshold",
+ lambda:
ListProp(ObjectProp(DictionaryEntry, False)),
iri="https://spdx.org/rdf/3.0.1/terms/AI/metricDecisionThreshold",
compact="ai_metricDecisionThreshold",
- )
+ deprecated=False,
+ ),
# Describes all the preprocessing steps applied to the training data before the
# model training.
- cls._add_property(
+ ClassProp(
"ai_modelDataPreprocessing",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/AI/modelDataPreprocessing",
compact="ai_modelDataPreprocessing",
- )
+ deprecated=False,
+ ),
# Describes methods that can be used to explain the results from the AI model.
- cls._add_property(
+ ClassProp(
"ai_modelExplainability",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/AI/modelExplainability",
compact="ai_modelExplainability",
- )
+ deprecated=False,
+ ),
# Records the results of general safety risk assessment of the AI system.
- cls._add_property(
+ ClassProp(
"ai_safetyRiskAssessment",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/high", "high"),
("https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/low", "low"),
("https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/medium", "medium"),
("https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/serious", "serious"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/AI/safetyRiskAssessment",
compact="ai_safetyRiskAssessment",
- )
+ deprecated=False,
+ ),
# Captures a standard that is being complied with.
- cls._add_property(
+ ClassProp(
"ai_standardCompliance",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/AI/standardCompliance",
compact="ai_standardCompliance",
- )
+ deprecated=False,
+ ),
# Records the type of the model used in the AI software.
- cls._add_property(
+ ClassProp(
"ai_typeOfModel",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/AI/typeOfModel",
compact="ai_typeOfModel",
- )
+ deprecated=False,
+ ),
# Records if sensitive personal information is used during model training or
# could be used during the inference.
- cls._add_property(
+ ClassProp(
"ai_useSensitivePersonalInformation",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/no", "no"),
("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/noAssertion", "noAssertion"),
("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/yes", "yes"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/AI/useSensitivePersonalInformation",
compact="ai_useSensitivePersonalInformation",
- )
+ deprecated=False,
+ ),
+ ]
-# Specifies a data package and its associated information.
-@register("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetPackage", compact_type="dataset_DatasetPackage", abstract=False)
class dataset_DatasetPackage(software_Package):
- NODE_KIND = NodeKind.IRI
- ID_ALIAS = "spdxId"
- NAMED_INDIVIDUALS = {
- }
+ """
+ Specifies a data package and its associated information.
+ """
- @classmethod
- def _register_props(cls):
- super()._register_props()
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetPackage"
+ COMPACT_TYPE = "dataset_DatasetPackage"
+ NODE_KIND: NodeKind = NodeKind.IRI
+ ID_ALIAS: Optional[str] = "spdxId"
+ PROPERTIES = [
# Describes the anonymization methods used.
- cls._add_property(
+ ClassProp(
"dataset_anonymizationMethodUsed",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/anonymizationMethodUsed",
compact="dataset_anonymizationMethodUsed",
- )
+ deprecated=False,
+ ),
# Describes the confidentiality level of the data points contained in the dataset.
- cls._add_property(
+ ClassProp(
"dataset_confidentialityLevel",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/amber", "amber"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/clear", "clear"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/green", "green"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/red", "red"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/confidentialityLevel",
compact="dataset_confidentialityLevel",
- )
+ deprecated=False,
+ ),
# Describes how the dataset was collected.
- cls._add_property(
+ ClassProp(
"dataset_dataCollectionProcess",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/dataCollectionProcess",
compact="dataset_dataCollectionProcess",
- )
+ deprecated=False,
+ ),
# Describes the preprocessing steps that were applied to the raw data to create the given dataset.
- cls._add_property(
+ ClassProp(
"dataset_dataPreprocessing",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/dataPreprocessing",
compact="dataset_dataPreprocessing",
- )
+ deprecated=False,
+ ),
# The field describes the availability of a dataset.
- cls._add_property(
+ ClassProp(
"dataset_datasetAvailability",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/clickthrough", "clickthrough"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/directDownload", "directDownload"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/query", "query"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/registration", "registration"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/scrapingScript", "scrapingScript"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/datasetAvailability",
compact="dataset_datasetAvailability",
- )
+ deprecated=False,
+ ),
# Describes potentially noisy elements of the dataset.
- cls._add_property(
+ ClassProp(
"dataset_datasetNoise",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/datasetNoise",
compact="dataset_datasetNoise",
- )
+ deprecated=False,
+ ),
# Captures the size of the dataset.
- cls._add_property(
+ ClassProp(
"dataset_datasetSize",
+ lambda:
NonNegativeIntegerProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/datasetSize",
compact="dataset_datasetSize",
- )
+ deprecated=False,
+ ),
# Describes the type of the given dataset.
- cls._add_property(
+ ClassProp(
"dataset_datasetType",
- ListProp(EnumProp([
+ lambda:
+ ListProp(EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/audio", "audio"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/categorical", "categorical"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/graph", "graph"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timeseries", "timeseries"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timestamp", "timestamp"),
("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/video", "video"),
- ])),
+ ))),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/datasetType",
min_count=1,
compact="dataset_datasetType",
- )
+ deprecated=False,
+ ),
# Describes a mechanism to update the dataset.
- cls._add_property(
+ ClassProp(
"dataset_datasetUpdateMechanism",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/datasetUpdateMechanism",
compact="dataset_datasetUpdateMechanism",
- )
+ deprecated=False,
+ ),
# Describes if any sensitive personal information is present in the dataset.
- cls._add_property(
+ ClassProp(
"dataset_hasSensitivePersonalInformation",
- EnumProp([
+ lambda:
+ EnumProp((
("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/no", "no"),
("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/noAssertion", "noAssertion"),
("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/yes", "yes"),
- ]),
+ )),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/hasSensitivePersonalInformation",
compact="dataset_hasSensitivePersonalInformation",
- )
+ deprecated=False,
+ ),
# Describes what the given dataset should be used for.
- cls._add_property(
+ ClassProp(
"dataset_intendedUse",
+ lambda:
StringProp(),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/intendedUse",
compact="dataset_intendedUse",
- )
+ deprecated=False,
+ ),
# Records the biases that the dataset is known to encompass.
- cls._add_property(
+ ClassProp(
"dataset_knownBias",
+ lambda:
ListProp(StringProp()),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/knownBias",
compact="dataset_knownBias",
- )
+ deprecated=False,
+ ),
# Describes a sensor used for collecting the data.
- cls._add_property(
+ ClassProp(
"dataset_sensor",
+ lambda:
ListProp(ObjectProp(DictionaryEntry, False)),
iri="https://spdx.org/rdf/3.0.1/terms/Dataset/sensor",
compact="dataset_sensor",
- )
+ deprecated=False,
+ ),
+ ]
"""Format Guard"""
# fmt: on
-
-
-def main():
- import argparse
- from pathlib import Path
-
- parser = argparse.ArgumentParser(description="Python SHACL model test")
- parser.add_argument("infile", type=Path, help="Input file")
- parser.add_argument("--print", action="store_true", help="Print object tree")
- parser.add_argument("--outfile", type=Path, help="Output file")
-
- args = parser.parse_args()
-
- objectset = SHACLObjectSet()
- with args.infile.open("r") as f:
- d = JSONLDDeserializer()
- d.read(f, objectset)
-
- if args.print:
- print_tree(objectset.objects)
-
- if args.outfile:
- with args.outfile.open("wb") as f:
- s = JSONLDSerializer()
- s.write(objectset, f)
-
- return 0
-
-
-if __name__ == "__main__":
- sys.exit(main())
--- /dev/null
+# This file was auto-generated by shacl2code 1.0.0. DO NOT MANUALLY MODIFY IT
+#
+# SPDX-License-Identifier: MIT
+"""Generated stub for the generated Python bindings"""
+
+from __future__ import annotations
+
+from datetime import datetime
+from enum import Enum
+from typing import (
+ Any,
+ BinaryIO,
+ Callable,
+ Dict,
+ Generic,
+ Iterable,
+ Iterator,
+ List,
+ Optional,
+ Tuple,
+ Type,
+ TypeVar,
+ Union,
+ overload,
+)
+
+T_PropV = TypeVar("T_PropV")
+T_SHACLObject = TypeVar("T_SHACLObject", bound="SHACLObject")
+
+
+class NodeKind(Enum):
+ BlankNode = 1
+ IRI = 2
+ BlankNodeOrIRI = 3
+
+
+class ListProxy(Generic[T_PropV]): ...
+
+
+class SHACLObject:
+ NAMED_INDIVIDUALS: Dict[str, str]
+ AUTO_NAMED_INDIVIDUALS: bool
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ IS_ABSTRACT: bool
+ IS_DEPRECATED: bool
+ TYPE: str
+ COMPACT_TYPE: Optional[str]
+
+ def __init__(self, **kwargs: Any) -> None: ...
+ def get_type(self) -> str: ...
+ def get_compact_type(self) -> Optional[str]: ...
+ def walk(
+ self,
+ callback: Callable[[Any, List[str]], bool],
+ path: Optional[List[str]] = None,
+ ) -> None: ...
+ def property_keys(
+ self,
+ ) -> Iterator[Tuple[Optional[str], str, Optional[str]]]: ...
+ def iter_objects(
+ self,
+ *,
+ recursive: bool = False,
+ visited: Optional[Any] = None,
+ ) -> Iterable[SHACLObject]: ...
+ def __iter__(self) -> Iterator[str]: ...
+ def __getitem__(self, iri: str) -> Any: ...
+ def __setitem__(self, iri: str, value: Any) -> None: ...
+ def __delitem__(self, iri: str) -> None: ...
+
+
+class SHACLExtensibleObject(SHACLObject):
+ CLOSED: bool
+
+ def __init__(self, typ: Optional[str] = None, **kwargs: Any) -> None: ...
+
+
+class SHACLObjectSet:
+ def __init__(self) -> None: ...
+ def add(self, obj: SHACLObject) -> SHACLObject: ...
+ def update(self, *others: Iterable[SHACLObject]) -> None: ...
+ def find_by_id(
+ self, _id: str, default: Optional[SHACLObject] = None
+ ) -> Optional[SHACLObject]: ...
+ def link(self) -> Any: ...
+ def merge(self, *objectsets: SHACLObjectSet) -> SHACLObjectSet: ...
+ def inline_blank_nodes(self) -> None: ...
+ def foreach(self) -> Iterable[SHACLObject]: ...
+ @overload
+ def foreach_type(
+ self,
+ typ: Type[T_SHACLObject],
+ *,
+ match_subclass: bool = ...,
+ ) -> Iterable[T_SHACLObject]: ...
+ @overload
+ def foreach_type(
+ self,
+ typ: str,
+ *,
+ match_subclass: bool = ...,
+ ) -> Iterable[SHACLObject]: ...
+ def __iter__(self) -> Iterator[SHACLObject]: ...
+ def __contains__(self, item: SHACLObject) -> bool: ...
+ @property
+ def objects(self) -> Iterable[SHACLObject]: ...
+
+
+class JSONLDDeserializer:
+ def deserialize_data(self, data: Any, objectset: SHACLObjectSet) -> None: ...
+ def read(self, f: BinaryIO, objectset: SHACLObjectSet) -> None: ...
+
+
+class JSONLDSerializer:
+ def __init__(self, **kwargs: Any) -> None: ...
+ def serialize_data(
+ self, objectset: SHACLObjectSet, force_at_graph: bool = False
+ ) -> Any: ...
+ def write(
+ self,
+ objectset: SHACLObjectSet,
+ f: BinaryIO,
+ force_at_graph: bool = False,
+ **kwargs: Any,
+ ) -> str: ...
+
+
+class JSONLDInlineSerializer:
+ def write(
+ self,
+ objectset: SHACLObjectSet,
+ f: BinaryIO,
+ force_at_graph: bool = False,
+ ) -> str: ...
+
+
+def encode_context(encoder: Any, objectset: SHACLObjectSet) -> None: ...
+def decode_context(decoder: Any, objectset: SHACLObjectSet) -> None: ...
+
+
+# fmt: off
+"""Format Guard"""
+# CLASSES
+class ai_EnergyConsumption(SHACLObject):
+ """
+ A class for describing the energy consumption incurred by an AI model in
+ different stages of its lifecycle.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyConsumption"
+ COMPACT_TYPE = "ai_EnergyConsumption"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ ai_finetuningEnergyConsumption: Optional[Iterable[Union[str, 'ai_EnergyConsumptionDescription']]] = None,
+ ai_inferenceEnergyConsumption: Optional[Iterable[Union[str, 'ai_EnergyConsumptionDescription']]] = None,
+ ai_trainingEnergyConsumption: Optional[Iterable[Union[str, 'ai_EnergyConsumptionDescription']]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ ai_finetuningEnergyConsumption: ListProxy[Union[str, 'ai_EnergyConsumptionDescription']]
+ ai_inferenceEnergyConsumption: ListProxy[Union[str, 'ai_EnergyConsumptionDescription']]
+ ai_trainingEnergyConsumption: ListProxy[Union[str, 'ai_EnergyConsumptionDescription']]
+
+
+class ai_EnergyConsumptionDescription(SHACLObject):
+ """
+ The class that helps note down the quantity of energy consumption and the unit
+ used for measurement.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyConsumptionDescription"
+ COMPACT_TYPE = "ai_EnergyConsumptionDescription"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ ai_energyQuantity: Optional[float] = None,
+ ai_energyUnit: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ ai_energyQuantity: Optional[float]
+ ai_energyUnit: Optional[str]
+
+
+class ai_EnergyUnitType(SHACLObject):
+ """
+ Specifies the unit of energy consumption.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType"
+ COMPACT_TYPE = "ai_EnergyUnitType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # Kilowatt-hour.
+ kilowattHour: str
+ # Megajoule.
+ megajoule: str
+ # Any other units of energy measurement.
+ other: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class ai_SafetyRiskAssessmentType(SHACLObject):
+ """
+ Specifies the safety risk level.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType"
+ COMPACT_TYPE = "ai_SafetyRiskAssessmentType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # The second-highest level of risk posed by an AI system.
+ high: str
+ # Low/no risk is posed by an AI system.
+ low: str
+ # The third-highest level of risk posed by an AI system.
+ medium: str
+ # The highest level of risk posed by an AI system.
+ serious: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class AnnotationType(SHACLObject):
+ """
+ Specifies the type of an annotation.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType"
+ COMPACT_TYPE = "AnnotationType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # Used to store extra information about an Element which is not part of a review (e.g. extra information provided during the creation of the Element).
+ other: str
+ # Used when someone reviews the Element.
+ review: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class CreationInfo(SHACLObject):
+ """
+ Provides information about the creation of the Element.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/CreationInfo"
+ COMPACT_TYPE = "CreationInfo"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ comment: Optional[str] = None,
+ created: Optional[datetime] = None,
+ createdBy: Optional[Iterable[Union[str, 'Agent']]] = None,
+ createdUsing: Optional[Iterable[Union[str, 'Tool']]] = None,
+ specVersion: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ comment: Optional[str]
+ created: Optional[datetime]
+ createdBy: ListProxy[Union[str, 'Agent']]
+ createdUsing: ListProxy[Union[str, 'Tool']]
+ specVersion: Optional[str]
+
+
+class DictionaryEntry(SHACLObject):
+ """
+ A key with an associated value.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/DictionaryEntry"
+ COMPACT_TYPE = "DictionaryEntry"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ key: Optional[str] = None,
+ value: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ key: Optional[str]
+ value: Optional[str]
+
+
+class Element(SHACLObject):
+ """
+ Base domain class from which all other SPDX-3.0 domain classes derive.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Element"
+ COMPACT_TYPE = "Element"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ *,
+ comment: Optional[str] = None,
+ creationInfo: Optional[Union[str, 'CreationInfo']] = None,
+ description: Optional[str] = None,
+ extension: Optional[Iterable[Union[str, 'extension_Extension']]] = None,
+ externalIdentifier: Optional[Iterable[Union[str, 'ExternalIdentifier']]] = None,
+ externalRef: Optional[Iterable[Union[str, 'ExternalRef']]] = None,
+ name: Optional[str] = None,
+ summary: Optional[str] = None,
+ verifiedUsing: Optional[Iterable[Union[str, 'IntegrityMethod']]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ comment: Optional[str]
+ creationInfo: Optional[Union[str, 'CreationInfo']]
+ description: Optional[str]
+ extension: ListProxy[Union[str, 'extension_Extension']]
+ externalIdentifier: ListProxy[Union[str, 'ExternalIdentifier']]
+ externalRef: ListProxy[Union[str, 'ExternalRef']]
+ name: Optional[str]
+ summary: Optional[str]
+ verifiedUsing: ListProxy[Union[str, 'IntegrityMethod']]
+
+
+class ElementCollection(Element):
+ """
+ A collection of Elements, not necessarily with unifying context.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ElementCollection"
+ COMPACT_TYPE = "ElementCollection"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ *,
+ element: Optional[Iterable[Union[str, 'Element']]] = None,
+ profileConformance: Optional[Iterable[str]] = None,
+ rootElement: Optional[Iterable[Union[str, 'Element']]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ element: ListProxy[Union[str, 'Element']]
+ profileConformance: ListProxy[str]
+ rootElement: ListProxy[Union[str, 'Element']]
+
+
+class ExternalIdentifier(SHACLObject):
+ """
+ A reference to a resource identifier defined outside the scope of SPDX-3.0 content that uniquely identifies an Element.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifier"
+ COMPACT_TYPE = "ExternalIdentifier"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ comment: Optional[str] = None,
+ externalIdentifierType: Optional[str] = None,
+ identifier: Optional[str] = None,
+ identifierLocator: Optional[Iterable[str]] = None,
+ issuingAuthority: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ comment: Optional[str]
+ externalIdentifierType: Optional[str]
+ identifier: Optional[str]
+ identifierLocator: ListProxy[str]
+ issuingAuthority: Optional[str]
+
+
+class ExternalIdentifierType(SHACLObject):
+ """
+ Specifies the type of an external identifier.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType"
+ COMPACT_TYPE = "ExternalIdentifierType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # [Common Platform Enumeration Specification 2.2](https://cpe.mitre.org/files/cpe-specification_2.2.pdf)
+ cpe22: str
+ # [Common Platform Enumeration: Naming Specification Version 2.3](https://csrc.nist.gov/publications/detail/nistir/7695/final)
+ cpe23: str
+ # Common Vulnerabilities and Exposures identifiers, an identifier for a specific software flaw defined within the official CVE Dictionary and that conforms to the [CVE specification](https://csrc.nist.gov/glossary/term/cve_id).
+ cve: str
+ # Email address, as defined in [RFC 3696](https://datatracker.ietf.org/doc/rfc3986/) Section 3.
+ email: str
+ # [Gitoid](https://www.iana.org/assignments/uri-schemes/prov/gitoid), stands for [Git Object ID](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects). A gitoid of type blob is a unique hash of a binary artifact. A gitoid may represent either an [Artifact Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-identifier-types) for the software artifact or an [Input Manifest Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#input-manifest-identifier) for the software artifact's associated [Artifact Input Manifest](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-input-manifest); this ambiguity exists because the Artifact Input Manifest is itself an artifact, and the gitoid of that artifact is its valid identifier. Gitoids calculated on software artifacts (Snippet, File, or Package Elements) should be recorded in the SPDX 3.0 SoftwareArtifact's contentIdentifier property. Gitoids calculated on the Artifact Input Manifest (Input Manifest Identifier) should be recorded in the SPDX 3.0 Element's externalIdentifier property. See [OmniBOR Specification](https://github.com/omnibor/spec/), a minimalistic specification for describing software [Artifact Dependency Graphs](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-dependency-graph-adg).
+ gitoid: str
+ # Used when the type does not match any of the other options.
+ other: str
+ # Package URL, as defined in the corresponding [Annex](../../../annexes/pkg-url-specification.md) of this specification.
+ packageUrl: str
+ # Used when there is a security related identifier of unspecified type.
+ securityOther: str
+ # SoftWare Hash IDentifier, a persistent intrinsic identifier for digital artifacts, such as files, trees (also known as directories or folders), commits, and other objects typically found in version control systems. The format of the identifiers is defined in the [SWHID specification](https://www.swhid.org/specification/v1.1/4.Syntax) (ISO/IEC DIS 18670). They typically look like `swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2`.
+ swhid: str
+ # Concise Software Identification (CoSWID) tag, as defined in [RFC 9393](https://datatracker.ietf.org/doc/rfc9393/) Section 2.3.
+ swid: str
+ # [Uniform Resource Identifier (URI) Schemes](https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml). The scheme used in order to locate a resource.
+ urlScheme: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class ExternalMap(SHACLObject):
+ """
+ A map of Element identifiers that are used within an SpdxDocument but defined
+ external to that SpdxDocument.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalMap"
+ COMPACT_TYPE = "ExternalMap"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ definingArtifact: Optional[Union[str, 'Artifact']] = None,
+ externalSpdxId: Optional[str] = None,
+ locationHint: Optional[str] = None,
+ verifiedUsing: Optional[Iterable[Union[str, 'IntegrityMethod']]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ definingArtifact: Optional[Union[str, 'Artifact']]
+ externalSpdxId: Optional[str]
+ locationHint: Optional[str]
+ verifiedUsing: ListProxy[Union[str, 'IntegrityMethod']]
+
+
+class ExternalRef(SHACLObject):
+ """
+ A reference to a resource outside the scope of SPDX-3.0 content related to an Element.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRef"
+ COMPACT_TYPE = "ExternalRef"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ comment: Optional[str] = None,
+ contentType: Optional[str] = None,
+ externalRefType: Optional[str] = None,
+ locator: Optional[Iterable[str]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ comment: Optional[str]
+ contentType: Optional[str]
+ externalRefType: Optional[str]
+ locator: ListProxy[str]
+
+
+class ExternalRefType(SHACLObject):
+ """
+ Specifies the type of an external reference.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType"
+ COMPACT_TYPE = "ExternalRefType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # A reference to an alternative download location.
+ altDownloadLocation: str
+ # A reference to an alternative web page.
+ altWebPage: str
+ # A reference to binary artifacts related to a package.
+ binaryArtifact: str
+ # A reference to a Bower package. The package locator format, looks like `package#version`, is defined in the "install" section of [Bower API documentation](https://bower.io/docs/api/#install).
+ bower: str
+ # A reference build metadata related to a published package.
+ buildMeta: str
+ # A reference build system used to create or publish the package.
+ buildSystem: str
+ # A reference to a certification report for a package from an accredited/independent body.
+ certificationReport: str
+ # A reference to the instant messaging system used by the maintainer for a package.
+ chat: str
+ # A reference to a Software Composition Analysis (SCA) report.
+ componentAnalysisReport: str
+ # [Common Weakness Enumeration](https://csrc.nist.gov/glossary/term/common_weakness_enumeration). A reference to a source of software flaw defined within the official [CWE List](https://cwe.mitre.org/data/) that conforms to the [CWE specification](https://cwe.mitre.org/).
+ cwe: str
+ # A reference to the documentation for a package.
+ documentation: str
+ # A reference to a dynamic analysis report for a package.
+ dynamicAnalysisReport: str
+ # A reference to the End Of Sale (EOS) and/or End Of Life (EOL) information related to a package.
+ eolNotice: str
+ # A reference to a export control assessment for a package.
+ exportControlAssessment: str
+ # A reference to funding information related to a package.
+ funding: str
+ # A reference to the issue tracker for a package.
+ issueTracker: str
+ # A reference to additional license information related to an artifact.
+ license: str
+ # A reference to the mailing list used by the maintainer for a package.
+ mailingList: str
+ # A reference to a Maven repository artifact. The artifact locator format is defined in the [Maven documentation](https://maven.apache.org/guides/mini/guide-naming-conventions.html) and looks like `groupId:artifactId[:version]`.
+ mavenCentral: str
+ # A reference to metrics related to package such as OpenSSF scorecards.
+ metrics: str
+ # A reference to an npm package. The package locator format is defined in the [npm documentation](https://docs.npmjs.com/cli/v10/configuring-npm/package-json) and looks like `package@version`.
+ npm: str
+ # A reference to a NuGet package. The package locator format is defined in the [NuGet documentation](https://docs.nuget.org) and looks like `package/version`.
+ nuget: str
+ # Used when the type does not match any of the other options.
+ other: str
+ # A reference to a privacy assessment for a package.
+ privacyAssessment: str
+ # A reference to additional product metadata such as reference within organization's product catalog.
+ productMetadata: str
+ # A reference to a purchase order for a package.
+ purchaseOrder: str
+ # A reference to a quality assessment for a package.
+ qualityAssessmentReport: str
+ # A reference to a published list of releases for a package.
+ releaseHistory: str
+ # A reference to the release notes for a package.
+ releaseNotes: str
+ # A reference to a risk assessment for a package.
+ riskAssessment: str
+ # A reference to a runtime analysis report for a package.
+ runtimeAnalysisReport: str
+ # A reference to information assuring that the software is developed using security practices as defined by [NIST SP 800-218 Secure Software Development Framework (SSDF) Version 1.1](https://csrc.nist.gov/pubs/sp/800/218/final) or [CISA Secure Software Development Attestation Form](https://www.cisa.gov/resources-tools/resources/secure-software-development-attestation-form).
+ secureSoftwareAttestation: str
+ # A reference to the security adversary model for a package.
+ securityAdversaryModel: str
+ # A reference to a published security advisory (where advisory as defined per [ISO 29147:2018](https://www.iso.org/standard/72311.html)) that may affect one or more elements, e.g., vendor advisories or specific NVD entries.
+ securityAdvisory: str
+ # A reference to the patch or source code that fixes a vulnerability.
+ securityFix: str
+ # A reference to related security information of unspecified type.
+ securityOther: str
+ # A reference to a [penetration test](https://en.wikipedia.org/wiki/Penetration_test) report for a package.
+ securityPenTestReport: str
+ # A reference to instructions for reporting newly discovered security vulnerabilities for a package.
+ securityPolicy: str
+ # A reference the [security threat model](https://en.wikipedia.org/wiki/Threat_model) for a package.
+ securityThreatModel: str
+ # A reference to a social media channel for a package.
+ socialMedia: str
+ # A reference to an artifact containing the sources for a package.
+ sourceArtifact: str
+ # A reference to a static analysis report for a package.
+ staticAnalysisReport: str
+ # A reference to the software support channel or other support information for a package.
+ support: str
+ # A reference to a version control system related to a software artifact.
+ vcs: str
+ # A reference to a Vulnerability Disclosure Report (VDR) which provides the software supplier's analysis and findings describing the impact (or lack of impact) that reported vulnerabilities have on packages or products in the supplier's SBOM as defined in [NIST SP 800-161 Cybersecurity Supply Chain Risk Management Practices for Systems and Organizations](https://csrc.nist.gov/pubs/sp/800/161/r1/final).
+ vulnerabilityDisclosureReport: str
+ # A reference to a Vulnerability Exploitability eXchange (VEX) statement which provides information on whether a product is impacted by a specific vulnerability in an included package and, if affected, whether there are actions recommended to remediate. See also [NTIA VEX one-page summary](https://ntia.gov/files/ntia/publications/vex_one-page_summary.pdf).
+ vulnerabilityExploitabilityAssessment: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class HashAlgorithm(SHACLObject):
+ """
+ A mathematical algorithm that maps data of arbitrary size to a bit string.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm"
+ COMPACT_TYPE = "HashAlgorithm"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # Adler-32 checksum is part of the widely used zlib compression library as defined in [RFC 1950](https://datatracker.ietf.org/doc/rfc1950/) Section 2.3.
+ adler32: str
+ # BLAKE2b algorithm with a digest size of 256, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
+ blake2b256: str
+ # BLAKE2b algorithm with a digest size of 384, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
+ blake2b384: str
+ # BLAKE2b algorithm with a digest size of 512, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
+ blake2b512: str
+ # [BLAKE3](https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf)
+ blake3: str
+ # [Dilithium](https://pq-crystals.org/dilithium/)
+ crystalsDilithium: str
+ # [Kyber](https://pq-crystals.org/kyber/)
+ crystalsKyber: str
+ # [FALCON](https://falcon-sign.info/falcon.pdf)
+ falcon: str
+ # MD2 message-digest algorithm, as defined in [RFC 1319](https://datatracker.ietf.org/doc/rfc1319/).
+ md2: str
+ # MD4 message-digest algorithm, as defined in [RFC 1186](https://datatracker.ietf.org/doc/rfc1186/).
+ md4: str
+ # MD5 message-digest algorithm, as defined in [RFC 1321](https://datatracker.ietf.org/doc/rfc1321/).
+ md5: str
+ # [MD6 hash function](https://people.csail.mit.edu/rivest/pubs/RABCx08.pdf)
+ md6: str
+ # any hashing algorithm that does not exist in this list of entries
+ other: str
+ # SHA-1, a secure hashing algorithm, as defined in [RFC 3174](https://datatracker.ietf.org/doc/rfc3174/).
+ sha1: str
+ # SHA-2 with a digest length of 224, as defined in [RFC 3874](https://datatracker.ietf.org/doc/rfc3874/).
+ sha224: str
+ # SHA-2 with a digest length of 256, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
+ sha256: str
+ # SHA-2 with a digest length of 384, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
+ sha384: str
+ # SHA-3 with a digest length of 224, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
+ sha3_224: str
+ # SHA-3 with a digest length of 256, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
+ sha3_256: str
+ # SHA-3 with a digest length of 384, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
+ sha3_384: str
+ # SHA-3 with a digest length of 512, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
+ sha3_512: str
+ # SHA-2 with a digest length of 512, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
+ sha512: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class IndividualElement(Element):
+ """
+ A concrete subclass of Element used by Individuals in the
+ Core profile.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/IndividualElement"
+ COMPACT_TYPE = "IndividualElement"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # An Individual Value for Element representing a set of Elements of unknown
+ # identify or cardinality (number).
+ NoAssertionElement: str
+ # An Individual Value for Element representing a set of Elements with
+ # cardinality (number/count) of zero.
+ NoneElement: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class IntegrityMethod(SHACLObject):
+ """
+ Provides an independently reproducible mechanism that permits verification of a specific Element.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/IntegrityMethod"
+ COMPACT_TYPE = "IntegrityMethod"
+ NODE_KIND: NodeKind
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ *,
+ comment: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ comment: Optional[str]
+
+
+class LifecycleScopeType(SHACLObject):
+ """
+ Provide an enumerated set of lifecycle phases that can provide context to relationships.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType"
+ COMPACT_TYPE = "LifecycleScopeType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # A relationship has specific context implications during an element's build phase, during development.
+ build: str
+ # A relationship has specific context implications during an element's design.
+ design: str
+ # A relationship has specific context implications during development phase of an element.
+ development: str
+ # A relationship has other specific context information necessary to capture that the above set of enumerations does not handle.
+ other: str
+ # A relationship has specific context implications during the execution phase of an element.
+ runtime: str
+ # A relationship has specific context implications during an element's testing phase, during development.
+ test: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class NamespaceMap(SHACLObject):
+ """
+ A mapping between prefixes and namespace partial URIs.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/NamespaceMap"
+ COMPACT_TYPE = "NamespaceMap"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ namespace: Optional[str] = None,
+ prefix: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ namespace: Optional[str]
+ prefix: Optional[str]
+
+
+class PackageVerificationCode(IntegrityMethod):
+ """
+ An SPDX version 2.X compatible verification method for software packages.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/PackageVerificationCode"
+ COMPACT_TYPE = "PackageVerificationCode"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ algorithm: Optional[str] = None,
+ hashValue: Optional[str] = None,
+ packageVerificationCodeExcludedFile: Optional[Iterable[str]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ algorithm: Optional[str]
+ hashValue: Optional[str]
+ packageVerificationCodeExcludedFile: ListProxy[str]
+
+
+class PositiveIntegerRange(SHACLObject):
+ """
+ A tuple of two positive integers that define a range.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/PositiveIntegerRange"
+ COMPACT_TYPE = "PositiveIntegerRange"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ beginIntegerRange: Optional[int] = None,
+ endIntegerRange: Optional[int] = None,
+ **kwargs: Any
+ ) -> None: ...
+ beginIntegerRange: Optional[int]
+ endIntegerRange: Optional[int]
+
+
+class PresenceType(SHACLObject):
+ """
+ Categories of presence or absence.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType"
+ COMPACT_TYPE = "PresenceType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # Indicates absence of the field.
+ no: str
+ # Makes no assertion about the field.
+ noAssertion: str
+ # Indicates presence of the field.
+ yes: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class ProfileIdentifierType(SHACLObject):
+ """
+ Enumeration of the valid profiles.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType"
+ COMPACT_TYPE = "ProfileIdentifierType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # the element follows the AI profile specification
+ ai: str
+ # the element follows the Build profile specification
+ build: str
+ # the element follows the Core profile specification
+ core: str
+ # the element follows the Dataset profile specification
+ dataset: str
+ # the element follows the ExpandedLicensing profile specification
+ expandedLicensing: str
+ # the element follows the Extension profile specification
+ extension: str
+ # the element follows the Lite profile specification
+ lite: str
+ # the element follows the Security profile specification
+ security: str
+ # the element follows the SimpleLicensing profile specification
+ simpleLicensing: str
+ # the element follows the Software profile specification
+ software: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class Relationship(Element):
+ """
+ Describes a relationship between one or more elements.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Relationship"
+ COMPACT_TYPE = "Relationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ completeness: Optional[str] = None,
+ endTime: Optional[datetime] = None,
+ from_: Optional[Union[str, 'Element']] = None,
+ relationshipType: Optional[str] = None,
+ startTime: Optional[datetime] = None,
+ to: Optional[Iterable[Union[str, 'Element']]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ completeness: Optional[str]
+ endTime: Optional[datetime]
+ from_: Optional[Union[str, 'Element']]
+ relationshipType: Optional[str]
+ startTime: Optional[datetime]
+ to: ListProxy[Union[str, 'Element']]
+
+
+class RelationshipCompleteness(SHACLObject):
+ """
+ Indicates whether a relationship is known to be complete, incomplete, or if no assertion is made with respect to relationship completeness.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness"
+ COMPACT_TYPE = "RelationshipCompleteness"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # The relationship is known to be exhaustive.
+ complete: str
+ # The relationship is known not to be exhaustive.
+ incomplete: str
+ # No assertion can be made about the completeness of the relationship.
+ noAssertion: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class RelationshipType(SHACLObject):
+ """
+ Information about the relationship between two Elements.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType"
+ COMPACT_TYPE = "RelationshipType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # The `from` Vulnerability affects each `to` Element. The use of the `affects` type is constrained to `VexAffectedVulnAssessmentRelationship` classed relationships.
+ affects: str
+ # The `from` Element is amended by each `to` Element.
+ amendedBy: str
+ # The `from` Element is an ancestor of each `to` Element.
+ ancestorOf: str
+ # The `from` Element is available from the additional supplier described by each `to` Element.
+ availableFrom: str
+ # The `from` Element is a configuration applied to each `to` Element, during a LifecycleScopeType period.
+ configures: str
+ # The `from` Element contains each `to` Element.
+ contains: str
+ # The `from` Vulnerability is coordinatedBy the `to` Agent(s) (vendor, researcher, or consumer agent).
+ coordinatedBy: str
+ # The `from` Element has been copied to each `to` Element.
+ copiedTo: str
+ # The `from` Agent is delegating an action to the Agent of the `to` Relationship (which must be of type invokedBy), during a LifecycleScopeType (e.g. the `to` invokedBy Relationship is being done on behalf of `from`).
+ delegatedTo: str
+ # The `from` Element depends on each `to` Element, during a LifecycleScopeType period.
+ dependsOn: str
+ # The `from` Element is a descendant of each `to` Element.
+ descendantOf: str
+ # The `from` Element describes each `to` Element. To denote the root(s) of a tree of elements in a collection, the rootElement property should be used.
+ describes: str
+ # The `from` Vulnerability has no impact on each `to` Element. The use of the `doesNotAffect` is constrained to `VexNotAffectedVulnAssessmentRelationship` classed relationships.
+ doesNotAffect: str
+ # The `from` archive expands out as an artifact described by each `to` Element.
+ expandsTo: str
+ # The `from` Vulnerability has had an exploit created against it by each `to` Agent.
+ exploitCreatedBy: str
+ # Designates a `from` Vulnerability has been fixed by the `to` Agent(s).
+ fixedBy: str
+ # A `from` Vulnerability has been fixed in each `to` Element. The use of the `fixedIn` type is constrained to `VexFixedVulnAssessmentRelationship` classed relationships.
+ fixedIn: str
+ # Designates a `from` Vulnerability was originally discovered by the `to` Agent(s).
+ foundBy: str
+ # The `from` Element generates each `to` Element.
+ generates: str
+ # Every `to` Element is a file added to the `from` Element (`from` hasAddedFile `to`).
+ hasAddedFile: str
+ # Relates a `from` Vulnerability and each `to` Element with a security assessment. To be used with `VulnAssessmentRelationship` types.
+ hasAssessmentFor: str
+ # Used to associate a `from` Artifact with each `to` Vulnerability.
+ hasAssociatedVulnerability: str
+ # The `from` SoftwareArtifact is concluded by the SPDX data creator to be governed by each `to` license.
+ hasConcludedLicense: str
+ # The `from` Element treats each `to` Element as a data file. A data file is an artifact that stores data required or optional for the `from` Element's functionality. A data file can be a database file, an index file, a log file, an AI model file, a calibration data file, a temporary file, a backup file, and more. For AI training dataset, test dataset, test artifact, configuration data, build input data, and build output data, please consider using the more specific relationship types: `trainedOn`, `testedOn`, `hasTest`, `configures`, `hasInput`, and `hasOutput`, respectively. This relationship does not imply dependency.
+ hasDataFile: str
+ # The `from` SoftwareArtifact was discovered to actually contain each `to` license, for example as detected by use of automated tooling.
+ hasDeclaredLicense: str
+ # Every `to` Element is a file deleted from the `from` Element (`from` hasDeletedFile `to`).
+ hasDeletedFile: str
+ # The `from` Element has manifest files that contain dependency information in each `to` Element.
+ hasDependencyManifest: str
+ # The `from` Element is distributed as an artifact in each `to` Element (e.g. an RPM or archive file).
+ hasDistributionArtifact: str
+ # The `from` Element is documented by each `to` Element.
+ hasDocumentation: str
+ # The `from` Element dynamically links in each `to` Element, during a LifecycleScopeType period.
+ hasDynamicLink: str
+ # Every `to` Element is considered as evidence for the `from` Element (`from` hasEvidence `to`).
+ hasEvidence: str
+ # Every `to` Element is an example for the `from` Element (`from` hasExample `to`).
+ hasExample: str
+ # The `from` Build was run on the `to` Element during a LifecycleScopeType period (e.g. the host that the build runs on).
+ hasHost: str
+ # The `from` Build has each `to` Element as an input, during a LifecycleScopeType period.
+ hasInput: str
+ # Every `to` Element is metadata about the `from` Element (`from` hasMetadata `to`).
+ hasMetadata: str
+ # Every `to` Element is an optional component of the `from` Element (`from` hasOptionalComponent `to`).
+ hasOptionalComponent: str
+ # The `from` Element optionally depends on each `to` Element, during a LifecycleScopeType period.
+ hasOptionalDependency: str
+ # The `from` Build element generates each `to` Element as an output, during a LifecycleScopeType period.
+ hasOutput: str
+ # The `from` Element has a prerequisite on each `to` Element, during a LifecycleScopeType period.
+ hasPrerequisite: str
+ # The `from` Element has a dependency on each `to` Element, dependency is not in the distributed artifact, but assumed to be provided, during a LifecycleScopeType period.
+ hasProvidedDependency: str
+ # The `from` Element has a requirement on each `to` Element, during a LifecycleScopeType period.
+ hasRequirement: str
+ # Every `to` Element is a specification for the `from` Element (`from` hasSpecification `to`), during a LifecycleScopeType period.
+ hasSpecification: str
+ # The `from` Element statically links in each `to` Element, during a LifecycleScopeType period.
+ hasStaticLink: str
+ # Every `to` Element is a test artifact for the `from` Element (`from` hasTest `to`), during a LifecycleScopeType period.
+ hasTest: str
+ # Every `to` Element is a test case for the `from` Element (`from` hasTestCase `to`).
+ hasTestCase: str
+ # Every `to` Element is a variant the `from` Element (`from` hasVariant `to`).
+ hasVariant: str
+ # The `from` Element was invoked by the `to` Agent, during a LifecycleScopeType period (for example, a Build element that describes a build step).
+ invokedBy: str
+ # The `from` Element is modified by each `to` Element.
+ modifiedBy: str
+ # Every `to` Element is related to the `from` Element where the relationship type is not described by any of the SPDX relationship types (this relationship is directionless).
+ other: str
+ # Every `to` Element is a packaged instance of the `from` Element (`from` packagedBy `to`).
+ packagedBy: str
+ # Every `to` Element is a patch for the `from` Element (`from` patchedBy `to`).
+ patchedBy: str
+ # Designates a `from` Vulnerability was made available for public use or reference by each `to` Agent.
+ publishedBy: str
+ # Designates a `from` Vulnerability was first reported to a project, vendor, or tracking database for formal identification by each `to` Agent.
+ reportedBy: str
+ # Designates a `from` Vulnerability's details were tracked, aggregated, and/or enriched to improve context (i.e. NVD) by each `to` Agent.
+ republishedBy: str
+ # The `from` SpdxDocument can be found in a serialized form in each `to` Artifact.
+ serializedInArtifact: str
+ # The `from` Element has been tested on the `to` Element(s).
+ testedOn: str
+ # The `from` Element has been trained on the `to` Element(s).
+ trainedOn: str
+ # The `from` Vulnerability impact is being investigated for each `to` Element. The use of the `underInvestigationFor` type is constrained to `VexUnderInvestigationVulnAssessmentRelationship` classed relationships.
+ underInvestigationFor: str
+ # The `from` Element uses each `to` Element as a tool, during a LifecycleScopeType period.
+ usesTool: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class SpdxDocument(ElementCollection):
+ """
+ A collection of SPDX Elements that could potentially be serialized.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/SpdxDocument"
+ COMPACT_TYPE = "SpdxDocument"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ dataLicense: Optional[Union[str, 'simplelicensing_AnyLicenseInfo']] = None,
+ import_: Optional[Iterable[Union[str, 'ExternalMap']]] = None,
+ namespaceMap: Optional[Iterable[Union[str, 'NamespaceMap']]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ dataLicense: Optional[Union[str, 'simplelicensing_AnyLicenseInfo']]
+ import_: ListProxy[Union[str, 'ExternalMap']]
+ namespaceMap: ListProxy[Union[str, 'NamespaceMap']]
+
+
+class SupportType(SHACLObject):
+ """
+ Indicates the type of support that is associated with an artifact.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType"
+ COMPACT_TYPE = "SupportType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # in addition to being supported by the supplier, the software is known to have been deployed and is in use. For a software as a service provider, this implies the software is now available as a service.
+ deployed: str
+ # the artifact is in active development and is not considered ready for formal support from the supplier.
+ development: str
+ # there is a defined end of support for the artifact from the supplier. This may also be referred to as end of life. There is a validUntilDate that can be used to signal when support ends for the artifact.
+ endOfSupport: str
+ # the artifact has been released, and there is limited support available from the supplier. There is a validUntilDate that can provide additional information about the duration of support.
+ limitedSupport: str
+ # no assertion about the type of support is made. This is considered the default if no other support type is used.
+ noAssertion: str
+ # there is no support for the artifact from the supplier, consumer assumes any support obligations.
+ noSupport: str
+ # the artifact has been released, and is supported from the supplier. There is a validUntilDate that can provide additional information about the duration of support.
+ support: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class Tool(Element):
+ """
+ An element of hardware and/or software utilized to carry out a particular function.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Tool"
+ COMPACT_TYPE = "Tool"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class dataset_ConfidentialityLevelType(SHACLObject):
+ """
+ Categories of confidentiality level.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType"
+ COMPACT_TYPE = "dataset_ConfidentialityLevelType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # Data points in the dataset can be shared only with specific organizations and their clients on a need to know basis.
+ amber: str
+ # Dataset may be distributed freely, without restriction.
+ clear: str
+ # Dataset can be shared within a community of peers and partners.
+ green: str
+ # Data points in the dataset are highly confidential and can only be shared with named recipients.
+ red: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class dataset_DatasetAvailabilityType(SHACLObject):
+ """
+ Availability of dataset.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType"
+ COMPACT_TYPE = "dataset_DatasetAvailabilityType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # the dataset is not publicly available and can only be accessed after affirmatively accepting terms on a clickthrough webpage.
+ clickthrough: str
+ # the dataset is publicly available and can be downloaded directly.
+ directDownload: str
+ # the dataset is publicly available, but not all at once, and can only be accessed through queries which return parts of the dataset.
+ query: str
+ # the dataset is not publicly available and an email registration is required before accessing the dataset, although without an affirmative acceptance of terms.
+ registration: str
+ # the dataset provider is not making available the underlying data and the dataset must be reassembled, typically using the provided script for scraping the data.
+ scrapingScript: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class dataset_DatasetType(SHACLObject):
+ """
+ Enumeration of dataset types.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType"
+ COMPACT_TYPE = "dataset_DatasetType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # data is audio based, such as a collection of music from the 80s.
+ audio: str
+ # data that is classified into a discrete number of categories, such as the eye color of a population of people.
+ categorical: str
+ # data is in the form of a graph where entries are somehow related to each other through edges, such a social network of friends.
+ graph: str
+ # data is a collection of images such as pictures of animals.
+ image: str
+ # data type is not known.
+ noAssertion: str
+ # data consists only of numeric entries.
+ numeric: str
+ # data is of a type not included in this list.
+ other: str
+ # data is recorded from a physical sensor, such as a thermometer reading or biometric device.
+ sensor: str
+ # data is stored in tabular format or retrieved from a relational database.
+ structured: str
+ # data describes the syntax or semantics of a language or text, such as a parse tree used for natural language processing.
+ syntactic: str
+ # data consists of unstructured text, such as a book, Wikipedia article (without images), or transcript.
+ text: str
+ # data is recorded in an ordered sequence of timestamped entries, such as the price of a stock over the course of a day.
+ timeseries: str
+ # data is recorded with a timestamp for each entry, but not necessarily ordered or at specific intervals, such as when a taxi ride starts and ends.
+ timestamp: str
+ # data is video based, such as a collection of movie clips featuring Tom Hanks.
+ video: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class expandedlicensing_LicenseAddition(Element):
+ """
+ Abstract class for additional text intended to be added to a License, but
+ which is not itself a standalone License.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/LicenseAddition"
+ COMPACT_TYPE = "expandedlicensing_LicenseAddition"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ *,
+ expandedlicensing_additionText: Optional[str] = None,
+ expandedlicensing_isDeprecatedAdditionId: Optional[bool] = None,
+ expandedlicensing_licenseXml: Optional[str] = None,
+ expandedlicensing_obsoletedBy: Optional[str] = None,
+ expandedlicensing_seeAlso: Optional[Iterable[str]] = None,
+ expandedlicensing_standardAdditionTemplate: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ expandedlicensing_additionText: Optional[str]
+ expandedlicensing_isDeprecatedAdditionId: Optional[bool]
+ expandedlicensing_licenseXml: Optional[str]
+ expandedlicensing_obsoletedBy: Optional[str]
+ expandedlicensing_seeAlso: ListProxy[str]
+ expandedlicensing_standardAdditionTemplate: Optional[str]
+
+
+class expandedlicensing_ListedLicenseException(expandedlicensing_LicenseAddition):
+ """
+ A license exception that is listed on the SPDX Exceptions list.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ListedLicenseException"
+ COMPACT_TYPE = "expandedlicensing_ListedLicenseException"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ expandedlicensing_deprecatedVersion: Optional[str] = None,
+ expandedlicensing_listVersionAdded: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ expandedlicensing_deprecatedVersion: Optional[str]
+ expandedlicensing_listVersionAdded: Optional[str]
+
+
+class extension_CdxPropertyEntry(SHACLObject):
+ """
+ A property name with an associated value.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Extension/CdxPropertyEntry"
+ COMPACT_TYPE = "extension_CdxPropertyEntry"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ extension_cdxPropName: Optional[str] = None,
+ extension_cdxPropValue: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ extension_cdxPropName: Optional[str]
+ extension_cdxPropValue: Optional[str]
+
+
+class extension_Extension(SHACLExtensibleObject):
+ """
+ A characterization of some aspect of an Element that is associated with the Element in a generalized fashion.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Extension/Extension"
+ COMPACT_TYPE = "extension_Extension"
+ NODE_KIND: NodeKind
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class security_CvssSeverityType(SHACLObject):
+ """
+ Specifies the CVSS base, temporal, threat, or environmental severity type.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType"
+ COMPACT_TYPE = "security_CvssSeverityType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # When a CVSS score is between 9.0 - 10.0
+ critical: str
+ # When a CVSS score is between 7.0 - 8.9
+ high: str
+ # When a CVSS score is between 0.1 - 3.9
+ low: str
+ # When a CVSS score is between 4.0 - 6.9
+ medium: str
+ # When a CVSS score is 0.0
+ none: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class security_ExploitCatalogType(SHACLObject):
+ """
+ Specifies the exploit catalog type.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType"
+ COMPACT_TYPE = "security_ExploitCatalogType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # CISA's Known Exploited Vulnerability (KEV) Catalog
+ kev: str
+ # Other exploit catalogs
+ other: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class security_SsvcDecisionType(SHACLObject):
+ """
+ Specifies the SSVC decision type.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType"
+ COMPACT_TYPE = "security_SsvcDecisionType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # The vulnerability requires attention from the organization's internal, supervisory-level and leadership-level individuals. Necessary actions include requesting assistance or information about the vulnerability, as well as publishing a notification either internally and/or externally. Typically, internal groups would meet to determine the overall response and then execute agreed upon actions. CISA recommends remediating Act vulnerabilities as soon as possible.
+ act: str
+ # The vulnerability requires attention from the organization's internal, supervisory-level individuals. Necessary actions include requesting assistance or information about the vulnerability, and may involve publishing a notification either internally and/or externally. CISA recommends remediating Attend vulnerabilities sooner than standard update timelines.
+ attend: str
+ # The vulnerability does not require action at this time. The organization would continue to track the vulnerability and reassess it if new information becomes available. CISA recommends remediating Track vulnerabilities within standard update timelines.
+ track: str
+ # ("Track\*" in the SSVC spec) The vulnerability contains specific characteristics that may require closer monitoring for changes. CISA recommends remediating Track\* vulnerabilities within standard update timelines.
+ trackStar: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class security_VexJustificationType(SHACLObject):
+ """
+ Specifies the VEX justification type.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType"
+ COMPACT_TYPE = "security_VexJustificationType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # The software is not affected because the vulnerable component is not in the product.
+ componentNotPresent: str
+ # Built-in inline controls or mitigations prevent an adversary from leveraging the vulnerability.
+ inlineMitigationsAlreadyExist: str
+ # The vulnerable component is present, and the component contains the vulnerable code. However, vulnerable code is used in such a way that an attacker cannot mount any anticipated attack.
+ vulnerableCodeCannotBeControlledByAdversary: str
+ # The affected code is not reachable through the execution of the code, including non-anticipated states of the product.
+ vulnerableCodeNotInExecutePath: str
+ # The product is not affected because the code underlying the vulnerability is not present in the product.
+ vulnerableCodeNotPresent: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class security_VulnAssessmentRelationship(Relationship):
+ """
+ Abstract ancestor class for all vulnerability assessments
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ *,
+ suppliedBy: Optional[Union[str, 'Agent']] = None,
+ security_assessedElement: Optional[Union[str, 'software_SoftwareArtifact']] = None,
+ security_modifiedTime: Optional[datetime] = None,
+ security_publishedTime: Optional[datetime] = None,
+ security_withdrawnTime: Optional[datetime] = None,
+ **kwargs: Any
+ ) -> None: ...
+ suppliedBy: Optional[Union[str, 'Agent']]
+ security_assessedElement: Optional[Union[str, 'software_SoftwareArtifact']]
+ security_modifiedTime: Optional[datetime]
+ security_publishedTime: Optional[datetime]
+ security_withdrawnTime: Optional[datetime]
+
+
+class simplelicensing_AnyLicenseInfo(Element):
+ """
+ Abstract class representing a license combination consisting of one or more licenses.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/AnyLicenseInfo"
+ COMPACT_TYPE = "simplelicensing_AnyLicenseInfo"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class simplelicensing_LicenseExpression(simplelicensing_AnyLicenseInfo):
+ """
+ An SPDX Element containing an SPDX license expression string.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/LicenseExpression"
+ COMPACT_TYPE = "simplelicensing_LicenseExpression"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ simplelicensing_customIdToUri: Optional[Iterable[Union[str, 'DictionaryEntry']]] = None,
+ simplelicensing_licenseExpression: Optional[str] = None,
+ simplelicensing_licenseListVersion: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ simplelicensing_customIdToUri: ListProxy[Union[str, 'DictionaryEntry']]
+ simplelicensing_licenseExpression: Optional[str]
+ simplelicensing_licenseListVersion: Optional[str]
+
+
+class simplelicensing_SimpleLicensingText(Element):
+ """
+ A license or addition that is not listed on the SPDX License List.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/SimpleLicensingText"
+ COMPACT_TYPE = "simplelicensing_SimpleLicensingText"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ simplelicensing_licenseText: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ simplelicensing_licenseText: Optional[str]
+
+
+class software_ContentIdentifier(IntegrityMethod):
+ """
+ A canonical, unique, immutable identifier
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifier"
+ COMPACT_TYPE = "software_ContentIdentifier"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ software_contentIdentifierType: Optional[str] = None,
+ software_contentIdentifierValue: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ software_contentIdentifierType: Optional[str]
+ software_contentIdentifierValue: Optional[str]
+
+
+class software_ContentIdentifierType(SHACLObject):
+ """
+ Specifies the type of a content identifier.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType"
+ COMPACT_TYPE = "software_ContentIdentifierType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # [Gitoid](https://www.iana.org/assignments/uri-schemes/prov/gitoid), stands for [Git Object ID](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects). A gitoid of type blob is a unique hash of a binary artifact. A gitoid may represent either an [Artifact Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-identifier-types) for the software artifact or an [Input Manifest Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#input-manifest-identifier) for the software artifact's associated [Artifact Input Manifest](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-input-manifest); this ambiguity exists because the Artifact Input Manifest is itself an artifact, and the gitoid of that artifact is its valid identifier. Gitoids calculated on software artifacts (Snippet, File, or Package Elements) should be recorded in the SPDX 3.0 SoftwareArtifact's contentIdentifier property. Gitoids calculated on the Artifact Input Manifest (Input Manifest Identifier) should be recorded in the SPDX 3.0 Element's externalIdentifier property. See [OmniBOR Specification](https://github.com/omnibor/spec/), a minimalistic specification for describing software [Artifact Dependency Graphs](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-dependency-graph-adg).
+ gitoid: str
+ # SoftWare Hash IDentifier, a persistent intrinsic identifier for digital artifacts, such as files, trees (also known as directories or folders), commits, and other objects typically found in version control systems. The format of the identifiers is defined in the [SWHID specification](https://www.swhid.org/specification/v1.1/4.Syntax) (ISO/IEC DIS 18670). They typically look like `swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2`.
+ swhid: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class software_FileKindType(SHACLObject):
+ """
+ Enumeration of the different kinds of SPDX file.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/FileKindType"
+ COMPACT_TYPE = "software_FileKindType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # The file represents a directory and all content stored in that directory.
+ directory: str
+ # The file represents a single file (default).
+ file: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class software_SbomType(SHACLObject):
+ """
+ Provides a set of values to be used to describe the common types of SBOMs that
+ tools may create.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType"
+ COMPACT_TYPE = "software_SbomType"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # SBOM generated through analysis of artifacts (e.g., executables, packages, containers, and virtual machine images) after its build. Such analysis generally requires a variety of heuristics. In some contexts, this may also be referred to as a "3rd party" SBOM.
+ analyzed: str
+ # SBOM generated as part of the process of building the software to create a releasable artifact (e.g., executable or package) from data such as source files, dependencies, built components, build process ephemeral data, and other SBOMs.
+ build: str
+ # SBOM provides an inventory of software that is present on a system. This may be an assembly of other SBOMs that combines analysis of configuration options, and examination of execution behavior in a (potentially simulated) deployment environment.
+ deployed: str
+ # SBOM of intended, planned software project or product with included components (some of which may not yet exist) for a new software artifact.
+ design: str
+ # SBOM generated through instrumenting the system running the software, to capture only components present in the system, as well as external call-outs or dynamically loaded components. In some contexts, this may also be referred to as an "Instrumented" or "Dynamic" SBOM.
+ runtime: str
+ # SBOM created directly from the development environment, source files, and included dependencies used to build an product artifact.
+ source: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class software_SoftwarePurpose(SHACLObject):
+ """
+ Provides information about the primary purpose of an Element.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose"
+ COMPACT_TYPE = "software_SoftwarePurpose"
+ NODE_KIND: NodeKind
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # The Element is a software application.
+ application: str
+ # The Element is an archived collection of one or more files (.tar, .zip, etc.).
+ archive: str
+ # The Element is a bill of materials.
+ bom: str
+ # The Element is configuration data.
+ configuration: str
+ # The Element is a container image which can be used by a container runtime application.
+ container: str
+ # The Element is data.
+ data: str
+ # The Element refers to a chipset, processor, or electronic board.
+ device: str
+ # The Element represents software that controls hardware devices.
+ deviceDriver: str
+ # The Element refers to a disk image that can be written to a disk, booted in a VM, etc. A disk image typically contains most or all of the components necessary to boot, such as bootloaders, kernels, firmware, userspace, etc.
+ diskImage: str
+ # The Element is documentation.
+ documentation: str
+ # The Element is the evidence that a specification or requirement has been fulfilled.
+ evidence: str
+ # The Element is an Artifact that can be run on a computer.
+ executable: str
+ # The Element is a single file which can be independently distributed (configuration file, statically linked binary, Kubernetes deployment, etc.).
+ file: str
+ # The Element is a file system image that can be written to a disk (or virtual) partition.
+ filesystemImage: str
+ # The Element provides low level control over a device's hardware.
+ firmware: str
+ # The Element is a software framework.
+ framework: str
+ # The Element is used to install software on disk.
+ install: str
+ # The Element is a software library.
+ library: str
+ # The Element is a software manifest.
+ manifest: str
+ # The Element is a machine learning or artificial intelligence model.
+ model: str
+ # The Element is a module of a piece of software.
+ module: str
+ # The Element is an operating system.
+ operatingSystem: str
+ # The Element doesn't fit into any of the other categories.
+ other: str
+ # The Element contains a set of changes to update, fix, or improve another Element.
+ patch: str
+ # The Element represents a runtime environment.
+ platform: str
+ # The Element provides a requirement needed as input for another Element.
+ requirement: str
+ # The Element is a single or a collection of source files.
+ source: str
+ # The Element is a plan, guideline or strategy how to create, perform or analyze an application.
+ specification: str
+ # The Element is a test used to verify functionality on an software element.
+ test: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class build_Build(Element):
+ """
+ Class that describes a build instance of software/artifacts.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Build/Build"
+ COMPACT_TYPE = "build_Build"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ build_buildEndTime: Optional[datetime] = None,
+ build_buildId: Optional[str] = None,
+ build_buildStartTime: Optional[datetime] = None,
+ build_buildType: Optional[str] = None,
+ build_configSourceDigest: Optional[Iterable[Union[str, 'Hash']]] = None,
+ build_configSourceEntrypoint: Optional[Iterable[str]] = None,
+ build_configSourceUri: Optional[Iterable[str]] = None,
+ build_environment: Optional[Iterable[Union[str, 'DictionaryEntry']]] = None,
+ build_parameter: Optional[Iterable[Union[str, 'DictionaryEntry']]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ build_buildEndTime: Optional[datetime]
+ build_buildId: Optional[str]
+ build_buildStartTime: Optional[datetime]
+ build_buildType: Optional[str]
+ build_configSourceDigest: ListProxy[Union[str, 'Hash']]
+ build_configSourceEntrypoint: ListProxy[str]
+ build_configSourceUri: ListProxy[str]
+ build_environment: ListProxy[Union[str, 'DictionaryEntry']]
+ build_parameter: ListProxy[Union[str, 'DictionaryEntry']]
+
+
+class Agent(Element):
+ """
+ Agent represents anything with the potential to act on a system.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Agent"
+ COMPACT_TYPE = "Agent"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class Annotation(Element):
+ """
+ An assertion made in relation to one or more elements.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Annotation"
+ COMPACT_TYPE = "Annotation"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ annotationType: Optional[str] = None,
+ contentType: Optional[str] = None,
+ statement: Optional[str] = None,
+ subject: Optional[Union[str, 'Element']] = None,
+ **kwargs: Any
+ ) -> None: ...
+ annotationType: Optional[str]
+ contentType: Optional[str]
+ statement: Optional[str]
+ subject: Optional[Union[str, 'Element']]
+
+
+class Artifact(Element):
+ """
+ A distinct article or unit within the digital domain.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Artifact"
+ COMPACT_TYPE = "Artifact"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ *,
+ builtTime: Optional[datetime] = None,
+ originatedBy: Optional[Iterable[Union[str, 'Agent']]] = None,
+ releaseTime: Optional[datetime] = None,
+ standardName: Optional[Iterable[str]] = None,
+ suppliedBy: Optional[Union[str, 'Agent']] = None,
+ supportLevel: Optional[Iterable[str]] = None,
+ validUntilTime: Optional[datetime] = None,
+ **kwargs: Any
+ ) -> None: ...
+ builtTime: Optional[datetime]
+ originatedBy: ListProxy[Union[str, 'Agent']]
+ releaseTime: Optional[datetime]
+ standardName: ListProxy[str]
+ suppliedBy: Optional[Union[str, 'Agent']]
+ supportLevel: ListProxy[str]
+ validUntilTime: Optional[datetime]
+
+
+class Bundle(ElementCollection):
+ """
+ A collection of Elements that have a shared context.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Bundle"
+ COMPACT_TYPE = "Bundle"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ context: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ context: Optional[str]
+
+
+class Hash(IntegrityMethod):
+ """
+ A mathematically calculated representation of a grouping of data.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Hash"
+ COMPACT_TYPE = "Hash"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ algorithm: Optional[str] = None,
+ hashValue: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ algorithm: Optional[str]
+ hashValue: Optional[str]
+
+
+class LifecycleScopedRelationship(Relationship):
+ """
+ Provide context for a relationship that occurs in the lifecycle.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopedRelationship"
+ COMPACT_TYPE = "LifecycleScopedRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ scope: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ scope: Optional[str]
+
+
+class Organization(Agent):
+ """
+ A group of people who work together in an organized way for a shared purpose.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Organization"
+ COMPACT_TYPE = "Organization"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # An Organization representing the SPDX Project.
+ SpdxOrganization: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class Person(Agent):
+ """
+ An individual human being.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Person"
+ COMPACT_TYPE = "Person"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class SoftwareAgent(Agent):
+ """
+ A software agent.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/SoftwareAgent"
+ COMPACT_TYPE = "SoftwareAgent"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class expandedlicensing_ConjunctiveLicenseSet(simplelicensing_AnyLicenseInfo):
+ """
+ Portion of an AnyLicenseInfo representing a set of licensing information
+ where all elements apply.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ConjunctiveLicenseSet"
+ COMPACT_TYPE = "expandedlicensing_ConjunctiveLicenseSet"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ expandedlicensing_member: Optional[Iterable[Union[str, 'simplelicensing_AnyLicenseInfo']]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ expandedlicensing_member: ListProxy[Union[str, 'simplelicensing_AnyLicenseInfo']]
+
+
+class expandedlicensing_CustomLicenseAddition(expandedlicensing_LicenseAddition):
+ """
+ A license addition that is not listed on the SPDX Exceptions List.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/CustomLicenseAddition"
+ COMPACT_TYPE = "expandedlicensing_CustomLicenseAddition"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class expandedlicensing_DisjunctiveLicenseSet(simplelicensing_AnyLicenseInfo):
+ """
+ Portion of an AnyLicenseInfo representing a set of licensing information where
+ only one of the elements applies.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/DisjunctiveLicenseSet"
+ COMPACT_TYPE = "expandedlicensing_DisjunctiveLicenseSet"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ expandedlicensing_member: Optional[Iterable[Union[str, 'simplelicensing_AnyLicenseInfo']]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ expandedlicensing_member: ListProxy[Union[str, 'simplelicensing_AnyLicenseInfo']]
+
+
+class expandedlicensing_ExtendableLicense(simplelicensing_AnyLicenseInfo):
+ """
+ Abstract class representing a License or an OrLaterOperator.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ExtendableLicense"
+ COMPACT_TYPE = "expandedlicensing_ExtendableLicense"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class expandedlicensing_IndividualLicensingInfo(simplelicensing_AnyLicenseInfo):
+ """
+ A concrete subclass of AnyLicenseInfo used by Individuals in the
+ ExpandedLicensing profile.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/IndividualLicensingInfo"
+ COMPACT_TYPE = "expandedlicensing_IndividualLicensingInfo"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ NAMED_INDIVIDUALS: Dict[str, str]
+ # An Individual Value for License when no assertion can be made about its actual
+ # value.
+ NoAssertionLicense: str
+ # An Individual Value for License where the SPDX data creator determines that no
+ # license is present.
+ NoneLicense: str
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class expandedlicensing_License(expandedlicensing_ExtendableLicense):
+ """
+ Abstract class for the portion of an AnyLicenseInfo representing a license.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/License"
+ COMPACT_TYPE = "expandedlicensing_License"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ *,
+ expandedlicensing_isDeprecatedLicenseId: Optional[bool] = None,
+ expandedlicensing_isFsfLibre: Optional[bool] = None,
+ expandedlicensing_isOsiApproved: Optional[bool] = None,
+ expandedlicensing_licenseXml: Optional[str] = None,
+ expandedlicensing_obsoletedBy: Optional[str] = None,
+ expandedlicensing_seeAlso: Optional[Iterable[str]] = None,
+ expandedlicensing_standardLicenseHeader: Optional[str] = None,
+ expandedlicensing_standardLicenseTemplate: Optional[str] = None,
+ simplelicensing_licenseText: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ expandedlicensing_isDeprecatedLicenseId: Optional[bool]
+ expandedlicensing_isFsfLibre: Optional[bool]
+ expandedlicensing_isOsiApproved: Optional[bool]
+ expandedlicensing_licenseXml: Optional[str]
+ expandedlicensing_obsoletedBy: Optional[str]
+ expandedlicensing_seeAlso: ListProxy[str]
+ expandedlicensing_standardLicenseHeader: Optional[str]
+ expandedlicensing_standardLicenseTemplate: Optional[str]
+ simplelicensing_licenseText: Optional[str]
+
+
+class expandedlicensing_ListedLicense(expandedlicensing_License):
+ """
+ A license that is listed on the SPDX License List.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ListedLicense"
+ COMPACT_TYPE = "expandedlicensing_ListedLicense"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ expandedlicensing_deprecatedVersion: Optional[str] = None,
+ expandedlicensing_listVersionAdded: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ expandedlicensing_deprecatedVersion: Optional[str]
+ expandedlicensing_listVersionAdded: Optional[str]
+
+
+class expandedlicensing_OrLaterOperator(expandedlicensing_ExtendableLicense):
+ """
+ Portion of an AnyLicenseInfo representing this version, or any later version,
+ of the indicated License.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/OrLaterOperator"
+ COMPACT_TYPE = "expandedlicensing_OrLaterOperator"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ expandedlicensing_subjectLicense: Optional[Union[str, 'expandedlicensing_License']] = None,
+ **kwargs: Any
+ ) -> None: ...
+ expandedlicensing_subjectLicense: Optional[Union[str, 'expandedlicensing_License']]
+
+
+class expandedlicensing_WithAdditionOperator(simplelicensing_AnyLicenseInfo):
+ """
+ Portion of an AnyLicenseInfo representing a License which has additional
+ text applied to it.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/WithAdditionOperator"
+ COMPACT_TYPE = "expandedlicensing_WithAdditionOperator"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ expandedlicensing_subjectAddition: Optional[Union[str, 'expandedlicensing_LicenseAddition']] = None,
+ expandedlicensing_subjectExtendableLicense: Optional[Union[str, 'expandedlicensing_ExtendableLicense']] = None,
+ **kwargs: Any
+ ) -> None: ...
+ expandedlicensing_subjectAddition: Optional[Union[str, 'expandedlicensing_LicenseAddition']]
+ expandedlicensing_subjectExtendableLicense: Optional[Union[str, 'expandedlicensing_ExtendableLicense']]
+
+
+class extension_CdxPropertiesExtension(extension_Extension):
+ """
+ A type of extension consisting of a list of name value pairs.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Extension/CdxPropertiesExtension"
+ COMPACT_TYPE = "extension_CdxPropertiesExtension"
+ NODE_KIND: NodeKind
+
+ def __init__(
+ self,
+ *,
+ extension_cdxProperty: Optional[Iterable[Union[str, 'extension_CdxPropertyEntry']]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ extension_cdxProperty: ListProxy[Union[str, 'extension_CdxPropertyEntry']]
+
+
+class security_CvssV2VulnAssessmentRelationship(security_VulnAssessmentRelationship):
+ """
+ Provides a CVSS version 2.0 assessment for a vulnerability.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/CvssV2VulnAssessmentRelationship"
+ COMPACT_TYPE = "security_CvssV2VulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ security_score: Optional[float] = None,
+ security_vectorString: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ security_score: Optional[float]
+ security_vectorString: Optional[str]
+
+
+class security_CvssV3VulnAssessmentRelationship(security_VulnAssessmentRelationship):
+ """
+ Provides a CVSS version 3 assessment for a vulnerability.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/CvssV3VulnAssessmentRelationship"
+ COMPACT_TYPE = "security_CvssV3VulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ security_score: Optional[float] = None,
+ security_severity: Optional[str] = None,
+ security_vectorString: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ security_score: Optional[float]
+ security_severity: Optional[str]
+ security_vectorString: Optional[str]
+
+
+class security_CvssV4VulnAssessmentRelationship(security_VulnAssessmentRelationship):
+ """
+ Provides a CVSS version 4 assessment for a vulnerability.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/CvssV4VulnAssessmentRelationship"
+ COMPACT_TYPE = "security_CvssV4VulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ security_score: Optional[float] = None,
+ security_severity: Optional[str] = None,
+ security_vectorString: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ security_score: Optional[float]
+ security_severity: Optional[str]
+ security_vectorString: Optional[str]
+
+
+class security_EpssVulnAssessmentRelationship(security_VulnAssessmentRelationship):
+ """
+ Provides an EPSS assessment for a vulnerability.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/EpssVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_EpssVulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ security_percentile: Optional[float] = None,
+ security_probability: Optional[float] = None,
+ **kwargs: Any
+ ) -> None: ...
+ security_percentile: Optional[float]
+ security_probability: Optional[float]
+
+
+class security_ExploitCatalogVulnAssessmentRelationship(security_VulnAssessmentRelationship):
+ """
+ Provides an exploit assessment of a vulnerability.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_ExploitCatalogVulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ security_catalogType: Optional[str] = None,
+ security_exploited: Optional[bool] = None,
+ security_locator: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ security_catalogType: Optional[str]
+ security_exploited: Optional[bool]
+ security_locator: Optional[str]
+
+
+class security_SsvcVulnAssessmentRelationship(security_VulnAssessmentRelationship):
+ """
+ Provides an SSVC assessment for a vulnerability.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_SsvcVulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ security_decisionType: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ security_decisionType: Optional[str]
+
+
+class security_VexVulnAssessmentRelationship(security_VulnAssessmentRelationship):
+ """
+ Abstract ancestor class for all VEX relationships
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VexVulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ *,
+ security_statusNotes: Optional[str] = None,
+ security_vexVersion: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ security_statusNotes: Optional[str]
+ security_vexVersion: Optional[str]
+
+
+class security_Vulnerability(Artifact):
+ """
+ Specifies a vulnerability and its associated information.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/Vulnerability"
+ COMPACT_TYPE = "security_Vulnerability"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ security_modifiedTime: Optional[datetime] = None,
+ security_publishedTime: Optional[datetime] = None,
+ security_withdrawnTime: Optional[datetime] = None,
+ **kwargs: Any
+ ) -> None: ...
+ security_modifiedTime: Optional[datetime]
+ security_publishedTime: Optional[datetime]
+ security_withdrawnTime: Optional[datetime]
+
+
+class software_SoftwareArtifact(Artifact):
+ """
+ A distinct article or unit related to Software.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwareArtifact"
+ COMPACT_TYPE = "software_SoftwareArtifact"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+ IS_ABSTRACT: bool
+
+ def __init__(
+ self,
+ *,
+ software_additionalPurpose: Optional[Iterable[str]] = None,
+ software_attributionText: Optional[Iterable[str]] = None,
+ software_contentIdentifier: Optional[Iterable[Union[str, 'software_ContentIdentifier']]] = None,
+ software_copyrightText: Optional[str] = None,
+ software_primaryPurpose: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ software_additionalPurpose: ListProxy[str]
+ software_attributionText: ListProxy[str]
+ software_contentIdentifier: ListProxy[Union[str, 'software_ContentIdentifier']]
+ software_copyrightText: Optional[str]
+ software_primaryPurpose: Optional[str]
+
+
+class Bom(Bundle):
+ """
+ A container for a grouping of SPDX-3.0 content characterizing details
+ (provenence, composition, licensing, etc.) about a product.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Core/Bom"
+ COMPACT_TYPE = "Bom"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class expandedlicensing_CustomLicense(expandedlicensing_License):
+ """
+ A license that is not listed on the SPDX License List.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/CustomLicense"
+ COMPACT_TYPE = "expandedlicensing_CustomLicense"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class security_VexAffectedVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
+ """
+ Connects a vulnerability and an element designating the element as a product
+ affected by the vulnerability.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexAffectedVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VexAffectedVulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ security_actionStatement: Optional[str] = None,
+ security_actionStatementTime: Optional[datetime] = None,
+ **kwargs: Any
+ ) -> None: ...
+ security_actionStatement: Optional[str]
+ security_actionStatementTime: Optional[datetime]
+
+
+class security_VexFixedVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
+ """
+ Links a vulnerability and elements representing products (in the VEX sense) where
+ a fix has been applied and are no longer affected.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexFixedVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VexFixedVulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class security_VexNotAffectedVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
+ """
+ Links a vulnerability and one or more elements designating the latter as products
+ not affected by the vulnerability.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexNotAffectedVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VexNotAffectedVulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ security_impactStatement: Optional[str] = None,
+ security_impactStatementTime: Optional[datetime] = None,
+ security_justificationType: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ security_impactStatement: Optional[str]
+ security_impactStatementTime: Optional[datetime]
+ security_justificationType: Optional[str]
+
+
+class security_VexUnderInvestigationVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
+ """
+ Designates elements as products where the impact of a vulnerability is being
+ investigated.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Security/VexUnderInvestigationVulnAssessmentRelationship"
+ COMPACT_TYPE = "security_VexUnderInvestigationVulnAssessmentRelationship"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None: ...
+
+
+class software_File(software_SoftwareArtifact):
+ """
+ Refers to any object that stores content on a computer.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/File"
+ COMPACT_TYPE = "software_File"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ contentType: Optional[str] = None,
+ software_fileKind: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ contentType: Optional[str]
+ software_fileKind: Optional[str]
+
+
+class software_Package(software_SoftwareArtifact):
+ """
+ Refers to any unit of content that can be associated with a distribution of
+ software.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/Package"
+ COMPACT_TYPE = "software_Package"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ software_downloadLocation: Optional[str] = None,
+ software_homePage: Optional[str] = None,
+ software_packageUrl: Optional[str] = None,
+ software_packageVersion: Optional[str] = None,
+ software_sourceInfo: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ software_downloadLocation: Optional[str]
+ software_homePage: Optional[str]
+ software_packageUrl: Optional[str]
+ software_packageVersion: Optional[str]
+ software_sourceInfo: Optional[str]
+
+
+class software_Sbom(Bom):
+ """
+ A collection of SPDX Elements describing a single package.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/Sbom"
+ COMPACT_TYPE = "software_Sbom"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ software_sbomType: Optional[Iterable[str]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ software_sbomType: ListProxy[str]
+
+
+class software_Snippet(software_SoftwareArtifact):
+ """
+ Describes a certain part of a file.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Software/Snippet"
+ COMPACT_TYPE = "software_Snippet"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ software_byteRange: Optional[Union[str, 'PositiveIntegerRange']] = None,
+ software_lineRange: Optional[Union[str, 'PositiveIntegerRange']] = None,
+ software_snippetFromFile: Optional[Union[str, 'software_File']] = None,
+ **kwargs: Any
+ ) -> None: ...
+ software_byteRange: Optional[Union[str, 'PositiveIntegerRange']]
+ software_lineRange: Optional[Union[str, 'PositiveIntegerRange']]
+ software_snippetFromFile: Optional[Union[str, 'software_File']]
+
+
+class ai_AIPackage(software_Package):
+ """
+ Specifies an AI package and its associated information.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/AI/AIPackage"
+ COMPACT_TYPE = "ai_AIPackage"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ ai_autonomyType: Optional[str] = None,
+ ai_domain: Optional[Iterable[str]] = None,
+ ai_energyConsumption: Optional[Union[str, 'ai_EnergyConsumption']] = None,
+ ai_hyperparameter: Optional[Iterable[Union[str, 'DictionaryEntry']]] = None,
+ ai_informationAboutApplication: Optional[str] = None,
+ ai_informationAboutTraining: Optional[str] = None,
+ ai_limitation: Optional[str] = None,
+ ai_metric: Optional[Iterable[Union[str, 'DictionaryEntry']]] = None,
+ ai_metricDecisionThreshold: Optional[Iterable[Union[str, 'DictionaryEntry']]] = None,
+ ai_modelDataPreprocessing: Optional[Iterable[str]] = None,
+ ai_modelExplainability: Optional[Iterable[str]] = None,
+ ai_safetyRiskAssessment: Optional[str] = None,
+ ai_standardCompliance: Optional[Iterable[str]] = None,
+ ai_typeOfModel: Optional[Iterable[str]] = None,
+ ai_useSensitivePersonalInformation: Optional[str] = None,
+ **kwargs: Any
+ ) -> None: ...
+ ai_autonomyType: Optional[str]
+ ai_domain: ListProxy[str]
+ ai_energyConsumption: Optional[Union[str, 'ai_EnergyConsumption']]
+ ai_hyperparameter: ListProxy[Union[str, 'DictionaryEntry']]
+ ai_informationAboutApplication: Optional[str]
+ ai_informationAboutTraining: Optional[str]
+ ai_limitation: Optional[str]
+ ai_metric: ListProxy[Union[str, 'DictionaryEntry']]
+ ai_metricDecisionThreshold: ListProxy[Union[str, 'DictionaryEntry']]
+ ai_modelDataPreprocessing: ListProxy[str]
+ ai_modelExplainability: ListProxy[str]
+ ai_safetyRiskAssessment: Optional[str]
+ ai_standardCompliance: ListProxy[str]
+ ai_typeOfModel: ListProxy[str]
+ ai_useSensitivePersonalInformation: Optional[str]
+
+
+class dataset_DatasetPackage(software_Package):
+ """
+ Specifies a data package and its associated information.
+ """
+
+ TYPE = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetPackage"
+ COMPACT_TYPE = "dataset_DatasetPackage"
+ NODE_KIND: NodeKind
+ ID_ALIAS: Optional[str]
+
+ def __init__(
+ self,
+ *,
+ dataset_anonymizationMethodUsed: Optional[Iterable[str]] = None,
+ dataset_confidentialityLevel: Optional[str] = None,
+ dataset_dataCollectionProcess: Optional[str] = None,
+ dataset_dataPreprocessing: Optional[Iterable[str]] = None,
+ dataset_datasetAvailability: Optional[str] = None,
+ dataset_datasetNoise: Optional[str] = None,
+ dataset_datasetSize: Optional[int] = None,
+ dataset_datasetType: Optional[Iterable[str]] = None,
+ dataset_datasetUpdateMechanism: Optional[str] = None,
+ dataset_hasSensitivePersonalInformation: Optional[str] = None,
+ dataset_intendedUse: Optional[str] = None,
+ dataset_knownBias: Optional[Iterable[str]] = None,
+ dataset_sensor: Optional[Iterable[Union[str, 'DictionaryEntry']]] = None,
+ **kwargs: Any
+ ) -> None: ...
+ dataset_anonymizationMethodUsed: ListProxy[str]
+ dataset_confidentialityLevel: Optional[str]
+ dataset_dataCollectionProcess: Optional[str]
+ dataset_dataPreprocessing: ListProxy[str]
+ dataset_datasetAvailability: Optional[str]
+ dataset_datasetNoise: Optional[str]
+ dataset_datasetSize: Optional[int]
+ dataset_datasetType: ListProxy[str]
+ dataset_datasetUpdateMechanism: Optional[str]
+ dataset_hasSensitivePersonalInformation: Optional[str]
+ dataset_intendedUse: Optional[str]
+ dataset_knownBias: ListProxy[str]
+ dataset_sensor: ListProxy[Union[str, 'DictionaryEntry']]
+
+
+"""Format Guard"""
+# fmt: on