diff --git a/api/views.py b/api/views.py index 116f3c4..188bcd7 100644 --- a/api/views.py +++ b/api/views.py @@ -118,7 +118,7 @@ class NewSnapshotView(ApiMixing): prop = SystemProperty.objects.filter( uuid=ev_uuid, # TODO this is hardcoded, it should select the user preferred algorithm - key="hidalgo1", + key="ereuse24", owner=self.tk.owner.institution ).first() diff --git a/device/models.py b/device/models.py index 8ade593..a385895 100644 --- a/device/models.py +++ b/device/models.py @@ -149,7 +149,7 @@ class Device: ORDER BY CASE WHEN t1.key = 'CUSTOM_ID' THEN 1 - WHEN t1.key = 'hidalgo1' THEN 2 + WHEN t1.key = 'ereuse24' THEN 2 ELSE 3 END, t1.created DESC @@ -195,7 +195,7 @@ class Device: ORDER BY CASE WHEN t1.key = 'CUSTOM_ID' THEN 1 - WHEN t1.key = 'hidalgo1' THEN 2 + WHEN t1.key = 'ereuse24' THEN 2 ELSE 3 END, t1.created DESC @@ -230,7 +230,7 @@ class Device: ORDER BY CASE WHEN t1.key = 'CUSTOM_ID' THEN 1 - WHEN t1.key = 'hidalgo1' THEN 2 + WHEN t1.key = 'ereuse24' THEN 2 ELSE 3 END, t1.created DESC diff --git a/evidence/mixin_parse.py b/evidence/mixin_parse.py index e0b4209..58351fb 100644 --- a/evidence/mixin_parse.py +++ b/evidence/mixin_parse.py @@ -31,11 +31,13 @@ class BuildMix: return hid def generate_chids(self): - self.algorithms = { - 'hidalgo1': self.get_hid('hidalgo1'), - } - if settings.DPP: - self.algorithms["legacy_dpp"] = self.get_hid("legacy_dpp") + self.algorithms = {} + for k in ALGOS.keys(): + if not settings.DPP and k == 'ereuse22': + continue + + self.algorithms[k] = self.get_hid(k) + def get_doc(self): self._get_components() @@ -43,7 +45,7 @@ class BuildMix: c.pop("actions", None) components = sorted(self.components, key=lambda x: x.get("type")) - device = self.algorithms.get('legacy_dpp') + device = self.algorithms.get('ereuse22') doc = [("computer", device)] @@ -51,7 +53,7 @@ class BuildMix: doc.append((c.get("type"), self.get_id_hw_dpp(c))) def get_id_hw_dpp(self, d): - algorithm = ALGOS.get("legacy_dpp", []) + algorithm = ALGOS.get("ereuse22", []) hid = "" for f in algorithm: hid += d.get(f, '') diff --git a/evidence/models.py b/evidence/models.py index 5753a50..a056736 100644 --- a/evidence/models.py +++ b/evidence/models.py @@ -209,7 +209,7 @@ class Evidence: def get_all(cls, user): return SystemProperty.objects.filter( owner=user.institution, - key="hidalgo1", + key="ereuse24", ).order_by("-created").values_list("uuid", "created").distinct() def set_components(self): diff --git a/evidence/parse.py b/evidence/parse.py index 7699c67..d73cff7 100644 --- a/evidence/parse.py +++ b/evidence/parse.py @@ -88,7 +88,7 @@ class Build: return hashlib.sha3_256(doc.encode()).hexdigest() def register_device_dlt(self): - legacy_dpp = self.build.algorithms.get('legacy_dpp') + legacy_dpp = self.build.algorithms.get('ereuse22') chid = self.sign(legacy_dpp) phid = self.sign(json.dumps(self.build.get_doc())) register_device_dlt(chid, phid, self.uuid, self.user) diff --git a/utils/constants.py b/utils/constants.py index 3104f59..64f9e1e 100644 --- a/utils/constants.py +++ b/utils/constants.py @@ -9,7 +9,7 @@ STR_EXTEND_SIZE = 256 # Algorithms for build hids -HID_ALGO1 = [ +EREUSE24 = [ "manufacturer", "model", "chassis", @@ -17,7 +17,8 @@ HID_ALGO1 = [ "sku" ] -LEGACY_DPP = [ +# EREUSE22 is used for build the chid of DPP +EREUSE22 = [ "manufacturer", "model", "chassis", @@ -28,8 +29,8 @@ LEGACY_DPP = [ ] ALGOS = { - "hidalgo1": HID_ALGO1, - "legacy_dpp": LEGACY_DPP + "ereuse24": EREUSE24, + "ereuse22": EREUSE22 }