How to use the pymisp.MISPObject function in pymisp

To help you get started, weā€™ve selected a few pymisp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MISP / PyMISP / tests / testlive_comprehensive.py View on Github external
def test_delete_by_uuid(self):
        try:
            first = self.create_simple_event()
            obj = MISPObject('file')
            obj.add_attribute('filename', 'foo')
            first.add_object(obj)
            first = self.user_misp_connector.add_event(first)
            r = self.user_misp_connector.delete_attribute(first.attributes[0].uuid)
            self.assertEqual(r['message'], 'Attribute deleted.')
            r = self.user_misp_connector.delete_object(first.objects[0].uuid)
            self.assertEqual(r['message'], 'Object deleted')
            r = self.user_misp_connector.delete_event(first.uuid)
            self.assertEqual(r['message'], 'Event deleted.')
        finally:
            # Delete event
            self.admin_misp_connector.delete_event(first)
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
dates_already_imported = []
        if update:
            # get all datetime from existing event
            for obj in event.get_objects_by_name('scrippsco2-co2-monthly'):
                date_attribute = obj.get_attributes_by_relation('sample-datetime')[0]
                dates_already_imported.append(date_attribute.value)

        reader = csv.reader(data)
        for row in reader:
            if not row[0].isdigit():
                # This file has fucked up headers
                continue
            sample_date = parse(f'{row[0]}-{row[1]}-16T00:00:00')
            if sample_date in dates_already_imported:
                continue
            obj = MISPObject('scrippsco2-co2-monthly', standalone=False)
            obj.add_attribute('sample-datetime', sample_date)
            obj.add_attribute('sample-date-excel', float(row[2]))
            obj.add_attribute('sample-date-fractional', float(row[3]))
            obj.add_attribute('monthly-co2', float(row[4]))
            obj.add_attribute('monthly-co2-seasonal-adjustment', float(row[5]))
            obj.add_attribute('monthly-co2-smoothed', float(row[6]))
            obj.add_attribute('monthly-co2-smoothed-seasonal-adjustment', float(row[7]))
            obj.add_reference(location, 'sampling-location')
            event.add_object(obj)
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
dates_already_imported = []
        if update:
            # get all datetime from existing event
            for obj in event.get_objects_by_name('scrippsco2-o18-monthly'):
                date_attribute = obj.get_attributes_by_relation('sample-datetime')[0]
                dates_already_imported.append(date_attribute.value)

        reader = csv.reader(data)
        for row in reader:
            if not row[0].isdigit():
                # This file has fucked up headers
                continue
            sample_date = parse(f'{row[0]}-{row[1]}-16T00:00:00')
            if sample_date in dates_already_imported:
                continue
            obj = MISPObject('scrippsco2-o18-monthly', standalone=False)
            obj.add_attribute('sample-datetime', sample_date)
            obj.add_attribute('sample-date-excel', float(row[2]))
            obj.add_attribute('sample-date-fractional', float(row[3]))
            obj.add_attribute('monthly-o18', float(row[4]))
            obj.add_attribute('monthly-o18-seasonal-adjustment', float(row[5]))
            obj.add_attribute('monthly-o18-smoothed', float(row[6]))
            obj.add_attribute('monthly-o18-smoothed-seasonal-adjustment', float(row[7]))
            obj.add_reference(location, 'sampling-location')
            event.add_object(obj)
github alephdata / followthemoney / followthemoney / export / misp.py View on Github external
def __init__(
        self, fh: Optional[TextIO] = None, edge_types: Tuple[str] = DEFAULT_EDGE_TYPES
    ):
        super(MISPExporter, self).__init__(edge_types=edge_types)
        self._nodes_mapping: Dict[str, MISPObject] = {}
        self._references_to_add: List[Tuple[MISPObject, str]] = []

        self.misp_objects: List[MISPObject] = []
        self.fh: Optional[TextIO] = fh
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def geolocation_bcs(self) -> MISPObject:
        # Baja California Sur, Mexico
        location = MISPObject('geolocation')
        location.add_attribute('latitude', 23.3)
        location.add_attribute('longitude', 110.2)
        location.add_attribute('altitude', 4)
        location.add_attribute('text', 'Baja California Sur, Mexico')
        return location
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def geolocation_ljo(self) -> MISPObject:
        # La Jolla Pier, California
        location = MISPObject('geolocation')
        location.add_attribute('latitude', 32.9)
        location.add_attribute('longitude', 117.3)
        location.add_attribute('altitude', 10)
        location.add_attribute('text', 'La Jolla Pier, California')
        return location
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def geolocation_mlo(self) -> MISPObject:
        # Mauna Loa Observatory, Hawaii
        location = MISPObject('geolocation')
        location.add_attribute('latitude', 19.5)
        location.add_attribute('longitude', 155.6)
        location.add_attribute('altitude', 3397)
        location.add_attribute('text', 'Mauna Loa Observatory, Hawaii')
        return location
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def daily_flask_o18(self, event, location, csv_file, update):
        data = self.split_data_comment(csv_file, update, event)

        dates_already_imported = []
        if update:
            # get all datetime from existing event
            for obj in event.get_objects_by_name('scrippsco2-o18-daily'):
                date_attribute = obj.get_attributes_by_relation('sample-datetime')[0]
                dates_already_imported.append(date_attribute.value)

        reader = csv.reader(data)
        for row in reader:
            sample_date = parse(f'{row[0]}-{row[1]}')
            if sample_date in dates_already_imported:
                continue
            obj = MISPObject('scrippsco2-o18-daily', standalone=False)
            obj.add_attribute('sample-datetime', sample_date)
            obj.add_attribute('sample-date-excel', float(row[2]))
            obj.add_attribute('sample-date-fractional', float(row[3]))
            obj.add_attribute('number-flask', int(row[4]))
            obj.add_attribute('flag', int(row[5]))
            attr = obj.add_attribute('o18-value', float(row[6]))
            attr.add_tag(f'scrippsco2-fgi:{int(row[5])}')
            obj.add_reference(location, 'sampling-location')
            event.add_object(obj)
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def geolocation_ptb(self):
        # Point Barrow, Alaska
        location = MISPObject('geolocation')
        location.add_attribute('latitude', 71.3)
        location.add_attribute('longitude', 156.6)
        location.add_attribute('altitude', 11)
        location.add_attribute('text', 'Point Barrow, Alaska')
        return location
github MISP / PyMISP / examples / import_scrippsc02.py View on Github external
def geolocation_kum(self) -> MISPObject:
        # Cape Kumukahi, Hawaii
        location = MISPObject('geolocation')
        location.add_attribute('latitude', 19.5)
        location.add_attribute('longitude', 154.8)
        location.add_attribute('altitude', 3)
        location.add_attribute('text', 'Cape Kumukahi, Hawaii')
        return location