Skip to content

Commit

Permalink
Calculate id of ArtefactMetadata from key
Browse files Browse the repository at this point in the history
  • Loading branch information
8R0WNI3 committed Nov 29, 2024
1 parent 8495756 commit ceab577
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dso/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dataclasses
import datetime
import enum
import hashlib
import typing

import dacite
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit ceab577

Please sign in to comment.