Skip to content

Commit

Permalink
Autocreate the identity ID from the software-name if required
Browse files Browse the repository at this point in the history
This is really useful for software like 'gcc' that has no defined UUID or GUID.
  • Loading branch information
hughsie committed Sep 18, 2023
1 parent eff9cb7 commit dac50fd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion uswid/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# pylint: disable=protected-access,too-many-boolean-expressions

from typing import Dict, Optional, List
import uuid

from .errors import NotSupportedError
from .enums import uSwidVersionScheme
Expand Down Expand Up @@ -43,7 +44,7 @@ def __init__(
self._auto_increment_tag_version = False
self.tag_id: Optional[str] = tag_id
self.tag_version: int = tag_version
self.software_name: Optional[str] = software_name
self._software_name: Optional[str] = software_name
self.software_version: Optional[str] = software_version
self.version_scheme: Optional[uSwidVersionScheme] = None
self.summary: Optional[str] = None
Expand All @@ -57,6 +58,16 @@ def __init__(
self._entities: Dict[str, uSwidEntity] = {}
self._links: Dict[str, uSwidLink] = {}

@property
def software_name(self) -> Optional[str]:
return self._software_name

@software_name.setter
def software_name(self, software_name: Optional[str]) -> None:
if not self.tag_id and software_name:
self.tag_id = str(uuid.uuid5(uuid.NAMESPACE_DNS, identity.software_name))
self._software_name = software_name

def merge(self, identity_new: "uSwidIdentity") -> None:
"""adds new things from the new identity into the current one"""
if identity_new.tag_version:
Expand Down

0 comments on commit dac50fd

Please sign in to comment.