redefine algo names as hidalgo1 for ereuse24

This commit is contained in:
Cayo Puigdefabregas 2025-02-06 10:29:48 +01:00 committed by pedro
parent 7145e721f1
commit c540bb7f7f
6 changed files with 20 additions and 17 deletions

View file

@ -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()

View file

@ -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

View file

@ -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, '')

View file

@ -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):

View file

@ -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)

View file

@ -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
}