本文整理汇总了Python中pymisp.PyMISP类的典型用法代码示例。如果您正苦于以下问题:Python PyMISP类的具体用法?Python PyMISP怎么用?Python PyMISP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PyMISP类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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"})
开发者ID:CIRCL,项目名称:PyMISP,代码行数:7,代码来源:test_offline.py
示例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'})
开发者ID:TheDr1ver,项目名称:PyMISP,代码行数:7,代码来源:test_offline.py
示例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)
开发者ID:CIRCL,项目名称:PyMISP,代码行数:7,代码来源:test_offline.py
示例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)
开发者ID:CIRCL,项目名称:PyMISP,代码行数:7,代码来源:test_offline.py
示例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)
开发者ID:3c7,项目名称:PyMISP,代码行数:7,代码来源:asciidoc_generator.py
示例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)
开发者ID:tomking2,项目名称:PyMISP,代码行数:8,代码来源:test_offline.py
示例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")
开发者ID:tomking2,项目名称:PyMISP,代码行数:8,代码来源:test_offline.py
示例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
开发者ID:tomking2,项目名称:PyMISP,代码行数:8,代码来源:test_offline.py
示例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
开发者ID:tomking2,项目名称:PyMISP,代码行数:8,代码来源:test_offline.py
示例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'})
开发者ID:pombredanne,项目名称:PyMISP,代码行数:9,代码来源:test_offline.py
示例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)
开发者ID:CIRCL,项目名称:PyMISP,代码行数:9,代码来源:test_offline.py
示例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"}
)
开发者ID:CIRCL,项目名称:PyMISP,代码行数:9,代码来源:test_offline.py
示例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)
开发者ID:FloatingGhost,项目名称:PyMISP,代码行数:9,代码来源:test_offline.py
示例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"})
开发者ID:CIRCL,项目名称:PyMISP,代码行数:9,代码来源:test_offline.py
示例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))
开发者ID:tomking2,项目名称:PyMISP,代码行数:9,代码来源:test_offline.py
示例16: test_flatten_error_messages_nested
def test_flatten_error_messages_nested(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'] = {
'fo': {'o': 42}, 'ba': {'r': True}, 'b': {'a': ['z']}, 'd': {'e': {'e': ['p']}}}
messages = pymisp.flatten_error_messages(response)
self.assertEqual(set(['Error in o: 42', 'Error in r: True', 'Error in a: z', "Error in e: {'e': ['p']}"]), set(messages))
开发者ID:tomking2,项目名称:PyMISP,代码行数:10,代码来源:test_offline.py
示例17: test_newEvent
def test_newEvent(self, m):
error_empty_info = {'message': 'The event could not be saved.', 'name': 'Add event failed.', 'errors': ['Error in info: Info cannot be empty.'], 'url': '/events/add'}
error_empty_info_flatten = {u'message': u'The event could not be saved.', u'name': u'Add event failed.', u'errors': [u"Error in info: Info cannot be empty."], u'url': u'/events/add'}
self.initURI(m)
pymisp = PyMISP(self.domain, self.key)
m.register_uri('POST', self.domain + 'events', json=error_empty_info)
# TODO Add test exception if info field isn't set
response = pymisp.new_event(0, 1, 0, 'Foo')
self.assertEqual(response, error_empty_info_flatten)
m.register_uri('POST', self.domain + 'events', json=self.new_misp_event)
response = pymisp.new_event(0, 1, 0, "This is a test.", '2016-08-26', False)
self.assertEqual(response, self.new_misp_event)
开发者ID:TheDr1ver,项目名称:PyMISP,代码行数:12,代码来源:test_offline.py
示例18: MISPCollectorBot
class MISPCollectorBot(CollectorBot):
def init(self):
if PyMISP is None:
self.logger.error('Could not import pymisp. Please install it.')
self.stop()
# Initialise MISP connection
self.misp = PyMISP(self.parameters.misp_url,
self.parameters.misp_key,
self.parameters.misp_verify)
# URLs used for deleting and adding MISP event tags
self.misp_add_tag_url = urljoin(self.parameters.misp_url,
'events/addTag')
self.misp_del_tag_url = urljoin(self.parameters.misp_url,
'events/removeTag')
def process(self):
# Grab the events from MISP
misp_result = self.misp.search(
tags=self.parameters.misp_tag_to_process
)
# Process the response and events
if 'response' in misp_result:
# Extract the MISP event details
for e in misp_result['response']:
misp_event = e['Event']
# Send the results to the parser
report = self.new_report()
report.add('raw', json.dumps(misp_event, sort_keys=True))
report.add('feed.url', self.parameters.misp_url)
self.send_message(report)
# Finally, update the tags on the MISP events.
# Note PyMISP does not currently support this so we use
# the API URLs directly with the requests module.
for misp_event in misp_result['response']:
# Remove the 'to be processed' tag
self.misp.remove_tag(misp_event,
self.parameters.misp_tag_to_process)
# Add a 'processed' tag to the event
self.misp.add_tag(misp_event,
self.parameters.misp_tag_processed)
开发者ID:Dognaedis,项目名称:intelmq,代码行数:49,代码来源:collector.py
示例19: getMISPData
def getMISPData(self, since=None):
# Connect to your MISP API
misp = PyMISP(self.url, self.key, True, 'json')
since = since if since else "5d"
if since.lower() == "all": since = ""
misp_last = misp.download_last(since)
# Verify output
if 'message' in misp_last.keys():
if misp_last['message'].lower().startswith('no matches'):
return [] # No output
elif misp_last['message'].startswith('Authentication failed.'):
raise Exception("[-] MISP Authentication failed")
if not 'response' in misp_last:
raise Exception("[-] Error occured while fetching MISP data")
return misp_last['response']
开发者ID:PidgeyL,项目名称:MISP-Extractor,代码行数:15,代码来源:MispExtractor.py
示例20: __init__
def __init__(self, misp_key, misp_url, misp_verify_cert, siem_mode=False, debugon=False):
self.misp = PyMISP(misp_url, misp_key, misp_verify_cert, 'json')
self.debugon = debugon
if siem_mode:
self.siem_mode = True
self.separator = ","
self.use_headers = True
self.use_filename_regex = False
开发者ID:453483289,项目名称:signature-base,代码行数:8,代码来源:get-misp-iocs.py
注:本文中的pymisp.PyMISP类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论