fix rebase from main
This commit is contained in:
parent
d1abb206e8
commit
5d190d07a3
|
@ -29,17 +29,17 @@ class UploadForm(forms.Form):
|
|||
|
||||
try:
|
||||
file_json = json.loads(file_data)
|
||||
Build(file_json, None, check=True)
|
||||
snap = Build(file_json, None, check=True)
|
||||
exist_annotation = Annotation.objects.filter(
|
||||
uuid=file_json['uuid']
|
||||
uuid=snap.uuid
|
||||
).first()
|
||||
|
||||
|
||||
if exist_annotation:
|
||||
raise ValidationError(
|
||||
raise ValidationError(
|
||||
_("The snapshot already exists"),
|
||||
code="duplicate_snapshot",
|
||||
)
|
||||
|
||||
|
||||
#Catch any error and display it as Validation Error so the Form handles it
|
||||
except Exception as e:
|
||||
raise ValidationError(
|
||||
|
@ -221,7 +221,7 @@ class EraseServerForm(forms.Form):
|
|||
|
||||
if self.instance:
|
||||
return
|
||||
|
||||
|
||||
Annotation.objects.create(
|
||||
uuid=self.uuid,
|
||||
type=Annotation.Type.ERASE_SERVER,
|
||||
|
|
|
@ -68,8 +68,11 @@ class Evidence:
|
|||
|
||||
def get_doc(self):
|
||||
self.doc = {}
|
||||
self.inxi = None
|
||||
|
||||
if not self.owner:
|
||||
self.get_owner()
|
||||
|
||||
qry = 'uuid:"{}"'.format(self.uuid)
|
||||
matches = search(self.owner, qry, limit=1)
|
||||
if matches and matches.size() < 0:
|
||||
|
@ -93,6 +96,10 @@ class Evidence:
|
|||
self.dmi = DMIParse(dmidecode_raw)
|
||||
try:
|
||||
self.inxi = json.loads(inxi_raw)
|
||||
except Exception:
|
||||
pass
|
||||
if self.inxi:
|
||||
try:
|
||||
machine = get_inxi_key(self.inxi, 'Machine')
|
||||
for m in machine:
|
||||
system = get_inxi(m, "System")
|
||||
|
@ -102,7 +109,6 @@ class Evidence:
|
|||
self.device_serial_number = get_inxi(m, "serial")
|
||||
self.device_chassis = get_inxi(m, "Type")
|
||||
self.device_version = get_inxi(m, "v")
|
||||
|
||||
except Exception:
|
||||
return
|
||||
|
||||
|
@ -157,9 +163,6 @@ class Evidence:
|
|||
if self.inxi:
|
||||
return self.device_chassis
|
||||
|
||||
if self.inxi:
|
||||
return self.device_chassis
|
||||
|
||||
chassis = self.dmi.get("Chassis")[0].get("Type", '_virtual')
|
||||
lower_type = chassis.lower()
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ from evidence.parse_details import ParseSnapshot
|
|||
|
||||
from evidence.models import Annotation
|
||||
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 django.conf import settings
|
||||
|
||||
|
@ -78,27 +77,16 @@ class Build:
|
|||
sku = device.get("sku", '')
|
||||
hid = f"{manufacturer}{model}{chassis}{serial_number}{sku}"
|
||||
|
||||
|
||||
self.chid = hashlib.sha3_256(hid.encode()).hexdigest()
|
||||
return self.chid
|
||||
|
||||
def get_chid_dpp(self):
|
||||
if self.json.get("software") == "workbench-script":
|
||||
dmidecode_raw = self.json["data"]["dmidecode"]
|
||||
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}"
|
||||
device = ParseSnapshot(self.json).device
|
||||
else:
|
||||
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()
|
||||
return self.chid
|
||||
|
||||
|
|
Loading…
Reference in a new issue