Merge branch 'main' of github.com:misp/pymisp

pull/1002/head
Christian Studer 2023-02-20 19:22:28 +01:00
commit e4cb51ecd9
10 changed files with 2023 additions and 282 deletions

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@ from pymisp import MISPEvent
try:
from keys import misp_url, misp_key, misp_verifycert
from pymisp import ExpandedPyMISP
from pymisp import PyMISP
offline = False
except ImportError as e:
offline = True
@ -66,7 +66,7 @@ if __name__ == '__main__':
if offline:
print('You are in offline mode, quitting.')
else:
misp = ExpandedPyMISP(url=misp_url, key=misp_key, ssl=misp_verifycert)
misp = PyMISP(url=misp_url, key=misp_key, ssl=misp_verifycert)
if args.new_event:
event = MISPEvent()
event.info = args.new_event
@ -80,7 +80,7 @@ if __name__ == '__main__':
else:
print('Something went wrong:')
print(new_event)
else:
elif args.update_event:
for o in objects:
new_object = misp.add_object(args.update_event, o, pythonify=True)
if isinstance(new_object, str):
@ -90,3 +90,5 @@ if __name__ == '__main__':
else:
print('Something went wrong:')
print(new_event)
else:
print('you need to pass either a event info field (flag -i), or the event ID you want to update (flag -u)')

649
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -3097,7 +3097,7 @@ class PyMISP:
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_id}', data=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)

@ -1 +1 @@
Subproject commit fd603be3283953b68ed48ede7afd2e19f43577ac
Subproject commit 3d238ffc407563e2d81cfcb867f426ae4f0ae898

View File

@ -36,7 +36,7 @@ class ELFObject(AbstractMISPObjectGenerator):
"""Creates an ELF object, with lief"""
super().__init__('elf', **kwargs)
if not HAS_PYDEEP:
logger.warning("Please install pydeep: pip install git+https://github.com/kbandla/pydeep.git")
logger.warning("pydeep is missing, please install pymisp this way: pip install pymisp[fileobjects]")
if pseudofile:
if isinstance(pseudofile, BytesIO):
self.__elf = lief.ELF.parse(raw=pseudofile.getvalue())

View File

@ -33,9 +33,9 @@ class FileObject(AbstractMISPObjectGenerator):
def __init__(self, filepath: Optional[Union[Path, str]] = None, pseudofile: Optional[BytesIO] = None, filename: Optional[str] = None, **kwargs) -> None:
super().__init__('file', **kwargs)
if not HAS_PYDEEP:
logger.warning("Please install pydeep: pip install git+https://github.com/kbandla/pydeep.git")
logger.warning("pydeep is missing, please install pymisp this way: pip install pymisp[fileobjects]")
if not HAS_MAGIC:
logger.warning("Please install python-magic: pip install python-magic.")
logger.warning("python-magic is missing, please install pymisp this way: pip install pymisp[fileobjects]")
if filename:
# Useful in case the file is copied with a pre-defined name by a script but we want to keep the original name
self.__filename = filename

View File

@ -36,7 +36,7 @@ class MachOObject(AbstractMISPObjectGenerator):
"""Creates an MachO object, with lief"""
super().__init__('macho', **kwargs)
if not HAS_PYDEEP:
logger.warning("Please install pydeep: pip install git+https://github.com/kbandla/pydeep.git")
logger.warning("pydeep is missing, please install pymisp this way: pip install pymisp[fileobjects]")
if pseudofile:
if isinstance(pseudofile, BytesIO):
self.__macho = lief.MachO.parse(raw=pseudofile.getvalue())

View File

@ -39,7 +39,7 @@ class PEObject(AbstractMISPObjectGenerator):
"""Creates an PE object, with lief"""
super().__init__('pe', **kwargs)
if not HAS_PYDEEP:
logger.warning("Please install pydeep: pip install git+https://github.com/kbandla/pydeep.git")
logger.warning("pydeep is missing, please install pymisp this way: pip install pymisp[fileobjects]")
if pseudofile:
if isinstance(pseudofile, BytesIO):
self.__pe = lief.PE.parse(raw=pseudofile.getvalue())

View File

@ -47,19 +47,19 @@ requests = "^2.28.2"
python-dateutil = "^2.8.2"
jsonschema = "^4.17.3"
deprecated = "^1.2.13"
extract_msg = {version = "^0.39.0", optional = true}
extract_msg = {version = "^0.39.1", optional = true}
RTFDE = {version = "^0.0.2", optional = true}
oletools = {version = "^0.60.1", optional = true}
python-magic = {version = "^0.4.27", optional = true}
pydeep2 = {version = "^0.5.1", optional = true}
lief = {version = "^0.12.3", optional = true}
beautifulsoup4 = {version = "^4.11.1", optional = true}
beautifulsoup4 = {version = "^4.11.2", optional = true}
validators = {version = "^0.20.0", optional = true}
sphinx-autodoc-typehints = {version = "^1.21.7", optional = true}
sphinx-autodoc-typehints = {version = "^1.22", optional = true}
recommonmark = {version = "^0.7.1", optional = true}
reportlab = {version = "^3.6.12", optional = true}
pyfaup = {version = "^1.2", optional = true}
publicsuffixlist = {version = "^0.9.2", optional = true}
publicsuffixlist = {version = "^0.9.3", optional = true}
urllib3 = {extras = ["brotli"], version = "^1.26.14", optional = true}
[tool.poetry.extras]
@ -74,12 +74,12 @@ brotli = ['urllib3']
[tool.poetry.group.dev.dependencies]
requests-mock = "^1.10.0"
mypy = "^0.991"
ipython = "^8.8.0"
jupyterlab = "^3.5.2"
types-requests = "^2.28.11.8"
types-python-dateutil = "^2.8.19.6"
types-redis = "^4.4.0.3"
mypy = "^1.0.1"
ipython = "^8.10.0"
jupyterlab = "^3.6.1"
types-requests = "^2.28.11.13"
types-python-dateutil = "^2.8.19.7"
types-redis = "^4.5.1.1"
types-Flask = "^1.1.6"
pytest-cov = "^4.0.0"