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
24,947
pymisp.mispevent
to_dict
null
def to_dict(self, json_format: bool = False, strict: bool = False) -> dict[str, Any]: if strict or self._strict and self._known_template: self._validate() return super().to_dict(json_format)
(self, json_format: bool = False, strict: bool = False) -> dict[str, typing.Any]
24,948
pymisp.mispevent
to_json
null
def to_json(self, sort_keys: bool = False, indent: int | None = None, strict: bool = False) -> str: if strict or self._strict and self._known_template: self._validate() return super().to_json(sort_keys=sort_keys, indent=indent)
(self, sort_keys: bool = False, indent: Optional[int] = None, strict: bool = False) -> str
24,952
pymisp.abstract
Analysis
An enumeration.
class Analysis(Enum): initial = 0 ongoing = 1 completed = 2
(value, names=None, *, module=None, qualname=None, type=None, start=1)
24,953
pymisp.abstract
Distribution
An enumeration.
class Distribution(Enum): your_organisation_only = 0 this_community_only = 1 connected_communities = 2 all_communities = 3 sharing_group = 4 inherit = 5
(value, names=None, *, module=None, qualname=None, type=None, start=1)
24,954
pymisp
ExpandedPyMISP
null
class ExpandedPyMISP(PyMISP): def __init__(self, *args, **kwargs): warnings.warn('This class is deprecated, use PyMISP instead', FutureWarning) super().__init__(*args, **kwargs)
(*args, **kwargs)
24,955
pymisp
__init__
null
def __init__(self, *args, **kwargs): warnings.warn('This class is deprecated, use PyMISP instead', FutureWarning) super().__init__(*args, **kwargs)
(self, *args, **kwargs)
24,956
pymisp.api
__repr__
null
def __repr__(self) -> str: return f'<{self.__class__.__name__}(url={self.root_url})'
(self) -> str
24,957
pymisp.api
_add_entries_to_blocklist
null
def _add_entries_to_blocklist(self, blocklist_type: str, uuids: str | list[str], **kwargs) -> dict[str, Any] | list[dict[str, Any]]: # type: ignore[no-untyped-def] if blocklist_type == 'event': url = 'eventBlocklists/add' elif blocklist_type == 'organisation': url = 'orgBlocklists/add' else: raise PyMISPError('blocklist_type can only be "event" or "organisation"') if isinstance(uuids, str): uuids = [uuids] data = {'uuids': uuids} if kwargs: data.update({k: v for k, v in kwargs.items() if v}) r = self._prepare_request('POST', url, data=data) return self._check_json_response(r)
(self, blocklist_type: str, uuids: str | list[str], **kwargs) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,958
pymisp.api
_check_head_response
null
def _check_head_response(self, response: requests.Response) -> bool: if response.status_code == 200: return True elif response.status_code == 404: return False else: raise MISPServerError(f'Error code {response.status_code} for HEAD request')
(self, response: requests.models.Response) -> bool
24,959
pymisp.api
_check_json_response
null
def _check_json_response(self, response: requests.Response) -> dict[str, Any] | list[dict[str, Any]]: r = self._check_response(response, expect_json=True) if isinstance(r, (dict, list)): return r # Else: an exception was raised anyway raise PyMISPUnexpectedResponse(f'A dict was expected, got a string: {r}')
(self, response: requests.models.Response) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,960
pymisp.api
_check_response
Check if the response from the server is not an unexpected error
def _check_response(self, response: requests.Response, lenient_response_type: bool = False, expect_json: bool = False) -> dict[str, Any] | str: """Check if the response from the server is not an unexpected error""" if response.status_code >= 500: headers_without_auth = {h_name: h_value for h_name, h_value in response.request.headers.items() if h_value != self.key} logger.critical(everything_broken.format(headers_without_auth, response.request.body, response.text)) raise MISPServerError(f'Error code 500:\n{response.text}') if 400 <= response.status_code < 500: # The server returns a json message with the error details try: error_message = loads(response.content) except Exception: raise MISPServerError(f'Error code {response.status_code}:\n{response.text}') logger.error(f'Something went wrong ({response.status_code}): {error_message}') return {'errors': (response.status_code, error_message)} # At this point, we had no error. try: response_json = loads(response.content) logger.debug(response_json) if isinstance(response_json, dict) and response_json.get('response') is not None: # Cleanup. response_json = response_json['response'] return response_json except Exception: logger.debug(response.text) if expect_json: error_msg = f'Unexpected response (size: {len(response.text)}) from server: {response.text}' raise PyMISPUnexpectedResponse(error_msg) if lenient_response_type and not response.headers['Content-Type'].startswith('application/json'): return response.text if not response.content: # Empty response logger.error('Got an empty response.') return {'errors': 'The response is empty.'} return response.text
(self, response: requests.models.Response, lenient_response_type: bool = False, expect_json: bool = False) -> dict[str, typing.Any] | str
24,961
pymisp.api
_csv_to_dict
Makes a list of dict out of a csv file (requires headers)
def _csv_to_dict(self, csv_content: str) -> list[dict[str, Any]]: '''Makes a list of dict out of a csv file (requires headers)''' fieldnames, lines = csv_content.split('\n', 1) fields = fieldnames.split(',') to_return = [] for line in csv.reader(lines.split('\n')): if line: to_return.append({fname: value for fname, value in zip(fields, line)}) return to_return
(self, csv_content: str) -> list[dict[str, typing.Any]]
24,962
pymisp.api
_make_misp_bool
MISP wants 0 or 1 for bool, so we avoid True/False '0', '1'
def _make_misp_bool(self, parameter: bool | str | None = None) -> int: '''MISP wants 0 or 1 for bool, so we avoid True/False '0', '1' ''' if parameter is None: return 0 return 1 if int(parameter) else 0
(self, parameter: Union[bool, str, NoneType] = None) -> int
24,963
pymisp.api
_make_timestamp
Catch-all method to normalize anything that can be converted to a timestamp
def _make_timestamp(self, value: datetime | date | int | str | float | None) -> str | int | float | None: '''Catch-all method to normalize anything that can be converted to a timestamp''' if not value: return None if isinstance(value, datetime): return value.timestamp() if isinstance(value, date): return datetime.combine(value, datetime.max.time()).timestamp() if isinstance(value, str): if value.isdigit(): return value try: float(value) return value except ValueError: # The value can also be '1d', '10h', ... return value return value
(self, value: datetime.datetime | datetime.date | int | str | float | None) -> str | int | float | None
24,964
pymisp.api
_old_misp
null
def _old_misp(self, minimal_version_required: tuple[int], removal_date: str | date | datetime, method: str | None = None, message: str | None = None) -> bool: if self._misp_version >= minimal_version_required: return False if isinstance(removal_date, (datetime, date)): removal_date = removal_date.isoformat() to_print = f'The instance of MISP you are using is outdated. Unless you update your MISP instance, {method} will stop working after {removal_date}.' if message: to_print += f' {message}' warnings.warn(to_print, DeprecationWarning) return True
(self, minimal_version_required: tuple[int], removal_date: str | datetime.date | datetime.datetime, method: Optional[str] = None, message: Optional[str] = None) -> bool
24,965
pymisp.api
_prepare_request
Prepare a request for python-requests
def _prepare_request(self, request_type: str, url: str, data: Iterable[Any] | Mapping[str, Any] | AbstractMISP | bytes | None = None, params: Mapping[str, Any] = {}, kw_params: Mapping[str, Any] = {}, output_type: str = 'json', content_type: str = 'json') -> requests.Response: '''Prepare a request for python-requests''' if url[0] == '/': # strip it: it will fail if MISP is in a sub directory url = url[1:] # Cake PHP being an idiot, it doesn't accept %20 (space) in the URL path, # so we need to make it a + instead and hope for the best url = url.replace(' ', '+') url = urljoin(self.root_url, url) d: bytes | str | None = None if data is not None: if isinstance(data, bytes): d = data else: if isinstance(data, dict): # Remove None values. data = {k: v for k, v in data.items() if v is not None} d = dumps(data, default=pymisp_json_default) logger.debug('%s - %s', request_type, url) if d is not None: logger.debug(d) if kw_params: # CakePHP params in URL to_append_url = '/'.join([f'{k}:{v}' for k, v in kw_params.items()]) url = f'{url}/{to_append_url}' req = requests.Request(request_type, url, data=d, params=params) req.auth = self.auth prepped = self.__session.prepare_request(req) prepped.headers.update( {'Accept': f'application/{output_type}', 'content-type': f'application/{content_type}'}) logger.debug(prepped.headers) settings = self.__session.merge_environment_settings(req.url, proxies=self.proxies or {}, stream=None, verify=self.ssl, cert=self.cert) return self.__session.send(prepped, timeout=self.timeout, **settings)
(self, request_type: str, url: str, data: Union[Iterable[Any], Mapping[str, Any], pymisp.abstract.AbstractMISP, bytes, NoneType] = None, params: Mapping[str, Any] = {}, kw_params: Mapping[str, Any] = {}, output_type: str = 'json', content_type: str = 'json') -> requests.models.Response
24,966
pymisp.api
_update_entries_in_blocklist
null
def _update_entries_in_blocklist(self, blocklist_type: str, uuid, **kwargs) -> dict[str, Any] | list[dict[str, Any]]: # type: ignore[no-untyped-def] if blocklist_type == 'event': url = f'eventBlocklists/edit/{uuid}' elif blocklist_type == 'organisation': url = f'orgBlocklists/edit/{uuid}' else: raise PyMISPError('blocklist_type can only be "event" or "organisation"') data = {k: v for k, v in kwargs.items() if v} r = self._prepare_request('POST', url, data=data) return self._check_json_response(r)
(self, blocklist_type: str, uuid, **kwargs) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,967
pymisp.api
accept_attribute_proposal
Accept a proposal. You cannot modify an existing proposal, only accept/discard :param proposal: attribute proposal to accept
def accept_attribute_proposal(self, proposal: MISPShadowAttribute | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Accept a proposal. You cannot modify an existing proposal, only accept/discard :param proposal: attribute proposal to accept """ proposal_id = get_uuid_or_id_from_abstract_misp(proposal) response = self._prepare_request('POST', f'shadowAttributes/accept/{proposal_id}') return self._check_json_response(response)
(self, proposal: pymisp.mispevent.MISPShadowAttribute | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,968
pymisp.api
accept_event_delegation
Accept the delegation of an event :param delegation: event delegation to accept :param pythonify: Returns a PyMISP Object instead of the plain json output
def accept_event_delegation(self, delegation: MISPEventDelegation | int | str, pythonify: bool = False) -> dict[str, Any] | list[dict[str, Any]]: """Accept the delegation of an event :param delegation: event delegation to accept :param pythonify: Returns a PyMISP Object instead of the plain json output """ delegation_id = get_uuid_or_id_from_abstract_misp(delegation) r = self._prepare_request('POST', f'eventDelegations/acceptDelegation/{delegation_id}') return self._check_json_response(r)
(self, delegation: pymisp.mispevent.MISPEventDelegation | int | str, pythonify: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,969
pymisp.api
accept_user_registration
Accept a user registration :param registration: the registration to accept :param organisation: user organization :param role: user role :param perm_sync: indicator for sync :param perm_publish: indicator for publish :param perm_admin: indicator for admin :param unsafe_fallback: indicator for unsafe fallback
def accept_user_registration(self, registration: MISPInbox | int | str | UUID, organisation: MISPOrganisation | int | str | UUID | None = None, role: MISPRole | int | str | None = None, perm_sync: bool = False, perm_publish: bool = False, perm_admin: bool = False, unsafe_fallback: bool = False) -> dict[str, Any] | list[dict[str, Any]]: """Accept a user registration :param registration: the registration to accept :param organisation: user organization :param role: user role :param perm_sync: indicator for sync :param perm_publish: indicator for publish :param perm_admin: indicator for admin :param unsafe_fallback: indicator for unsafe fallback """ registration_id = get_uuid_or_id_from_abstract_misp(registration) if role: role_id = role_id = get_uuid_or_id_from_abstract_misp(role) else: for _r in self.roles(pythonify=True): if not isinstance(_r, MISPRole): continue if _r.default_role: # type: ignore role_id = get_uuid_or_id_from_abstract_misp(_r) break else: raise PyMISPError('Unable to find default role') organisation_id = None if organisation: organisation_id = get_uuid_or_id_from_abstract_misp(organisation) elif unsafe_fallback and isinstance(registration, MISPInbox): if 'org_uuid' in registration.data: org = self.get_organisation(registration.data['org_uuid'], pythonify=True) if isinstance(org, MISPOrganisation): organisation_id = org.id if unsafe_fallback and isinstance(registration, MISPInbox): # Blindly use request from user, and instance defaults. to_post = {'User': {'org_id': organisation_id, 'role_id': role_id, 'perm_sync': registration.data['perm_sync'], 'perm_publish': registration.data['perm_publish'], 'perm_admin': registration.data['perm_admin']}} else: to_post = {'User': {'org_id': organisation_id, 'role_id': role_id, 'perm_sync': perm_sync, 'perm_publish': perm_publish, 'perm_admin': perm_admin}} r = self._prepare_request('POST', f'users/acceptRegistrations/{registration_id}', data=to_post) return self._check_json_response(r)
(self, registration: pymisp.mispevent.MISPInbox | int | str | uuid.UUID, organisation: Union[pymisp.mispevent.MISPOrganisation, int, str, uuid.UUID, NoneType] = None, role: Union[pymisp.mispevent.MISPRole, int, str, NoneType] = None, perm_sync: bool = False, perm_publish: bool = False, perm_admin: bool = False, unsafe_fallback: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,970
pymisp.api
add_attribute
Add an attribute to an existing MISP event: https://www.misp-project.org/openapi/#tag/Attributes/operation/addAttribute :param event: event to extend :param attribute: attribute or (MISP version 2.4.113+) list of attributes to add. If a list is passed, the pythonified response is a dict with the following structure: {'attributes': [MISPAttribute], 'errors': {errors by attributes}} :param pythonify: Returns a PyMISP Object instead of the plain json output :param break_on_duplicate: if False, do not fail if the attribute already exists, updates existing attribute instead (timestamp will be always updated)
def add_attribute(self, event: MISPEvent | int | str | UUID, attribute: MISPAttribute | Iterable[str], pythonify: bool = False, break_on_duplicate: bool = True) -> dict[str, Any] | MISPAttribute | MISPShadowAttribute: """Add an attribute to an existing MISP event: https://www.misp-project.org/openapi/#tag/Attributes/operation/addAttribute :param event: event to extend :param attribute: attribute or (MISP version 2.4.113+) list of attributes to add. If a list is passed, the pythonified response is a dict with the following structure: {'attributes': [MISPAttribute], 'errors': {errors by attributes}} :param pythonify: Returns a PyMISP Object instead of the plain json output :param break_on_duplicate: if False, do not fail if the attribute already exists, updates existing attribute instead (timestamp will be always updated) """ params = {'breakOnDuplicate': 0} if break_on_duplicate is not True else {} event_id = get_uuid_or_id_from_abstract_misp(event) r = self._prepare_request('POST', f'attributes/add/{event_id}', data=attribute, kw_params=params) new_attribute = self._check_json_response(r) if isinstance(attribute, list): # Multiple attributes were passed at once, the handling is totally different if not (self.global_pythonify or pythonify): return new_attribute to_return: dict[str, list[MISPAttribute]] = {'attributes': []} if 'errors' in new_attribute: to_return['errors'] = new_attribute['errors'] if len(attribute) == 1: # input list size 1 yields dict, not list of size 1 if 'Attribute' in new_attribute: a = MISPAttribute() a.from_dict(**new_attribute['Attribute']) to_return['attributes'].append(a) else: for new_attr in new_attribute['Attribute']: a = MISPAttribute() a.from_dict(**new_attr) to_return['attributes'].append(a) return to_return if ('errors' in new_attribute and new_attribute['errors'][0] == 403 and new_attribute['errors'][1]['message'] == 'You do not have permission to do that.'): # At this point, we assume the user tried to add an attribute on an event they don't own # Re-try with a proposal if isinstance(attribute, (MISPAttribute, dict)): return self.add_attribute_proposal(event_id, attribute, pythonify) # type: ignore if not (self.global_pythonify or pythonify) or 'errors' in new_attribute: return new_attribute a = MISPAttribute() a.from_dict(**new_attribute) return a
(self, event: pymisp.mispevent.MISPEvent | int | str | uuid.UUID, attribute: Union[pymisp.mispevent.MISPAttribute, Iterable[str]], pythonify: bool = False, break_on_duplicate: bool = True) -> dict[str, typing.Any] | pymisp.mispevent.MISPAttribute | pymisp.mispevent.MISPShadowAttribute
24,971
pymisp.api
add_attribute_proposal
Propose a new attribute in an event :param event: event to receive new attribute :param attribute: attribute to propose :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_attribute_proposal(self, event: MISPEvent | int | str | UUID, attribute: MISPAttribute, pythonify: bool = False) -> dict[str, Any] | MISPShadowAttribute: """Propose a new attribute in an event :param event: event to receive new attribute :param attribute: attribute to propose :param pythonify: Returns a PyMISP Object instead of the plain json output """ event_id = get_uuid_or_id_from_abstract_misp(event) r = self._prepare_request('POST', f'shadowAttributes/add/{event_id}', data=attribute) new_attribute_proposal = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in new_attribute_proposal: return new_attribute_proposal a = MISPShadowAttribute() a.from_dict(**new_attribute_proposal) return a
(self, event: pymisp.mispevent.MISPEvent | int | str | uuid.UUID, attribute: pymisp.mispevent.MISPAttribute, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPShadowAttribute
24,972
pymisp.api
add_correlation_exclusion
Add a new correlation exclusion :param correlation_exclusion: correlation exclusion to add :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_correlation_exclusion(self, correlation_exclusion: MISPCorrelationExclusion, pythonify: bool = False) -> dict[str, Any] | MISPCorrelationExclusion: """Add a new correlation exclusion :param correlation_exclusion: correlation exclusion to add :param pythonify: Returns a PyMISP Object instead of the plain json output """ r = self._prepare_request('POST', 'correlation_exclusions/add', data=correlation_exclusion) new_correlation_exclusion = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in new_correlation_exclusion: return new_correlation_exclusion c = MISPCorrelationExclusion() c.from_dict(**new_correlation_exclusion) return c
(self, correlation_exclusion: pymisp.mispevent.MISPCorrelationExclusion, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPCorrelationExclusion
24,973
pymisp.api
add_event
Add a new event on a MISP instance: https://www.misp-project.org/openapi/#tag/Events/operation/addEvent :param event: event to add :param pythonify: Returns a PyMISP Object instead of the plain json output :param metadata: Return just event metadata after successful creating
def add_event(self, event: MISPEvent, pythonify: bool = False, metadata: bool = False) -> dict[str, Any] | MISPEvent: """Add a new event on a MISP instance: https://www.misp-project.org/openapi/#tag/Events/operation/addEvent :param event: event to add :param pythonify: Returns a PyMISP Object instead of the plain json output :param metadata: Return just event metadata after successful creating """ r = self._prepare_request('POST', 'events/add' + ('/metadata:1' if metadata else ''), data=event) new_event = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in new_event: return new_event e = MISPEvent() e.load(new_event) return e
(self, event: pymisp.mispevent.MISPEvent, pythonify: bool = False, metadata: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPEvent
24,974
pymisp.api
add_event_blocklist
Add a new event in the blocklist :param uuids: UUIDs :param comment: comment :param event_info: event information :param event_orgc: event organization
def add_event_blocklist(self, uuids: str | list[str], comment: str | None = None, event_info: str | None = None, event_orgc: str | None = None) -> dict[str, Any] | list[dict[str, Any]]: """Add a new event in the blocklist :param uuids: UUIDs :param comment: comment :param event_info: event information :param event_orgc: event organization """ return self._add_entries_to_blocklist('event', uuids=uuids, comment=comment, event_info=event_info, event_orgc=event_orgc)
(self, uuids: str | list[str], comment: Optional[str] = None, event_info: Optional[str] = None, event_orgc: Optional[str] = None) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,975
pymisp.api
add_event_report
Add an event report to an existing MISP event :param event: event to extend :param event_report: event report to add. :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_event_report(self, event: MISPEvent | int | str | UUID, event_report: MISPEventReport, pythonify: bool = False) -> dict[str, Any] | MISPEventReport: """Add an event report to an existing MISP event :param event: event to extend :param event_report: event report to add. :param pythonify: Returns a PyMISP Object instead of the plain json output """ event_id = get_uuid_or_id_from_abstract_misp(event) r = self._prepare_request('POST', f'eventReports/add/{event_id}', data=event_report) new_event_report = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in new_event_report: return new_event_report er = MISPEventReport() er.from_dict(**new_event_report) return er
(self, event: pymisp.mispevent.MISPEvent | int | str | uuid.UUID, event_report: pymisp.mispevent.MISPEventReport, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPEventReport
24,976
pymisp.api
add_feed
Add a new feed on a MISP instance: https://www.misp-project.org/openapi/#tag/Feeds/operation/addFeed :param feed: feed to add :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_feed(self, feed: MISPFeed, pythonify: bool = False) -> dict[str, Any] | MISPFeed: """Add a new feed on a MISP instance: https://www.misp-project.org/openapi/#tag/Feeds/operation/addFeed :param feed: feed to add :param pythonify: Returns a PyMISP Object instead of the plain json output """ # FIXME: https://github.com/MISP/MISP/issues/4834 r = self._prepare_request('POST', 'feeds/add', data={'Feed': feed}) new_feed = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in new_feed: return new_feed f = MISPFeed() f.from_dict(**new_feed) return f
(self, feed: pymisp.mispevent.MISPFeed, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPFeed
24,977
pymisp.api
add_galaxy_cluster
Add a new galaxy cluster to a MISP Galaxy: https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/addGalaxyCluster :param galaxy: A MISPGalaxy (or UUID) where you wish to add the galaxy cluster :param galaxy_cluster: A MISPGalaxyCluster you wish to add :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_galaxy_cluster(self, galaxy: MISPGalaxy | str | UUID, galaxy_cluster: MISPGalaxyCluster, pythonify: bool = False) -> dict[str, Any] | MISPGalaxyCluster: """Add a new galaxy cluster to a MISP Galaxy: https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/addGalaxyCluster :param galaxy: A MISPGalaxy (or UUID) where you wish to add the galaxy cluster :param galaxy_cluster: A MISPGalaxyCluster you wish to add :param pythonify: Returns a PyMISP Object instead of the plain json output """ if getattr(galaxy_cluster, "default", False): # We can't add default galaxies raise PyMISPError('You are not able add a default galaxy cluster') galaxy_id = get_uuid_or_id_from_abstract_misp(galaxy) r = self._prepare_request('POST', f'galaxy_clusters/add/{galaxy_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 | str | uuid.UUID, galaxy_cluster: pymisp.mispevent.MISPGalaxyCluster, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPGalaxyCluster
24,978
pymisp.api
add_galaxy_cluster_relation
Add a galaxy cluster relation, cluster relation must include cluster UUIDs in both directions :param galaxy_cluster_relation: The MISPGalaxyClusterRelation to add
def add_galaxy_cluster_relation(self, galaxy_cluster_relation: MISPGalaxyClusterRelation) -> dict[str, Any] | list[dict[str, Any]]: """Add a galaxy cluster relation, cluster relation must include cluster UUIDs in both directions :param galaxy_cluster_relation: The MISPGalaxyClusterRelation to add """ r = self._prepare_request('POST', 'galaxy_cluster_relations/add/', 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]]
24,979
pymisp.api
add_object
Add a MISP Object to an existing MISP event: https://www.misp-project.org/openapi/#tag/Objects/operation/addObject :param event: event to extend :param misp_object: object to add :param pythonify: Returns a PyMISP Object instead of the plain json output :param break_on_duplicate: if True, check and reject if this object's attributes match an existing object's attributes; may require much time
def add_object(self, event: MISPEvent | int | str | UUID, misp_object: MISPObject, pythonify: bool = False, break_on_duplicate: bool = False) -> dict[str, Any] | MISPObject: """Add a MISP Object to an existing MISP event: https://www.misp-project.org/openapi/#tag/Objects/operation/addObject :param event: event to extend :param misp_object: object to add :param pythonify: Returns a PyMISP Object instead of the plain json output :param break_on_duplicate: if True, check and reject if this object's attributes match an existing object's attributes; may require much time """ event_id = get_uuid_or_id_from_abstract_misp(event) params = {'breakOnDuplicate': 1} if break_on_duplicate else {} r = self._prepare_request('POST', f'objects/add/{event_id}', data=misp_object, kw_params=params) new_object = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in new_object: return new_object o = MISPObject(new_object['Object']['name'], standalone=False) o.from_dict(**new_object) return o
(self, event: pymisp.mispevent.MISPEvent | int | str | uuid.UUID, misp_object: pymisp.mispevent.MISPObject, pythonify: bool = False, break_on_duplicate: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPObject
24,980
pymisp.api
add_object_reference
Add a reference to an object :param misp_object_reference: object reference :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_object_reference(self, misp_object_reference: MISPObjectReference, pythonify: bool = False) -> dict[str, Any] | MISPObjectReference: """Add a reference to an object :param misp_object_reference: object reference :param pythonify: Returns a PyMISP Object instead of the plain json output """ r = self._prepare_request('POST', 'objectReferences/add', misp_object_reference) object_reference = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in object_reference: return object_reference ref = MISPObjectReference() ref.from_dict(**object_reference) return ref
(self, misp_object_reference: pymisp.mispevent.MISPObjectReference, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPObjectReference
24,981
pymisp.api
add_org_to_sharing_group
Add an organisation to a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/addOrganisationToSharingGroup :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 :param extend: Allow the organisation to extend the group
def add_org_to_sharing_group(self, sharing_group: MISPSharingGroup | int | str | UUID, organisation: MISPOrganisation | int | str | UUID, extend: bool = False) -> dict[str, Any] | list[dict[str, Any]]: '''Add an organisation to a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/addOrganisationToSharingGroup :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 :param extend: Allow the organisation to extend the group ''' 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, 'extend': extend} response = self._prepare_request('POST', 'sharingGroups/addOrg', 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, extend: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,982
pymisp.api
add_organisation
Add an organisation: https://www.misp-project.org/openapi/#tag/Organisations/operation/addOrganisation :param organisation: organization to add :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_organisation(self, organisation: MISPOrganisation, pythonify: bool = False) -> dict[str, Any] | MISPOrganisation: """Add an organisation: https://www.misp-project.org/openapi/#tag/Organisations/operation/addOrganisation :param organisation: organization to add :param pythonify: Returns a PyMISP Object instead of the plain json output """ r = self._prepare_request('POST', 'admin/organisations/add', data=organisation) new_organisation = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in new_organisation: return new_organisation o = MISPOrganisation() o.from_dict(**new_organisation) return o
(self, organisation: pymisp.mispevent.MISPOrganisation, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPOrganisation
24,983
pymisp.api
add_organisation_blocklist
Add a new organisation in the blocklist :param uuids: UUIDs :param comment: comment :param org_name: organization name
def add_organisation_blocklist(self, uuids: str | list[str], comment: str | None = None, org_name: str | None = None) -> dict[str, Any] | list[dict[str, Any]]: """Add a new organisation in the blocklist :param uuids: UUIDs :param comment: comment :param org_name: organization name """ return self._add_entries_to_blocklist('organisation', uuids=uuids, comment=comment, org_name=org_name)
(self, uuids: str | list[str], comment: Optional[str] = None, org_name: Optional[str] = None) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,984
pymisp.api
add_server
Add a server to synchronise with: https://www.misp-project.org/openapi/#tag/Servers/operation/getServers Note: You probably want to use PyMISP.get_sync_config and PyMISP.import_server instead :param server: sync server config :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_server(self, server: MISPServer, pythonify: bool = False) -> dict[str, Any] | MISPServer: """Add a server to synchronise with: https://www.misp-project.org/openapi/#tag/Servers/operation/getServers Note: You probably want to use PyMISP.get_sync_config and PyMISP.import_server instead :param server: sync server config :param pythonify: Returns a PyMISP Object instead of the plain json output """ r = self._prepare_request('POST', 'servers/add', 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
24,985
pymisp.api
add_server_to_sharing_group
Add a server to a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/addServerToSharingGroup :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 :param all_orgs: Add all the organisations of the server to the group
def add_server_to_sharing_group(self, sharing_group: MISPSharingGroup | int | str | UUID, server: MISPServer | int | str | UUID, all_orgs: bool = False) -> dict[str, Any] | list[dict[str, Any]]: '''Add a server to a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/addServerToSharingGroup :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 :param all_orgs: Add all the organisations of the server to the group ''' 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, 'all_orgs': all_orgs} response = self._prepare_request('POST', 'sharingGroups/addServer', 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, all_orgs: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,986
pymisp.api
add_sharing_group
Add a new sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/addSharingGroup :param sharing_group: sharing group to add :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_sharing_group(self, sharing_group: MISPSharingGroup, pythonify: bool = False) -> dict[str, Any] | MISPSharingGroup: """Add a new sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/addSharingGroup :param sharing_group: sharing group to add :param pythonify: Returns a PyMISP Object instead of the plain json output """ r = self._prepare_request('POST', 'sharingGroups/add', data=sharing_group) sharing_group_j = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in sharing_group_j: return sharing_group_j s = MISPSharingGroup() s.from_dict(**sharing_group_j) return s
(self, sharing_group: pymisp.mispevent.MISPSharingGroup, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPSharingGroup
24,987
pymisp.api
add_sighting
Add a new sighting (globally, or to a specific attribute): https://www.misp-project.org/openapi/#tag/Sightings/operation/addSighting and https://www.misp-project.org/openapi/#tag/Sightings/operation/getSightingsByEventId :param sighting: sighting to add :param attribute: specific attribute to modify with the sighting :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_sighting(self, sighting: MISPSighting | dict[str, Any], attribute: MISPAttribute | int | str | UUID | None = None, pythonify: bool = False) -> dict[str, Any] | MISPSighting: """Add a new sighting (globally, or to a specific attribute): https://www.misp-project.org/openapi/#tag/Sightings/operation/addSighting and https://www.misp-project.org/openapi/#tag/Sightings/operation/getSightingsByEventId :param sighting: sighting to add :param attribute: specific attribute to modify with the sighting :param pythonify: Returns a PyMISP Object instead of the plain json output """ if attribute: attribute_id = get_uuid_or_id_from_abstract_misp(attribute) r = self._prepare_request('POST', f'sightings/add/{attribute_id}', data=sighting) else: # Either the ID/UUID is in the sighting, or we want to add a sighting on all the attributes with the given value r = self._prepare_request('POST', 'sightings/add', data=sighting) new_sighting = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in new_sighting: return new_sighting s = MISPSighting() s.from_dict(**new_sighting) return s
(self, sighting: pymisp.mispevent.MISPSighting | dict[str, typing.Any], attribute: Union[pymisp.mispevent.MISPAttribute, int, str, uuid.UUID, NoneType] = None, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPSighting
24,988
pymisp.api
add_tag
Add a new tag on a MISP instance: https://www.misp-project.org/openapi/#tag/Tags/operation/addTag The user calling this method needs the Tag Editor permission. It doesn't add a tag to an event, simply creates it on the MISP instance. :param tag: tag to add :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_tag(self, tag: MISPTag, pythonify: bool = False) -> dict[str, Any] | MISPTag: """Add a new tag on a MISP instance: https://www.misp-project.org/openapi/#tag/Tags/operation/addTag The user calling this method needs the Tag Editor permission. It doesn't add a tag to an event, simply creates it on the MISP instance. :param tag: tag to add :param pythonify: Returns a PyMISP Object instead of the plain json output """ r = self._prepare_request('POST', 'tags/add', data=tag) new_tag = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in new_tag: return new_tag t = MISPTag() t.from_dict(**new_tag) return t
(self, tag: pymisp.abstract.MISPTag, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.abstract.MISPTag
24,989
pymisp.api
add_user
Add a new user: https://www.misp-project.org/openapi/#tag/Users/operation/addUser :param user: user to add :param pythonify: Returns a PyMISP Object instead of the plain json output
def add_user(self, user: MISPUser, pythonify: bool = False) -> dict[str, Any] | MISPUser: """Add a new user: https://www.misp-project.org/openapi/#tag/Users/operation/addUser :param user: user to add :param pythonify: Returns a PyMISP Object instead of the plain json output """ r = self._prepare_request('POST', 'admin/users/add', data=user) 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) return u
(self, user: pymisp.mispevent.MISPUser, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPUser
24,990
pymisp.api
attribute_exists
Fast check if attribute exists. :param attribute: Attribute to check
def attribute_exists(self, attribute: MISPAttribute | int | str | UUID) -> bool: """Fast check if attribute exists. :param attribute: Attribute to check """ attribute_id = get_uuid_or_id_from_abstract_misp(attribute) r = self._prepare_request('HEAD', f'attributes/view/{attribute_id}') return self._check_head_response(r)
(self, attribute: pymisp.mispevent.MISPAttribute | int | str | uuid.UUID) -> bool
24,991
pymisp.api
attribute_proposals
Get all the attribute proposals :param event: event :param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
def attribute_proposals(self, event: MISPEvent | int | str | UUID | None = None, pythonify: bool = False) -> dict[str, Any] | list[MISPShadowAttribute] | list[dict[str, Any]]: """Get all the attribute proposals :param event: event :param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM """ if event: event_id = get_uuid_or_id_from_abstract_misp(event) r = self._prepare_request('GET', f'shadowAttributes/index/{event_id}') else: r = self._prepare_request('GET', 'shadowAttributes/index') attribute_proposals = self._check_json_response(r) if not (self.global_pythonify or pythonify) or isinstance(attribute_proposals, dict): return attribute_proposals to_return = [] for attribute_proposal in attribute_proposals: a = MISPShadowAttribute() a.from_dict(**attribute_proposal) to_return.append(a) return to_return
(self, event: Union[pymisp.mispevent.MISPEvent, int, str, uuid.UUID, NoneType] = None, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPShadowAttribute] | list[dict[str, typing.Any]]
24,992
pymisp.api
attributes
Get all the attributes from the MISP instance: https://www.misp-project.org/openapi/#tag/Attributes/operation/getAttributes :param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
def attributes(self, pythonify: bool = False) -> dict[str, Any] | list[MISPAttribute] | list[dict[str, Any]]: """Get all the attributes from the MISP instance: https://www.misp-project.org/openapi/#tag/Attributes/operation/getAttributes :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', 'attributes/index') attributes_r = self._check_json_response(r) if not (self.global_pythonify or pythonify) or isinstance(attributes_r, dict): return attributes_r to_return = [] for attribute in attributes_r: a = MISPAttribute() a.from_dict(**attribute) to_return.append(a) return to_return
(self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPAttribute] | list[dict[str, typing.Any]]
24,993
pymisp.api
attributes_statistics
Get attribute statistics from the MISP instance :param context: "type" or "category" :param percentage: get percentages
def attributes_statistics(self, context: str = 'type', percentage: bool = False) -> dict[str, Any] | list[dict[str, Any]]: """Get attribute statistics from the MISP instance :param context: "type" or "category" :param percentage: get percentages """ # FIXME: https://github.com/MISP/MISP/issues/4874 if context not in ['type', 'category']: raise PyMISPError('context can only be "type" or "category"') if percentage: path = f'attributes/attributeStatistics/{context}/true' else: path = f'attributes/attributeStatistics/{context}' response = self._prepare_request('GET', path) return self._check_json_response(response)
(self, context: str = 'type', percentage: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,994
pymisp.api
build_complex_query
Build a complex search query. MISP expects a dictionary with AND, OR and NOT keys.
def build_complex_query(self, or_parameters: list[SearchType] | None = None, and_parameters: list[SearchType] | None = None, not_parameters: list[SearchType] | None = None) -> dict[str, list[SearchType]]: '''Build a complex search query. MISP expects a dictionary with AND, OR and NOT keys.''' to_return = {} if and_parameters: if isinstance(and_parameters, str): to_return['AND'] = [and_parameters] else: to_return['AND'] = [p for p in and_parameters if p] if not_parameters: if isinstance(not_parameters, str): to_return['NOT'] = [not_parameters] else: to_return['NOT'] = [p for p in not_parameters if p] if or_parameters: if isinstance(or_parameters, str): to_return['OR'] = [or_parameters] else: to_return['OR'] = [p for p in or_parameters if p] return to_return
(self, or_parameters: Optional[list[~SearchType]] = None, and_parameters: Optional[list[~SearchType]] = None, not_parameters: Optional[list[~SearchType]] = None) -> dict[str, list[~SearchType]]
24,995
pymisp.api
cache_all_feeds
Cache all the feeds: https://www.misp-project.org/openapi/#tag/Feeds/operation/cacheFeeds
def cache_all_feeds(self) -> dict[str, Any] | list[dict[str, Any]]: """ Cache all the feeds: https://www.misp-project.org/openapi/#tag/Feeds/operation/cacheFeeds""" response = self._prepare_request('GET', 'feeds/cacheFeeds/all') return self._check_json_response(response)
(self) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,996
pymisp.api
cache_feed
Cache a specific feed by id: https://www.misp-project.org/openapi/#tag/Feeds/operation/cacheFeeds :param feed: feed to cache
def cache_feed(self, feed: MISPFeed | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Cache a specific feed by id: https://www.misp-project.org/openapi/#tag/Feeds/operation/cacheFeeds :param feed: feed to cache """ feed_id = get_uuid_or_id_from_abstract_misp(feed) response = self._prepare_request('GET', f'feeds/cacheFeeds/{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]]
24,997
pymisp.api
cache_freetext_feeds
Cache all the freetext feeds
def cache_freetext_feeds(self) -> dict[str, Any] | list[dict[str, Any]]: """Cache all the freetext feeds""" response = self._prepare_request('GET', 'feeds/cacheFeeds/freetext') return self._check_json_response(response)
(self) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,998
pymisp.api
cache_misp_feeds
Cache all the MISP feeds
def cache_misp_feeds(self) -> dict[str, Any] | list[dict[str, Any]]: """Cache all the MISP feeds""" response = self._prepare_request('GET', 'feeds/cacheFeeds/misp') return self._check_json_response(response)
(self) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
24,999
pymisp.api
change_sharing_group_on_entity
Change the sharing group of an event, an attribute, or an object :param misp_entity: entity to change :param sharing_group_id: group to change :param pythonify: Returns a PyMISP Object instead of the plain json output
def change_sharing_group_on_entity(self, misp_entity: MISPEvent | MISPAttribute | MISPObject, sharing_group_id: int, pythonify: bool = False) -> dict[str, Any] | MISPEvent | MISPObject | MISPAttribute | MISPShadowAttribute: """Change the sharing group of an event, an attribute, or an object :param misp_entity: entity to change :param sharing_group_id: group to change :param pythonify: Returns a PyMISP Object instead of the plain json output """ misp_entity.distribution = 4 # Needs to be 'Sharing group' if 'SharingGroup' in misp_entity: # Delete former SharingGroup information del misp_entity.SharingGroup misp_entity.sharing_group_id = sharing_group_id # Set new sharing group id if isinstance(misp_entity, MISPEvent): return self.update_event(misp_entity, pythonify=pythonify) if isinstance(misp_entity, MISPObject): return self.update_object(misp_entity, pythonify=pythonify) if isinstance(misp_entity, MISPAttribute): return self.update_attribute(misp_entity, pythonify=pythonify) raise PyMISPError('The misp_entity must be MISPEvent, MISPObject or MISPAttribute')
(self, misp_entity: pymisp.mispevent.MISPEvent | pymisp.mispevent.MISPAttribute | pymisp.mispevent.MISPObject, sharing_group_id: int, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPEvent | pymisp.mispevent.MISPObject | pymisp.mispevent.MISPAttribute | pymisp.mispevent.MISPShadowAttribute
25,000
pymisp.api
change_user_password
Change the password of the curent user: :param new_password: password to set
def change_user_password(self, new_password: str) -> dict[str, Any] | list[dict[str, Any]]: """Change the password of the curent user: :param new_password: password to set """ response = self._prepare_request('POST', 'users/change_pw', data={'password': new_password}) return self._check_json_response(response)
(self, new_password: str) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,001
pymisp.api
clean_correlation_exclusions
Initiate correlation exclusions cleanup
def clean_correlation_exclusions(self) -> dict[str, Any] | list[dict[str, Any]]: """Initiate correlation exclusions cleanup""" r = self._prepare_request('POST', 'correlation_exclusions/clean') return self._check_json_response(r)
(self) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,002
pymisp.api
communities
Get all the communities :param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
def communities(self, pythonify: bool = False) -> dict[str, Any] | list[MISPCommunity] | list[dict[str, Any]]: """Get all the communities :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', 'communities/index') communities = self._check_json_response(r) if not (self.global_pythonify or pythonify) or isinstance(communities, dict): return communities to_return = [] for community in communities: c = MISPCommunity() c.from_dict(**community) to_return.append(c) return to_return
(self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPCommunity] | list[dict[str, typing.Any]]
25,003
pymisp.api
compare_feeds
Generate the comparison matrix for all the MISP feeds
def compare_feeds(self) -> dict[str, Any] | list[dict[str, Any]]: """Generate the comparison matrix for all the MISP feeds""" response = self._prepare_request('GET', 'feeds/compareFeeds') return self._check_json_response(response)
(self) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,004
pymisp.api
contact_event_reporter
Send a message to the reporter of an event :param event: event with reporter to contact :param message: message to send
def contact_event_reporter(self, event: MISPEvent | int | str | UUID, message: str) -> dict[str, Any] | list[dict[str, Any]]: """Send a message to the reporter of an event :param event: event with reporter to contact :param message: message to send """ event_id = get_uuid_or_id_from_abstract_misp(event) to_post = {'message': message} response = self._prepare_request('POST', f'events/contact/{event_id}', data=to_post) return self._check_json_response(response)
(self, event: pymisp.mispevent.MISPEvent | int | str | uuid.UUID, message: str) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,005
pymisp.api
correlation_exclusions
Get all the correlation exclusions :param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
def correlation_exclusions(self, pythonify: bool = False) -> dict[str, Any] | list[MISPCorrelationExclusion] | list[dict[str, Any]]: """Get all the correlation exclusions :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', 'correlation_exclusions') correlation_exclusions = self._check_json_response(r) if not (self.global_pythonify or pythonify) or isinstance(correlation_exclusions, dict): return correlation_exclusions to_return = [] for correlation_exclusion in correlation_exclusions: c = MISPCorrelationExclusion() c.from_dict(**correlation_exclusion) to_return.append(c) return to_return
(self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPCorrelationExclusion] | list[dict[str, typing.Any]]
25,006
pymisp.api
db_schema_diagnostic
Get the schema diagnostic
def db_schema_diagnostic(self) -> dict[str, Any] | list[dict[str, Any]]: """Get the schema diagnostic""" response = self._prepare_request('GET', 'servers/dbSchemaDiagnostic') return self._check_json_response(response)
(self) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,007
pymisp.api
decaying_models
Get all the decaying models :param pythonify: Returns a list of PyMISP Objects instead of the plain json output
def decaying_models(self, pythonify: bool = False) -> dict[str, Any] | list[MISPDecayingModel] | list[dict[str, Any]]: """Get all the decaying models :param pythonify: Returns a list of PyMISP Objects instead of the plain json output """ r = self._prepare_request('GET', 'decayingModel/index') models = self._check_json_response(r) if not (self.global_pythonify or pythonify) or isinstance(models, dict): return models to_return = [] for model in models: n = MISPDecayingModel() n.from_dict(**model) to_return.append(n) return to_return
(self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPDecayingModel] | list[dict[str, typing.Any]]
25,008
pymisp.api
delegate_event
Delegate an event. Either event and organisation OR event_delegation are required :param event: event to delegate :param organisation: organization :param event_delegation: event delegation :param distribution: distribution == -1 means recipient decides :param message: message :param pythonify: Returns a PyMISP Object instead of the plain json output
def delegate_event(self, event: MISPEvent | int | str | UUID | None = None, organisation: MISPOrganisation | int | str | UUID | None = None, event_delegation: MISPEventDelegation | None = None, distribution: int = -1, message: str = '', pythonify: bool = False) -> dict[str, Any] | MISPEventDelegation: """Delegate an event. Either event and organisation OR event_delegation are required :param event: event to delegate :param organisation: organization :param event_delegation: event delegation :param distribution: distribution == -1 means recipient decides :param message: message :param pythonify: Returns a PyMISP Object instead of the plain json output """ if event and organisation: event_id = get_uuid_or_id_from_abstract_misp(event) organisation_id = get_uuid_or_id_from_abstract_misp(organisation) data = {'event_id': event_id, 'org_id': organisation_id, 'distribution': distribution, 'message': message} r = self._prepare_request('POST', f'eventDelegations/delegateEvent/{event_id}', data=data) elif event_delegation: r = self._prepare_request('POST', f'eventDelegations/delegateEvent/{event_delegation.event_id}', data=event_delegation) else: raise PyMISPError('Either event and organisation OR event_delegation are required.') delegation_j = self._check_json_response(r) if not (self.global_pythonify or pythonify) or 'errors' in delegation_j: return delegation_j d = MISPEventDelegation() d.from_dict(**delegation_j) return d
(self, event: Union[pymisp.mispevent.MISPEvent, int, str, uuid.UUID, NoneType] = None, organisation: Union[pymisp.mispevent.MISPOrganisation, int, str, uuid.UUID, NoneType] = None, event_delegation: Optional[pymisp.mispevent.MISPEventDelegation] = None, distribution: int = -1, message: str = '', pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPEventDelegation
25,009
pymisp.api
delete_attribute
Delete an attribute from a MISP instance: https://www.misp-project.org/openapi/#tag/Attributes/operation/deleteAttribute :param attribute: attribute to delete :param hard: flag for hard delete
def delete_attribute(self, attribute: MISPAttribute | int | str | UUID, hard: bool = False) -> dict[str, Any] | list[dict[str, Any]]: """Delete an attribute from a MISP instance: https://www.misp-project.org/openapi/#tag/Attributes/operation/deleteAttribute :param attribute: attribute to delete :param hard: flag for hard delete """ attribute_id = get_uuid_or_id_from_abstract_misp(attribute) data = {} if hard: data['hard'] = 1 r = self._prepare_request('POST', f'attributes/delete/{attribute_id}', data=data) response = self._check_json_response(r) if ('errors' in response and response['errors'][0] == 403 and response['errors'][1]['message'] == 'You do not have permission to do that.'): # FIXME: https://github.com/MISP/MISP/issues/4913 # At this point, we assume the user tried to delete an attribute on an event they don't own # Re-try with a proposal return self.delete_attribute_proposal(attribute_id) return response
(self, attribute: pymisp.mispevent.MISPAttribute | int | str | uuid.UUID, hard: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,010
pymisp.api
delete_attribute_proposal
Propose the deletion of an attribute :param attribute: attribute to delete
def delete_attribute_proposal(self, attribute: MISPAttribute | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Propose the deletion of an attribute :param attribute: attribute to delete """ attribute_id = get_uuid_or_id_from_abstract_misp(attribute) response = self._prepare_request('POST', f'shadowAttributes/delete/{attribute_id}') return self._check_json_response(response)
(self, attribute: pymisp.mispevent.MISPAttribute | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,011
pymisp.api
delete_correlation_exclusion
Delete a correlation exclusion :param correlation_exclusion: The MISPCorrelationExclusion you wish to delete from MISP
def delete_correlation_exclusion(self, correlation_exclusion: MISPCorrelationExclusion | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete a correlation exclusion :param correlation_exclusion: The MISPCorrelationExclusion you wish to delete from MISP """ exclusion_id = get_uuid_or_id_from_abstract_misp(correlation_exclusion) r = self._prepare_request('POST', f'correlation_exclusions/delete/{exclusion_id}') return self._check_json_response(r)
(self, correlation_exclusion: pymisp.mispevent.MISPCorrelationExclusion | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,012
pymisp.api
delete_event
Delete an event from a MISP instance: https://www.misp-project.org/openapi/#tag/Events/operation/deleteEvent :param event: event to delete
def delete_event(self, event: MISPEvent | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete an event from a MISP instance: https://www.misp-project.org/openapi/#tag/Events/operation/deleteEvent :param event: event to delete """ event_id = get_uuid_or_id_from_abstract_misp(event) response = self._prepare_request('POST', f'events/delete/{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,013
pymisp.api
delete_event_blocklist
Delete a blocklisted event by id :param event_blocklist: event block list to delete
def delete_event_blocklist(self, event_blocklist: MISPEventBlocklist | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete a blocklisted event by id :param event_blocklist: event block list to delete """ event_blocklist_id = get_uuid_or_id_from_abstract_misp(event_blocklist) response = self._prepare_request('POST', f'eventBlocklists/delete/{event_blocklist_id}') return self._check_json_response(response)
(self, event_blocklist: pymisp.mispevent.MISPEventBlocklist | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,014
pymisp.api
delete_event_report
Delete an event report from a MISP instance :param event_report: event report to delete :param hard: flag for hard delete
def delete_event_report(self, event_report: MISPEventReport | int | str | UUID, hard: bool = False) -> dict[str, Any] | list[dict[str, Any]]: """Delete an event report from a MISP instance :param event_report: event report to delete :param hard: flag for hard delete """ event_report_id = get_uuid_or_id_from_abstract_misp(event_report) request_url = f'eventReports/delete/{event_report_id}' data = {} if hard: data['hard'] = 1 r = self._prepare_request('POST', request_url, data=data) return self._check_json_response(r)
(self, event_report: pymisp.mispevent.MISPEventReport | int | str | uuid.UUID, hard: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,015
pymisp.api
delete_feed
Delete a feed from a MISP instance :param feed: feed to delete
def delete_feed(self, feed: MISPFeed | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete a feed from a MISP instance :param feed: feed to delete """ feed_id = get_uuid_or_id_from_abstract_misp(feed) response = self._prepare_request('POST', f'feeds/delete/{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,016
pymisp.api
delete_galaxy_cluster
Deletes a galaxy cluster from MISP: https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/deleteGalaxyCluster :param galaxy_cluster: The MISPGalaxyCluster you wish to delete from MISP :param hard: flag for hard delete
def delete_galaxy_cluster(self, galaxy_cluster: MISPGalaxyCluster | int | str | UUID, hard: bool=False) -> dict[str, Any] | list[dict[str, Any]]: """Deletes a galaxy cluster from MISP: https://www.misp-project.org/openapi/#tag/Galaxy-Clusters/operation/deleteGalaxyCluster :param galaxy_cluster: The MISPGalaxyCluster you wish to delete from MISP :param hard: flag for hard delete """ if isinstance(galaxy_cluster, MISPGalaxyCluster) and getattr(galaxy_cluster, "default", False): raise PyMISPError('You are not able to delete a default galaxy cluster') data = {} if hard: data['hard'] = 1 cluster_id = get_uuid_or_id_from_abstract_misp(galaxy_cluster) r = self._prepare_request('POST', f'galaxy_clusters/delete/{cluster_id}', data=data) return self._check_json_response(r)
(self, galaxy_cluster: pymisp.mispevent.MISPGalaxyCluster | int | str | uuid.UUID, hard: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,017
pymisp.api
delete_galaxy_cluster_relation
Delete a galaxy cluster relation :param galaxy_cluster_relation: The MISPGalaxyClusterRelation to delete
def delete_galaxy_cluster_relation(self, galaxy_cluster_relation: MISPGalaxyClusterRelation | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete a galaxy cluster relation :param galaxy_cluster_relation: The MISPGalaxyClusterRelation to delete """ cluster_relation_id = get_uuid_or_id_from_abstract_misp(galaxy_cluster_relation) r = self._prepare_request('POST', f'galaxy_cluster_relations/delete/{cluster_relation_id}') cluster_rel_j = self._check_json_response(r) return cluster_rel_j
(self, galaxy_cluster_relation: pymisp.mispevent.MISPGalaxyClusterRelation | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,018
pymisp.api
delete_object
Delete an object from a MISP instance: https://www.misp-project.org/openapi/#tag/Objects/operation/deleteObject :param misp_object: object to delete :param hard: flag for hard delete
def delete_object(self, misp_object: MISPObject | int | str | UUID, hard: bool = False) -> dict[str, Any] | list[dict[str, Any]]: """Delete an object from a MISP instance: https://www.misp-project.org/openapi/#tag/Objects/operation/deleteObject :param misp_object: object to delete :param hard: flag for hard delete """ object_id = get_uuid_or_id_from_abstract_misp(misp_object) data = {} if hard: data['hard'] = 1 r = self._prepare_request('POST', f'objects/delete/{object_id}', data=data) return self._check_json_response(r)
(self, misp_object: pymisp.mispevent.MISPObject | int | str | uuid.UUID, hard: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,019
pymisp.api
delete_object_reference
Delete a reference to an object.
def delete_object_reference( self, object_reference: MISPObjectReference | int | str | UUID, hard: bool = False, ) -> dict[str, Any] | list[dict[str, Any]]: """Delete a reference to an object.""" object_reference_id = get_uuid_or_id_from_abstract_misp(object_reference) query_url = f"objectReferences/delete/{object_reference_id}" if hard: query_url += "/true" response = self._prepare_request("POST", query_url) return self._check_json_response(response)
(self, object_reference: pymisp.mispevent.MISPObjectReference | int | str | uuid.UUID, hard: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,020
pymisp.api
delete_organisation
Delete an organisation by id: https://www.misp-project.org/openapi/#tag/Organisations/operation/deleteOrganisation :param organisation: organization to delete
def delete_organisation(self, organisation: MISPOrganisation | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete an organisation by id: https://www.misp-project.org/openapi/#tag/Organisations/operation/deleteOrganisation :param organisation: organization to delete """ # NOTE: MISP in inconsistent and currently require "delete" in the path and doesn't support HTTP DELETE organisation_id = get_uuid_or_id_from_abstract_misp(organisation) response = self._prepare_request('POST', f'admin/organisations/delete/{organisation_id}') return self._check_json_response(response)
(self, organisation: pymisp.mispevent.MISPOrganisation | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,021
pymisp.api
delete_organisation_blocklist
Delete a blocklisted organisation by id :param organisation_blocklist: organization block list to delete
def delete_organisation_blocklist(self, organisation_blocklist: MISPOrganisationBlocklist | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete a blocklisted organisation by id :param organisation_blocklist: organization block list to delete """ org_blocklist_id = get_uuid_or_id_from_abstract_misp(organisation_blocklist) response = self._prepare_request('POST', f'orgBlocklists/delete/{org_blocklist_id}') return self._check_json_response(response)
(self, organisation_blocklist: pymisp.mispevent.MISPOrganisationBlocklist | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,022
pymisp.api
delete_server
Delete a sync server: https://www.misp-project.org/openapi/#tag/Servers/operation/getServers :param server: sync server config
def delete_server(self, server: MISPServer | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete a sync server: https://www.misp-project.org/openapi/#tag/Servers/operation/getServers :param server: sync server config """ server_id = get_uuid_or_id_from_abstract_misp(server) response = self._prepare_request('POST', f'servers/delete/{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,023
pymisp.api
delete_sharing_group
Delete a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/deleteSharingGroup :param sharing_group: sharing group to delete
def delete_sharing_group(self, sharing_group: MISPSharingGroup | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete a sharing group: https://www.misp-project.org/openapi/#tag/Sharing-Groups/operation/deleteSharingGroup :param sharing_group: sharing group to delete """ sharing_group_id = get_uuid_or_id_from_abstract_misp(sharing_group) response = self._prepare_request('POST', f'sharingGroups/delete/{sharing_group_id}') return self._check_json_response(response)
(self, sharing_group: pymisp.mispevent.MISPSharingGroup | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,024
pymisp.api
delete_sighting
Delete a sighting from a MISP instance: https://www.misp-project.org/openapi/#tag/Sightings/operation/deleteSighting :param sighting: sighting to delete
def delete_sighting(self, sighting: MISPSighting | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete a sighting from a MISP instance: https://www.misp-project.org/openapi/#tag/Sightings/operation/deleteSighting :param sighting: sighting to delete """ sighting_id = get_uuid_or_id_from_abstract_misp(sighting) response = self._prepare_request('POST', f'sightings/delete/{sighting_id}') return self._check_json_response(response)
(self, sighting: pymisp.mispevent.MISPSighting | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,025
pymisp.api
delete_tag
Delete a tag from a MISP instance: https://www.misp-project.org/openapi/#tag/Tags/operation/deleteTag :param tag: tag to delete
def delete_tag(self, tag: MISPTag | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete a tag from a MISP instance: https://www.misp-project.org/openapi/#tag/Tags/operation/deleteTag :param tag: tag to delete """ tag_id = get_uuid_or_id_from_abstract_misp(tag) response = self._prepare_request('POST', f'tags/delete/{tag_id}') return self._check_json_response(response)
(self, tag: pymisp.abstract.MISPTag | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,026
pymisp.api
delete_user
Delete a user by id: https://www.misp-project.org/openapi/#tag/Users/operation/deleteUser :param user: user to delete
def delete_user(self, user: MISPUser | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Delete a user by id: https://www.misp-project.org/openapi/#tag/Users/operation/deleteUser :param user: user to delete """ # NOTE: MISP in inconsistent and currently require "delete" in the path and doesn't support HTTP DELETE user_id = get_uuid_or_id_from_abstract_misp(user) response = self._prepare_request('POST', f'admin/users/delete/{user_id}') return self._check_json_response(response)
(self, user: pymisp.mispevent.MISPUser | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,027
pymisp.api
delete_user_setting
Delete a user setting: https://www.misp-project.org/openapi/#tag/UserSettings/operation/deleteUserSettingById :param user_setting: name of user setting :param user: user
def delete_user_setting(self, user_setting: str, user: MISPUser | int | str | UUID | None = None) -> dict[str, Any] | list[dict[str, Any]]: """Delete a user setting: https://www.misp-project.org/openapi/#tag/UserSettings/operation/deleteUserSettingById :param user_setting: name of user setting :param user: user """ 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/delete', data=query) return self._check_json_response(response)
(self, user_setting: str, user: Union[pymisp.mispevent.MISPUser, int, str, uuid.UUID, NoneType] = None) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,028
pymisp.api
direct_call
Very lightweight call that posts a data blob (python dictionary or json string) on the URL :param url: URL to post to :param data: data to post :param params: dict with parameters for request :param kw_params: dict with keyword parameters for request
def direct_call(self, url: str, data: dict[str, Any] | None = None, params: Mapping[str, Any] = {}, kw_params: Mapping[str, Any] = {}) -> Any: """Very lightweight call that posts a data blob (python dictionary or json string) on the URL :param url: URL to post to :param data: data to post :param params: dict with parameters for request :param kw_params: dict with keyword parameters for request """ if data is None: response = self._prepare_request('GET', url, params=params, kw_params=kw_params) else: response = self._prepare_request('POST', url, data=data, params=params, kw_params=kw_params) return self._check_response(response, lenient_response_type=True)
(self, url: str, data: Optional[dict[str, Any]] = None, params: Mapping[str, Any] = {}, kw_params: Mapping[str, Any] = {}) -> Any
25,029
pymisp.api
disable_decaying_model
Disable a decaying Model
def disable_decaying_model(self, decaying_model: MISPDecayingModel | int | str) -> dict[str, Any] | list[dict[str, Any]]: """Disable a decaying Model""" if isinstance(decaying_model, MISPDecayingModel): decaying_model_id = decaying_model.id else: decaying_model_id = int(decaying_model) response = self._prepare_request('POST', f'decayingModel/disable/{decaying_model_id}') return self._check_json_response(response)
(self, decaying_model: pymisp.mispevent.MISPDecayingModel | int | str) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,030
pymisp.api
disable_feed
Disable a feed: https://www.misp-project.org/openapi/#tag/Feeds/operation/disableFeed :param feed: feed to disable :param pythonify: Returns a PyMISP Object instead of the plain json output
def disable_feed(self, feed: MISPFeed | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPFeed: """Disable a feed: https://www.misp-project.org/openapi/#tag/Feeds/operation/disableFeed :param feed: feed to disable :param pythonify: Returns a PyMISP Object instead of the plain json output """ if not isinstance(feed, MISPFeed): feed_id = get_uuid_or_id_from_abstract_misp(feed) # In case we have a UUID f = MISPFeed() f.id = feed_id else: f = feed f.enabled = False return self.update_feed(feed=f, pythonify=pythonify)
(self, feed: pymisp.mispevent.MISPFeed | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPFeed
25,031
pymisp.api
disable_feed_cache
Disable the caching of a feed :param feed: feed to disable caching :param pythonify: Returns a PyMISP Object instead of the plain json output
def disable_feed_cache(self, feed: MISPFeed | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPFeed: """Disable the caching of a feed :param feed: feed to disable caching :param pythonify: Returns a PyMISP Object instead of the plain json output """ if not isinstance(feed, MISPFeed): feed_id = get_uuid_or_id_from_abstract_misp(feed) # In case we have a UUID f = MISPFeed() f.id = feed_id else: f = feed f.caching_enabled = False return self.update_feed(feed=f, pythonify=pythonify)
(self, feed: pymisp.mispevent.MISPFeed | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPFeed
25,032
pymisp.api
disable_noticelist
Disable a noticelist by id :param noticelist: Noticelist to disable
def disable_noticelist(self, noticelist: MISPNoticelist | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Disable a noticelist by id :param noticelist: Noticelist to disable """ # FIXME: https://github.com/MISP/MISP/issues/4856 # response = self._prepare_request('POST', f'noticelists/disable/{noticelist_id}') noticelist_id = get_uuid_or_id_from_abstract_misp(noticelist) response = self._prepare_request('POST', f'noticelists/enableNoticelist/{noticelist_id}') return self._check_json_response(response)
(self, noticelist: pymisp.mispevent.MISPNoticelist | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,033
pymisp.api
disable_tag
Disable a tag :param tag: tag to disable :param pythonify: Returns a PyMISP Object instead of the plain json output
def disable_tag(self, tag: MISPTag, pythonify: bool = False) -> dict[str, Any] | MISPTag: """Disable a tag :param tag: tag to disable :param pythonify: Returns a PyMISP Object instead of the plain json output """ tag.hide_tag = True return self.update_tag(tag, pythonify=pythonify)
(self, tag: pymisp.abstract.MISPTag, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.abstract.MISPTag
25,034
pymisp.api
disable_taxonomy
Disable a taxonomy: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/disableTaxonomy :param taxonomy: taxonomy to disable
def disable_taxonomy(self, taxonomy: MISPTaxonomy | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Disable a taxonomy: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/disableTaxonomy :param taxonomy: taxonomy to disable """ taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy) self.disable_taxonomy_tags(taxonomy_id) response = self._prepare_request('POST', f'taxonomies/disable/{taxonomy_id}') try: return self._check_json_response(response) except PyMISPError: return self._check_json_response(response)
(self, taxonomy: pymisp.mispevent.MISPTaxonomy | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,035
pymisp.api
disable_taxonomy_tags
Disable all the tags of a taxonomy :param taxonomy: taxonomy with tags to disable
def disable_taxonomy_tags(self, taxonomy: MISPTaxonomy | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Disable all the tags of a taxonomy :param taxonomy: taxonomy with tags to disable """ taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy) response = self._prepare_request('POST', f'taxonomies/disableTag/{taxonomy_id}') return self._check_json_response(response)
(self, taxonomy: pymisp.mispevent.MISPTaxonomy | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,036
pymisp.api
disable_warninglist
Disable a warninglist :param warninglist: warninglist to disable
def disable_warninglist(self, warninglist: MISPWarninglist | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Disable a warninglist :param warninglist: warninglist to disable """ warninglist_id = get_uuid_or_id_from_abstract_misp(warninglist) return self.toggle_warninglist(warninglist_id=warninglist_id, force_enable=False)
(self, warninglist: pymisp.mispevent.MISPWarninglist | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,037
pymisp.api
discard_attribute_proposal
Discard a proposal. You cannot modify an existing proposal, only accept/discard :param proposal: attribute proposal to discard
def discard_attribute_proposal(self, proposal: MISPShadowAttribute | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Discard a proposal. You cannot modify an existing proposal, only accept/discard :param proposal: attribute proposal to discard """ proposal_id = get_uuid_or_id_from_abstract_misp(proposal) response = self._prepare_request('POST', f'shadowAttributes/discard/{proposal_id}') return self._check_json_response(response)
(self, proposal: pymisp.mispevent.MISPShadowAttribute | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,038
pymisp.api
discard_event_delegation
Discard the delegation of an event :param delegation: event delegation to discard :param pythonify: Returns a PyMISP Object instead of the plain json output
def discard_event_delegation(self, delegation: MISPEventDelegation | int | str, pythonify: bool = False) -> dict[str, Any] | list[dict[str, Any]]: """Discard the delegation of an event :param delegation: event delegation to discard :param pythonify: Returns a PyMISP Object instead of the plain json output """ delegation_id = get_uuid_or_id_from_abstract_misp(delegation) r = self._prepare_request('POST', f'eventDelegations/deleteDelegation/{delegation_id}') return self._check_json_response(r)
(self, delegation: pymisp.mispevent.MISPEventDelegation | int | str, pythonify: bool = False) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,039
pymisp.api
discard_user_registration
Discard a user registration :param registration: the registration to discard
def discard_user_registration(self, registration: MISPInbox | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Discard a user registration :param registration: the registration to discard """ registration_id = get_uuid_or_id_from_abstract_misp(registration) r = self._prepare_request('POST', f'users/discardRegistrations/{registration_id}') return self._check_json_response(r)
(self, registration: pymisp.mispevent.MISPInbox | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,040
pymisp.api
enable_decaying_model
Enable a decaying Model
def enable_decaying_model(self, decaying_model: MISPDecayingModel | int | str) -> dict[str, Any] | list[dict[str, Any]]: """Enable a decaying Model""" if isinstance(decaying_model, MISPDecayingModel): decaying_model_id = decaying_model.id else: decaying_model_id = int(decaying_model) response = self._prepare_request('POST', f'decayingModel/enable/{decaying_model_id}') return self._check_json_response(response)
(self, decaying_model: pymisp.mispevent.MISPDecayingModel | int | str) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,041
pymisp.api
enable_feed
Enable a feed; fetching it will create event(s): https://www.misp-project.org/openapi/#tag/Feeds/operation/enableFeed :param feed: feed to enable :param pythonify: Returns a PyMISP Object instead of the plain json output
def enable_feed(self, feed: MISPFeed | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPFeed: """Enable a feed; fetching it will create event(s): https://www.misp-project.org/openapi/#tag/Feeds/operation/enableFeed :param feed: feed to enable :param pythonify: Returns a PyMISP Object instead of the plain json output """ if not isinstance(feed, MISPFeed): feed_id = get_uuid_or_id_from_abstract_misp(feed) # In case we have a UUID f = MISPFeed() f.id = feed_id else: f = feed f.enabled = True return self.update_feed(feed=f, pythonify=pythonify)
(self, feed: pymisp.mispevent.MISPFeed | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPFeed
25,042
pymisp.api
enable_feed_cache
Enable the caching of a feed :param feed: feed to enable caching :param pythonify: Returns a PyMISP Object instead of the plain json output
def enable_feed_cache(self, feed: MISPFeed | int | str | UUID, pythonify: bool = False) -> dict[str, Any] | MISPFeed: """Enable the caching of a feed :param feed: feed to enable caching :param pythonify: Returns a PyMISP Object instead of the plain json output """ if not isinstance(feed, MISPFeed): feed_id = get_uuid_or_id_from_abstract_misp(feed) # In case we have a UUID f = MISPFeed() f.id = feed_id else: f = feed f.caching_enabled = True return self.update_feed(feed=f, pythonify=pythonify)
(self, feed: pymisp.mispevent.MISPFeed | int | str | uuid.UUID, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.mispevent.MISPFeed
25,043
pymisp.api
enable_noticelist
Enable a noticelist by id: https://www.misp-project.org/openapi/#tag/Noticelists/operation/toggleEnableNoticelist :param noticelist: Noticelist to enable
def enable_noticelist(self, noticelist: MISPNoticelist | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Enable a noticelist by id: https://www.misp-project.org/openapi/#tag/Noticelists/operation/toggleEnableNoticelist :param noticelist: Noticelist to enable """ # FIXME: https://github.com/MISP/MISP/issues/4856 # response = self._prepare_request('POST', f'noticelists/enable/{noticelist_id}') noticelist_id = get_uuid_or_id_from_abstract_misp(noticelist) response = self._prepare_request('POST', f'noticelists/enableNoticelist/{noticelist_id}/true') return self._check_json_response(response)
(self, noticelist: pymisp.mispevent.MISPNoticelist | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,044
pymisp.api
enable_tag
Enable a tag :param tag: tag to enable :param pythonify: Returns a PyMISP Object instead of the plain json output
def enable_tag(self, tag: MISPTag, pythonify: bool = False) -> dict[str, Any] | MISPTag: """Enable a tag :param tag: tag to enable :param pythonify: Returns a PyMISP Object instead of the plain json output """ tag.hide_tag = False return self.update_tag(tag, pythonify=pythonify)
(self, tag: pymisp.abstract.MISPTag, pythonify: bool = False) -> dict[str, typing.Any] | pymisp.abstract.MISPTag
25,045
pymisp.api
enable_taxonomy
Enable a taxonomy: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/enableTaxonomy :param taxonomy: taxonomy to enable
def enable_taxonomy(self, taxonomy: MISPTaxonomy | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Enable a taxonomy: https://www.misp-project.org/openapi/#tag/Taxonomies/operation/enableTaxonomy :param taxonomy: taxonomy to enable """ taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy) response = self._prepare_request('POST', f'taxonomies/enable/{taxonomy_id}') return self._check_json_response(response)
(self, taxonomy: pymisp.mispevent.MISPTaxonomy | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,046
pymisp.api
enable_taxonomy_tags
Enable all the tags of a taxonomy. NOTE: this is automatically done when you call enable_taxonomy :param taxonomy: taxonomy with tags to enable
def enable_taxonomy_tags(self, taxonomy: MISPTaxonomy | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Enable all the tags of a taxonomy. NOTE: this is automatically done when you call enable_taxonomy :param taxonomy: taxonomy with tags to enable """ taxonomy_id = get_uuid_or_id_from_abstract_misp(taxonomy) t = self.get_taxonomy(taxonomy_id) if isinstance(t, MISPTaxonomy): if not t.enabled: # Can happen if global pythonify is enabled. raise PyMISPError(f"The taxonomy {t.namespace} is not enabled.") elif not t['Taxonomy']['enabled']: raise PyMISPError(f"The taxonomy {t['Taxonomy']['namespace']} is not enabled.") url = urljoin(self.root_url, f'taxonomies/addTag/{taxonomy_id}') response = self._prepare_request('POST', url) return self._check_json_response(response)
(self, taxonomy: pymisp.mispevent.MISPTaxonomy | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,047
pymisp.api
enable_warninglist
Enable a warninglist :param warninglist: warninglist to enable
def enable_warninglist(self, warninglist: MISPWarninglist | int | str | UUID) -> dict[str, Any] | list[dict[str, Any]]: """Enable a warninglist :param warninglist: warninglist to enable """ warninglist_id = get_uuid_or_id_from_abstract_misp(warninglist) return self.toggle_warninglist(warninglist_id=warninglist_id, force_enable=True)
(self, warninglist: pymisp.mispevent.MISPWarninglist | int | str | uuid.UUID) -> dict[str, typing.Any] | list[dict[str, typing.Any]]
25,048
pymisp.api
event_blocklists
Get all the blocklisted events :param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
def event_blocklists(self, pythonify: bool = False) -> dict[str, Any] | list[MISPEventBlocklist] | list[dict[str, Any]]: """Get all the blocklisted events :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', 'eventBlocklists/index') event_blocklists = self._check_json_response(r) if not (self.global_pythonify or pythonify) or isinstance(event_blocklists, dict): return event_blocklists to_return = [] for event_blocklist in event_blocklists: ebl = MISPEventBlocklist() ebl.from_dict(**event_blocklist) to_return.append(ebl) return to_return
(self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPEventBlocklist] | list[dict[str, typing.Any]]
25,049
pymisp.api
event_delegations
Get all the event delegations :param pythonify: Returns a list of PyMISP Objects instead of the plain json output. Warning: it might use a lot of RAM
def event_delegations(self, pythonify: bool = False) -> dict[str, Any] | list[MISPEventDelegation] | list[dict[str, Any]]: """Get all the event delegations :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', 'eventDelegations') delegations = self._check_json_response(r) if not (self.global_pythonify or pythonify) or isinstance(delegations, dict): return delegations to_return = [] for delegation in delegations: d = MISPEventDelegation() d.from_dict(**delegation) to_return.append(d) return to_return
(self, pythonify: bool = False) -> dict[str, typing.Any] | list[pymisp.mispevent.MISPEventDelegation] | list[dict[str, typing.Any]]