From 882338f5f47926e4bcc7deb7a259ae5f8b094f2f Mon Sep 17 00:00:00 2001 From: Stefano Ortolani Date: Wed, 26 Feb 2025 12:08:23 +0000 Subject: [PATCH] chg: [deps] Remove pyfaup --- misp_modules/__init__.py | 41 ------------------- misp_modules/modules/action_mod/mattermost.py | 2 +- .../expansion/extract_url_components.py | 2 +- .../modules/import_mod/email_import.py | 6 +-- misp_modules/modules/import_mod/url_import.py | 2 +- poetry.lock | 16 +------- pyproject.toml | 5 +-- 7 files changed, 7 insertions(+), 67 deletions(-) diff --git a/misp_modules/__init__.py b/misp_modules/__init__.py index f8fbf86e..3848d8d2 100644 --- a/misp_modules/__init__.py +++ b/misp_modules/__init__.py @@ -49,47 +49,6 @@ warnings.filterwarnings("ignore", category=SyntaxWarning) -LIBFAUP_PATHS = [ - "/usr/local/lib/", - "/usr/lib/", - "/opt/local/lib/", -] - -ARCH_TO_EXTENSION = { - "linux": "so", - "darwin": "dylib", -} - - -def _get_libfaup_path(lib_path: str) -> str: - extension = ARCH_TO_EXTENSION.get(platform.system().lower(), "lib") - return f"{lib_path.rstrip('/')}/libfaupl.{extension}" - - -def _replace_libfaup_path(module_path: str, libfaup_path: str) -> None: - with open(module_path, "r") as f: - file_data = f.read() - file_data = re.sub(r"cdll.LoadLibrary\(.*\)", f"cdll.LoadLibrary(\"{libfaup_path}\")", file_data) - with open(module_path, "w") as f: - f.write(file_data) - - -def _try_pyfaup_import(lib_path: typing.Optional[str]) -> None: - package = pkgutil.get_loader("pyfaup") - if not package: - return - if lib_path: - _replace_libfaup_path(package.path, _get_libfaup_path(lib_path)) - importlib.import_module("pyfaup") - - -for lib_path in [None, *LIBFAUP_PATHS]: - try: - _try_pyfaup_import(lib_path) - break - except OSError: - continue - try: from .modules import * # noqa HAS_PACKAGE_MODULES = True diff --git a/misp_modules/modules/action_mod/mattermost.py b/misp_modules/modules/action_mod/mattermost.py index 49c8ab9a..a25b5f01 100644 --- a/misp_modules/modules/action_mod/mattermost.py +++ b/misp_modules/modules/action_mod/mattermost.py @@ -1,5 +1,5 @@ import json -from pyfaup.faup import Faup +from pymisp.tools._psl_faup import PSLFaup as Faup from mattermostdriver import Driver from ._utils import utils diff --git a/misp_modules/modules/expansion/extract_url_components.py b/misp_modules/modules/expansion/extract_url_components.py index dd9c29fa..3f2b09c8 100644 --- a/misp_modules/modules/expansion/extract_url_components.py +++ b/misp_modules/modules/expansion/extract_url_components.py @@ -1,7 +1,7 @@ import json from pymisp import MISPEvent, MISPObject from . import check_input_attribute, standard_error_message -from pyfaup.faup import Faup +from pymisp.tools._psl_faup import PSLFaup as Faup misperrors = {'error': 'Error'} mispattributes = {'input': ['url'], 'format': 'misp_standard'} diff --git a/misp_modules/modules/import_mod/email_import.py b/misp_modules/modules/import_mod/email_import.py index 9ad65cc8..411185e6 100644 --- a/misp_modules/modules/import_mod/email_import.py +++ b/misp_modules/modules/import_mod/email_import.py @@ -4,11 +4,7 @@ import zipfile import re from html.parser import HTMLParser -from pymisp.tools import EMailObject, make_binary_objects -try: - from pymisp.tools import URLObject -except ImportError: - raise ImportError('Unable to import URLObject, pyfaup missing') +from pymisp.tools import EMailObject, make_binary_objects, URLObject from io import BytesIO from pathlib import Path diff --git a/misp_modules/modules/import_mod/url_import.py b/misp_modules/modules/import_mod/url_import.py index 1405f7e1..5b4ddda6 100755 --- a/misp_modules/modules/import_mod/url_import.py +++ b/misp_modules/modules/import_mod/url_import.py @@ -1,7 +1,7 @@ import json import base64 from pymisp import MISPEvent, MISPObject, MISPAttribute -from pyfaup.faup import Faup +from pymisp.tools._psl_faup import PSLFaup as Faup misperrors = {'error': 'Error'} userConfig = { diff --git a/poetry.lock b/poetry.lock index e9d1a30f..9f026a31 100644 --- a/poetry.lock +++ b/poetry.lock @@ -4196,19 +4196,6 @@ requests = ">=2.31.0,<3.0.0" [package.extras] docs = ["Sphinx (<7.2) ; python_version < \"3.9\"", "Sphinx (>=7.2,<8.0) ; python_version >= \"3.9\""] -[[package]] -name = "pyfaup" -version = "1.2" -description = "Python bindings for the faup library" -optional = false -python-versions = "*" -groups = ["main"] -markers = "platform_system == \"Linux\" and platform_machine == \"aarch64\"" -files = [ - {file = "pyfaup-1.2-py2.py3-none-any.whl", hash = "sha256:75f96f7da86ffb5402d3fcc2dbf98a511e792cf9100c159e34cdba8996ddc7f9"}, - {file = "pyfaup-1.2.tar.gz", hash = "sha256:5648bc3ebd80239aec927aedfc218c3a6ff36de636cc53822bfeb70b0869b1e7"}, -] - [[package]] name = "pyflakes" version = "3.2.0" @@ -4324,7 +4311,6 @@ lief = {version = ">=0.16.0,<0.17.0", optional = true, markers = "extra == \"fil oletools = {version = ">=0.60.1,<0.61.0", optional = true, markers = "extra == \"email\""} publicsuffixlist = ">=1.0.2.20241218,<2.0.0.0" pydeep2 = {version = ">=0.5.1,<0.6.0", optional = true, markers = "extra == \"fileobjects\""} -pyfaup = {version = ">=1.2,<2.0", optional = true, markers = "extra == \"url\""} python-dateutil = ">=2.9.0.post0,<3.0.0" python-magic = {version = ">=0.4.27,<0.5.0", optional = true, markers = "extra == \"fileobjects\""} reportlab = {version = ">=4.2.5,<5.0.0", optional = true, markers = "extra == \"pdfexport\""} @@ -6725,4 +6711,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = ">=3.9,<3.13" -content-hash = "91389bc41c858fec57a5181cf5062df5b2f0ce30c6d276f983ea12fb749c3ac3" +content-hash = "2b3779a53b236f007b2c0e60b9f026e3ef09eef2bb543cea7d0f98b7bdc85891" diff --git a/pyproject.toml b/pyproject.toml index c9b2c3bd..a20237e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "misp-modules" -version = "2.4.200" +version = "2.4.201" description = "MISP modules are autonomous modules that can be used for expansion and other services in MISP" authors = [ {name = "Alexandre Dulaunoy", email = "alexandre.dulaunoy@circl.lu"} @@ -59,11 +59,10 @@ dependencies = [ "pycountry", "pyeti-python3", "pyeupi", - "pyfaup", "pygeoip", "pyintel471", "pyipasnhistory", - "pymisp[fileobjects, openioc, pdfexport, email, url]", + "pymisp[fileobjects, openioc, pdfexport, email]", "pypdns", "pypssl", "pysafebrowsing",