fix rebase from main
This commit is contained in:
parent
d1abb206e8
commit
5d190d07a3
|
@ -29,9 +29,9 @@ class UploadForm(forms.Form):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file_json = json.loads(file_data)
|
file_json = json.loads(file_data)
|
||||||
Build(file_json, None, check=True)
|
snap = Build(file_json, None, check=True)
|
||||||
exist_annotation = Annotation.objects.filter(
|
exist_annotation = Annotation.objects.filter(
|
||||||
uuid=file_json['uuid']
|
uuid=snap.uuid
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
if exist_annotation:
|
if exist_annotation:
|
||||||
|
|
|
@ -68,8 +68,11 @@ class Evidence:
|
||||||
|
|
||||||
def get_doc(self):
|
def get_doc(self):
|
||||||
self.doc = {}
|
self.doc = {}
|
||||||
|
self.inxi = None
|
||||||
|
|
||||||
if not self.owner:
|
if not self.owner:
|
||||||
self.get_owner()
|
self.get_owner()
|
||||||
|
|
||||||
qry = 'uuid:"{}"'.format(self.uuid)
|
qry = 'uuid:"{}"'.format(self.uuid)
|
||||||
matches = search(self.owner, qry, limit=1)
|
matches = search(self.owner, qry, limit=1)
|
||||||
if matches and matches.size() < 0:
|
if matches and matches.size() < 0:
|
||||||
|
@ -93,6 +96,10 @@ class Evidence:
|
||||||
self.dmi = DMIParse(dmidecode_raw)
|
self.dmi = DMIParse(dmidecode_raw)
|
||||||
try:
|
try:
|
||||||
self.inxi = json.loads(inxi_raw)
|
self.inxi = json.loads(inxi_raw)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if self.inxi:
|
||||||
|
try:
|
||||||
machine = get_inxi_key(self.inxi, 'Machine')
|
machine = get_inxi_key(self.inxi, 'Machine')
|
||||||
for m in machine:
|
for m in machine:
|
||||||
system = get_inxi(m, "System")
|
system = get_inxi(m, "System")
|
||||||
|
@ -102,7 +109,6 @@ class Evidence:
|
||||||
self.device_serial_number = get_inxi(m, "serial")
|
self.device_serial_number = get_inxi(m, "serial")
|
||||||
self.device_chassis = get_inxi(m, "Type")
|
self.device_chassis = get_inxi(m, "Type")
|
||||||
self.device_version = get_inxi(m, "v")
|
self.device_version = get_inxi(m, "v")
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -157,9 +163,6 @@ class Evidence:
|
||||||
if self.inxi:
|
if self.inxi:
|
||||||
return self.device_chassis
|
return self.device_chassis
|
||||||
|
|
||||||
if self.inxi:
|
|
||||||
return self.device_chassis
|
|
||||||
|
|
||||||
chassis = self.dmi.get("Chassis")[0].get("Type", '_virtual')
|
chassis = self.dmi.get("Chassis")[0].get("Type", '_virtual')
|
||||||
lower_type = chassis.lower()
|
lower_type = chassis.lower()
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ from evidence.parse_details import ParseSnapshot
|
||||||
|
|
||||||
from evidence.models import Annotation
|
from evidence.models import Annotation
|
||||||
from evidence.xapian import index
|
from evidence.xapian import index
|
||||||
from dpp.api_dlt import register_device_dlt, register_passport_dlt
|
|
||||||
from evidence.parse_details import get_inxi_key, get_inxi
|
from evidence.parse_details import get_inxi_key, get_inxi
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
@ -78,27 +77,16 @@ class Build:
|
||||||
sku = device.get("sku", '')
|
sku = device.get("sku", '')
|
||||||
hid = f"{manufacturer}{model}{chassis}{serial_number}{sku}"
|
hid = f"{manufacturer}{model}{chassis}{serial_number}{sku}"
|
||||||
|
|
||||||
|
|
||||||
self.chid = hashlib.sha3_256(hid.encode()).hexdigest()
|
self.chid = hashlib.sha3_256(hid.encode()).hexdigest()
|
||||||
return self.chid
|
return self.chid
|
||||||
|
|
||||||
def get_chid_dpp(self):
|
def get_chid_dpp(self):
|
||||||
if self.json.get("software") == "workbench-script":
|
if self.json.get("software") == "workbench-script":
|
||||||
dmidecode_raw = self.json["data"]["dmidecode"]
|
device = ParseSnapshot(self.json).device
|
||||||
dmi = DMIParse(dmidecode_raw)
|
|
||||||
|
|
||||||
manufacturer = dmi.manufacturer().strip()
|
|
||||||
model = dmi.model().strip()
|
|
||||||
chassis = self.get_chassis_dh()
|
|
||||||
serial_number = dmi.serial_number()
|
|
||||||
sku = self.get_sku()
|
|
||||||
typ = chassis
|
|
||||||
version = self.get_version()
|
|
||||||
hid = f"{manufacturer}{model}{chassis}{serial_number}{sku}{typ}{version}"
|
|
||||||
else:
|
else:
|
||||||
device = self.json['device']
|
device = self.json['device']
|
||||||
hid = self.get_id_hw_dpp(device)
|
|
||||||
|
|
||||||
|
hid = self.get_id_hw_dpp(device)
|
||||||
self.chid = hashlib.sha3_256(hid.encode("utf-8")).hexdigest()
|
self.chid = hashlib.sha3_256(hid.encode("utf-8")).hexdigest()
|
||||||
return self.chid
|
return self.chid
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue