From f5cbb417c8b39dc7ae65593b1f737ccfa6421af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 19 Jul 2019 11:41:56 +0200 Subject: [PATCH] new: [Sightings] Delete method Fix #230 --- pymisp/aping.py | 6 ++++++ tests/testlive_comprehensive.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/pymisp/aping.py b/pymisp/aping.py index a7c2bfa..a159ebd 100644 --- a/pymisp/aping.py +++ b/pymisp/aping.py @@ -447,6 +447,12 @@ class ExpandedPyMISP(PyMISP): s.from_dict(**new_sighting) return s + def delete_sighting(self, sighting: Union[MISPSighting, int, str, UUID]): + '''Delete a sighting from a MISP instance''' + sighting_id = self.__get_uuid_or_id_from_abstract_misp(sighting) + response = self._prepare_request('POST', f'sightings/delete/{sighting_id}') + return self._check_response(response, expect_json=True) + # ## END Sighting ### # ## BEGIN Tags ### diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index 5b359c3..5523f3d 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -798,6 +798,10 @@ class TestComprehensive(unittest.TestCase): s = self.user_misp_connector.sightings(second.attributes[0], self.test_org.id, pythonify=True) self.assertEqual(len(s), 1) self.assertEqual(s[0].org_id, self.test_org.id) + # Delete sighting + r = self.user_misp_connector.delete_sighting(s[0]) + self.assertEqual(r['message'], 'Sighting successfuly deleted.') + finally: # Delete event self.admin_misp_connector.delete_event(first.id)