From ceab577adf632a941ae88b819b4a169c7f99d521 Mon Sep 17 00:00:00 2001 From: "Jonas Brand (8R0WNI3)" Date: Thu, 28 Nov 2024 10:53:59 +0100 Subject: [PATCH] Calculate `id` of `ArtefactMetadata` from `key` --- dso/model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dso/model.py b/dso/model.py index 0a7930f8e..3923187e9 100644 --- a/dso/model.py +++ b/dso/model.py @@ -1,6 +1,7 @@ import dataclasses import datetime import enum +import hashlib import typing import dacite @@ -522,7 +523,6 @@ class ArtefactMetadata: | ComplianceSnapshot | dict # fallback, there should be a type ) - id: int | None = None discovery_date: datetime.date | None = None # required for finding specific SLA tracking @staticmethod @@ -548,6 +548,10 @@ def key(self) -> str: return _as_key(self.artefact.key, self.meta.datasource, self.meta.type, data_key) + @property + def id(self) -> str: + return hashlib.sha1(self.key.encode('utf-8'), usedforsecurity=False).hexdigest() + def artefact_scan_info( artefact_node: cnudie.iter.ArtefactNode,