2024-01-17 13:13:14 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2017-11-08 03:10:04 +01:00
|
|
|
import logging
|
2021-02-15 16:12:38 +01:00
|
|
|
import sys
|
|
|
|
import warnings
|
2017-12-22 14:49:14 +01:00
|
|
|
|
2023-10-24 15:03:46 +02:00
|
|
|
import importlib.metadata
|
|
|
|
|
2018-01-22 16:42:43 +01:00
|
|
|
logger = logging.getLogger(__name__)
|
2015-09-18 12:03:56 +02:00
|
|
|
|
2023-10-24 15:03:46 +02:00
|
|
|
__version__ = importlib.metadata.version("pymisp")
|
|
|
|
|
2017-12-22 14:49:14 +01:00
|
|
|
|
2024-01-30 12:51:23 +01:00
|
|
|
def warning_2024() -> None:
|
2023-01-07 14:16:45 +01:00
|
|
|
if sys.version_info < (3, 10):
|
2021-02-15 16:12:38 +01:00
|
|
|
warnings.warn("""
|
2023-01-07 14:16:45 +01:00
|
|
|
As our baseline system is the latest Ubuntu LTS, and Ubuntu LTS 22.04 has Python 3.10 available,
|
|
|
|
we will officially deprecate python versions below 3.10 on January 1st 2024.
|
2021-02-15 16:12:38 +01:00
|
|
|
**Please update your codebase.**""", DeprecationWarning, stacklevel=3)
|
|
|
|
|
|
|
|
|
2019-12-18 14:45:14 +01:00
|
|
|
everything_broken = '''Unknown error: the response is not in JSON.
|
|
|
|
Something is broken server-side, please send us everything that follows (careful with the auth key):
|
|
|
|
Request headers:
|
|
|
|
{}
|
|
|
|
Request body:
|
|
|
|
{}
|
|
|
|
Response (if any):
|
|
|
|
{}'''
|
2017-12-22 14:49:14 +01:00
|
|
|
|
|
|
|
|
2017-08-25 16:08:05 +02:00
|
|
|
try:
|
2023-01-07 14:16:45 +01:00
|
|
|
warning_2024()
|
2022-12-01 10:05:38 +01:00
|
|
|
from .exceptions import (PyMISPError, NewEventError, NewAttributeError, MissingDependency, NoURL, NoKey, # noqa
|
|
|
|
InvalidMISPObject, UnknownMISPObjectTemplate, PyMISPInvalidFormat, MISPServerError, PyMISPNotImplementedYet, PyMISPUnexpectedResponse, PyMISPEmptyResponse)
|
|
|
|
from .abstract import AbstractMISP, MISPEncode, pymisp_json_default, MISPTag, Distribution, ThreatLevel, Analysis # noqa
|
2021-04-22 10:47:51 +02:00
|
|
|
from .mispevent import (MISPEvent, MISPAttribute, MISPObjectReference, MISPObjectAttribute, MISPObject, MISPUser, # noqa
|
|
|
|
MISPOrganisation, MISPSighting, MISPLog, MISPShadowAttribute, MISPWarninglist, MISPTaxonomy,
|
|
|
|
MISPNoticelist, MISPObjectTemplate, MISPSharingGroup, MISPRole, MISPServer, MISPFeed,
|
|
|
|
MISPEventDelegation, MISPUserSetting, MISPInbox, MISPEventBlocklist, MISPOrganisationBlocklist,
|
2022-12-01 10:05:38 +01:00
|
|
|
MISPEventReport, MISPCorrelationExclusion, MISPDecayingModel, MISPGalaxy, MISPGalaxyCluster,
|
|
|
|
MISPGalaxyClusterElement, MISPGalaxyClusterRelation)
|
2024-02-12 11:35:24 +01:00
|
|
|
from .api import PyMISP, register_user # noqa
|
|
|
|
# NOTE: the direct imports to .tools are kept for backward compatibility but should be removed in the future
|
2017-09-12 16:46:06 +02:00
|
|
|
from .tools import AbstractMISPObjectGenerator # noqa
|
2017-09-20 12:24:51 +02:00
|
|
|
from .tools import openioc # noqa
|
2018-01-26 17:02:47 +01:00
|
|
|
from .tools import ext_lookups # noqa
|
2020-09-10 15:26:34 +02:00
|
|
|
from .tools import update_objects # noqa
|
2019-12-18 14:45:14 +01:00
|
|
|
from .tools import load_warninglists # noqa
|
2024-02-12 11:35:24 +01:00
|
|
|
|
2019-12-18 14:45:14 +01:00
|
|
|
try:
|
|
|
|
from .tools import reportlab_generator # noqa
|
|
|
|
except ImportError:
|
|
|
|
# FIXME: The import should not raise an exception if reportlab isn't installed
|
|
|
|
pass
|
|
|
|
except NameError:
|
|
|
|
# FIXME: The import should not raise an exception if reportlab isn't installed
|
|
|
|
pass
|
2017-11-08 03:10:04 +01:00
|
|
|
logger.debug('pymisp loaded properly')
|
|
|
|
except ImportError as e:
|
2024-01-17 13:13:14 +01:00
|
|
|
logger.warning(f'Unable to load pymisp properly: {e}')
|
2024-01-30 12:51:23 +01:00
|
|
|
|
2024-02-06 14:46:59 +01:00
|
|
|
|
|
|
|
class ExpandedPyMISP(PyMISP):
|
2024-02-06 16:40:49 +01:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
warnings.warn('This class is deprecated, use PyMISP instead', FutureWarning)
|
|
|
|
super().__init__(*args, **kwargs)
|
2024-02-06 14:46:59 +01:00
|
|
|
|
|
|
|
|
2024-01-30 12:51:23 +01:00
|
|
|
__all__ = ['PyMISP', 'register_user', 'AbstractMISP', 'MISPTag',
|
|
|
|
'MISPEvent', 'MISPAttribute', 'MISPObjectReference', 'MISPObjectAttribute',
|
|
|
|
'MISPObject', 'MISPUser', 'MISPOrganisation', 'MISPSighting', 'MISPLog',
|
|
|
|
'MISPShadowAttribute', 'MISPWarninglist', 'MISPTaxonomy', 'MISPNoticelist',
|
|
|
|
'MISPObjectTemplate', 'MISPSharingGroup', 'MISPRole', 'MISPServer', 'MISPFeed',
|
|
|
|
'MISPEventDelegation', 'MISPUserSetting', 'MISPInbox', 'MISPEventBlocklist',
|
|
|
|
'MISPOrganisationBlocklist', 'MISPEventReport', 'MISPCorrelationExclusion',
|
|
|
|
'MISPDecayingModel', 'MISPGalaxy', 'MISPGalaxyCluster', 'MISPGalaxyClusterElement',
|
|
|
|
'MISPGalaxyClusterRelation', 'PyMISPError', 'NewEventError', 'NewAttributeError',
|
|
|
|
'NoURL', 'NoKey', 'InvalidMISPObject', 'UnknownMISPObjectTemplate', 'PyMISPInvalidFormat',
|
2024-02-06 14:46:59 +01:00
|
|
|
'Distribution', 'ThreatLevel', 'Analysis', 'ExpandedPyMISP'
|
2024-01-30 12:51:23 +01:00
|
|
|
]
|