index
int64 0
731k
| package
stringlengths 2
98
⌀ | name
stringlengths 1
76
| docstring
stringlengths 0
281k
⌀ | code
stringlengths 4
1.07M
⌀ | signature
stringlengths 2
42.8k
⌀ |
---|---|---|---|---|---|
25,050 | pymisp.api | event_exists | Fast check if event exists.
:param event: Event to check
| def event_exists(self, event: MISPEvent | int | str | UUID) -> bool:
"""Fast check if event exists.
:param event: Event to check
"""
event_id = get_uuid_or_id_from_abstract_misp(event)
r = self._prepare_request('HEAD', f'events/view/{event_id}')
return self._check_head_response(r)
| (self, event: pymisp.mispevent.MISPEvent | int | str | uuid.UUID) -> bool |
25,051 | pymisp.api | events | Get all the events from the MISP instance: https://www.misp-project.org/openapi/#tag/Events/operation/getEvents
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def events(self, pythonify: bool = False) -> dict[str, Any] | list[MISPEvent] | list[dict[str, Any]]:
"""Get all the events from the MISP instance: https://www.misp-project.org/openapi/#tag/Events/operation/getEvents
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
r = self._prepare_request('GET', 'events/index')
events_r = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(events_r, dict):
return events_r
to_return = []
for event in events_r:
e = MISPEvent()
e.from_dict(**event)
to_return.append(e)
return to_return
| (self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPEvent] | list[dict[str, typing.Any]] |
25,052 | pymisp.api | feeds | Get the list of existing feeds: https://www.misp-project.org/openapi/#tag/Feeds/operation/getFeeds
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def feeds(self, pythonify: bool = False) -> dict[str, Any] | list[MISPFeed] | list[dict[str, Any]]:
"""Get the list of existing feeds: https://www.misp-project.org/openapi/#tag/Feeds/operation/getFeeds
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
r = self._prepare_request('GET', 'feeds/index')
feeds = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(feeds, dict):
return feeds
to_return = []
for feed in feeds:
f = MISPFeed()
f.from_dict(**feed)
to_return.append(f)
return to_return
| (self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPFeed] | list[dict[str, typing.Any]] |
25,053 | pymisp.api | fetch_feed | Fetch one single feed by id: https://www.misp-project.org/openapi/#tag/Feeds/operation/fetchFromFeed
:param feed: feed to fetch
| def fetch_feed(self, feed: MISPFeed | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]:
"""Fetch one single feed by id: https://www.misp-project.org/openapi/#tag/Feeds/operation/fetchFromFeed
:param feed: feed to fetch
"""
feed_id = get_uuid_or_id_from_abstract_misp(feed)
response = self._prepare_request('GET', f'feeds/fetchFromFeed/{feed_id}')
return self._check_json_response(response)
| (self, feed: pymisp.mispevent.MISPFeed | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,054 | pymisp.api | fork_galaxy_cluster | Forks an existing galaxy cluster, creating a new one with matching attributes
:param galaxy: The galaxy (or galaxy ID) where the cluster you want to fork resides
:param galaxy_cluster: The galaxy cluster you wish to fork
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def fork_galaxy_cluster(self, galaxy: MISPGalaxy | int | str | UUID, galaxy_cluster: MISPGalaxyCluster, pythonify: bool = False) -> dict[str, Any] | MISPGalaxyCluster:
"""Forks an existing galaxy cluster, creating a new one with matching attributes
:param galaxy: The galaxy (or galaxy ID) where the cluster you want to fork resides
:param galaxy_cluster: The galaxy cluster you wish to fork
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
galaxy_id = get_uuid_or_id_from_abstract_misp(galaxy)
cluster_id = get_uuid_or_id_from_abstract_misp(galaxy_cluster)
# Create a duplicate cluster from the cluster to fork
forked_galaxy_cluster = MISPGalaxyCluster()
forked_galaxy_cluster.from_dict(**galaxy_cluster)
# Set the UUID and version it extends from the existing galaxy cluster
forked_galaxy_cluster.extends_uuid = forked_galaxy_cluster.pop('uuid')
forked_galaxy_cluster.extends_version = forked_galaxy_cluster.pop('version')
r = self._prepare_request('POST', f'galaxy_clusters/add/{galaxy_id}/forkUUID:{cluster_id}', data=galaxy_cluster)
cluster_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in cluster_j:
return cluster_j
gc = MISPGalaxyCluster()
gc.from_dict(**cluster_j)
return gc
| (self, galaxy: pymisp.mispevent.MISPGalaxy | int | str | uuid.UUID, galaxy_cluster: pymisp.mispevent.MISPGalaxyCluster, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPGalaxyCluster |
25,055 | pymisp.api | freetext | Pass a text to the freetext importer
:param event: event
:param string: query
:param adhereToWarninglists: flag
:param distribution: distribution == -1 means recipient decides
:param returnMetaAttributes: flag
:param pythonify: Returns a PyMISP Object instead of the plain json output
:param kwargs: kwargs passed to prepare_request
| def freetext(self, event: MISPEvent | int | str | UUID, string: str, adhereToWarninglists: bool | str = False, # type: ignore[no-untyped-def]
distribution: int | None = None, returnMetaAttributes: bool = False, pythonify: bool = False, **kwargs) -> dict[str, Any] | list[MISPAttribute] | list[dict[str, Any]]:
"""Pass a text to the freetext importer
:param event: event
:param string: query
:param adhereToWarninglists: flag
:param distribution: distribution == -1 means recipient decides
:param returnMetaAttributes: flag
:param pythonify: Returns a PyMISP Object instead of the plain json output
:param kwargs: kwargs passed to prepare_request
"""
event_id = get_uuid_or_id_from_abstract_misp(event)
query: dict[str, Any] = {"value": string}
wl_params = [False, True, 'soft']
if adhereToWarninglists in wl_params:
query['adhereToWarninglists'] = adhereToWarninglists
else:
raise PyMISPError('Invalid parameter, adhereToWarninglists Can only be False, True, or soft')
if distribution is not None:
query['distribution'] = distribution
if returnMetaAttributes:
query['returnMetaAttributes'] = returnMetaAttributes
r = self._prepare_request('POST', f'events/freeTextImport/{event_id}', data=query, **kwargs)
attributes = self._check_json_response(r)
if returnMetaAttributes or not (self.global_pythonify or pythonify) or isinstance(attributes, dict):
return attributes
to_return = []
for attribute in attributes:
a = MISPAttribute()
a.from_dict(**attribute)
to_return.append(a)
return to_return
| (self, event: pymisp.mispevent.MISPEvent | int | str | uuid.UUID, string: str, adhereToWarninglists: bool | str = False, distribution: Optional[int] = None, returnMetaAttributes: bool = False, pythonify: bool = False, **kwargs) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPAttribute] | list[dict[str, typing.Any]] |
25,056 | pymisp.api | galaxies | Get all the galaxies: https://www.misp-project.org/openapi/#tag/Galaxies/operation/getGalaxies
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def galaxies(
self,
withCluster: bool = False,
pythonify: bool = False,
) -> dict[str, Any] | list[MISPGalaxy] | list[dict[str, Any]]:
"""Get all the galaxies: https://www.misp-project.org/openapi/#tag/Galaxies/operation/getGalaxies
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
r = self._prepare_request('GET', 'galaxies/index')
galaxies = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(galaxies, dict):
return galaxies
to_return = []
for galaxy in galaxies:
g = MISPGalaxy()
g.from_dict(**galaxy, withCluster=withCluster)
to_return.append(g)
return to_return
| (self, withCluster: bool = False, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPGalaxy] | list[dict[str, typing.Any]] |
25,057 | pymisp.api | get_all_functions | Get all methods available via the API, including ones that are not implemented. | def get_all_functions(self, not_implemented: bool = False) -> list[str]:
'''Get all methods available via the API, including ones that are not implemented.'''
response = self._prepare_request('GET', 'servers/queryACL/printAllFunctionNames')
functions = self._check_json_response(response)
# Format as URLs
paths = []
for controller, methods in functions.items():
if controller == '*':
continue
for method in methods:
if method.startswith('admin_'):
path = f'admin/{controller}/{method[6:]}'
else:
path = f'{controller}/{method}'
paths.append(path)
if not not_implemented:
return [str(path)]
with open(__file__) as f:
content = f.read()
not_implemented_paths: list[str] = []
for path in paths:
if path not in content:
not_implemented_paths.append(path)
return not_implemented_paths
| (self, not_implemented: bool = False) -> list[str] |
25,058 | pymisp.api | get_attribute | Get an attribute from a MISP instance: https://www.misp-project.org/openapi/#tag/Attributes/operation/getAttributeById
:param attribute: attribute to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_attribute(self, attribute: MISPAttribute | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPAttribute:
"""Get an attribute from a MISP instance: https://www.misp-project.org/openapi/#tag/Attributes/operation/getAttributeById
:param attribute: attribute to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
attribute_id = get_uuid_or_id_from_abstract_misp(attribute)
r = self._prepare_request('GET', f'attributes/view/{attribute_id}')
attribute_r = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in attribute_r:
return attribute_r
a = MISPAttribute()
a.from_dict(**attribute_r)
return a
| (self, attribute: pymisp.mispevent.MISPAttribute | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPAttribute |
25,059 | pymisp.api | get_attribute_proposal | Get an attribute proposal
:param proposal: proposal to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_attribute_proposal(self, proposal: MISPShadowAttribute | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPShadowAttribute:
"""Get an attribute proposal
:param proposal: proposal to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
proposal_id = get_uuid_or_id_from_abstract_misp(proposal)
r = self._prepare_request('GET', f'shadowAttributes/view/{proposal_id}')
attribute_proposal = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in attribute_proposal:
return attribute_proposal
a = MISPShadowAttribute()
a.from_dict(**attribute_proposal)
return a
| (self, proposal: pymisp.mispevent.MISPShadowAttribute | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPShadowAttribute |
25,060 | pymisp.api | get_community | Get a community by id from a MISP instance
:param community: community to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_community(self, community: MISPCommunity | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPCommunity:
"""Get a community by id from a MISP instance
:param community: community to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
community_id = get_uuid_or_id_from_abstract_misp(community)
r = self._prepare_request('GET', f'communities/view/{community_id}')
community_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in community_j:
return community_j
c = MISPCommunity()
c.from_dict(**community_j)
return c
| (self, community: pymisp.mispevent.MISPCommunity | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPCommunity |
25,061 | pymisp.api | get_correlation_exclusion | Get a correlation exclusion by ID
:param correlation_exclusion: Correlation exclusion to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_correlation_exclusion(self, correlation_exclusion: MISPCorrelationExclusion | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPCorrelationExclusion:
"""Get a correlation exclusion by ID
:param correlation_exclusion: Correlation exclusion to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
exclusion_id = get_uuid_or_id_from_abstract_misp(correlation_exclusion)
r = self._prepare_request('GET', f'correlation_exclusions/view/{exclusion_id}')
correlation_exclusion_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in correlation_exclusion_j:
return correlation_exclusion_j
c = MISPCorrelationExclusion()
c.from_dict(**correlation_exclusion_j)
return c
| (self, correlation_exclusion: pymisp.mispevent.MISPCorrelationExclusion | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPCorrelationExclusion |
25,062 | pymisp.api | get_event | Get an event from a MISP instance. Includes collections like
Attribute, EventReport, Feed, Galaxy, Object, Tag, etc. so the
response size may be large : https://www.misp-project.org/openapi/#tag/Events/operation/getEventById
:param event: event to get
:param deleted: whether to include soft-deleted attributes
:param extended: whether to get extended events
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def get_event(self, event: MISPEvent | int | str | UUID,
deleted: bool | int | list[int] = False,
extended: bool | int = False,
pythonify: bool = False) -> dict[str, Any] | MISPEvent:
"""Get an event from a MISP instance. Includes collections like
Attribute, EventReport, Feed, Galaxy, Object, Tag, etc. so the
response size may be large : https://www.misp-project.org/openapi/#tag/Events/operation/getEventById
:param event: event to get
:param deleted: whether to include soft-deleted attributes
:param extended: whether to get extended events
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
event_id = get_uuid_or_id_from_abstract_misp(event)
data = {}
if deleted:
data['deleted'] = deleted
if extended:
data['extended'] = extended
if data:
r = self._prepare_request('POST', f'events/view/{event_id}', data=data)
else:
r = self._prepare_request('GET', f'events/view/{event_id}')
event_r = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in event_r:
return event_r
e = MISPEvent()
e.load(event_r)
return e
| (self, event: pymisp.mispevent.MISPEvent | int | str | uuid.UUID, deleted: bool | int | list[int] = False, extended: bool | int = False, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPEvent |
25,063 | pymisp.api | get_event_report | Get an event report from a MISP instance
:param event_report: event report to get
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def get_event_report(self, event_report: MISPEventReport | int | str | UUID,
pythonify: bool = False) -> dict[str, Any] | MISPEventReport:
"""Get an event report from a MISP instance
:param event_report: event report to get
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
event_report_id = get_uuid_or_id_from_abstract_misp(event_report)
r = self._prepare_request('GET', f'eventReports/view/{event_report_id}')
event_report_r = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in event_report_r:
return event_report_r
er = MISPEventReport()
er.from_dict(**event_report_r)
return er
| (self, event_report: pymisp.mispevent.MISPEventReport | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPEventReport |
25,064 | pymisp.api | get_event_reports | Get event report from a MISP instance that are attached to an event ID
:param event_id: event id to get the event reports for
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output.
| def get_event_reports(self, event_id: int | str,
pythonify: bool = False) -> dict[str, Any] | list[MISPEventReport] | list[dict[str, Any]]:
"""Get event report from a MISP instance that are attached to an event ID
:param event_id: event id to get the event reports for
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output.
"""
r = self._prepare_request('GET', f'eventReports/index/event_id:{event_id}')
event_reports = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(event_reports, dict):
return event_reports
to_return = []
for event_report in event_reports:
er = MISPEventReport()
er.from_dict(**event_report)
to_return.append(er)
return to_return
| (self, event_id: int | str, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPEventReport] | list[dict[str, typing.Any]] |
25,065 | pymisp.api | get_feed | Get a feed by id: https://www.misp-project.org/openapi/#tag/Feeds/operation/getFeedById
:param feed: feed to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_feed(self, feed: MISPFeed | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPFeed:
"""Get a feed by id: https://www.misp-project.org/openapi/#tag/Feeds/operation/getFeedById
:param feed: feed to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
feed_id = get_uuid_or_id_from_abstract_misp(feed)
r = self._prepare_request('GET', f'feeds/view/{feed_id}')
feed_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in feed_j:
return feed_j
f = MISPFeed()
f.from_dict(**feed_j)
return f
| (self, feed: pymisp.mispevent.MISPFeed | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPFeed |
25,066 | pymisp.api | get_galaxy | Get a galaxy by id: https://www.misp-project.org/openapi/#tag/Galaxies/operation/getGalaxyById
:param galaxy: galaxy to get
:param withCluster: Include the clusters associated with the galaxy
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_galaxy(self, galaxy: MISPGalaxy | int | str | UUID, withCluster: bool = False, pythonify: bool = False) -> dict[str, Any] | MISPGalaxy:
"""Get a galaxy by id: https://www.misp-project.org/openapi/#tag/Galaxies/operation/getGalaxyById
:param galaxy: galaxy to get
:param withCluster: Include the clusters associated with the galaxy
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
galaxy_id = get_uuid_or_id_from_abstract_misp(galaxy)
r = self._prepare_request('GET', f'galaxies/view/{galaxy_id}')
galaxy_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in galaxy_j:
return galaxy_j
g = MISPGalaxy()
g.from_dict(**galaxy_j, withCluster=withCluster)
return g
| (self, galaxy: pymisp.mispevent.MISPGalaxy | int | str | uuid.UUID, withCluster: bool = False, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPGalaxy |
25,067 | pymisp.api | get_galaxy_cluster | Gets a specific galaxy cluster
:param galaxy_cluster: The MISPGalaxyCluster you want to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_galaxy_cluster(self, galaxy_cluster: MISPGalaxyCluster | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPGalaxyCluster:
"""Gets a specific galaxy cluster
:param galaxy_cluster: The MISPGalaxyCluster you want to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
cluster_id = get_uuid_or_id_from_abstract_misp(galaxy_cluster)
r = self._prepare_request('GET', f'galaxy_clusters/view/{cluster_id}')
cluster_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in cluster_j:
return cluster_j
gc = MISPGalaxyCluster()
gc.from_dict(**cluster_j)
return gc
| (self, galaxy_cluster: pymisp.mispevent.MISPGalaxyCluster | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPGalaxyCluster |
25,068 | pymisp.api | get_new_authkey | Get a new authorization key for a specific user, defaults to user doing the call: https://www.misp-project.org/openapi/#tag/AuthKeys/operation/addAuthKey
:param user: The owner of the key
| def get_new_authkey(self, user: MISPUser | int | str | UUID = 'me') -> str:
'''Get a new authorization key for a specific user, defaults to user doing the call: https://www.misp-project.org/openapi/#tag/AuthKeys/operation/addAuthKey
:param user: The owner of the key
'''
user_id = get_uuid_or_id_from_abstract_misp(user)
r = self._prepare_request('POST', f'/auth_keys/add/{user_id}', data={})
authkey = self._check_json_response(r)
if 'AuthKey' in authkey and 'authkey_raw' in authkey['AuthKey']:
return authkey['AuthKey']['authkey_raw']
else:
raise PyMISPUnexpectedResponse(f'Unable to get authkey: {authkey}')
| (self, user: pymisp.mispevent.MISPUser | int | str | uuid.UUID = 'me') -> str |
25,069 | pymisp.api | get_noticelist | Get a noticelist by id: https://www.misp-project.org/openapi/#tag/Noticelists/operation/getNoticelistById
:param notistlist: Noticelist to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_noticelist(self, noticelist: MISPNoticelist | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPNoticelist:
"""Get a noticelist by id: https://www.misp-project.org/openapi/#tag/Noticelists/operation/getNoticelistById
:param notistlist: Noticelist to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
noticelist_id = get_uuid_or_id_from_abstract_misp(noticelist)
r = self._prepare_request('GET', f'noticelists/view/{noticelist_id}')
noticelist_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in noticelist_j:
return noticelist_j
n = MISPNoticelist()
n.from_dict(**noticelist_j)
return n
| (self, noticelist: pymisp.mispevent.MISPNoticelist | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPNoticelist |
25,070 | pymisp.api | get_object | Get an object from the remote MISP instance: https://www.misp-project.org/openapi/#tag/Objects/operation/getObjectById
:param misp_object: object to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_object(self, misp_object: MISPObject | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPObject:
"""Get an object from the remote MISP instance: https://www.misp-project.org/openapi/#tag/Objects/operation/getObjectById
:param misp_object: object to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
object_id = get_uuid_or_id_from_abstract_misp(misp_object)
r = self._prepare_request('GET', f'objects/view/{object_id}')
misp_object_r = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in misp_object_r:
return misp_object_r
o = MISPObject(misp_object_r['Object']['name'], standalone=False)
o.from_dict(**misp_object_r)
return o
| (self, misp_object: pymisp.mispevent.MISPObject | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPObject |
25,071 | pymisp.api | get_object_template | Gets the full object template
:param object_template: template or ID to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_object_template(self, object_template: MISPObjectTemplate | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPObjectTemplate:
"""Gets the full object template
:param object_template: template or ID to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
object_template_id = get_uuid_or_id_from_abstract_misp(object_template)
r = self._prepare_request('GET', f'objectTemplates/view/{object_template_id}')
object_template_r = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in object_template_r:
return object_template_r
t = MISPObjectTemplate()
t.from_dict(**object_template_r)
return t
| (self, object_template: pymisp.mispevent.MISPObjectTemplate | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPObjectTemplate |
25,072 | pymisp.api | get_organisation | Get an organisation by id: https://www.misp-project.org/openapi/#tag/Organisations/operation/getOrganisationById
:param organisation: organization to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_organisation(self, organisation: MISPOrganisation | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPOrganisation:
"""Get an organisation by id: https://www.misp-project.org/openapi/#tag/Organisations/operation/getOrganisationById
:param organisation: organization to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
organisation_id = get_uuid_or_id_from_abstract_misp(organisation)
r = self._prepare_request('GET', f'organisations/view/{organisation_id}')
organisation_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in organisation_j:
return organisation_j
o = MISPOrganisation()
o.from_dict(**organisation_j)
return o
| (self, organisation: pymisp.mispevent.MISPOrganisation | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPOrganisation |
25,073 | pymisp.api | get_raw_object_template | Get a row template. It needs to be present on disk on the MISP instance you're connected to.
The response of this method can be passed to MISPObject(<name>, misp_objects_template_custom=<response>)
| def get_raw_object_template(self, uuid_or_name: str) -> dict[str, Any] | list[dict[str, Any]]:
"""Get a row template. It needs to be present on disk on the MISP instance you're connected to.
The response of this method can be passed to MISPObject(<name>, misp_objects_template_custom=<response>)
"""
r = self._prepare_request('GET', f'objectTemplates/getRaw/{uuid_or_name}')
return self._check_json_response(r)
| (self, uuid_or_name: str) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,074 | pymisp.api | get_server_setting | Get a setting from the MISP instance
:param setting: server setting name
| def get_server_setting(self, setting: str) -> dict[str, Any] | list[dict[str, Any]]:
"""Get a setting from the MISP instance
:param setting: server setting name
"""
response = self._prepare_request('GET', f'servers/getSetting/{setting}')
return self._check_json_response(response)
| (self, setting: str) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,075 | pymisp.api | get_sharing_group | Get a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/getSharingGroupById
:param sharing_group: sharing group to find
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_sharing_group(self, sharing_group: MISPSharingGroup | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPSharingGroup:
"""Get a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/getSharingGroupById
:param sharing_group: sharing group to find
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
sharing_group_id = get_uuid_or_id_from_abstract_misp(sharing_group)
r = self._prepare_request('GET', f'sharing_groups/view/{sharing_group_id}')
sharing_group_resp = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in sharing_group_resp:
return sharing_group_resp
s = MISPSharingGroup()
s.from_dict(**sharing_group_resp)
return s
| (self, sharing_group: pymisp.mispevent.MISPSharingGroup | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPSharingGroup |
25,076 | pymisp.api | get_sync_config | Get the sync server config.
WARNING: This method only works if the user calling it is a sync user
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_sync_config(self, pythonify: bool = False) -> dict[str, Any] | MISPServer:
"""Get the sync server config.
WARNING: This method only works if the user calling it is a sync user
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
r = self._prepare_request('GET', 'servers/createSync')
server = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in server:
return server
s = MISPServer()
s.from_dict(**server)
return s
| (self, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPServer |
25,077 | pymisp.api | get_tag | Get a tag by id: https://www.misp-project.org/openapi/#tag/Tags/operation/getTagById
:param tag: tag to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_tag(self, tag: MISPTag | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPTag:
"""Get a tag by id: https://www.misp-project.org/openapi/#tag/Tags/operation/getTagById
:param tag: tag to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
tag_id = get_uuid_or_id_from_abstract_misp(tag)
r = self._prepare_request('GET', f'tags/view/{tag_id}')
tag_r = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in tag_r:
return tag_r
t = MISPTag()
t.from_dict(**tag_r)
return t
| (self, tag: pymisp.abstract.MISPTag | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.abstract.MISPTag |
25,078 | pymisp.api | get_taxonomy | Get a taxonomy by id or namespace from a MISP instance: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/getTaxonomyById
:param taxonomy: taxonomy to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_taxonomy(self, taxonomy: MISPTaxonomy | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPTaxonomy:
"""Get a taxonomy by id or namespace from a MISP instance: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/getTaxonomyById
:param taxonomy: taxonomy to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy)
r = self._prepare_request('GET', f'taxonomies/view/{taxonomy_id}')
taxonomy_r = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in taxonomy_r:
return taxonomy_r
t = MISPTaxonomy()
t.from_dict(**taxonomy_r)
return t
| (self, taxonomy: pymisp.mispevent.MISPTaxonomy | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPTaxonomy |
25,079 | pymisp.api | get_user | Get a user by id: https://www.misp-project.org/openapi/#tag/Users/operation/getUsers
:param user: user to get; `me` means the owner of the API key doing the query
:param pythonify: Returns a PyMISP Object instead of the plain json output
:param expanded: Also returns a MISPRole and a MISPUserSetting. Only taken in account if pythonify is True.
| def get_user(self, user: MISPUser | int | str | UUID = 'me', pythonify: bool = False, expanded: bool = False) -> dict[str, Any] | MISPUser | tuple[MISPUser, MISPRole, list[MISPUserSetting]]:
"""Get a user by id: https://www.misp-project.org/openapi/#tag/Users/operation/getUsers
:param user: user to get; `me` means the owner of the API key doing the query
:param pythonify: Returns a PyMISP Object instead of the plain json output
:param expanded: Also returns a MISPRole and a MISPUserSetting. Only taken in account if pythonify is True.
"""
user_id = get_uuid_or_id_from_abstract_misp(user)
r = self._prepare_request('GET', f'users/view/{user_id}')
user_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in user_j:
return user_j
u = MISPUser()
u.from_dict(**user_j)
if not expanded:
return u
else:
role = MISPRole()
role.from_dict(**user_j['Role'])
usersettings = []
if user_j['UserSetting']:
for name, value in user_j['UserSetting'].items():
us = MISPUserSetting()
us.from_dict(**{'name': name, 'value': value})
usersettings.append(us)
return u, role, usersettings
| (self, user: pymisp.mispevent.MISPUser | int | str | uuid.UUID = 'me', pythonify: bool = False, expanded: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPUser | tuple[pymisp.mispevent.MISPUser, pymisp.mispevent.MISPRole, list[pymisp.mispevent.MISPUserSetting]] |
25,080 | pymisp.api | get_user_setting | Get a user setting: https://www.misp-project.org/openapi/#tag/UserSettings/operation/getUserSettingById
:param user_setting: name of user setting
:param user: user
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_user_setting(self, user_setting: str, user: MISPUser | int | str | UUID | None = None,
pythonify: bool = False) -> dict[str, Any] | MISPUserSetting:
"""Get a user setting: https://www.misp-project.org/openapi/#tag/UserSettings/operation/getUserSettingById
:param user_setting: name of user setting
:param user: user
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
query: dict[str, Any] = {'setting': user_setting}
if user:
query['user_id'] = get_uuid_or_id_from_abstract_misp(user)
response = self._prepare_request('POST', 'userSettings/getSetting', data=query)
user_setting_j = self._check_json_response(response)
if not (self.global_pythonify or pythonify) or 'errors' in user_setting_j:
return user_setting_j
u = MISPUserSetting()
u.from_dict(**user_setting_j)
return u
| (self, user_setting: str, user: Union[pymisp.mispevent.MISPUser, int, str, uuid.UUID, NoneType] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPUserSetting |
25,081 | pymisp.api | get_warninglist | Get a warninglist by id: https://www.misp-project.org/openapi/#tag/Warninglists/operation/getWarninglistById
:param warninglist: warninglist to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def get_warninglist(self, warninglist: MISPWarninglist | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPWarninglist:
"""Get a warninglist by id: https://www.misp-project.org/openapi/#tag/Warninglists/operation/getWarninglistById
:param warninglist: warninglist to get
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
warninglist_id = get_uuid_or_id_from_abstract_misp(warninglist)
r = self._prepare_request('GET', f'warninglists/view/{warninglist_id}')
wl = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in wl:
return wl
w = MISPWarninglist()
w.from_dict(**wl)
return w
| (self, warninglist: pymisp.mispevent.MISPWarninglist | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPWarninglist |
25,082 | pymisp.api | import_server | Import a sync server config received from get_sync_config
:param server: sync server config
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def import_server(self, server: MISPServer, pythonify: bool = False) -> dict[str, Any] | MISPServer:
"""Import a sync server config received from get_sync_config
:param server: sync server config
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
r = self._prepare_request('POST', 'servers/import', data=server)
server_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in server_j:
return server_j
s = MISPServer()
s.from_dict(**server_j)
return s
| (self, server: pymisp.mispevent.MISPServer, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPServer |
25,083 | pymisp.api | load_default_feeds | Load all the default feeds. | def load_default_feeds(self) -> dict[str, Any] | list[dict[str, Any]]:
"""Load all the default feeds."""
response = self._prepare_request('POST', 'feeds/loadDefaultFeeds')
return self._check_json_response(response)
| (self) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,084 | pymisp.api | noticelists | Get all the noticelists: https://www.misp-project.org/openapi/#tag/Noticelists/operation/getNoticelists
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def noticelists(self, pythonify: bool = False) -> dict[str, Any] | list[MISPNoticelist] | list[dict[str, Any]]:
"""Get all the noticelists: https://www.misp-project.org/openapi/#tag/Noticelists/operation/getNoticelists
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
r = self._prepare_request('GET', 'noticelists/index')
noticelists = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(noticelists, dict):
return noticelists
to_return = []
for noticelist in noticelists:
n = MISPNoticelist()
n.from_dict(**noticelist)
to_return.append(n)
return to_return
| (self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPNoticelist] | list[dict[str, typing.Any]] |
25,085 | pymisp.api | object_exists | Fast check if object exists.
:param misp_object: Attribute to check
| def object_exists(self, misp_object: MISPObject | int | str | UUID) -> bool:
"""Fast check if object exists.
:param misp_object: Attribute to check
"""
object_id = get_uuid_or_id_from_abstract_misp(misp_object)
r = self._prepare_request('HEAD', f'objects/view/{object_id}')
return self._check_head_response(r)
| (self, misp_object: pymisp.mispevent.MISPObject | int | str | uuid.UUID) -> bool |
25,086 | pymisp.api | object_templates | Get all the object templates
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def object_templates(self, pythonify: bool = False) -> dict[str, Any] | list[MISPObjectTemplate] | list[dict[str, Any]]:
"""Get all the object templates
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
r = self._prepare_request('GET', 'objectTemplates/index')
templates = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(templates, dict):
return templates
to_return = []
for object_template in templates:
o = MISPObjectTemplate()
o.from_dict(**object_template)
to_return.append(o)
return to_return
| (self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPObjectTemplate] | list[dict[str, typing.Any]] |
25,087 | pymisp.api | organisation_blocklists | Get all the blocklisted organisations
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def organisation_blocklists(self, pythonify: bool = False) -> dict[str, Any] | list[MISPOrganisationBlocklist] | list[dict[str, Any]]:
"""Get all the blocklisted organisations
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
r = self._prepare_request('GET', 'orgBlocklists/index')
organisation_blocklists = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(organisation_blocklists, dict):
return organisation_blocklists
to_return = []
for organisation_blocklist in organisation_blocklists:
obl = MISPOrganisationBlocklist()
obl.from_dict(**organisation_blocklist)
to_return.append(obl)
return to_return
| (self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPOrganisationBlocklist] | list[dict[str, typing.Any]] |
25,088 | pymisp.api | organisation_exists | Fast check if organisation exists.
:param organisation: Organisation to check
| def organisation_exists(self, organisation: MISPOrganisation | int | str | UUID) -> bool:
"""Fast check if organisation exists.
:param organisation: Organisation to check
"""
organisation_id = get_uuid_or_id_from_abstract_misp(organisation)
r = self._prepare_request('HEAD', f'organisations/view/{organisation_id}')
return self._check_head_response(r)
| (self, organisation: pymisp.mispevent.MISPOrganisation | int | str | uuid.UUID) -> bool |
25,089 | pymisp.api | organisations | Get all the organisations: https://www.misp-project.org/openapi/#tag/Organisations/operation/getOrganisations
:param scope: scope of organizations to get
:param search: The search to make against the list of organisations
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def organisations(self, scope: str="local", search: str | None = None, pythonify: bool = False) -> dict[str, Any] | list[MISPOrganisation] | list[dict[str, Any]]:
"""Get all the organisations: https://www.misp-project.org/openapi/#tag/Organisations/operation/getOrganisations
:param scope: scope of organizations to get
:param search: The search to make against the list of organisations
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
url_path = f'organisations/index/scope:{scope}'
if search:
url_path += f"/searchall:{search}"
r = self._prepare_request('GET', url_path)
organisations = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(organisations, dict):
return organisations
to_return = []
for organisation in organisations:
o = MISPOrganisation()
o.from_dict(**organisation)
to_return.append(o)
return to_return
| (self, scope: str = 'local', search: Optional[str] = None, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPOrganisation] | list[dict[str, typing.Any]] |
25,090 | pymisp.api | publish | Publish the event with one single HTTP POST: https://www.misp-project.org/openapi/#tag/Events/operation/publishEvent
:param event: event to publish
:param alert: whether to send an email. The default is to not send a mail as it is assumed this method is called on update.
| def publish(self, event: MISPEvent | int | str | UUID, alert: bool = False) -> dict[str, Any] | list[dict[str, Any]]:
"""Publish the event with one single HTTP POST: https://www.misp-project.org/openapi/#tag/Events/operation/publishEvent
:param event: event to publish
:param alert: whether to send an email. The default is to not send a mail as it is assumed this method is called on update.
"""
event_id = get_uuid_or_id_from_abstract_misp(event)
if alert:
response = self._prepare_request('POST', f'events/alert/{event_id}')
else:
response = self._prepare_request('POST', f'events/publish/{event_id}')
return self._check_json_response(response)
| (self, event: pymisp.mispevent.MISPEvent | int | str | uuid.UUID, alert: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,091 | pymisp.api | publish_galaxy_cluster | Publishes a galaxy cluster: https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/publishGalaxyCluster
:param galaxy_cluster: The galaxy cluster you wish to publish
| def publish_galaxy_cluster(self, galaxy_cluster: MISPGalaxyCluster | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]:
"""Publishes a galaxy cluster: https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/publishGalaxyCluster
:param galaxy_cluster: The galaxy cluster you wish to publish
"""
if isinstance(galaxy_cluster, MISPGalaxyCluster) and getattr(galaxy_cluster, "default", False):
raise PyMISPError('You are not able to publish a default galaxy cluster')
cluster_id = get_uuid_or_id_from_abstract_misp(galaxy_cluster)
r = self._prepare_request('POST', f'galaxy_clusters/publish/{cluster_id}')
response = self._check_json_response(r)
return response
| (self, galaxy_cluster: pymisp.mispevent.MISPGalaxyCluster | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,092 | pymisp.api | push_event_to_ZMQ | Force push an event by id on ZMQ
:param event: the event to push
| def push_event_to_ZMQ(self, event: MISPEvent | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]:
"""Force push an event by id on ZMQ
:param event: the event to push
"""
event_id = get_uuid_or_id_from_abstract_misp(event)
response = self._prepare_request('POST', f'events/pushEventToZMQ/{event_id}.json')
return self._check_json_response(response)
| (self, event: pymisp.mispevent.MISPEvent | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,093 | pymisp.api | remote_acl | This should return an empty list, unless the ACL is outdated.
:param debug_type: printAllFunctionNames, findMissingFunctionNames, or printRoleAccess
| def remote_acl(self, debug_type: str = 'findMissingFunctionNames') -> dict[str, Any] | list[dict[str, Any]]:
"""This should return an empty list, unless the ACL is outdated.
:param debug_type: printAllFunctionNames, findMissingFunctionNames, or printRoleAccess
"""
response = self._prepare_request('GET', f'events/queryACL/{debug_type}')
return self._check_json_response(response)
| (self, debug_type: str = 'findMissingFunctionNames') -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,094 | pymisp.api | remove_org_from_sharing_group | Remove an organisation from a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/removeOrganisationFromSharingGroup
:param sharing_group: Sharing group's local instance ID, or Sharing group's global UUID
:param organisation: Organisation's local instance ID, or Organisation's global UUID, or Organisation's name as known to the curent instance
| def remove_org_from_sharing_group(self, sharing_group: MISPSharingGroup | int | str | UUID,
organisation: MISPOrganisation | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]:
'''Remove an organisation from a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/removeOrganisationFromSharingGroup
:param sharing_group: Sharing group's local instance ID, or Sharing group's global UUID
:param organisation: Organisation's local instance ID, or Organisation's global UUID, or Organisation's name as known to the curent instance
'''
sharing_group_id = get_uuid_or_id_from_abstract_misp(sharing_group)
organisation_id = get_uuid_or_id_from_abstract_misp(organisation)
to_jsonify = {'sg_id': sharing_group_id, 'org_id': organisation_id}
response = self._prepare_request('POST', 'sharingGroups/removeOrg', data=to_jsonify)
return self._check_json_response(response)
| (self, sharing_group: pymisp.mispevent.MISPSharingGroup | int | str | uuid.UUID, organisation: pymisp.mispevent.MISPOrganisation | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,095 | pymisp.api | remove_server_from_sharing_group | Remove a server from a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/removeServerFromSharingGroup
:param sharing_group: Sharing group's local instance ID, or Sharing group's global UUID
:param server: Server's local instance ID, or URL of the Server, or Server's name as known to the curent instance
| def remove_server_from_sharing_group(self, sharing_group: MISPSharingGroup | int | str | UUID,
server: MISPServer | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]:
'''Remove a server from a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/removeServerFromSharingGroup
:param sharing_group: Sharing group's local instance ID, or Sharing group's global UUID
:param server: Server's local instance ID, or URL of the Server, or Server's name as known to the curent instance
'''
sharing_group_id = get_uuid_or_id_from_abstract_misp(sharing_group)
server_id = get_uuid_or_id_from_abstract_misp(server)
to_jsonify = {'sg_id': sharing_group_id, 'server_id': server_id}
response = self._prepare_request('POST', 'sharingGroups/removeServer', data=to_jsonify)
return self._check_json_response(response)
| (self, sharing_group: pymisp.mispevent.MISPSharingGroup | int | str | uuid.UUID, server: pymisp.mispevent.MISPServer | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,096 | pymisp.api | request_community_access | Request the access to a community
:param community: community to request access
:param requestor_email_address: requestor email
:param requestor_gpg_key: requestor key
:param requestor_organisation_name: requestor org name
:param requestor_organisation_uuid: requestor org ID
:param requestor_organisation_description: requestor org desc
:param message: requestor message
:param sync: synchronize flag
:param anonymise_requestor_server: anonymise flag
:param mock: mock flag
| def request_community_access(self, community: MISPCommunity | int | str | UUID,
requestor_email_address: str | None = None,
requestor_gpg_key: str | None = None,
requestor_organisation_name: str | None = None,
requestor_organisation_uuid: str | None = None,
requestor_organisation_description: str | None = None,
message: str | None = None, sync: bool = False,
anonymise_requestor_server: bool = False,
mock: bool = False) -> dict[str, Any] | list[dict[str, Any]]:
"""Request the access to a community
:param community: community to request access
:param requestor_email_address: requestor email
:param requestor_gpg_key: requestor key
:param requestor_organisation_name: requestor org name
:param requestor_organisation_uuid: requestor org ID
:param requestor_organisation_description: requestor org desc
:param message: requestor message
:param sync: synchronize flag
:param anonymise_requestor_server: anonymise flag
:param mock: mock flag
"""
community_id = get_uuid_or_id_from_abstract_misp(community)
to_post = {'org_name': requestor_organisation_name,
'org_uuid': requestor_organisation_uuid,
'org_description': requestor_organisation_description,
'email': requestor_email_address, 'gpgkey': requestor_gpg_key,
'message': message, 'anonymise': anonymise_requestor_server, 'sync': sync,
'mock': mock}
r = self._prepare_request('POST', f'communities/requestAccess/{community_id}', data=to_post)
return self._check_json_response(r)
| (self, community: pymisp.mispevent.MISPCommunity | int | str | uuid.UUID, requestor_email_address: Optional[str] = None, requestor_gpg_key: Optional[str] = None, requestor_organisation_name: Optional[str] = None, requestor_organisation_uuid: Optional[str] = None, requestor_organisation_description: Optional[str] = None, message: Optional[str] = None, sync: bool = False, anonymise_requestor_server: bool = False, mock: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,097 | pymisp.api | restart_workers | Restart all the workers | def restart_workers(self) -> dict[str, Any] | list[dict[str, Any]]:
"""Restart all the workers"""
response = self._prepare_request('POST', 'servers/restartWorkers')
return self._check_json_response(response)
| (self) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,098 | pymisp.api | restore_attribute | Restore a soft deleted attribute from a MISP instance: https://www.misp-project.org/openapi/#tag/Attributes/operation/restoreAttribute
:param attribute: attribute to restore
| def restore_attribute(self, attribute: MISPAttribute | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPAttribute:
"""Restore a soft deleted attribute from a MISP instance: https://www.misp-project.org/openapi/#tag/Attributes/operation/restoreAttribute
:param attribute: attribute to restore
"""
attribute_id = get_uuid_or_id_from_abstract_misp(attribute)
r = self._prepare_request('POST', f'attributes/restore/{attribute_id}')
response = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in response:
return response
a = MISPAttribute()
a.from_dict(**response)
return a
| (self, attribute: pymisp.mispevent.MISPAttribute | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPAttribute |
25,099 | pymisp.api | roles | Get the existing roles
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def roles(self, pythonify: bool = False) -> dict[str, Any] | list[MISPRole] | list[dict[str, Any]]:
"""Get the existing roles
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
r = self._prepare_request('GET', 'roles/index')
roles = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(roles, dict):
return roles
to_return = []
for role in roles:
nr = MISPRole()
nr.from_dict(**role)
to_return.append(nr)
return to_return
| (self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPRole] | list[dict[str, typing.Any]] |
25,100 | pymisp.api | search | Search in the MISP instance
:param controller: Controller to search on, it can be `events`, `objects`, `attributes`. The response will either be a list of events, objects, or attributes.
Reference documentation for each controller:
* events: https://www.misp-project.org/openapi/#tag/Events/operation/restSearchEvents
* attributes: https://www.misp-project.org/openapi/#tag/Attributes/operation/restSearchAttributes
* objects: N/A
:param return_format: Set the return format of the search (Currently supported: json, xml, openioc, suricata, snort - more formats are being moved to restSearch with the goal being that all searches happen through this API). Can be passed as the first parameter after restSearch or via the JSON payload.
:param limit: Limit the number of results returned, depending on the scope (for example 10 attributes or 10 full events).
:param page: If a limit is set, sets the page to be returned. page 3, limit 100 will return records 201->300).
:param value: Search for the given value in the attributes' value field.
:param type_attribute: The attribute type, any valid MISP attribute type is accepted.
:param category: The attribute category, any valid MISP attribute category is accepted.
:param org: Search by the creator organisation by supplying the organisation identifier.
:param tags: Tags to search or to exclude. You can pass a list, or the output of `build_complex_query`
:param event_tags: Tags to search or to exclude at the event level. You can pass a list, or the output of `build_complex_query`
:param quick_filter: The string passed to this field will ignore all of the other arguments. MISP will return an xml / json (depending on the header sent) of all events that have a sub-string match on value in the event info, event orgc, or any of the attribute value1 / value2 fields, or in the attribute comment.
:param date_from: Events with the date set to a date after the one specified. This filter will use the date of the event.
:param date_to: Events with the date set to a date before the one specified. This filter will use the date of the event.
:param eventid: The events that should be included / excluded from the search
:param with_attachments: If set, encodes the attachments / zipped malware samples as base64 in the data field within each attribute
:param metadata: Only the metadata (event, tags, relations) is returned, attributes and proposals are omitted.
:param uuid: Restrict the results by uuid.
:param publish_timestamp: Restrict the results by the last publish timestamp (newer than).
:param timestamp: Restrict the results by the timestamp (last edit). Any event with a timestamp newer than the given timestamp will be returned. In case you are dealing with /attributes as scope, the attribute's timestamp will be used for the lookup. The input can be a timestamp or a short-hand time description (7d or 24h for example). You can also pass a list with two values to set a time range (for example ["14d", "7d"]).
:param published: Set whether published or unpublished events should be returned. Do not set the parameter if you want both.
:param enforce_warninglist: Remove any attributes from the result that would cause a hit on a warninglist entry.
:param to_ids: By default all attributes are returned that match the other filter parameters, regardless of their to_ids setting. To restrict the returned data set to to_ids only attributes set this parameter to 1. 0 for the ones with to_ids set to False.
:param deleted: If this parameter is set to 1, it will only return soft-deleted attributes. ["0", "1"] will return the active ones as well as the soft-deleted ones.
:param include_event_uuid: Instead of just including the event ID, also include the event UUID in each of the attributes.
:param include_event_tags: Include the event level tags in each of the attributes.
:param event_timestamp: Only return attributes from events that have received a modification after the given timestamp.
:param sg_reference_only: If this flag is set, sharing group objects will not be included, instead only the sharing group ID is set.
:param eventinfo: Filter on the event's info field.
:param searchall: Search for a full or a substring (delimited by % for substrings) in the event info, event tags, attribute tags, attribute values or attribute comment fields.
:param requested_attributes: [CSV only] Select the fields that you wish to include in the CSV export. By setting event level fields additionally, includeContext is not required to get event metadata.
:param include_context: [Attribute only] Include the event data with each attribute. [CSV output] Add event level metadata in every line of the CSV.
:param headerless: [CSV Only] The CSV created when this setting is set to true will not contain the header row.
:param include_sightings: [JSON Only - Attribute] Include the sightings of the matching attributes.
:param include_decay_score: Include the decay score at attribute level.
:param include_correlations: [JSON Only - attribute] Include the correlations of the matching attributes.
:param object_name: [objects controller only] Search for objects with that name
:param exclude_decayed: [attributes controller only] Exclude the decayed attributes from the response
:param sharinggroup: Filter by sharing group ID(s)
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
Deprecated:
:param quickFilter: synonym for quick_filter
:param withAttachments: synonym for with_attachments
:param last: synonym for publish_timestamp
:param enforceWarninglist: synonym for enforce_warninglist
:param includeEventUuid: synonym for include_event_uuid
:param includeEventTags: synonym for include_event_tags
:param includeContext: synonym for include_context
| def search(self, controller: str = 'events', return_format: str = 'json', # type: ignore[no-untyped-def]
limit: int | None = None, page: int | None = None,
value: SearchParameterTypes | None = None,
type_attribute: SearchParameterTypes | None = None,
category: SearchParameterTypes | None = None,
org: SearchParameterTypes | None = None,
tags: SearchParameterTypes | None = None,
event_tags: SearchParameterTypes | None = None,
quick_filter: str | None = None, quickFilter: str | None = None,
date_from: datetime | date | int | str | float | None | None = None,
date_to: datetime | date | int | str | float | None | None = None,
eventid: SearchType | None = None,
with_attachments: bool | None = None, withAttachments: bool | None = None,
metadata: bool | None = None,
uuid: str | None = None,
publish_timestamp: None | (datetime | date | int | str | float | None
| tuple[datetime | date | int | str | float | None,
datetime | date | int | str | float | None]
) = None,
last: None | (datetime | date | int | str | float | None
| tuple[datetime | date | int | str | float | None,
datetime | date | int | str | float | None]
) = None,
timestamp: None | (datetime | date | int | str | float | None
| tuple[datetime | date | int | str | float | None,
datetime | date | int | str | float | None]
) = None,
published: bool | None = None,
enforce_warninglist: bool | None = None, enforceWarninglist: bool | None = None,
to_ids: ToIDSType | list[ToIDSType] | None = None,
deleted: str | None = None,
include_event_uuid: bool | None = None, includeEventUuid: bool | None = None,
include_event_tags: bool | None = None, includeEventTags: bool | None = None,
event_timestamp: datetime | date | int | str | float | None | None = None,
sg_reference_only: bool | None = None,
eventinfo: str | None = None,
searchall: bool | None = None,
requested_attributes: str | None = None,
include_context: bool | None = None, includeContext: bool | None = None,
headerless: bool | None = None,
include_sightings: bool | None = None, includeSightings: bool | None = None,
include_correlations: bool | None = None, includeCorrelations: bool | None = None,
include_decay_score: bool | None = None, includeDecayScore: bool | None = None,
object_name: str | None = None,
exclude_decayed: bool | None = None,
sharinggroup: int | list[int] | None = None,
pythonify: bool | None = False,
**kwargs) -> dict[str, Any] | str | list[MISPEvent | MISPAttribute | MISPObject] | list[dict[str, Any]]:
'''Search in the MISP instance
:param controller: Controller to search on, it can be `events`, `objects`, `attributes`. The response will either be a list of events, objects, or attributes.
Reference documentation for each controller:
* events: https://www.misp-project.org/openapi/#tag/Events/operation/restSearchEvents
* attributes: https://www.misp-project.org/openapi/#tag/Attributes/operation/restSearchAttributes
* objects: N/A
:param return_format: Set the return format of the search (Currently supported: json, xml, openioc, suricata, snort - more formats are being moved to restSearch with the goal being that all searches happen through this API). Can be passed as the first parameter after restSearch or via the JSON payload.
:param limit: Limit the number of results returned, depending on the scope (for example 10 attributes or 10 full events).
:param page: If a limit is set, sets the page to be returned. page 3, limit 100 will return records 201->300).
:param value: Search for the given value in the attributes' value field.
:param type_attribute: The attribute type, any valid MISP attribute type is accepted.
:param category: The attribute category, any valid MISP attribute category is accepted.
:param org: Search by the creator organisation by supplying the organisation identifier.
:param tags: Tags to search or to exclude. You can pass a list, or the output of `build_complex_query`
:param event_tags: Tags to search or to exclude at the event level. You can pass a list, or the output of `build_complex_query`
:param quick_filter: The string passed to this field will ignore all of the other arguments. MISP will return an xml / json (depending on the header sent) of all events that have a sub-string match on value in the event info, event orgc, or any of the attribute value1 / value2 fields, or in the attribute comment.
:param date_from: Events with the date set to a date after the one specified. This filter will use the date of the event.
:param date_to: Events with the date set to a date before the one specified. This filter will use the date of the event.
:param eventid: The events that should be included / excluded from the search
:param with_attachments: If set, encodes the attachments / zipped malware samples as base64 in the data field within each attribute
:param metadata: Only the metadata (event, tags, relations) is returned, attributes and proposals are omitted.
:param uuid: Restrict the results by uuid.
:param publish_timestamp: Restrict the results by the last publish timestamp (newer than).
:param timestamp: Restrict the results by the timestamp (last edit). Any event with a timestamp newer than the given timestamp will be returned. In case you are dealing with /attributes as scope, the attribute's timestamp will be used for the lookup. The input can be a timestamp or a short-hand time description (7d or 24h for example). You can also pass a list with two values to set a time range (for example ["14d", "7d"]).
:param published: Set whether published or unpublished events should be returned. Do not set the parameter if you want both.
:param enforce_warninglist: Remove any attributes from the result that would cause a hit on a warninglist entry.
:param to_ids: By default all attributes are returned that match the other filter parameters, regardless of their to_ids setting. To restrict the returned data set to to_ids only attributes set this parameter to 1. 0 for the ones with to_ids set to False.
:param deleted: If this parameter is set to 1, it will only return soft-deleted attributes. ["0", "1"] will return the active ones as well as the soft-deleted ones.
:param include_event_uuid: Instead of just including the event ID, also include the event UUID in each of the attributes.
:param include_event_tags: Include the event level tags in each of the attributes.
:param event_timestamp: Only return attributes from events that have received a modification after the given timestamp.
:param sg_reference_only: If this flag is set, sharing group objects will not be included, instead only the sharing group ID is set.
:param eventinfo: Filter on the event's info field.
:param searchall: Search for a full or a substring (delimited by % for substrings) in the event info, event tags, attribute tags, attribute values or attribute comment fields.
:param requested_attributes: [CSV only] Select the fields that you wish to include in the CSV export. By setting event level fields additionally, includeContext is not required to get event metadata.
:param include_context: [Attribute only] Include the event data with each attribute. [CSV output] Add event level metadata in every line of the CSV.
:param headerless: [CSV Only] The CSV created when this setting is set to true will not contain the header row.
:param include_sightings: [JSON Only - Attribute] Include the sightings of the matching attributes.
:param include_decay_score: Include the decay score at attribute level.
:param include_correlations: [JSON Only - attribute] Include the correlations of the matching attributes.
:param object_name: [objects controller only] Search for objects with that name
:param exclude_decayed: [attributes controller only] Exclude the decayed attributes from the response
:param sharinggroup: Filter by sharing group ID(s)
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
Deprecated:
:param quickFilter: synonym for quick_filter
:param withAttachments: synonym for with_attachments
:param last: synonym for publish_timestamp
:param enforceWarninglist: synonym for enforce_warninglist
:param includeEventUuid: synonym for include_event_uuid
:param includeEventTags: synonym for include_event_tags
:param includeContext: synonym for include_context
'''
return_formats = ('openioc', 'json', 'xml', 'suricata', 'snort', 'text', 'rpz', 'csv', 'cache', 'stix-xml',
'stix', 'stix2', 'yara', 'yara-json', 'attack', 'attack-sightings', 'context', 'context-markdown')
if controller not in ('events', 'attributes', 'objects'):
raise ValueError('controller has to be in {}'.format(', '.join(['events', 'attributes', 'objects'])))
# Deprecated stuff / synonyms
if quickFilter is not None:
quick_filter = quickFilter
if withAttachments is not None:
with_attachments = withAttachments
if last is not None:
publish_timestamp = last
if enforceWarninglist is not None:
enforce_warninglist = enforceWarninglist
if includeEventUuid is not None:
include_event_uuid = includeEventUuid
if includeEventTags is not None:
include_event_tags = includeEventTags
if includeContext is not None:
include_context = includeContext
if includeDecayScore is not None:
include_decay_score = includeDecayScore
if includeCorrelations is not None:
include_correlations = includeCorrelations
if includeSightings is not None:
include_sightings = includeSightings
# Add all the parameters in kwargs are aimed at modules, or other 3rd party components, and cannot be sanitized.
# They are passed as-is.
query = kwargs
if return_format not in return_formats:
raise ValueError('return_format has to be in {}'.format(', '.join(return_formats)))
if return_format == 'stix-xml':
query['returnFormat'] = 'stix'
else:
query['returnFormat'] = return_format
query['page'] = page
query['limit'] = limit
query['value'] = value
query['type'] = type_attribute
query['category'] = category
query['org'] = org
query['tags'] = tags
query['event_tags'] = event_tags
query['quickFilter'] = quick_filter
query['from'] = self._make_timestamp(date_from)
query['to'] = self._make_timestamp(date_to)
query['eventid'] = eventid
query['withAttachments'] = self._make_misp_bool(with_attachments)
query['metadata'] = self._make_misp_bool(metadata)
query['uuid'] = uuid
if publish_timestamp is not None:
if isinstance(publish_timestamp, (list, tuple)):
query['publish_timestamp'] = (self._make_timestamp(publish_timestamp[0]), self._make_timestamp(publish_timestamp[1]))
else:
query['publish_timestamp'] = self._make_timestamp(publish_timestamp)
if timestamp is not None:
if isinstance(timestamp, (list, tuple)):
query['timestamp'] = (self._make_timestamp(timestamp[0]), self._make_timestamp(timestamp[1]))
else:
query['timestamp'] = self._make_timestamp(timestamp)
query['published'] = published
query['enforceWarninglist'] = self._make_misp_bool(enforce_warninglist)
if to_ids is not None:
if to_ids not in [0, 1, '0', '1']:
raise ValueError('to_ids has to be in 0 or 1')
query['to_ids'] = to_ids
query['deleted'] = deleted
query['includeEventUuid'] = self._make_misp_bool(include_event_uuid)
query['includeEventTags'] = self._make_misp_bool(include_event_tags)
if event_timestamp is not None:
if isinstance(event_timestamp, (list, tuple)):
query['event_timestamp'] = (self._make_timestamp(event_timestamp[0]), self._make_timestamp(event_timestamp[1]))
else:
query['event_timestamp'] = self._make_timestamp(event_timestamp)
query['sgReferenceOnly'] = self._make_misp_bool(sg_reference_only)
query['eventinfo'] = eventinfo
query['searchall'] = searchall
query['requested_attributes'] = requested_attributes
query['includeContext'] = self._make_misp_bool(include_context)
query['headerless'] = self._make_misp_bool(headerless)
query['includeSightings'] = self._make_misp_bool(include_sightings)
query['includeDecayScore'] = self._make_misp_bool(include_decay_score)
query['includeCorrelations'] = self._make_misp_bool(include_correlations)
query['object_name'] = object_name
query['excludeDecayed'] = self._make_misp_bool(exclude_decayed)
query['sharinggroup'] = sharinggroup
url = urljoin(self.root_url, f'{controller}/restSearch')
if return_format == 'stix-xml':
response = self._prepare_request('POST', url, data=query, output_type='xml')
else:
response = self._prepare_request('POST', url, data=query)
if return_format == 'csv':
normalized_response_text = self._check_response(response)
if (self.global_pythonify or pythonify) and not headerless:
return self._csv_to_dict(normalized_response_text) # type: ignore
else:
return normalized_response_text
elif return_format not in ['json', 'yara-json']:
return self._check_response(response)
normalized_response: list[dict[str, Any]] | dict[str, Any]
if controller in ['events', 'objects']:
# This one is truly fucked: event returns a list, attributes doesn't.
normalized_response = self._check_json_response(response)
elif controller == 'attributes':
normalized_response = self._check_json_response(response)
if 'errors' in normalized_response:
return normalized_response
if return_format == 'json' and self.global_pythonify or pythonify:
# The response is in json, we can convert it to a list of pythonic MISP objects
to_return: list[MISPEvent | MISPAttribute | MISPObject] = []
if controller == 'events':
if isinstance(normalized_response, dict):
return normalized_response
for e in normalized_response:
me = MISPEvent()
me.load(e)
to_return.append(me)
elif controller == 'attributes':
# FIXME: obvs, this is hurting my soul. We need something generic.
for a in normalized_response['Attribute']: # type: ignore[call-overload]
ma = MISPAttribute()
ma.from_dict(**a)
if 'Event' in ma:
me = MISPEvent()
me.from_dict(**ma.Event)
ma.Event = me
if 'RelatedAttribute' in ma:
related_attributes = []
for ra in ma.RelatedAttribute:
r_attribute = MISPAttribute()
r_attribute.from_dict(**ra)
if 'Event' in r_attribute:
me = MISPEvent()
me.from_dict(**r_attribute.Event)
r_attribute.Event = me
related_attributes.append(r_attribute)
ma.RelatedAttribute = related_attributes
if 'Sighting' in ma:
sightings = []
for sighting in ma.Sighting:
s = MISPSighting()
s.from_dict(**sighting)
sightings.append(s)
ma.Sighting = sightings
to_return.append(ma)
elif controller == 'objects':
if isinstance(normalized_response, dict):
return normalized_response
for o in normalized_response:
mo = MISPObject(o['Object']['name'])
mo.from_dict(**o)
to_return.append(mo)
return to_return
return normalized_response
| (self, controller: str = 'events', return_format: str = 'json', limit: Optional[int] = None, page: Optional[int] = None, value: Optional[~SearchParameterTypes] = None, type_attribute: Optional[~SearchParameterTypes] = None, category: Optional[~SearchParameterTypes] = None, org: Optional[~SearchParameterTypes] = None, tags: Optional[~SearchParameterTypes] = None, event_tags: Optional[~SearchParameterTypes] = None, quick_filter: Optional[str] = None, quickFilter: Optional[str] = None, date_from: Union[datetime.datetime, datetime.date, int, str, float, NoneType] = None, date_to: Union[datetime.datetime, datetime.date, int, str, float, NoneType] = None, eventid: Optional[~SearchType] = None, with_attachments: Optional[bool] = None, withAttachments: Optional[bool] = None, metadata: Optional[bool] = None, uuid: Optional[str] = None, publish_timestamp: Union[NoneType, datetime.datetime, datetime.date, int, str, float, tuple[datetime.datetime | datetime.date | int | str | float | None, datetime.datetime | datetime.date | int | str | float | None]] = None, last: Union[NoneType, datetime.datetime, datetime.date, int, str, float, tuple[datetime.datetime | datetime.date | int | str | float | None, datetime.datetime | datetime.date | int | str | float | None]] = None, timestamp: Union[NoneType, datetime.datetime, datetime.date, int, str, float, tuple[datetime.datetime | datetime.date | int | str | float | None, datetime.datetime | datetime.date | int | str | float | None]] = None, published: Optional[bool] = None, enforce_warninglist: Optional[bool] = None, enforceWarninglist: Optional[bool] = None, to_ids: Union[~ToIDSType, list[~ToIDSType], NoneType] = None, deleted: Optional[str] = None, include_event_uuid: Optional[bool] = None, includeEventUuid: Optional[bool] = None, include_event_tags: Optional[bool] = None, includeEventTags: Optional[bool] = None, event_timestamp: Union[datetime.datetime, datetime.date, int, str, float, NoneType] = None, sg_reference_only: Optional[bool] = None, eventinfo: Optional[str] = None, searchall: Optional[bool] = None, requested_attributes: Optional[str] = None, include_context: Optional[bool] = None, includeContext: Optional[bool] = None, headerless: Optional[bool] = None, include_sightings: Optional[bool] = None, includeSightings: Optional[bool] = None, include_correlations: Optional[bool] = None, includeCorrelations: Optional[bool] = None, include_decay_score: Optional[bool] = None, includeDecayScore: Optional[bool] = None, object_name: Optional[str] = None, exclude_decayed: Optional[bool] = None, sharinggroup: Union[int, list[int], NoneType] = None, pythonify: bool | None = False, **kwargs) -> dict[str, typing.Any] | str | list[pymisp.mispevent.MISPEvent | pymisp.mispevent.MISPAttribute | pymisp.mispevent.MISPObject] | list[dict[str, typing.Any]] |
25,101 | pymisp.api | search_feeds | Search in the feeds cached on the servers | def search_feeds(self, value: SearchParameterTypes | None = None, pythonify: bool | None = False) -> dict[str, Any] | list[MISPFeed] | list[dict[str, Any]]:
'''Search in the feeds cached on the servers'''
response = self._prepare_request('POST', 'feeds/searchCaches', data={'value': value})
normalized_response = self._check_json_response(response)
if not (self.global_pythonify or pythonify) or isinstance(normalized_response, dict):
return normalized_response
to_return = []
for feed in normalized_response:
f = MISPFeed()
f.from_dict(**feed)
to_return.append(f)
return to_return
| (self, value: Optional[~SearchParameterTypes] = None, pythonify: bool | None = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPFeed] | list[dict[str, typing.Any]] |
25,102 | pymisp.api | search_galaxy | Text search to find a matching galaxy name, namespace, description, or uuid. | def search_galaxy(
self,
value: str,
withCluster: bool = False,
pythonify: bool = False,
) -> dict[str, Any] | list[MISPGalaxy] | list[dict[str, Any]]:
"""Text search to find a matching galaxy name, namespace, description, or uuid."""
r = self._prepare_request("POST", "galaxies", data={"value": value})
galaxies = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(galaxies, dict):
return galaxies
to_return = []
for galaxy in galaxies:
g = MISPGalaxy()
g.from_dict(**galaxy, withCluster=withCluster)
to_return.append(g)
return to_return
| (self, value: str, withCluster: bool = False, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPGalaxy] | list[dict[str, typing.Any]] |
25,103 | pymisp.api | search_galaxy_clusters | Searches the galaxy clusters within a specific galaxy: https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/getGalaxyClusters and https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/getGalaxyClusterById
:param galaxy: The MISPGalaxy you wish to search in
:param context: The context of how you want to search within the galaxy_
:param searchall: The search you want to make against the galaxy and context
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def search_galaxy_clusters(self, galaxy: MISPGalaxy | int | str | UUID, context: str = "all", searchall: str | None = None, pythonify: bool = False) -> dict[str, Any] | list[MISPGalaxyCluster] | list[dict[str, Any]]:
"""Searches the galaxy clusters within a specific galaxy: https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/getGalaxyClusters and https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/getGalaxyClusterById
:param galaxy: The MISPGalaxy you wish to search in
:param context: The context of how you want to search within the galaxy_
:param searchall: The search you want to make against the galaxy and context
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
galaxy_id = get_uuid_or_id_from_abstract_misp(galaxy)
allowed_context_types: list[str] = ["all", "default", "custom", "org", "deleted"]
if context not in allowed_context_types:
raise PyMISPError(f"The context must be one of {', '.join(allowed_context_types)}")
kw_params = {"context": context}
if searchall:
kw_params["searchall"] = searchall
r = self._prepare_request('POST', f"galaxy_clusters/index/{galaxy_id}", data=kw_params)
clusters_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(clusters_j, dict):
return clusters_j
response = []
for cluster in clusters_j:
c = MISPGalaxyCluster()
c.from_dict(**cluster)
response.append(c)
return response
| (self, galaxy: pymisp.mispevent.MISPGalaxy | int | str | uuid.UUID, context: str = 'all', searchall: Optional[str] = None, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPGalaxyCluster] | list[dict[str, typing.Any]] |
25,104 | pymisp.api | search_index | Search event metadata shown on the event index page. Using ! in front of a value
means NOT, except for parameters date_from, date_to and timestamp which cannot be negated.
Criteria are AND-ed together; values in lists are OR-ed together. Return matching events
with metadata but no attributes or objects; also see minimal parameter.
:param all: Search for a full or a substring (delimited by % for substrings) in the
event info, event tags, attribute tags, attribute values or attribute comment fields.
:param attribute: Filter on attribute's value.
:param email: Filter on user's email.
:param published: Set whether published or unpublished events should be returned.
Do not set the parameter if you want both.
:param hasproposal: Filter for events containing proposal(s).
:param eventid: The events that should be included / excluded from the search
:param tags: Tags to search or to exclude. You can pass a list, or the output of
`build_complex_query`
:param date_from: Events with the date set to a date after the one specified.
This filter will use the date of the event.
:param date_to: Events with the date set to a date before the one specified.
This filter will use the date of the event.
:param eventinfo: Filter on the event's info field.
:param threatlevel: Threat level(s) (1,2,3,4) | list
:param distribution: Distribution level(s) (0,1,2,3) | list
:param analysis: Analysis level(s) (0,1,2) | list
:param org: Search by the creator organisation by supplying the organisation identifier.
:param timestamp: Restrict the results by the timestamp (last edit). Any event with a
timestamp newer than the given timestamp will be returned. In case you are dealing
with /attributes as scope, the attribute's timestamp will be used for the lookup.
:param publish_timestamp: Filter on event's publish timestamp.
:param sharinggroup: Restrict by a sharing group | list
:param minimal: Return only event ID, UUID, timestamp, sighting_timestamp and published.
:param sort: The field to sort the events by, such as 'id', 'date', 'attribute_count'.
:param desc: Whether to sort events ascending (default) or descending.
:param limit: Limit the number of events returned
:param page: If a limit is set, sets the page to be returned. page 3, limit 100 will return records 201->300).
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output.
Warning: it might use a lot of RAM
| def search_index(self,
all: str | None = None,
attribute: str | None = None,
email: str | None = None,
published: bool | None = None,
hasproposal: bool | None = None,
eventid: SearchType | None = None,
tags: SearchParameterTypes | None = None,
date_from: datetime | date | int | str | float | None | None = None,
date_to: datetime | date | int | str | float | None | None = None,
eventinfo: str | None = None,
threatlevel: list[SearchType] | None = None,
distribution: list[SearchType] | None = None,
analysis: list[SearchType] | None = None,
org: SearchParameterTypes | None = None,
timestamp: None | (datetime | date | int | str | float | None
| tuple[datetime | date | int | str | float | None,
datetime | date | int | str | float | None]
) = None,
publish_timestamp: None | (datetime | date | int | str | float | None
| tuple[datetime | date | int | str | float | None,
datetime | date | int | str | float | None]
) = None,
sharinggroup: list[SearchType] | None = None,
minimal: bool | None = None,
sort: str | None = None,
desc: bool | None = None,
limit: int | None = None,
page: int | None = None,
pythonify: bool | None = None) -> dict[str, Any] | list[MISPEvent] | list[dict[str, Any]]:
"""Search event metadata shown on the event index page. Using ! in front of a value
means NOT, except for parameters date_from, date_to and timestamp which cannot be negated.
Criteria are AND-ed together; values in lists are OR-ed together. Return matching events
with metadata but no attributes or objects; also see minimal parameter.
:param all: Search for a full or a substring (delimited by % for substrings) in the
event info, event tags, attribute tags, attribute values or attribute comment fields.
:param attribute: Filter on attribute's value.
:param email: Filter on user's email.
:param published: Set whether published or unpublished events should be returned.
Do not set the parameter if you want both.
:param hasproposal: Filter for events containing proposal(s).
:param eventid: The events that should be included / excluded from the search
:param tags: Tags to search or to exclude. You can pass a list, or the output of
`build_complex_query`
:param date_from: Events with the date set to a date after the one specified.
This filter will use the date of the event.
:param date_to: Events with the date set to a date before the one specified.
This filter will use the date of the event.
:param eventinfo: Filter on the event's info field.
:param threatlevel: Threat level(s) (1,2,3,4) | list
:param distribution: Distribution level(s) (0,1,2,3) | list
:param analysis: Analysis level(s) (0,1,2) | list
:param org: Search by the creator organisation by supplying the organisation identifier.
:param timestamp: Restrict the results by the timestamp (last edit). Any event with a
timestamp newer than the given timestamp will be returned. In case you are dealing
with /attributes as scope, the attribute's timestamp will be used for the lookup.
:param publish_timestamp: Filter on event's publish timestamp.
:param sharinggroup: Restrict by a sharing group | list
:param minimal: Return only event ID, UUID, timestamp, sighting_timestamp and published.
:param sort: The field to sort the events by, such as 'id', 'date', 'attribute_count'.
:param desc: Whether to sort events ascending (default) or descending.
:param limit: Limit the number of events returned
:param page: If a limit is set, sets the page to be returned. page 3, limit 100 will return records 201->300).
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output.
Warning: it might use a lot of RAM
"""
query = locals()
query.pop('self')
query.pop('pythonify')
if query.get('date_from'):
query['datefrom'] = self._make_timestamp(query.pop('date_from'))
if query.get('date_to'):
query['dateuntil'] = self._make_timestamp(query.pop('date_to'))
if isinstance(query.get('sharinggroup'), list):
query['sharinggroup'] = '|'.join([str(sg) for sg in query['sharinggroup']])
if query.get('timestamp') is not None:
timestamp = query.pop('timestamp')
if isinstance(timestamp, (list, tuple)):
query['timestamp'] = (self._make_timestamp(timestamp[0]), self._make_timestamp(timestamp[1]))
else:
query['timestamp'] = self._make_timestamp(timestamp)
if query.get("sort"):
query["direction"] = "desc" if desc else "asc"
url = urljoin(self.root_url, 'events/index')
response = self._prepare_request('POST', url, data=query)
normalized_response = self._check_json_response(response)
if not (self.global_pythonify or pythonify) or isinstance(normalized_response, dict):
return normalized_response
to_return = []
for e_meta in normalized_response:
me = MISPEvent()
me.from_dict(**e_meta)
to_return.append(me)
return to_return
| (self, all: Optional[str] = None, attribute: Optional[str] = None, email: Optional[str] = None, published: Optional[bool] = None, hasproposal: Optional[bool] = None, eventid: Optional[~SearchType] = None, tags: Optional[~SearchParameterTypes] = None, date_from: Union[datetime.datetime, datetime.date, int, str, float, NoneType] = None, date_to: Union[datetime.datetime, datetime.date, int, str, float, NoneType] = None, eventinfo: Optional[str] = None, threatlevel: Optional[list[~SearchType]] = None, distribution: Optional[list[~SearchType]] = None, analysis: Optional[list[~SearchType]] = None, org: Optional[~SearchParameterTypes] = None, timestamp: Union[NoneType, datetime.datetime, datetime.date, int, str, float, tuple[datetime.datetime | datetime.date | int | str | float | None, datetime.datetime | datetime.date | int | str | float | None]] = None, publish_timestamp: Union[NoneType, datetime.datetime, datetime.date, int, str, float, tuple[datetime.datetime | datetime.date | int | str | float | None, datetime.datetime | datetime.date | int | str | float | None]] = None, sharinggroup: Optional[list[~SearchType]] = None, minimal: Optional[bool] = None, sort: Optional[str] = None, desc: Optional[bool] = None, limit: Optional[int] = None, page: Optional[int] = None, pythonify: Optional[bool] = None) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPEvent] | list[dict[str, typing.Any]] |
25,105 | pymisp.api | search_logs | Search in logs
Note: to run substring queries simply append/prepend/encapsulate the search term with %
:param limit: Limit the number of results returned, depending on the scope (for example 10 attributes or 10 full events).
:param page: If a limit is set, sets the page to be returned. page 3, limit 100 will return records 201->300).
:param log_id: Log ID
:param title: Log Title
:param created: Creation timestamp
:param model: Model name that generated the log entry
:param action: The thing that was done
:param user_id: ID of the user doing the action
:param change: Change that occured
:param email: Email of the user
:param org: Organisation of the User doing the action
:param description: Description of the action
:param ip: Origination IP of the User doing the action
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def search_logs(self, limit: int | None = None, page: int | None = None,
log_id: int | None = None, title: str | None = None,
created: datetime | date | int | str | float | None | None = None, model: str | None = None,
action: str | None = None, user_id: int | None = None,
change: str | None = None, email: str | None = None,
org: str | None = None, description: str | None = None,
ip: str | None = None, pythonify: bool | None = False) -> dict[str, Any] | list[MISPLog] | list[dict[str, Any]]:
'''Search in logs
Note: to run substring queries simply append/prepend/encapsulate the search term with %
:param limit: Limit the number of results returned, depending on the scope (for example 10 attributes or 10 full events).
:param page: If a limit is set, sets the page to be returned. page 3, limit 100 will return records 201->300).
:param log_id: Log ID
:param title: Log Title
:param created: Creation timestamp
:param model: Model name that generated the log entry
:param action: The thing that was done
:param user_id: ID of the user doing the action
:param change: Change that occured
:param email: Email of the user
:param org: Organisation of the User doing the action
:param description: Description of the action
:param ip: Origination IP of the User doing the action
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
'''
query = locals()
query.pop('self')
query.pop('pythonify')
if log_id is not None:
query['id'] = query.pop('log_id')
if created is not None and isinstance(created, datetime):
query['created'] = query.pop('created').timestamp()
response = self._prepare_request('POST', 'admin/logs/index', data=query)
normalized_response = self._check_json_response(response)
if not (self.global_pythonify or pythonify) or isinstance(normalized_response, dict):
return normalized_response
to_return = []
for log in normalized_response:
ml = MISPLog()
ml.from_dict(**log)
to_return.append(ml)
return to_return
| (self, limit: Optional[int] = None, page: Optional[int] = None, log_id: Optional[int] = None, title: Optional[str] = None, created: Union[datetime.datetime, datetime.date, int, str, float, NoneType] = None, model: Optional[str] = None, action: Optional[str] = None, user_id: Optional[int] = None, change: Optional[str] = None, email: Optional[str] = None, org: Optional[str] = None, description: Optional[str] = None, ip: Optional[str] = None, pythonify: bool | None = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPLog] | list[dict[str, typing.Any]] |
25,106 | pymisp.api | search_sightings | Search sightings
:param context: The context of the search. Can be either "attribute", "event", or nothing (will then match on events and attributes).
:param context_id: Only relevant if context is either "attribute" or "event". Then it is the relevant ID.
:param type_sighting: Type of sighting
:param date_from: Events with the date set to a date after the one specified. This filter will use the date of the event.
:param date_to: Events with the date set to a date before the one specified. This filter will use the date of the event.
:param publish_timestamp: Restrict the results by the last publish timestamp (newer than).
:param org: Search by the creator organisation by supplying the organisation identifier.
:param source: Source of the sighting
:param include_attribute: Include the attribute.
:param include_event_meta: Include the meta information of the event.
Deprecated:
:param last: synonym for publish_timestamp
:Example:
>>> misp.search_sightings(publish_timestamp='30d') # search sightings for the last 30 days on the instance
[ ... ]
>>> misp.search_sightings(context='attribute', context_id=6, include_attribute=True) # return list of sighting for attribute 6 along with the attribute itself
[ ... ]
>>> misp.search_sightings(context='event', context_id=17, include_event_meta=True, org=2) # return list of sighting for event 17 filtered with org id 2
| def search_sightings(self, context: str | None = None,
context_id: SearchType | None = None,
type_sighting: str | None = None,
date_from: datetime | date | int | str | float | None | None = None,
date_to: datetime | date | int | str | float | None | None = None,
publish_timestamp: None | (datetime | date | int | str | float | None
| tuple[datetime | date | int | str | float | None,
datetime | date | int | str | float | None]
) = None,
last: None | (datetime | date | int | str | float | None
| tuple[datetime | date | int | str | float | None,
datetime | date | int | str | float | None]
) = None,
org: SearchType | None = None,
source: str | None = None,
include_attribute: bool | None = None,
include_event_meta: bool | None = None,
pythonify: bool | None = False
) -> dict[str, Any] | list[dict[str, MISPEvent | MISPAttribute | MISPSighting]]:
'''Search sightings
:param context: The context of the search. Can be either "attribute", "event", or nothing (will then match on events and attributes).
:param context_id: Only relevant if context is either "attribute" or "event". Then it is the relevant ID.
:param type_sighting: Type of sighting
:param date_from: Events with the date set to a date after the one specified. This filter will use the date of the event.
:param date_to: Events with the date set to a date before the one specified. This filter will use the date of the event.
:param publish_timestamp: Restrict the results by the last publish timestamp (newer than).
:param org: Search by the creator organisation by supplying the organisation identifier.
:param source: Source of the sighting
:param include_attribute: Include the attribute.
:param include_event_meta: Include the meta information of the event.
Deprecated:
:param last: synonym for publish_timestamp
:Example:
>>> misp.search_sightings(publish_timestamp='30d') # search sightings for the last 30 days on the instance
[ ... ]
>>> misp.search_sightings(context='attribute', context_id=6, include_attribute=True) # return list of sighting for attribute 6 along with the attribute itself
[ ... ]
>>> misp.search_sightings(context='event', context_id=17, include_event_meta=True, org=2) # return list of sighting for event 17 filtered with org id 2
'''
query: dict[str, Any] = {'returnFormat': 'json'}
if context is not None:
if context not in ['attribute', 'event']:
raise ValueError('context has to be in {}'.format(', '.join(['attribute', 'event'])))
url_path = f'sightings/restSearch/{context}'
else:
url_path = 'sightings/restSearch'
if isinstance(context_id, (MISPEvent, MISPAttribute)):
context_id = get_uuid_or_id_from_abstract_misp(context_id)
query['id'] = context_id
query['type'] = type_sighting
query['from'] = date_from
query['to'] = date_to
query['last'] = publish_timestamp
query['org_id'] = org
query['source'] = source
query['includeAttribute'] = include_attribute
query['includeEvent'] = include_event_meta
url = urljoin(self.root_url, url_path)
response = self._prepare_request('POST', url, data=query)
normalized_response = self._check_json_response(response)
if not (self.global_pythonify or pythonify) or isinstance(normalized_response, dict):
return normalized_response
if self.global_pythonify or pythonify:
to_return = []
for s in normalized_response:
entries: dict[str, MISPEvent | MISPAttribute | MISPSighting] = {}
s_data = s['Sighting']
if include_event_meta:
e = s_data.pop('Event')
me = MISPEvent()
me.from_dict(**e)
entries['event'] = me
if include_attribute:
a = s_data.pop('Attribute')
ma = MISPAttribute()
ma.from_dict(**a)
entries['attribute'] = ma
ms = MISPSighting()
ms.from_dict(**s_data)
entries['sighting'] = ms
to_return.append(entries)
return to_return
return normalized_response
| (self, context: Optional[str] = None, context_id: Optional[~SearchType] = None, type_sighting: Optional[str] = None, date_from: Union[datetime.datetime, datetime.date, int, str, float, NoneType] = None, date_to: Union[datetime.datetime, datetime.date, int, str, float, NoneType] = None, publish_timestamp: Union[NoneType, datetime.datetime, datetime.date, int, str, float, tuple[datetime.datetime | datetime.date | int | str | float | None, datetime.datetime | datetime.date | int | str | float | None]] = None, last: Union[NoneType, datetime.datetime, datetime.date, int, str, float, tuple[datetime.datetime | datetime.date | int | str | float | None, datetime.datetime | datetime.date | int | str | float | None]] = None, org: Optional[~SearchType] = None, source: Optional[str] = None, include_attribute: Optional[bool] = None, include_event_meta: Optional[bool] = None, pythonify: bool | None = False) -> dict[str, typing.Any] | list[dict[str, pymisp.mispevent.MISPEvent | pymisp.mispevent.MISPAttribute | pymisp.mispevent.MISPSighting]] |
25,107 | pymisp.api | search_tags | Search for tags by name: https://www.misp-project.org/openapi/#tag/Tags/operation/searchTag
:param tag_name: Name to search, use % for substrings matches.
:param strict_tagname: only return tags matching exactly the tag name (so skipping synonyms and cluster's value)
| def search_tags(self, tagname: str, strict_tagname: bool = False, pythonify: bool = False) -> dict[str, Any] | list[MISPTag] | list[dict[str, Any]]:
"""Search for tags by name: https://www.misp-project.org/openapi/#tag/Tags/operation/searchTag
:param tag_name: Name to search, use % for substrings matches.
:param strict_tagname: only return tags matching exactly the tag name (so skipping synonyms and cluster's value)
"""
query = {'tagname': tagname, 'strict_tagname': strict_tagname}
response = self._prepare_request('POST', 'tags/search', data=query)
normalized_response = self._check_json_response(response)
if not (self.global_pythonify or pythonify) or isinstance(normalized_response, dict):
return normalized_response
to_return: list[MISPTag] = []
for tag in normalized_response:
t = MISPTag()
t.from_dict(**tag)
to_return.append(t)
return to_return
| (self, tagname: str, strict_tagname: bool = False, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.abstract.MISPTag] | list[dict[str, typing.Any]] |
25,108 | pymisp.api | server_pull | Initialize a pull from a sync server, optionally limited to one event: https://www.misp-project.org/openapi/#tag/Servers/operation/pullServer
:param server: sync server config
:param event: event
| def server_pull(self, server: MISPServer | int | str | UUID, event: MISPEvent | int | str | UUID | None = None) -> dict[str, Any] | list[dict[str, Any]]:
"""Initialize a pull from a sync server, optionally limited to one event: https://www.misp-project.org/openapi/#tag/Servers/operation/pullServer
:param server: sync server config
:param event: event
"""
server_id = get_uuid_or_id_from_abstract_misp(server)
if event:
event_id = get_uuid_or_id_from_abstract_misp(event)
url = f'servers/pull/{server_id}/{event_id}'
else:
url = f'servers/pull/{server_id}'
response = self._prepare_request('GET', url)
# FIXME: can we pythonify?
return self._check_json_response(response)
| (self, server: pymisp.mispevent.MISPServer | int | str | uuid.UUID, event: Union[pymisp.mispevent.MISPEvent, int, str, uuid.UUID, NoneType] = None) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,109 | pymisp.api | server_push | Initialize a push to a sync server, optionally limited to one event: https://www.misp-project.org/openapi/#tag/Servers/operation/pushServer
:param server: sync server config
:param event: event
| def server_push(self, server: MISPServer | int | str | UUID, event: MISPEvent | int | str | UUID | None = None) -> dict[str, Any] | list[dict[str, Any]]:
"""Initialize a push to a sync server, optionally limited to one event: https://www.misp-project.org/openapi/#tag/Servers/operation/pushServer
:param server: sync server config
:param event: event
"""
server_id = get_uuid_or_id_from_abstract_misp(server)
if event:
event_id = get_uuid_or_id_from_abstract_misp(event)
url = f'servers/push/{server_id}/{event_id}'
else:
url = f'servers/push/{server_id}'
response = self._prepare_request('GET', url)
# FIXME: can we pythonify?
return self._check_json_response(response)
| (self, server: pymisp.mispevent.MISPServer | int | str | uuid.UUID, event: Union[pymisp.mispevent.MISPEvent, int, str, uuid.UUID, NoneType] = None) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,110 | pymisp.api | server_settings | Get all the settings from the server | def server_settings(self) -> dict[str, Any] | list[dict[str, Any]]:
"""Get all the settings from the server"""
response = self._prepare_request('GET', 'servers/serverSettings')
return self._check_json_response(response)
| (self) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,111 | pymisp.api | servers | Get the existing servers the MISP instance can synchronise with: https://www.misp-project.org/openapi/#tag/Servers/operation/getServers
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def servers(self, pythonify: bool = False) -> dict[str, Any] | list[MISPServer] | list[dict[str, Any]]:
"""Get the existing servers the MISP instance can synchronise with: https://www.misp-project.org/openapi/#tag/Servers/operation/getServers
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
r = self._prepare_request('GET', 'servers/index')
servers = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(servers, dict):
return servers
to_return = []
for server in servers:
s = MISPServer()
s.from_dict(**server)
to_return.append(s)
return to_return
| (self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPServer] | list[dict[str, typing.Any]] |
25,112 | pymisp.api | set_default_role | Set a default role for the new user accounts
:param role: the default role to set
| def set_default_role(self, role: MISPRole | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]:
"""Set a default role for the new user accounts
:param role: the default role to set
"""
role_id = get_uuid_or_id_from_abstract_misp(role)
url = urljoin(self.root_url, f'admin/roles/set_default/{role_id}')
response = self._prepare_request('POST', url)
return self._check_json_response(response)
| (self, role: pymisp.mispevent.MISPRole | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,113 | pymisp.api | set_server_setting | Set a setting on the MISP instance
:param setting: server setting name
:param value: value to set
:param force: override value test
| def set_server_setting(self, setting: str, value: str | int | bool, force: bool = False) -> dict[str, Any] | list[dict[str, Any]]:
"""Set a setting on the MISP instance
:param setting: server setting name
:param value: value to set
:param force: override value test
"""
data = {'value': value, 'force': force}
response = self._prepare_request('POST', f'servers/serverSettingsEdit/{setting}', data=data)
return self._check_json_response(response)
| (self, setting: str, value: str | int | bool, force: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,114 | pymisp.api | set_taxonomy_required | null | def set_taxonomy_required(self, taxonomy: MISPTaxonomy | int | str, required: bool = False) -> dict[str, Any] | list[dict[str, Any]]:
taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy)
url = urljoin(self.root_url, f'taxonomies/toggleRequired/{taxonomy_id}')
payload = {
"Taxonomy": {
"required": required
}
}
response = self._prepare_request('POST', url, data=payload)
return self._check_json_response(response)
| (self, taxonomy: pymisp.mispevent.MISPTaxonomy | int | str, required: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,115 | pymisp.api | set_user_setting | Set a user setting: https://www.misp-project.org/openapi/#tag/UserSettings/operation/setUserSetting
:param user_setting: name of user setting
:param value: value to set
:param user: user
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def set_user_setting(self, user_setting: str, value: str | dict[str, Any], user: MISPUser | int | str | UUID | None = None,
pythonify: bool = False) -> dict[str, Any] | MISPUserSetting:
"""Set a user setting: https://www.misp-project.org/openapi/#tag/UserSettings/operation/setUserSetting
:param user_setting: name of user setting
:param value: value to set
:param user: user
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
query: dict[str, Any] = {'setting': user_setting}
if isinstance(value, dict):
value = str(dumps(value)) if HAS_ORJSON else dumps(value)
query['value'] = value
if user:
query['user_id'] = get_uuid_or_id_from_abstract_misp(user)
response = self._prepare_request('POST', 'userSettings/setSetting', data=query)
user_setting_j = self._check_json_response(response)
if not (self.global_pythonify or pythonify) or 'errors' in user_setting_j:
return user_setting_j
u = MISPUserSetting()
u.from_dict(**user_setting_j)
return u
| (self, user_setting: str, value: str | dict[str, typing.Any], user: Union[pymisp.mispevent.MISPUser, int, str, uuid.UUID, NoneType] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPUserSetting |
25,116 | pymisp.api | sharing_group_exists | Fast check if sharing group exists.
:param sharing_group: Sharing group to check
| def sharing_group_exists(self, sharing_group: MISPSharingGroup | int | str | UUID) -> bool:
"""Fast check if sharing group exists.
:param sharing_group: Sharing group to check
"""
sharing_group_id = get_uuid_or_id_from_abstract_misp(sharing_group)
r = self._prepare_request('HEAD', f'sharing_groups/view/{sharing_group_id}')
return self._check_head_response(r)
| (self, sharing_group: pymisp.mispevent.MISPSharingGroup | int | str | uuid.UUID) -> bool |
25,117 | pymisp.api | sharing_groups | Get the existing sharing groups: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/getSharingGroup
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def sharing_groups(self, pythonify: bool = False) -> dict[str, Any] | list[MISPSharingGroup] | list[dict[str, Any]]:
"""Get the existing sharing groups: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/getSharingGroup
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
r = self._prepare_request('GET', 'sharingGroups/index')
sharing_groups = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(sharing_groups, dict):
return sharing_groups
to_return = []
for sharing_group in sharing_groups:
s = MISPSharingGroup()
s.from_dict(**sharing_group)
to_return.append(s)
return to_return
| (self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPSharingGroup] | list[dict[str, typing.Any]] |
25,118 | pymisp.api | sightings | Get the list of sightings related to a MISPEvent or a MISPAttribute (depending on type of misp_entity): https://www.misp-project.org/openapi/#tag/Sightings/operation/getSightingsByEventId
:param misp_entity: MISP entity
:param org: MISP organization
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def sightings(self, misp_entity: AbstractMISP | None = None,
org: MISPOrganisation | int | str | UUID | None = None,
pythonify: bool = False) -> dict[str, Any] | list[MISPSighting] | list[dict[str, Any]]:
"""Get the list of sightings related to a MISPEvent or a MISPAttribute (depending on type of misp_entity): https://www.misp-project.org/openapi/#tag/Sightings/operation/getSightingsByEventId
:param misp_entity: MISP entity
:param org: MISP organization
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
if isinstance(misp_entity, MISPEvent):
url = 'sightings/listSightings'
to_post = {'context': 'event', 'id': misp_entity.id}
elif isinstance(misp_entity, MISPAttribute):
url = 'sightings/listSightings'
to_post = {'context': 'attribute', 'id': misp_entity.id}
else:
url = 'sightings/index'
to_post = {}
if org is not None:
org_id = get_uuid_or_id_from_abstract_misp(org)
to_post['org_id'] = org_id
r = self._prepare_request('POST', url, data=to_post)
sightings = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(sightings, dict):
return sightings
to_return = []
for sighting in sightings:
s = MISPSighting()
s.from_dict(**sighting)
to_return.append(s)
return to_return
| (self, misp_entity: Optional[pymisp.abstract.AbstractMISP] = None, org: Union[pymisp.mispevent.MISPOrganisation, int, str, uuid.UUID, NoneType] = None, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPSighting] | list[dict[str, typing.Any]] |
25,119 | pymisp.api | tag | Tag an event or an attribute.
:param misp_entity: a MISPEvent, a MISP Attribute, or a UUID
:param tag: tag to add
:param local: whether to tag locally
:param relationship_type: Type of relationship between the tag and the attribute or event
| def tag(self, misp_entity: AbstractMISP | str | dict[str, Any], tag: MISPTag | str,
local: bool = False, relationship_type: str | None = None) -> dict[str, Any] | list[dict[str, Any]]:
"""Tag an event or an attribute.
:param misp_entity: a MISPEvent, a MISP Attribute, or a UUID
:param tag: tag to add
:param local: whether to tag locally
:param relationship_type: Type of relationship between the tag and the attribute or event
"""
uuid = get_uuid_or_id_from_abstract_misp(misp_entity)
if isinstance(tag, MISPTag):
tag_name = tag.name if 'name' in tag else ""
else:
tag_name = tag
to_post = {'uuid': uuid, 'tag': tag_name, 'local': local}
if relationship_type:
to_post['relationship_type'] = relationship_type
response = self._prepare_request('POST', 'tags/attachTagToObject', data=to_post)
return self._check_json_response(response)
| (self, misp_entity: pymisp.abstract.AbstractMISP | str | dict[str, typing.Any], tag: pymisp.abstract.MISPTag | str, local: bool = False, relationship_type: Optional[str] = None) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,120 | pymisp.api | tags | Get the list of existing tags: https://www.misp-project.org/openapi/#tag/Tags/operation/getTags
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def tags(self, pythonify: bool = False, **kw_params) -> dict[str, Any] | list[MISPTag]: # type: ignore[no-untyped-def]
"""Get the list of existing tags: https://www.misp-project.org/openapi/#tag/Tags/operation/getTags
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
r = self._prepare_request('GET', 'tags/index', kw_params=kw_params)
tags = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in tags:
return tags['Tag']
to_return = []
for tag in tags['Tag']:
t = MISPTag()
t.from_dict(**tag)
to_return.append(t)
return to_return
| (self, pythonify: bool = False, **kw_params) -> dict[str, typing.Any] | list[pymisp.abstract.MISPTag] |
25,121 | pymisp.api | tags_statistics | Get tag statistics from the MISP instance
:param percentage: get percentages
:param name_sort: sort by name
| def tags_statistics(self, percentage: bool = False, name_sort: bool = False) -> dict[str, Any] | list[dict[str, Any]]:
"""Get tag statistics from the MISP instance
:param percentage: get percentages
:param name_sort: sort by name
"""
# FIXME: https://github.com/MISP/MISP/issues/4874
# NOTE: https://github.com/MISP/MISP/issues/4879
if percentage:
p = 'true'
else:
p = 'false'
if name_sort:
ns = 'true'
else:
ns = 'false'
response = self._prepare_request('GET', f'tags/tagStatistics/{p}/{ns}')
return self._check_json_response(response)
| (self, percentage: bool = False, name_sort: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,122 | pymisp.api | taxonomies | Get all the taxonomies: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/getTaxonomies
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
| def taxonomies(self, pythonify: bool = False) -> dict[str, Any] | list[MISPTaxonomy] | list[dict[str, Any]]:
"""Get all the taxonomies: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/getTaxonomies
:param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
"""
r = self._prepare_request('GET', 'taxonomies/index')
taxonomies = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or isinstance(taxonomies, dict):
return taxonomies
to_return = []
for taxonomy in taxonomies:
t = MISPTaxonomy()
t.from_dict(**taxonomy)
to_return.append(t)
return to_return
| (self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPTaxonomy] | list[dict[str, typing.Any]] |
25,123 | pymisp.api | test_server | Test if a sync link is working as expected
:param server: sync server config
| def test_server(self, server: MISPServer | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]:
"""Test if a sync link is working as expected
:param server: sync server config
"""
server_id = get_uuid_or_id_from_abstract_misp(server)
response = self._prepare_request('POST', f'servers/testConnection/{server_id}')
return self._check_json_response(response)
| (self, server: pymisp.mispevent.MISPServer | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,124 | pymisp.api | toggle_global_pythonify | Toggle the pythonify variable for the class | def toggle_global_pythonify(self) -> None:
"""Toggle the pythonify variable for the class"""
self.global_pythonify = not self.global_pythonify
| (self) -> NoneType |
25,125 | pymisp.api | toggle_warninglist | Toggle (enable/disable) the status of a warninglist by id: https://www.misp-project.org/openapi/#tag/Warninglists/operation/toggleEnableWarninglist
:param warninglist_id: ID of the WarningList
:param warninglist_name: name of the WarningList
:param force_enable: Force the warning list in the enabled state (does nothing if already enabled) - None means toggle.
| def toggle_warninglist(self, warninglist_id: str | int | list[int] | None = None, warninglist_name: str | list[str] | None = None, force_enable: bool | None = None) -> dict[str, Any] | list[dict[str, Any]]:
'''Toggle (enable/disable) the status of a warninglist by id: https://www.misp-project.org/openapi/#tag/Warninglists/operation/toggleEnableWarninglist
:param warninglist_id: ID of the WarningList
:param warninglist_name: name of the WarningList
:param force_enable: Force the warning list in the enabled state (does nothing if already enabled) - None means toggle.
'''
if warninglist_id is None and warninglist_name is None:
raise PyMISPError('Either warninglist_id or warninglist_name is required.')
query: dict[str, list[str] | list[int] | bool] = {}
if warninglist_id is not None:
if isinstance(warninglist_id, list):
query['id'] = warninglist_id
else:
query['id'] = [warninglist_id] # type: ignore
if warninglist_name is not None:
if isinstance(warninglist_name, list):
query['name'] = warninglist_name
else:
query['name'] = [warninglist_name]
if force_enable is not None:
query['enabled'] = force_enable
response = self._prepare_request('POST', 'warninglists/toggleEnable', data=query)
return self._check_json_response(response)
| (self, warninglist_id: Union[str, int, list[int], NoneType] = None, warninglist_name: Union[str, list[str], NoneType] = None, force_enable: Optional[bool] = None) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,126 | pymisp.api | unpublish | Unpublish the event with one single HTTP POST: https://www.misp-project.org/openapi/#tag/Events/operation/unpublishEvent
:param event: event to unpublish
| def unpublish(self, event: MISPEvent | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]:
"""Unpublish the event with one single HTTP POST: https://www.misp-project.org/openapi/#tag/Events/operation/unpublishEvent
:param event: event to unpublish
"""
event_id = get_uuid_or_id_from_abstract_misp(event)
response = self._prepare_request('POST', f'events/unpublish/{event_id}')
return self._check_json_response(response)
| (self, event: pymisp.mispevent.MISPEvent | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,127 | pymisp.api | untag | Untag an event or an attribute
:param misp_entity: misp_entity can be a UUID
:param tag: tag to remove
| def untag(self, misp_entity: AbstractMISP | str | dict[str, Any], tag: MISPTag | str) -> dict[str, Any] | list[dict[str, Any]]:
"""Untag an event or an attribute
:param misp_entity: misp_entity can be a UUID
:param tag: tag to remove
"""
uuid = get_uuid_or_id_from_abstract_misp(misp_entity)
if isinstance(tag, MISPTag):
tag_name = tag.name if 'name' in tag else ""
else:
tag_name = tag
to_post = {'uuid': uuid, 'tag': tag_name}
response = self._prepare_request('POST', 'tags/removeTagFromObject', data=to_post)
return self._check_json_response(response)
| (self, misp_entity: pymisp.abstract.AbstractMISP | str | dict[str, typing.Any], tag: pymisp.abstract.MISPTag | str) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,128 | pymisp.api | update_attribute | Update an attribute on a MISP instance: https://www.misp-project.org/openapi/#tag/Attributes/operation/editAttribute
:param attribute: attribute to update
:param attribute_id: attribute ID to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_attribute(self, attribute: MISPAttribute, attribute_id: int | None = None, pythonify: bool = False) -> dict[str, Any] | MISPAttribute | MISPShadowAttribute:
"""Update an attribute on a MISP instance: https://www.misp-project.org/openapi/#tag/Attributes/operation/editAttribute
:param attribute: attribute to update
:param attribute_id: attribute ID to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if attribute_id is None:
aid = get_uuid_or_id_from_abstract_misp(attribute)
else:
aid = get_uuid_or_id_from_abstract_misp(attribute_id)
r = self._prepare_request('POST', f'attributes/edit/{aid}', data=attribute)
updated_attribute = self._check_json_response(r)
if 'errors' in updated_attribute:
if (updated_attribute['errors'][0] == 403
and updated_attribute['errors'][1]['message'] == 'You do not have permission to do that.'):
# At this point, we assume the user tried to update an attribute on an event they don't own
# Re-try with a proposal
return self.update_attribute_proposal(aid, attribute, pythonify)
if not (self.global_pythonify or pythonify) or 'errors' in updated_attribute:
return updated_attribute
a = MISPAttribute()
a.from_dict(**updated_attribute)
return a
| (self, attribute: pymisp.mispevent.MISPAttribute, attribute_id: Optional[int] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPAttribute | pymisp.mispevent.MISPShadowAttribute |
25,129 | pymisp.api | update_attribute_proposal | Propose a change for an attribute
:param initial_attribute: attribute to change
:param attribute: attribute to propose
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_attribute_proposal(self, initial_attribute: MISPAttribute | int | str | UUID, attribute: MISPAttribute, pythonify: bool = False) -> dict[str, Any] | MISPShadowAttribute:
"""Propose a change for an attribute
:param initial_attribute: attribute to change
:param attribute: attribute to propose
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
initial_attribute_id = get_uuid_or_id_from_abstract_misp(initial_attribute)
r = self._prepare_request('POST', f'shadowAttributes/edit/{initial_attribute_id}', data=attribute)
update_attribute_proposal = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in update_attribute_proposal:
return update_attribute_proposal
a = MISPShadowAttribute()
a.from_dict(**update_attribute_proposal)
return a
| (self, initial_attribute: pymisp.mispevent.MISPAttribute | int | str | uuid.UUID, attribute: pymisp.mispevent.MISPAttribute, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPShadowAttribute |
25,130 | pymisp.api | update_decaying_models | Update all the Decaying models | def update_decaying_models(self) -> dict[str, Any] | list[dict[str, Any]]:
"""Update all the Decaying models"""
response = self._prepare_request('POST', 'decayingModel/update')
return self._check_json_response(response)
| (self) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,131 | pymisp.api | update_event | Update an event on a MISP instance: https://www.misp-project.org/openapi/#tag/Events/operation/editEvent
:param event: event to update
:param event_id: ID of event to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
:param metadata: Return just event metadata after successful update
| def update_event(self, event: MISPEvent, event_id: int | None = None, pythonify: bool = False,
metadata: bool = False) -> dict[str, Any] | MISPEvent:
"""Update an event on a MISP instance: https://www.misp-project.org/openapi/#tag/Events/operation/editEvent
:param event: event to update
:param event_id: ID of event to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
:param metadata: Return just event metadata after successful update
"""
if event_id is None:
eid = get_uuid_or_id_from_abstract_misp(event)
else:
eid = get_uuid_or_id_from_abstract_misp(event_id)
r = self._prepare_request('POST', f'events/edit/{eid}' + ('/metadata:1' if metadata else ''), data=event)
updated_event = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in updated_event:
return updated_event
e = MISPEvent()
e.load(updated_event)
return e
| (self, event: pymisp.mispevent.MISPEvent, event_id: Optional[int] = None, pythonify: bool = False, metadata: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPEvent |
25,132 | pymisp.api | update_event_blocklist | Update an event in the blocklist
:param event_blocklist: event block list
:param event_blocklist_id: event block lisd id
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_event_blocklist(self, event_blocklist: MISPEventBlocklist, event_blocklist_id: int | str | UUID | None = None, pythonify: bool = False) -> dict[str, Any] | MISPEventBlocklist:
"""Update an event in the blocklist
:param event_blocklist: event block list
:param event_blocklist_id: event block lisd id
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if event_blocklist_id is None:
eblid = get_uuid_or_id_from_abstract_misp(event_blocklist)
else:
eblid = get_uuid_or_id_from_abstract_misp(event_blocklist_id)
updated_event_blocklist = self._update_entries_in_blocklist('event', eblid, **event_blocklist)
if not (self.global_pythonify or pythonify) or 'errors' in updated_event_blocklist:
return updated_event_blocklist
e = MISPEventBlocklist()
e.from_dict(**updated_event_blocklist)
return e
| (self, event_blocklist: pymisp.mispevent.MISPEventBlocklist, event_blocklist_id: Union[int, str, uuid.UUID, NoneType] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPEventBlocklist |
25,133 | pymisp.api | update_event_report | Update an event report on a MISP instance
:param event_report: event report to update
:param event_report_id: event report ID to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_event_report(self, event_report: MISPEventReport, event_report_id: int | None = None, pythonify: bool = False) -> dict[str, Any] | MISPEventReport:
"""Update an event report on a MISP instance
:param event_report: event report to update
:param event_report_id: event report ID to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if event_report_id is None:
erid = get_uuid_or_id_from_abstract_misp(event_report)
else:
erid = get_uuid_or_id_from_abstract_misp(event_report_id)
r = self._prepare_request('POST', f'eventReports/edit/{erid}', data=event_report)
updated_event_report = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in updated_event_report:
return updated_event_report
er = MISPEventReport()
er.from_dict(**updated_event_report)
return er
| (self, event_report: pymisp.mispevent.MISPEventReport, event_report_id: Optional[int] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPEventReport |
25,134 | pymisp.api | update_feed | Update a feed on a MISP instance
:param feed: feed to update
:param feed_id: feed id
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_feed(self, feed: MISPFeed, feed_id: int | None = None, pythonify: bool = False) -> dict[str, Any] | MISPFeed:
"""Update a feed on a MISP instance
:param feed: feed to update
:param feed_id: feed id
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if feed_id is None:
fid = get_uuid_or_id_from_abstract_misp(feed)
else:
fid = get_uuid_or_id_from_abstract_misp(feed_id)
# FIXME: https://github.com/MISP/MISP/issues/4834
r = self._prepare_request('POST', f'feeds/edit/{fid}', data={'Feed': feed})
updated_feed = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in updated_feed:
return updated_feed
f = MISPFeed()
f.from_dict(**updated_feed)
return f
| (self, feed: pymisp.mispevent.MISPFeed, feed_id: Optional[int] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPFeed |
25,135 | pymisp.api | update_galaxies | Update all the galaxies: https://www.misp-project.org/openapi/#tag/Galaxies/operation/updateGalaxies | def update_galaxies(self) -> dict[str, Any] | list[dict[str, Any]]:
"""Update all the galaxies: https://www.misp-project.org/openapi/#tag/Galaxies/operation/updateGalaxies"""
response = self._prepare_request('POST', 'galaxies/update')
return self._check_json_response(response)
| (self) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,136 | pymisp.api | update_galaxy_cluster | Update a custom galaxy cluster: https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/editGalaxyCluster
;param galaxy_cluster: The MISPGalaxyCluster you wish to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_galaxy_cluster(self, galaxy_cluster: MISPGalaxyCluster, pythonify: bool = False) -> dict[str, Any] | MISPGalaxyCluster:
"""Update a custom galaxy cluster: https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/editGalaxyCluster
;param galaxy_cluster: The MISPGalaxyCluster you wish to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if getattr(galaxy_cluster, "default", False):
# We can't edit default galaxies
raise PyMISPError('You are not able to update a default galaxy cluster')
cluster_id = get_uuid_or_id_from_abstract_misp(galaxy_cluster)
r = self._prepare_request('POST', f'galaxy_clusters/edit/{cluster_id}', data=galaxy_cluster)
cluster_j = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in cluster_j:
return cluster_j
gc = MISPGalaxyCluster()
gc.from_dict(**cluster_j)
return gc
| (self, galaxy_cluster: pymisp.mispevent.MISPGalaxyCluster, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPGalaxyCluster |
25,137 | pymisp.api | update_galaxy_cluster_relation | Update a galaxy cluster relation
:param galaxy_cluster_relation: The MISPGalaxyClusterRelation to update
| def update_galaxy_cluster_relation(self, galaxy_cluster_relation: MISPGalaxyClusterRelation) -> dict[str, Any] | list[dict[str, Any]]:
"""Update a galaxy cluster relation
:param galaxy_cluster_relation: The MISPGalaxyClusterRelation to update
"""
cluster_relation_id = get_uuid_or_id_from_abstract_misp(galaxy_cluster_relation)
r = self._prepare_request('POST', f'galaxy_cluster_relations/edit/{cluster_relation_id}', data=galaxy_cluster_relation)
cluster_rel_j = self._check_json_response(r)
return cluster_rel_j
| (self, galaxy_cluster_relation: pymisp.mispevent.MISPGalaxyClusterRelation) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,138 | pymisp.api | update_misp | Trigger a server update | def update_misp(self) -> dict[str, Any] | list[dict[str, Any]]:
"""Trigger a server update"""
response = self._prepare_request('POST', 'servers/update')
return self._check_json_response(response)
| (self) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,139 | pymisp.api | update_noticelists | Update all the noticelists: https://www.misp-project.org/openapi/#tag/Noticelists/operation/updateNoticelists | def update_noticelists(self) -> dict[str, Any] | list[dict[str, Any]]:
"""Update all the noticelists: https://www.misp-project.org/openapi/#tag/Noticelists/operation/updateNoticelists"""
response = self._prepare_request('POST', 'noticelists/update')
return self._check_json_response(response)
| (self) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,140 | pymisp.api | update_object | Update an object on a MISP instance
:param misp_object: object to update
:param object_id: ID of object to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_object(self, misp_object: MISPObject, object_id: int | None = None, pythonify: bool = False) -> dict[str, Any] | MISPObject:
"""Update an object on a MISP instance
:param misp_object: object to update
:param object_id: ID of object to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if object_id is None:
oid = get_uuid_or_id_from_abstract_misp(misp_object)
else:
oid = get_uuid_or_id_from_abstract_misp(object_id)
r = self._prepare_request('POST', f'objects/edit/{oid}', data=misp_object)
updated_object = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in updated_object:
return updated_object
o = MISPObject(updated_object['Object']['name'], standalone=False)
o.from_dict(**updated_object)
return o
| (self, misp_object: pymisp.mispevent.MISPObject, object_id: Optional[int] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPObject |
25,141 | pymisp.api | update_object_templates | Trigger an update of the object templates | def update_object_templates(self) -> dict[str, Any] | list[dict[str, Any]]:
"""Trigger an update of the object templates"""
response = self._prepare_request('POST', 'objectTemplates/update')
return self._check_json_response(response)
| (self) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,142 | pymisp.api | update_organisation | Update an organisation: https://www.misp-project.org/openapi/#tag/Organisations/operation/editOrganisation
:param organisation: organization to update
:param organisation_id: id to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_organisation(self, organisation: MISPOrganisation, organisation_id: int | None = None, pythonify: bool = False) -> dict[str, Any] | MISPOrganisation:
"""Update an organisation: https://www.misp-project.org/openapi/#tag/Organisations/operation/editOrganisation
:param organisation: organization to update
:param organisation_id: id to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if organisation_id is None:
oid = get_uuid_or_id_from_abstract_misp(organisation)
else:
oid = get_uuid_or_id_from_abstract_misp(organisation_id)
r = self._prepare_request('POST', f'admin/organisations/edit/{oid}', data=organisation)
updated_organisation = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in updated_organisation:
return updated_organisation
o = MISPOrganisation()
o.from_dict(**organisation)
return o
| (self, organisation: pymisp.mispevent.MISPOrganisation, organisation_id: Optional[int] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPOrganisation |
25,143 | pymisp.api | update_organisation_blocklist | Update an organisation in the blocklist
:param organisation_blocklist: organization block list
:param organisation_blocklist_id: organization block lisd id
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_organisation_blocklist(self, organisation_blocklist: MISPOrganisationBlocklist, organisation_blocklist_id: int | str | UUID | None = None, pythonify: bool = False) -> dict[str, Any] | MISPOrganisationBlocklist:
"""Update an organisation in the blocklist
:param organisation_blocklist: organization block list
:param organisation_blocklist_id: organization block lisd id
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if organisation_blocklist_id is None:
oblid = get_uuid_or_id_from_abstract_misp(organisation_blocklist)
else:
oblid = get_uuid_or_id_from_abstract_misp(organisation_blocklist_id)
updated_organisation_blocklist = self._update_entries_in_blocklist('organisation', oblid, **organisation_blocklist)
if not (self.global_pythonify or pythonify) or 'errors' in updated_organisation_blocklist:
return updated_organisation_blocklist
o = MISPOrganisationBlocklist()
o.from_dict(**updated_organisation_blocklist)
return o
| (self, organisation_blocklist: pymisp.mispevent.MISPOrganisationBlocklist, organisation_blocklist_id: Union[int, str, uuid.UUID, NoneType] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPOrganisationBlocklist |
25,144 | pymisp.api | update_server | Update a server to synchronise with: https://www.misp-project.org/openapi/#tag/Servers/operation/getServers
:param server: sync server config
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_server(self, server: MISPServer, server_id: int | None = None, pythonify: bool = False) -> dict[str, Any] | MISPServer:
"""Update a server to synchronise with: https://www.misp-project.org/openapi/#tag/Servers/operation/getServers
:param server: sync server config
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if server_id is None:
sid = get_uuid_or_id_from_abstract_misp(server)
else:
sid = get_uuid_or_id_from_abstract_misp(server_id)
r = self._prepare_request('POST', f'servers/edit/{sid}', data=server)
updated_server = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in updated_server:
return updated_server
s = MISPServer()
s.from_dict(**updated_server)
return s
| (self, server: pymisp.mispevent.MISPServer, server_id: Optional[int] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPServer |
25,145 | pymisp.api | update_sharing_group | Update sharing group parameters: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/editSharingGroup
:param sharing_group: MISP Sharing Group
:param sharing_group_id Sharing group ID
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_sharing_group(self, sharing_group: MISPSharingGroup | dict[str, Any], sharing_group_id: int | None = None, pythonify: bool = False) -> dict[str, Any] | MISPSharingGroup:
"""Update sharing group parameters: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/editSharingGroup
:param sharing_group: MISP Sharing Group
:param sharing_group_id Sharing group ID
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if sharing_group_id is None:
sid = get_uuid_or_id_from_abstract_misp(sharing_group)
else:
sid = get_uuid_or_id_from_abstract_misp(sharing_group_id)
sharing_group.pop('modified', None) # Quick fix for https://github.com/MISP/PyMISP/issues/1049 - remove when fixed in MISP.
r = self._prepare_request('POST', f'sharing_groups/edit/{sid}', data=sharing_group)
updated_sharing_group = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in updated_sharing_group:
return updated_sharing_group
s = MISPSharingGroup()
s.from_dict(**updated_sharing_group)
return s
| (self, sharing_group: pymisp.mispevent.MISPSharingGroup | dict[str, typing.Any], sharing_group_id: Optional[int] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPSharingGroup |
25,146 | pymisp.api | update_tag | Edit only the provided parameters of a tag: https://www.misp-project.org/openapi/#tag/Tags/operation/editTag
:param tag: tag to update
:aram tag_id: tag ID to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_tag(self, tag: MISPTag, tag_id: int | None = None, pythonify: bool = False) -> dict[str, Any] | MISPTag:
"""Edit only the provided parameters of a tag: https://www.misp-project.org/openapi/#tag/Tags/operation/editTag
:param tag: tag to update
:aram tag_id: tag ID to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if tag_id is None:
tid = get_uuid_or_id_from_abstract_misp(tag)
else:
tid = get_uuid_or_id_from_abstract_misp(tag_id)
r = self._prepare_request('POST', f'tags/edit/{tid}', data=tag)
updated_tag = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in updated_tag:
return updated_tag
t = MISPTag()
t.from_dict(**updated_tag)
return t
| (self, tag: pymisp.abstract.MISPTag, tag_id: Optional[int] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.abstract.MISPTag |
25,147 | pymisp.api | update_taxonomies | Update all the taxonomies: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/updateTaxonomies | def update_taxonomies(self) -> dict[str, Any] | list[dict[str, Any]]:
"""Update all the taxonomies: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/updateTaxonomies"""
response = self._prepare_request('POST', 'taxonomies/update')
return self._check_json_response(response)
| (self) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
25,148 | pymisp.api | update_user | Update a user on a MISP instance: https://www.misp-project.org/openapi/#tag/Users/operation/editUser
:param user: user to update
:param user_id: id to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
| def update_user(self, user: MISPUser, user_id: int | None = None, pythonify: bool = False) -> dict[str, Any] | MISPUser:
"""Update a user on a MISP instance: https://www.misp-project.org/openapi/#tag/Users/operation/editUser
:param user: user to update
:param user_id: id to update
:param pythonify: Returns a PyMISP Object instead of the plain json output
"""
if user_id is None:
uid = get_uuid_or_id_from_abstract_misp(user)
else:
uid = get_uuid_or_id_from_abstract_misp(user_id)
url = f'users/edit/{uid}'
if self._current_role.perm_admin or self._current_role.perm_site_admin:
url = f'admin/{url}'
r = self._prepare_request('POST', url, data=user)
updated_user = self._check_json_response(r)
if not (self.global_pythonify or pythonify) or 'errors' in updated_user:
return updated_user
e = MISPUser()
e.from_dict(**updated_user)
return e
| (self, user: pymisp.mispevent.MISPUser, user_id: Optional[int] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPUser |
25,149 | pymisp.api | update_warninglists | Update all the warninglists: https://www.misp-project.org/openapi/#tag/Warninglists/operation/updateWarninglists | def update_warninglists(self) -> dict[str, Any] | list[dict[str, Any]]:
"""Update all the warninglists: https://www.misp-project.org/openapi/#tag/Warninglists/operation/updateWarninglists"""
response = self._prepare_request('POST', 'warninglists/update')
return self._check_json_response(response)
| (self) -> dict[str, typing.Any] | list[dict[str, typing.Any]] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.