From a0a22e7840b3e1af346e23c375e02f3ec6271308 Mon Sep 17 00:00:00 2001 From: Thomas Rusiecki Date: Mon, 11 Nov 2024 03:41:08 -0300 Subject: [PATCH] minor fix in mac parsing --- evidence/parse.py | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/evidence/parse.py b/evidence/parse.py index b98f840..fd68e06 100644 --- a/evidence/parse.py +++ b/evidence/parse.py @@ -22,8 +22,10 @@ def get_mac(lshw): except json.decoder.JSONDecodeError: hw = json.loads(repair_json(lshw)) - networks = [] - get_lshw_child(hw, networks, 'network') + nets = [] + get_lshw_child(hw, nets, 'network') + + nets_sorted = sorted(nets, key=lambda x: x['businfo']) if nets_sorted: mac = nets_sorted[0]['serial'] @@ -31,36 +33,6 @@ def get_mac(lshw): return mac -def get_network_cards(child, nets): - if child['id'] == 'network' and "PCI:" in child.get("businfo"): - nets.append(child) - if child.get('children'): - [get_network_cards(x, nets) for x in child['children']] - - -def get_mac(lshw): - nets = [] - try: - if type(lshw) is dict: - hw = lshw - else: - hw = json.loads(lshw) - except json.decoder.JSONDecodeError: - hw = json.loads(repair_json(lshw)) - - try: - get_network_cards(hw, nets) - except Exception as ss: - logger.warning("%s", ss) - return - - nets_sorted = sorted(nets, key=lambda x: x['businfo']) - # This funcion get the network card integrated in motherboard - # integrate = [x for x in nets if "pci@0000:00:" in x.get('businfo', '')] - - if nets_sorted: - return nets_sorted[0]['serial'] - class Build: def __init__(self, evidence_json, user, check=False):