本文整理汇总了Python中pymisp.PyMISP类的典型用法代码示例。如果您正苦于以下问题:Python PyMISP类的具体用法?Python PyMISP怎么用?Python PyMISP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PyMISP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getVersions
def test_getVersions(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
api_version = pymisp.get_api_version()
self.assertEqual(api_version, {"version": pm.__version__})
server_version = pymisp.get_version()
self.assertEqual(server_version, {"version": "2.4.56"})
示例2: test_deleteEvent
def test_deleteEvent(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
d = pymisp.delete_event(2)
self.assertEqual(d, {'message': 'Event deleted.'})
d = pymisp.delete_event(3)
self.assertEqual(d, {'errors': ['Invalid event'], 'message': 'Invalid event', 'name': 'Invalid event', 'url': '/events/3'})
示例3: test_auth_error
def test_auth_error(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
error = pymisp.get(1)
response = self.auth_error_msg
response["errors"] = [response["message"]]
self.assertEqual(error, response)
示例4: test_getEvent
def test_getEvent(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
e1 = pymisp.get_event(2)
e2 = pymisp.get(2)
self.assertEqual(e1, e2)
self.assertEqual(self.event, e2)
示例5: from_remote
def from_remote(self, event_id):
from pymisp import PyMISP
from keys import misp_url, misp_key, misp_verifycert
misp = PyMISP(misp_url, misp_key, misp_verifycert)
result = misp.get(event_id)
self.misp_event = MISPEvent()
self.misp_event.load(result)
示例6: test_flatten_error_messages_singular
def test_flatten_error_messages_singular(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
pymisp.get(1)
response = self.auth_error_msg
response['error'] = ['foo', 'bar', 'baz']
messages = pymisp.flatten_error_messages(response)
self.assertEqual(["foo", "bar", "baz"], messages)
示例7: test_tag_event
def test_tag_event(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
uuid = self.event["Event"]["uuid"]
pymisp.tag(uuid, "foo")
self.assertRaises(pm.PyMISPError, pymisp.tag, "test_uuid", "foo")
self.assertRaises(pm.PyMISPError, pymisp.tag, uuid.replace("a", "z"), "foo")
示例8: test_freetext_offdomain
def test_freetext_offdomain(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
try:
pymisp.freetext(1, None, adhereToWarninglists='hard')
self.assertFalse('Exception required for off domain value')
except Exception:
pass
示例9: test_change_toids_invalid
def test_change_toids_invalid(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
try:
pymisp.change_toids(self.key, 42)
self.assertFalse('Exception required for off domain value')
except Exception:
pass
示例10: test_publish
def test_publish(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
e = pymisp.publish(self.event)
pub = self.event
pub['Event']['published'] = True
self.assertEqual(e, pub)
e = pymisp.publish(self.event)
self.assertEqual(e, {'error': 'Already published'})
示例11: test_updateEvent
def test_updateEvent(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
e0 = pymisp.update_event("5758ebf5-c898-48e6-9fe9-5665c0a83866", json.dumps(self.event))
e1 = pymisp.update_event("5758ebf5-c898-48e6-9fe9-5665c0a83866", self.event)
self.assertEqual(e0, e1)
e2 = pymisp.update(e0)
self.assertEqual(e1, e2)
self.assertEqual(self.event, e2)
示例12: test_deleteEvent
def test_deleteEvent(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
d = pymisp.delete_event(2)
self.assertEqual(d, {"message": "Event deleted."})
d = pymisp.delete_event(3)
self.assertEqual(
d, {"errors": ["Invalid event"], "message": "Invalid event", "name": "Invalid event", "url": "/events/3"}
)
示例13: test_updateEvent
def test_updateEvent(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
e0 = pymisp.update_event(2, json.dumps(self.event))
e1 = pymisp.update_event(2, self.event)
self.assertEqual(e0, e1)
e2 = pymisp.update(e0)
self.assertEqual(e1, e2)
self.assertEqual(self.event, e2)
示例14: test_publish
def test_publish(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
e = pymisp.publish(self.event) # requests-mock always return the non-published event
pub = self.event
pub["Event"]["published"] = True
# self.assertEqual(e, pub) FIXME: broken test, not-published event returned
e = pymisp.publish(self.event)
self.assertEqual(e, {"error": "Already published"})
示例15: test_flatten_error_messages_plural
def test_flatten_error_messages_plural(self, m):
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
error = pymisp.get(1)
self.assertIn("Authentication failed", error["message"])
response = self.auth_error_msg
response['errors'] = {'foo': 42, 'bar': False, 'baz': ['oo', 'ka']}
messages = pymisp.flatten_error_messages(response)
self.assertEqual(set(['42 (foo)', 'False (bar)', 'oo', 'ka']), set(messages))