redefine algo names as hidalgo1 for ereuse24
This commit is contained in:
parent
7145e721f1
commit
c540bb7f7f
|
@ -118,7 +118,7 @@ class NewSnapshotView(ApiMixing):
|
||||||
prop = SystemProperty.objects.filter(
|
prop = SystemProperty.objects.filter(
|
||||||
uuid=ev_uuid,
|
uuid=ev_uuid,
|
||||||
# TODO this is hardcoded, it should select the user preferred algorithm
|
# TODO this is hardcoded, it should select the user preferred algorithm
|
||||||
key="hidalgo1",
|
key="ereuse24",
|
||||||
owner=self.tk.owner.institution
|
owner=self.tk.owner.institution
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ class Device:
|
||||||
ORDER BY
|
ORDER BY
|
||||||
CASE
|
CASE
|
||||||
WHEN t1.key = 'CUSTOM_ID' THEN 1
|
WHEN t1.key = 'CUSTOM_ID' THEN 1
|
||||||
WHEN t1.key = 'hidalgo1' THEN 2
|
WHEN t1.key = 'ereuse24' THEN 2
|
||||||
ELSE 3
|
ELSE 3
|
||||||
END,
|
END,
|
||||||
t1.created DESC
|
t1.created DESC
|
||||||
|
@ -195,7 +195,7 @@ class Device:
|
||||||
ORDER BY
|
ORDER BY
|
||||||
CASE
|
CASE
|
||||||
WHEN t1.key = 'CUSTOM_ID' THEN 1
|
WHEN t1.key = 'CUSTOM_ID' THEN 1
|
||||||
WHEN t1.key = 'hidalgo1' THEN 2
|
WHEN t1.key = 'ereuse24' THEN 2
|
||||||
ELSE 3
|
ELSE 3
|
||||||
END,
|
END,
|
||||||
t1.created DESC
|
t1.created DESC
|
||||||
|
@ -230,7 +230,7 @@ class Device:
|
||||||
ORDER BY
|
ORDER BY
|
||||||
CASE
|
CASE
|
||||||
WHEN t1.key = 'CUSTOM_ID' THEN 1
|
WHEN t1.key = 'CUSTOM_ID' THEN 1
|
||||||
WHEN t1.key = 'hidalgo1' THEN 2
|
WHEN t1.key = 'ereuse24' THEN 2
|
||||||
ELSE 3
|
ELSE 3
|
||||||
END,
|
END,
|
||||||
t1.created DESC
|
t1.created DESC
|
||||||
|
|
|
@ -31,11 +31,13 @@ class BuildMix:
|
||||||
return hid
|
return hid
|
||||||
|
|
||||||
def generate_chids(self):
|
def generate_chids(self):
|
||||||
self.algorithms = {
|
self.algorithms = {}
|
||||||
'hidalgo1': self.get_hid('hidalgo1'),
|
for k in ALGOS.keys():
|
||||||
}
|
if not settings.DPP and k == 'ereuse22':
|
||||||
if settings.DPP:
|
continue
|
||||||
self.algorithms["legacy_dpp"] = self.get_hid("legacy_dpp")
|
|
||||||
|
self.algorithms[k] = self.get_hid(k)
|
||||||
|
|
||||||
|
|
||||||
def get_doc(self):
|
def get_doc(self):
|
||||||
self._get_components()
|
self._get_components()
|
||||||
|
@ -43,7 +45,7 @@ class BuildMix:
|
||||||
c.pop("actions", None)
|
c.pop("actions", None)
|
||||||
|
|
||||||
components = sorted(self.components, key=lambda x: x.get("type"))
|
components = sorted(self.components, key=lambda x: x.get("type"))
|
||||||
device = self.algorithms.get('legacy_dpp')
|
device = self.algorithms.get('ereuse22')
|
||||||
|
|
||||||
doc = [("computer", device)]
|
doc = [("computer", device)]
|
||||||
|
|
||||||
|
@ -51,7 +53,7 @@ class BuildMix:
|
||||||
doc.append((c.get("type"), self.get_id_hw_dpp(c)))
|
doc.append((c.get("type"), self.get_id_hw_dpp(c)))
|
||||||
|
|
||||||
def get_id_hw_dpp(self, d):
|
def get_id_hw_dpp(self, d):
|
||||||
algorithm = ALGOS.get("legacy_dpp", [])
|
algorithm = ALGOS.get("ereuse22", [])
|
||||||
hid = ""
|
hid = ""
|
||||||
for f in algorithm:
|
for f in algorithm:
|
||||||
hid += d.get(f, '')
|
hid += d.get(f, '')
|
||||||
|
|
|
@ -209,7 +209,7 @@ class Evidence:
|
||||||
def get_all(cls, user):
|
def get_all(cls, user):
|
||||||
return SystemProperty.objects.filter(
|
return SystemProperty.objects.filter(
|
||||||
owner=user.institution,
|
owner=user.institution,
|
||||||
key="hidalgo1",
|
key="ereuse24",
|
||||||
).order_by("-created").values_list("uuid", "created").distinct()
|
).order_by("-created").values_list("uuid", "created").distinct()
|
||||||
|
|
||||||
def set_components(self):
|
def set_components(self):
|
||||||
|
|
|
@ -88,7 +88,7 @@ class Build:
|
||||||
return hashlib.sha3_256(doc.encode()).hexdigest()
|
return hashlib.sha3_256(doc.encode()).hexdigest()
|
||||||
|
|
||||||
def register_device_dlt(self):
|
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)
|
chid = self.sign(legacy_dpp)
|
||||||
phid = self.sign(json.dumps(self.build.get_doc()))
|
phid = self.sign(json.dumps(self.build.get_doc()))
|
||||||
register_device_dlt(chid, phid, self.uuid, self.user)
|
register_device_dlt(chid, phid, self.uuid, self.user)
|
||||||
|
|
|
@ -9,7 +9,7 @@ STR_EXTEND_SIZE = 256
|
||||||
|
|
||||||
|
|
||||||
# Algorithms for build hids
|
# Algorithms for build hids
|
||||||
HID_ALGO1 = [
|
EREUSE24 = [
|
||||||
"manufacturer",
|
"manufacturer",
|
||||||
"model",
|
"model",
|
||||||
"chassis",
|
"chassis",
|
||||||
|
@ -17,7 +17,8 @@ HID_ALGO1 = [
|
||||||
"sku"
|
"sku"
|
||||||
]
|
]
|
||||||
|
|
||||||
LEGACY_DPP = [
|
# EREUSE22 is used for build the chid of DPP
|
||||||
|
EREUSE22 = [
|
||||||
"manufacturer",
|
"manufacturer",
|
||||||
"model",
|
"model",
|
||||||
"chassis",
|
"chassis",
|
||||||
|
@ -28,8 +29,8 @@ LEGACY_DPP = [
|
||||||
]
|
]
|
||||||
|
|
||||||
ALGOS = {
|
ALGOS = {
|
||||||
"hidalgo1": HID_ALGO1,
|
"ereuse24": EREUSE24,
|
||||||
"legacy_dpp": LEGACY_DPP
|
"ereuse22": EREUSE22
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue