Skip to content

Use new classifier format for packaging #4768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = [ "setuptools>=62.0.0" ]
requires = [ "setuptools>=77.0.0" ]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -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" ]
Expand All @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions scapy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions scapy/layers/l2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scapy/layers/smbclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 15 additions & 2 deletions scapy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading