cyclonedx.model

Submodules

Package Contents

Classes

SchemaVersion1Dot3

Helper class that provides a standard way to create an ABC using

SchemaVersion1Dot4

Helper class that provides a standard way to create an ABC using

ComparableTuple

Allows comparison of tuples, allowing for None values.

DataFlow

This is our internal representation of the dataFlowType simple type within the CycloneDX standard.

DataClassification

This is our internal representation of the dataClassificationType complex type within the CycloneDX standard.

Encoding

This is our internal representation of the encoding simple type within the CycloneDX standard.

AttachedText

This is our internal representation of the attachedTextType complex type within the CycloneDX standard.

HashAlgorithm

This is our internal representation of the hashAlg simple type within the CycloneDX standard.

HashType

This is our internal representation of the hashType complex type within the CycloneDX standard.

ExternalReferenceType

Enum object that defines the permissible 'types' for an External Reference according to the CycloneDX schema.

XsUri

Helper class that allows us to perform validation on data strings that are defined as xs:anyURI

ExternalReference

This is our internal representation of an ExternalReference complex type that can be used in multiple places within

License

This is our internal representation of licenseType complex type that can be used in multiple places within

LicenseChoice

This is our internal representation of licenseChoiceType complex type that can be used in multiple places within

Property

This is our internal representation of propertyType complex type that can be used in multiple places within

NoteText

This is our internal representation of the Note.text complex type that can be used in multiple places within

Note

This is our internal representation of the Note complex type that can be used in multiple places within

OrganizationalContact

This is our internal representation of the organizationalContact complex type that can be used in multiple places

OrganizationalEntity

This is our internal representation of the organizationalEntity complex type that can be used in multiple places

Tool

This is our internal representation of the toolType complex type within the CycloneDX standard.

IdentifiableAction

This is our internal representation of the identifiableActionType complex type.

Copyright

This is our internal representation of the copyrightsType complex type.

Functions

get_now_utc(→ datetime.datetime)

sha1sum(→ str)

Generate a SHA1 hash of the provided file.

Attributes

__ThisToolVersion

_T

ThisTool

cyclonedx.model.__ThisToolVersion = '4.2.0'
exception cyclonedx.model.InvalidLocaleTypeException[source]

Bases: CycloneDxModelException

Raised when the supplied locale does not conform to ISO-639 specification.

Good examples:
  • en

  • en-US

  • en-GB

  • fr

  • fr-CA

The language code MUST be lowercase. If the country code is specified, the country code MUST be upper case. The language code and country code MUST be separated by a minus sign.

exception cyclonedx.model.InvalidUriException[source]

Bases: CycloneDxModelException

Raised when a str is provided that needs to be a valid URI, but isn’t.

exception cyclonedx.model.MutuallyExclusivePropertiesException[source]

Bases: CycloneDxModelException

Raised when mutually exclusive properties are provided.

exception cyclonedx.model.NoPropertiesProvidedException[source]

Bases: CycloneDxModelException

Raised when attempting to construct a model class and providing NO values (where all properites are defined as Optional, but at least one is required).

exception cyclonedx.model.UnknownHashTypeException[source]

Bases: CycloneDxModelException

Exception raised when we are unable to determine the type of hash from a composite hash string.

class cyclonedx.model.SchemaVersion1Dot3[source]

Bases: BaseSchemaVersion

Helper class that provides a standard way to create an ABC using inheritance.

property schema_version_enum: cyclonedx.schema.SchemaVersion
class cyclonedx.model.SchemaVersion1Dot4[source]

Bases: BaseSchemaVersion

Helper class that provides a standard way to create an ABC using inheritance.

property schema_version_enum: cyclonedx.schema.SchemaVersion
cyclonedx.model.get_now_utc() datetime.datetime[source]
cyclonedx.model.sha1sum(filename: str) str[source]

Generate a SHA1 hash of the provided file.

Args:
filename:

Absolute path to file to hash as str

Returns:

SHA-1 hash

cyclonedx.model._T[source]
class cyclonedx.model.ComparableTuple[source]

Bases: Tuple[Optional[_T], Ellipsis]

Allows comparison of tuples, allowing for None values.

__lt__(other: Any) bool[source]

Return self<value.

__gt__(other: Any) bool[source]

Return self>value.

class cyclonedx.model.DataFlow[source]

Bases: str, enum.Enum

This is our internal representation of the dataFlowType simple type within the CycloneDX standard.

INBOUND = 'inbound'[source]
OUTBOUND = 'outbound'[source]
BI_DIRECTIONAL = 'bi-directional'[source]
UNKNOWN = 'unknown'[source]
class cyclonedx.model.DataClassification(*, flow: DataFlow, classification: str)[source]

This is our internal representation of the dataClassificationType complex type within the CycloneDX standard.

Note

See the CycloneDX Schema for dataClassificationType: https://cyclonedx.org/docs/1.4/xml/#type_dataClassificationType

property flow: DataFlow[source]

Specifies the flow direction of the data.

Valid values are: inbound, outbound, bi-directional, and unknown.

Direction is relative to the service.

  • Inbound flow states that data enters the service

  • Outbound flow states that data leaves the service

  • Bi-directional states that data flows both ways

  • Unknown states that the direction is not known

Returns:

DataFlow

property classification: str[source]

Data classification tags data according to its type, sensitivity, and value if altered, stolen, or destroyed.

Returns:

str

__eq__(other: object) bool[source]

Return self==value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.Encoding[source]

Bases: str, enum.Enum

This is our internal representation of the encoding simple type within the CycloneDX standard.

Note

See the CycloneDX Schema: https://cyclonedx.org/docs/1.4/#type_encoding

BASE_64 = 'base64'[source]
class cyclonedx.model.AttachedText(*, content: str, content_type: str = DEFAULT_CONTENT_TYPE, encoding: Encoding | None = None)[source]

This is our internal representation of the attachedTextType complex type within the CycloneDX standard.

Note

See the CycloneDX Schema for hashType: https://cyclonedx.org/docs/1.3/#type_attachedTextType

property content_type: str[source]

Specifies the content type of the text. Defaults to text/plain if not specified.

Returns:

str

property encoding: Encoding | None[source]

Specifies the optional encoding the text is represented in.

Returns:

Encoding if set else None

property content: str[source]

The attachment data.

Proactive controls such as input validation and sanitization should be employed to prevent misuse of attachment text.

Returns:

str

DEFAULT_CONTENT_TYPE = 'text/plain'[source]
__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.HashAlgorithm[source]

Bases: str, enum.Enum

This is our internal representation of the hashAlg simple type within the CycloneDX standard.

Note

See the CycloneDX Schema: https://cyclonedx.org/docs/1.3/#type_hashAlg

BLAKE2B_256 = 'BLAKE2b-256'[source]
BLAKE2B_384 = 'BLAKE2b-384'[source]
BLAKE2B_512 = 'BLAKE2b-512'[source]
BLAKE3 = 'BLAKE3'[source]
MD5 = 'MD5'[source]
SHA_1 = 'SHA-1'[source]
SHA_256 = 'SHA-256'[source]
SHA_384 = 'SHA-384'[source]
SHA_512 = 'SHA-512'[source]
SHA3_256 = 'SHA3-256'[source]
SHA3_384 = 'SHA3-384'[source]
SHA3_512 = 'SHA3-512'[source]
class cyclonedx.model.HashType(*, alg: HashAlgorithm, content: str)[source]

This is our internal representation of the hashType complex type within the CycloneDX standard.

Note

See the CycloneDX Schema for hashType: https://cyclonedx.org/docs/1.3/#type_hashType

property alg: HashAlgorithm[source]

Specifies the algorithm used to create the hash.

Returns:

HashAlgorithm

property content: str[source]

Hash value content.

Returns:

str

static from_composite_str(composite_hash: str) HashType[source]

Attempts to convert a string which includes both the Hash Algorithm and Hash Value and represent using our internal model classes.

Args:
composite_hash:

Composite Hash string of the format HASH_ALGORITHM:HASH_VALUE. Example: sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b.

Raises:

UnknownHashTypeException if the type of hash cannot be determined.

Returns:

An instance of HashType.

__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.ExternalReferenceType[source]

Bases: str, enum.Enum

Enum object that defines the permissible ‘types’ for an External Reference according to the CycloneDX schema.

Note

See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.3/#type_externalReferenceType

ADVISORIES = 'advisories'[source]
BOM = 'bom'[source]
BUILD_META = 'build-meta'[source]
BUILD_SYSTEM = 'build-system'[source]
CHAT = 'chat'[source]
DISTRIBUTION = 'distribution'[source]
DOCUMENTATION = 'documentation'[source]
ISSUE_TRACKER = 'issue-tracker'[source]
LICENSE = 'license'[source]
MAILING_LIST = 'mailing-list'[source]
OTHER = 'other'[source]
RELEASE_NOTES = 'release-notes'[source]
SOCIAL = 'social'[source]
SCM = 'vcs'[source]
SUPPORT = 'support'[source]
VCS = 'vcs'[source]
WEBSITE = 'website'[source]
class cyclonedx.model.XsUri(uri: str)[source]

Bases: serializable.helpers.BaseHelper

Helper class that allows us to perform validation on data strings that are defined as xs:anyURI in CycloneDX schema.

Developers can just use this via str(XsUri(‘https://www.google.com’)).

Note

See XSD definition for xsd:anyURI: http://www.datypic.com/sc/xsd/t-xsd_anyURI.html

property uri: str[source]
_INVALID_URI_REGEX[source]
classmethod serialize(o: object) str[source]
classmethod deserialize(o: object) XsUri[source]
__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

__str__() str[source]

Return str(self).

class cyclonedx.model.ExternalReference(*, type: ExternalReferenceType, url: XsUri, comment: str | None = None, hashes: Iterable[HashType] | None = None)[source]

This is our internal representation of an ExternalReference complex type that can be used in multiple places within a CycloneDX BOM document.

Note

See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.3/#type_externalReference

property url: XsUri[source]

The URL to the external reference.

Returns:

XsUri

property comment: str | None[source]

An optional comment describing the external reference.

Returns:

str if set else None

property type: ExternalReferenceType[source]

Specifies the type of external reference.

There are built-in types to describe common references. If a type does not exist for the reference being referred to, use the “other” type.

Returns:

ExternalReferenceType

property hashes: SortedSet[HashType][source]

The hashes of the external reference (if applicable).

Returns:

Set of HashType

__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.License(*, id: str | None = None, name: str | None = None, text: AttachedText | None = None, url: XsUri | None = None)[source]

This is our internal representation of licenseType complex type that can be used in multiple places within a CycloneDX BOM document.

Note

See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_licenseType

property id: str | None[source]

A valid SPDX license ID

Returns:

str or None

property name: str | None[source]

If SPDX does not define the license used, this field may be used to provide the license name.

Returns:

str or None

property text: AttachedText | None[source]

Specifies the optional full text of the attachment

Returns:

AttachedText else None

property url: XsUri | None[source]

The URL to the attachment file. If the attachment is a license or BOM, an externalReference should also be specified for completeness.

Returns:

XsUri or None

__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.LicenseChoice(*, license: License | None = None, expression: str | None = None)[source]

This is our internal representation of licenseChoiceType complex type that can be used in multiple places within a CycloneDX BOM document.

Note

See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_licenseChoiceType

property license: License | None[source]

License definition

Returns:

License or None

property expression: str | None[source]

A valid SPDX license expression (not enforced).

Refer to https://spdx.org/specifications for syntax requirements.

Returns:

str or None

__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.Property(*, name: str, value: str)[source]

This is our internal representation of propertyType complex type that can be used in multiple places within a CycloneDX BOM document.

Note

See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_propertyType

Specifies an individual property with a name and value.

property name: str[source]

The name of the property.

Duplicate names are allowed, each potentially having a different value.

Returns:

str

property value: str[source]

Value of this Property.

Returns:

str

__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.NoteText(*, content: str, content_type: str | None = None, encoding: Encoding | None = None)[source]

This is our internal representation of the Note.text complex type that can be used in multiple places within a CycloneDX BOM document.

Note

See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_releaseNotesType

property content: str[source]

Get the text content of this Note.

Returns:

str note content

property content_type: str | None[source]

Get the content-type of this Note.

Defaults to ‘text/plain’ if one was not explicitly specified.

Returns:

str content-type

property encoding: Encoding | None[source]

Get the encoding method used for the note’s content.

Returns:

Encoding if set else None

DEFAULT_CONTENT_TYPE: str = 'text/plain'[source]
__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.Note(*, text: NoteText, locale: str | None = None)[source]

This is our internal representation of the Note complex type that can be used in multiple places within a CycloneDX BOM document.

Note

See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_releaseNotesType

@todo: Replace NoteText with AttachedText?

property text: NoteText[source]

Specifies the full content of the release note.

Returns:

NoteText

property locale: str | None[source]

Get the ISO locale of this Note.

The ISO-639 (or higher) language code and optional ISO-3166 (or higher) country code.

Examples include: “en”, “en-US”, “fr” and “fr-CA”.

Returns:

str locale if set else None

_LOCALE_TYPE_REGEX[source]
__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.OrganizationalContact(*, name: str | None = None, phone: str | None = None, email: str | None = None)[source]

This is our internal representation of the organizationalContact complex type that can be used in multiple places within a CycloneDX BOM document.

Note

See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_organizationalContact

property name: str | None[source]

Get the name of the contact.

Returns:

str if set else None

property email: str | None[source]

Get the email of the contact.

Returns:

str if set else None

property phone: str | None[source]

Get the phone of the contact.

Returns:

str if set else None

__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.OrganizationalEntity(*, name: str | None = None, urls: Iterable[XsUri] | None = None, contacts: Iterable[OrganizationalContact] | None = None)[source]

This is our internal representation of the organizationalEntity complex type that can be used in multiple places within a CycloneDX BOM document.

Note

See the CycloneDX Schema definition: https://cyclonedx.org/docs/1.4/xml/#type_organizationalEntity

property name: str | None[source]

Get the name of the organization.

Returns:

str if set else None

property urls: SortedSet[XsUri][source]

Get a list of URLs of the organization. Multiple URLs are allowed.

Returns:

Set of XsUri

property contacts: SortedSet[OrganizationalContact][source]

Get a list of contact person at the organization. Multiple contacts are allowed.

Returns:

Set of OrganizationalContact

__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.Tool(*, vendor: str | None = None, name: str | None = None, version: str | None = None, hashes: Iterable[HashType] | None = None, external_references: Iterable[ExternalReference] | None = None)[source]

This is our internal representation of the toolType complex type within the CycloneDX standard.

Tool(s) are the things used in the creation of the BOM.

Note

See the CycloneDX Schema for toolType: https://cyclonedx.org/docs/1.3/#type_toolType

property vendor: str | None[source]

The name of the vendor who created the tool.

Returns:

str if set else None

property name: str | None[source]

The name of the tool.

Returns:

str if set else None

property version: str | None[source]

The version of the tool.

Returns:

str if set else None

property hashes: SortedSet[HashType][source]

The hashes of the tool (if applicable).

Returns:

Set of HashType

property external_references: SortedSet[ExternalReference][source]

External References provide a way to document systems, sites, and information that may be relevant but which are not included with the BOM.

Returns:

Set of ExternalReference

__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.IdentifiableAction(*, timestamp: datetime.datetime | None = None, name: str | None = None, email: str | None = None)[source]

This is our internal representation of the identifiableActionType complex type.

property timestamp: datetime.datetime | None[source]

The timestamp in which the action occurred.

Returns:

datetime if set else None

property name: str | None[source]

The name of the individual who performed the action.

Returns:

str if set else None

property email: str | None[source]

The email address of the individual who performed the action.

Returns:

str if set else None

__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

class cyclonedx.model.Copyright(*, text: str)[source]

This is our internal representation of the copyrightsType complex type.

Note

See the CycloneDX specification: https://cyclonedx.org/docs/1.4/xml/#type_copyrightsType

property text: str[source]

Copyright statement.

Returns:

str if set else None

__eq__(other: object) bool[source]

Return self==value.

__lt__(other: Any) bool[source]

Return self<value.

__hash__() int[source]

Return hash(self).

__repr__() str[source]

Return repr(self).

cyclonedx.model.ThisTool[source]