diff --git a/pyproject.toml b/pyproject.toml index 501096e4ac4..c3f01f1488a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = [ "setuptools>=62.0.0" ] +requires = [ "setuptools>=77.0.0" ] build-backend = "setuptools.build_meta" [project] @@ -14,7 +14,7 @@ maintainers = [ { name="Guillaume VALADON" }, { name="Nils WEISS" }, ] -license = { text="GPL-2.0-only" } +license = "GPL-2.0-only" requires-python = ">=3.7, <4" description = "Scapy: interactive packet manipulation tool" keywords = [ "network" ] @@ -26,7 +26,6 @@ classifiers = [ "Intended Audience :: Science/Research", "Intended Audience :: System Administrators", "Intended Audience :: Telecommunications Industry", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.7", diff --git a/scapy/config.py b/scapy/config.py index a6a406fa979..4fe4c6253b8 100755 --- a/scapy/config.py +++ b/scapy/config.py @@ -587,10 +587,10 @@ def __repr__(self): class ExtsManager(importlib.abc.MetaPathFinder): __slots__ = ["exts", "_loaded", "all_specs"] - SCAPY_PLUGIN_CLASSIFIER = 'Framework :: Scapy' - GPLV2_CLASSIFIERS = [ - 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', - 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)', + SCAPY_PLUGIN_CLASSIFIER = "Framework :: Scapy Plugin" + ALLOWED_LICENCES = [ + "GPL-2.0-only", + "GPL-2.0-or-later", ] def __init__(self): @@ -639,8 +639,8 @@ def load(self): if pkg in self._loaded: continue if not any( - v in self.GPLV2_CLASSIFIERS - for k, v in distr.metadata.items() if k == 'Classifier' + v in self.ALLOWED_LICENCES + for k, v in distr.metadata.items() if k == 'License-Expression' ): log_loading.warning( "'%s' has no GPLv2 classifier therefore cannot be loaded." % pkg # noqa: E501 diff --git a/scapy/layers/l2.py b/scapy/layers/l2.py index 532cd9a5f21..a9d11d41b79 100644 --- a/scapy/layers/l2.py +++ b/scapy/layers/l2.py @@ -895,14 +895,14 @@ def arpcachepoison( @conf.commands.register def arp_mitm( - ip1, # type: str - ip2, # type: str + ip1: str, + ip2: str, mac1=None, # type: Optional[Union[str, List[str]]] mac2=None, # type: Optional[Union[str, List[str]]] - broadcast=False, # type: bool - target_mac=None, # type: Optional[str] - iface=None, # type: Optional[_GlobInterfaceType] - inter=3, # type: int + broadcast: bool = False, + target_mac: Optional[str] = None, + iface: Optional[_GlobInterfaceType] = None, + inter: int = 3, ): # type: (...) -> None r"""ARP MitM: poison 2 target's ARP cache diff --git a/scapy/layers/smbclient.py b/scapy/layers/smbclient.py index adf7b093fdb..fb5f059301d 100644 --- a/scapy/layers/smbclient.py +++ b/scapy/layers/smbclient.py @@ -1126,7 +1126,7 @@ def __init__( guest: bool = False, kerberos: bool = True, kerberos_required: bool = False, - HashNt: str = None, + HashNt: bytes = None, port: int = 445, timeout: int = 2, debug: int = 0, diff --git a/scapy/utils.py b/scapy/utils.py index c9d673c9244..d7251278116 100644 --- a/scapy/utils.py +++ b/scapy/utils.py @@ -3900,13 +3900,26 @@ def AutoArgparse(func: DecoratorCallable) -> None: continue parname = param.name paramkwargs = {} - if param.annotation is bool: + paramtype = param.annotation + # Process types we don't know + if paramtype not in [bool, str, int, float]: + try: + if paramtype.__origin__ is Union: + # Handles Optional[] and Union[] + paramtype = next( + x for x in paramtype.__args__ + if x in [bool, str, int, float] + ) + except Exception: + pass + # Process the types we know + if paramtype is bool: if param.default is True: parname = "no-" + parname paramkwargs["action"] = "store_false" else: paramkwargs["action"] = "store_true" - elif param.annotation in [str, int, float]: + elif paramtype in [str, int, float]: paramkwargs["type"] = param.annotation else: continue