Skip to content

Commit

Permalink
chg: [deps] Remove pyfaup
Browse files Browse the repository at this point in the history
  • Loading branch information
ostefano committed Feb 26, 2025
1 parent 0e04091 commit 882338f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 67 deletions.
41 changes: 0 additions & 41 deletions misp_modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion misp_modules/modules/action_mod/mattermost.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion misp_modules/modules/expansion/extract_url_components.py
Original file line number Diff line number Diff line change
@@ -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'}
Expand Down
6 changes: 1 addition & 5 deletions misp_modules/modules/import_mod/email_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion misp_modules/modules/import_mod/url_import.py
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
16 changes: 1 addition & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"}
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 882338f

Please sign in to comment.