chg: Raise exception on missing template in CSVLoader

Related: #714
pull/749/head
Raphaël Vinot 2021-03-05 19:33:14 +01:00
parent b5b2f7015b
commit 2734224958
1 changed files with 2 additions and 0 deletions

View File

@ -38,6 +38,8 @@ class CSVLoader():
else:
# Check if the CSV file has a header, and if it matches with the object template
tmp_object = MISPObject(self.template_name)
if not tmp_object._definition['attributes']:
raise Exception(f'Unable to find the object template ({self.template_name}), impossible to create objects.')
allowed_fieldnames = list(tmp_object._definition['attributes'].keys())
for fieldname in self.fieldnames:
if fieldname not in allowed_fieldnames: