Compare commits

..

No commits in common. "cdf4771b7dbce9783d4f370b8a97085d4886ac62" and "e65dffe4d113cbbdcc124c18b2ec8ee0972eed85" have entirely different histories.

4 changed files with 27 additions and 28 deletions

View File

@ -55,7 +55,8 @@
<div class="col-lg-3 col-md-4 label ">{% trans "Type" %}</div>
<div class="col-lg-9 col-md-8">{{ object.type }}</div>
</div>
{% if object.is_websnapshot and object.last_user_evidence %}
{% if object.is_websnapshot %}
{% for k, v in object.last_user_evidence %}
<div class="row">
<div class="col-lg-3 col-md-4 label">{{ k }}</div>

View File

@ -35,14 +35,10 @@ class UploadForm(forms.Form):
).first()
if exist_annotation:
raise ValidationError("Error: {} already exists".format(file_name))
raise ValidationError("error: {} exist".format(file_name))
except json.JSONDecodeError:
raise ValidationError("Error in parsing JSON: '{}'. Check for file integrity.".format(file_name))
except ValidationError as e:
raise e
except Exception as e:
raise ValidationError("Oops! Something went wrong in '{}': {}".format(file_name, str(e)))
except Exception:
raise ValidationError("error in: {}".format(file_name))
self.evidences.append((file_name, file_json))

View File

@ -41,17 +41,9 @@ class Command(BaseCommand):
self.open(filepath)
def open(self, filepath):
try:
with open(filepath, 'r') as file:
content = json.loads(file.read())
path_name = save_in_disk(content, self.user.institution.name)
self.snapshots.append((content, path_name))
except json.JSONDecodeError as e:
raise e
#or we cath'em all
except Exception:
raise Exception(f"Oops! Something went wrong there")
self.snapshots.append(content)
def parsing(self):
for s in self.snapshots:

View File

@ -5,15 +5,23 @@ import logging
from dmidecode import DMIParse
from json_repair import repair_json
from evidence.parse_details import get_lshw_child
from evidence.models import Annotation
from evidence.xapian import index
from utils.constants import CHASSIS_DH
logger = logging.getLogger(__name__)
logger = logging.getLogger('django')
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
@ -22,17 +30,19 @@ def get_mac(lshw):
except json.decoder.JSONDecodeError:
hw = json.loads(repair_json(lshw))
networks = []
get_lshw_child(hw, networks, 'network')
try:
get_network_cards(hw, nets)
except Exception as ss:
print("WARNING!! {}".format(ss))
return
nets_sorted = sorted(networks, key=lambda x: x['businfo'])
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:
mac = nets_sorted[0]['serial']
logger.debug("The snapshot has the following MAC: %s" , mac)
return mac
return nets_sorted[0]['serial']
class Build:
def __init__(self, evidence_json, user, check=False):