2024-10-31 09:14:02 +00:00
|
|
|
import logging
|
2024-09-25 10:51:08 +00:00
|
|
|
|
2025-01-11 19:44:21 +00:00
|
|
|
from evidence import (
|
|
|
|
legacy_parse_details,
|
|
|
|
normal_parse_details,
|
|
|
|
old_parse_details
|
|
|
|
)
|
2024-09-25 10:51:08 +00:00
|
|
|
|
|
|
|
|
2024-10-31 09:14:02 +00:00
|
|
|
logger = logging.getLogger('django')
|
|
|
|
|
|
|
|
|
2024-09-25 10:51:08 +00:00
|
|
|
class ParseSnapshot:
|
|
|
|
def __init__(self, snapshot, default="n/a"):
|
2025-01-11 19:44:21 +00:00
|
|
|
if snapshot.get("credentialSubject"):
|
|
|
|
self.build = normal_parse_details.ParseSnapshot(
|
|
|
|
snapshot,
|
|
|
|
default=default
|
|
|
|
)
|
|
|
|
elif snapshot.get("software") != "workbench-script":
|
|
|
|
self.build = old_parse_details.ParseSnapshot(
|
|
|
|
snapshot,
|
|
|
|
default=default
|
|
|
|
)
|
|
|
|
elif snapshot.get("data",{}).get("lshw"):
|
|
|
|
self.build = legacy_parse_details.ParseSnapshot(
|
|
|
|
snapshot,
|
|
|
|
default=default
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
self.build = normal_parse_details.ParseSnapshot(
|
|
|
|
snapshot,
|
|
|
|
default=default
|
|
|
|
)
|
|
|
|
|
|
|
|
self.default = default
|
|
|
|
self.device = self.build.snapshot_json.get("device")
|
|
|
|
self.components = self.build.snapshot_json.get("components")
|