fix: Avoid trying to build attributes with not intended fields

- Previously: if the header field is not an attribute type, then
              it was added as an attribute field.
              PyMISP then used to skip it if needed

- Now: Those fields are discarded before they are put in an attribute
chrisr3d 2018-05-17 16:24:11 +02:00
parent c088b13f03
commit dba8bd8c5b
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 6 additions and 2 deletions

View File

@ -14,6 +14,7 @@ userConfig = {'header': {
duplicatedFields = {'mispType': {'mispComment': 'comment'},
'attrField': {'attrComment': 'comment'}}
attributesFields = ['type', 'value', 'category', 'to_ids', 'comment', 'distribution']
class CsvParser():
def __init__(self, header):
@ -96,9 +97,12 @@ class CsvParser():
elif h in duplicatedFields['attrField']:
# fields that should be considered as attribute fields
# otherwise, it is an attribute field
# or, it could be an attribute field
elif h in attributesFields:
# otherwise, it is not defined
# return list of indexes of the misp types, list of the misp types, remaining fields that will be attribute fields
return list2pop, misp, list(reversed(head))