cyclonedx.model
Submodules
Package Contents
Classes
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Allows comparison of tuples, allowing for None values. |
|
This is our internal representation of the dataFlowType simple type within the CycloneDX standard. |
|
This is our internal representation of the dataClassificationType complex type within the CycloneDX standard. |
|
This is our internal representation of the encoding simple type within the CycloneDX standard. |
|
This is our internal representation of the attachedTextType complex type within the CycloneDX standard. |
|
This is our internal representation of the hashAlg simple type within the CycloneDX standard. |
|
This is our internal representation of the hashType complex type within the CycloneDX standard. |
|
Enum object that defines the permissible 'types' for an External Reference according to the CycloneDX schema. |
|
Helper class that allows us to perform validation on data strings that are defined as xs:anyURI |
|
This is our internal representation of an ExternalReference complex type that can be used in multiple places within |
|
This is our internal representation of licenseType complex type that can be used in multiple places within |
|
This is our internal representation of licenseChoiceType complex type that can be used in multiple places within |
|
This is our internal representation of propertyType complex type that can be used in multiple places within |
|
This is our internal representation of the Note.text complex type that can be used in multiple places within |
|
This is our internal representation of the Note complex type that can be used in multiple places within |
|
This is our internal representation of the organizationalContact complex type that can be used in multiple places |
|
This is our internal representation of the organizationalEntity complex type that can be used in multiple places |
|
This is our internal representation of the toolType complex type within the CycloneDX standard. |
|
This is our internal representation of the identifiableActionType complex type. |
|
This is our internal representation of the copyrightsType complex type. |
Functions
|
|
|
Generate a SHA1 hash of the provided file. |
Attributes
- cyclonedx.model.__ThisToolVersion = '4.2.0'
- exception cyclonedx.model.InvalidLocaleTypeException[source]
Bases:
CycloneDxModelExceptionRaised 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:
CycloneDxModelExceptionRaised when a str is provided that needs to be a valid URI, but isn’t.
- exception cyclonedx.model.MutuallyExclusivePropertiesException[source]
Bases:
CycloneDxModelExceptionRaised when mutually exclusive properties are provided.
- exception cyclonedx.model.NoPropertiesProvidedException[source]
Bases:
CycloneDxModelExceptionRaised 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:
CycloneDxModelExceptionException raised when we are unable to determine the type of hash from a composite hash string.
- class cyclonedx.model.SchemaVersion1Dot3[source]
Bases:
BaseSchemaVersionHelper 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:
BaseSchemaVersionHelper class that provides a standard way to create an ABC using inheritance.
- property schema_version_enum: cyclonedx.schema.SchemaVersion
- 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
- class cyclonedx.model.ComparableTuple[source]
Bases:
Tuple[Optional[_T],Ellipsis]Allows comparison of tuples, allowing for None values.
- class cyclonedx.model.DataFlow[source]
Bases:
str,enum.EnumThis is our internal representation of the dataFlowType simple type within the CycloneDX standard.
Note
See the CycloneDX Schema: https://cyclonedx.org/docs/1.4/xml/#type_dataFlowType
- 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
- class cyclonedx.model.Encoding[source]
Bases:
str,enum.EnumThis 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
- 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
- class cyclonedx.model.HashAlgorithm[source]
Bases:
str,enum.EnumThis 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
- 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
- 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.
- class cyclonedx.model.ExternalReferenceType[source]
Bases:
str,enum.EnumEnum 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
- class cyclonedx.model.XsUri(uri: str)[source]
Bases:
serializable.helpers.BaseHelperHelper 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
- 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 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
- 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 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
- 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 expression: str | None[source]
A valid SPDX license expression (not enforced).
Refer to https://spdx.org/specifications for syntax requirements.
- Returns:
str or None
- 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.
- 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_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
- 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
NoteTextwithAttachedText?
- 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
- 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 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
- 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 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
- 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.
Note
See the CycloneDX specification: https://cyclonedx.org/docs/1.4/xml/#type_identifiableActionType
- 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
- 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