Skip to content
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

Deprecate direct commandline scripts invocation and exclude nonsense ones #2364

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

tkmikan
Copy link
Contributor

@tkmikan tkmikan commented Mar 10, 2024

Deprecate the direct invocations to scripts before refactoring all tools to have a single entry point (Not finished in #660)
Check #2361

@tkmikan tkmikan changed the title deprecate direct commandline scripts invocation and exclude nonsense ones Deprecate direct commandline scripts invocation and exclude nonsense ones Mar 10, 2024
@Arusekk
Copy link
Member

Arusekk commented Mar 12, 2024

I would keep checksec, asm, disasm, constgrep, cyclic and errno, honestly, but most distros (pentoo, kali, AUR, not sure what else) already use the flag anyway.

@peace-maker
Copy link
Member

We can add the inverse of the current pwn-only flag for users who wish to keep the wrapper scripts. I too think you can discover the other commands more easily when using the pwn wrapper. I use the tools you listed frequently as well, but do you suggest to keep them as is since distros already remove the scripts and users installing through pip expect them to be available?

@Arusekk Arusekk linked an issue Jun 15, 2024 that may be closed by this pull request
@peace-maker
Copy link
Member

I would keep checksec, asm, disasm, constgrep, cyclic and errno, honestly, but most distros (pentoo, kali, AUR, not sure what else) already use the flag anyway.

Hm, I think keeping those is benefitial or at least leaving an option to have them installed. I frequently use those tools and always typing pwn feels annoying. Removing main and update etc. is a no-brainer.

@Arusekk
Copy link
Member

Arusekk commented Jul 2, 2024

I thought about something like this, but removing the flag might annoy distro maintainers, as it force-reintroduces the deprecated scripts to those using the magic flag:

From baf9b8532a2f54f47035af0c792bf7e30e5cf1cd Mon Sep 17 00:00:00 2001
From: Arusekk <[email protected]>
Date: Mon, 24 Jun 2024 21:47:13 +0200
Subject: [PATCH] Clean up entry points

---
 pyproject.toml | 24 +++++++++++++++++++++++-
 setup.py       |  2 +-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index ce59233f..a3320880 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -3,7 +3,7 @@ requires = ["setuptools>=44.0", "wheel", "toml; python_version<'3.4'"]
 build-backend = "setuptools.build_meta"
 
 [project]
-dynamic = ["version", "scripts"]
+dynamic = ["version"]
 
 name = "pwntools"
 description = "Pwntools CTF framework and exploit development library."
@@ -63,6 +63,28 @@ dependencies = [
 homepage = "https://pwntools.com"
 download = "https://github.com/Gallopsled/pwntools/releases"
 
+[project.scripts]
+pwn = "pwnlib.commandline.main:main"
+asm = "pwnlib.commandline.common:deprecated_main"
+checksec = "pwnlib.commandline.common:main"
+constgrep = "pwnlib.commandline.common:main"
+cyclic = "pwnlib.commandline.common:deprecated_main"
+debug = "pwnlib.commandline.common:deprecated_main"
+disablenx = "pwnlib.commandline.common:deprecated_main"
+disasm = "pwnlib.commandline.common:deprecated_main"
+elfdiff = "pwnlib.commandline.common:deprecated_main"
+elfpatch = "pwnlib.commandline.common:deprecated_main"
+errno = "pwnlib.commandline.common:deprecated_main"
+hex = "pwnlib.commandline.common:deprecated_main"
+libcdb = "pwnlib.commandline.common:main"
+phd = "pwnlib.commandline.common:main"
+pwnstrip = "pwnlib.commandline.common:main"
+scramble = "pwnlib.commandline.common:deprecated_main"
+shellcraft = "pwnlib.commandline.common:main"
+template = "pwnlib.commandline.common:deprecated_main"
+unhex = "pwnlib.commandline.common:deprecated_main"
+
+
 [tool.distutils.bdist_wheel]
 universal = 1
 
diff --git a/setup.py b/setup.py
index 812a0121..104b5fda 100755
--- a/setup.py
+++ b/setup.py
@@ -51,6 +51,7 @@ if sys.version_info < (3, 4):
     compat['packages'] = find_packages()
     compat['install_requires'] = project['dependencies']
     compat['name'] = project['name']
+    compat['entry_points'] = {'console_scripts': project['scripts']}
     # https://github.com/pypa/pip/issues/7953
     site.ENABLE_USER_SITE = "--user" in sys.argv[1:]
 
@@ -77,6 +78,5 @@ setup(
             'data/templates/*.mako',
         ] + templates,
     },
-    entry_points = {'console_scripts': console_scripts},
     **compat
 )
-- 
2.45.2

I'd like to remove all the useless scripts (as the PR does for main, common etc.), and for sure deprecate template, scramble & debug, and also maybe deprecate direct invocation of the tools that are not strictly pwntools-specific; the rest should stay non-deprecated for now, especially constgrep, shellcraft, phd, checksec.

Later on, we can use python packaging extras for those scripts, see #2245 (sadly, deps can only be positive, and I would honestly love pwntools[slim] vs pwntools over pwntools vs pwntools[full], but whatever). I'm getting ready for cutting a release, and removing the truly useless scripts would be a great feature to have in it. I think that the 'bigger' changes to the scripts, deprecation or removal of the quasi-useful ones, can be coupled with the other PR to reduce the burden on distro maintainers, and just annoy them once.

@peace-maker
Copy link
Member

@Arusekk I've converted your list of deprecated commands into the setup.py code. I wanted to keep the --only-use-pwn-command option available but after a quick search it doesn't seem to possible to pass it to pip anymore without some more work overriding some pip internals on our side. So maybe removing the flag and going with your proposed changes to the pyproject.toml is cleaner.

But Python 2 pip still allows to pass the --install-option. So switch to the declarative solution in v5?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

installing pwntools pollutes /usr/local/bin
3 participants