chg: Cleanup new sbsignature generator

pull/181/head
Raphaël Vinot 2018-01-23 11:07:36 +01:00
parent cb4d464526
commit e2bb66d01c
2 changed files with 8 additions and 14 deletions

View File

@ -11,7 +11,6 @@ a = [(x['name'], x['description']) for x in a["signatures"]]
b = SBSignatureObject(a)
template_id = [x['ObjectTemplate']['id'] for x in pymisp.get_object_templates_list(
) if x['ObjectTemplate']['name'] == 'sb-signature'][0]
template_id = [x['ObjectTemplate']['id'] for x in pymisp.get_object_templates_list() if x['ObjectTemplate']['name'] == 'sb-signature'][0]
pymisp.add_object(234111, template_id, b)
pymisp.add_object(234111, template_id, b)

View File

@ -1,26 +1,21 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
import requests
from .abstractgenerator import AbstractMISPObjectGenerator
from .. import InvalidMISPObject
class SBSignatureObject(AbstractMISPObjectGenerator):
'''
Sandbox Analyzer
'''
def __init__(self, report, software, parsed=None, filepath=None, pseudofile=None, standalone=True, **kwargs):
# PY3 way:
# super().__init__("virustotal-report")
def __init__(self, software, report, standalone=True, **kwargs):
super(SBSignatureObject, self).__init__("sb-signature", **kwargs)
self._report = report
self._software = software
self._report = report
self.generate_attributes()
def generate_attributes(self):
''' Parse the report for relevant attributes '''
self.add_attribute("software", value=self._software, type="text")
for (name, description) in self._report:
self.add_attribute("signature", value=name, comment=description, type="text")
self.add_attribute("software", value=self._software)
for (signature_name, description) in self._report:
self.add_attribute("signature", value=signature_name, comment=description)