Skip to content

Commit

Permalink
Allow to add a tag to a MISPEvent and MISPAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Jan 26, 2017
1 parent d260dc5 commit 48e1211
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pymisp/mispevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def sign(self, gpg_uid, passphrase=None):
def delete(self):
self.deleted = True

def add_tag(self, tag):
self.Tag.append({'name': tag})

def verify(self, gpg_uid):
if not has_pyme:
raise Exception('pyme is required, please install: pip install --pre pyme3. You will also need libgpg-error-dev and libgpgme11-dev.')
Expand Down Expand Up @@ -549,6 +552,19 @@ def _json_full(self):
jsonschema.validate(to_return, self.json_schema)
return to_return

def add_tag(self, tag):
self.Tag.append({'name': tag})

def add_attribute_tag(self, tag, attribute_identifier):
attribute = None
for a in self.attributes:
if a.id == attribute_identifier or a.uuid == attribute_identifier or attribute_identifier in a.value:
a.add_tag(tag)
attribute = a
if not attribute:
raise Exception('No attribute with identifier {} found.'.format(attribute_identifier))
return attribute

def publish(self):
self.published = True

Expand Down

0 comments on commit 48e1211

Please sign in to comment.