diff --git a/evidence/mixin_parse.py b/evidence/mixin_parse.py index 18dcf76..e0b4209 100644 --- a/evidence/mixin_parse.py +++ b/evidence/mixin_parse.py @@ -10,7 +10,7 @@ logger = logging.getLogger('django') class BuildMix: def __init__(self, evidence_json): self.json = evidence_json - self.uuid = self.json['uuid'] + self.uuid = self.json.get('uuid') self.manufacturer = "" self.model = "" self.serial_number = "" diff --git a/evidence/normal_parse.py b/evidence/normal_parse.py index 4ad901b..f0a8600 100644 --- a/evidence/normal_parse.py +++ b/evidence/normal_parse.py @@ -49,6 +49,7 @@ class Build(BuildMix): if not self.json.get("credentialSubject"): return + self.uuid = self.json.get("credentialSubject", {}).get("uuid") self.json.update(self.json["credentialSubject"]) if self.json.get("evidence"): self.json["data"] = {} diff --git a/evidence/parse.py b/evidence/parse.py index fd04e2d..45ed35c 100644 --- a/evidence/parse.py +++ b/evidence/parse.py @@ -39,11 +39,12 @@ class Build: 4) normal snapshot from worbench-script is the most basic and is parsed as normal_parse """ self.evidence = evidence_json.copy() - self.uuid = self.evidence['uuid'] + self.uuid = self.evidence.get('uuid') self.user = user if evidence_json.get("credentialSubject"): self.build = normal_parse.Build(evidence_json) + self.uuid = evidence_json.get("credentialSubject", {}).get("uuid") elif evidence_json.get("software") != "workbench-script": self.build = old_parse.Build(evidence_json) elif evidence_json.get("data",{}).get("lshw"):