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 2 commits into
base: dev
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ The table below shows which release corresponds to each branch, and what date th
- [#2327][2327] Add basic support to debug processes on Windows
- [#2322][2322] Add basic RISCV64 shellcraft support
- [#2330][2330] Change `context.newline` when setting `context.os` to `"windows"`
- [#2364][2364] Deprecate direct commandline scripts invocation and exclude nonsense ones
- [#2389][2389] Fix passing bytes to `context.log_file` and `crc.BitPolynom`
- [#2391][2391] Fix error message when passing invalid kwargs to `xor`
- [#2376][2376] Return buffered data on first EOF in tube.readline()
Expand All @@ -90,6 +91,7 @@ The table below shows which release corresponds to each branch, and what date th
[2327]: https://github.com/Gallopsled/pwntools/pull/2327
[2322]: https://github.com/Gallopsled/pwntools/pull/2322
[2330]: https://github.com/Gallopsled/pwntools/pull/2330
[2364]: https://github.com/Gallopsled/pwntools/pull/2364
[2389]: https://github.com/Gallopsled/pwntools/pull/2389
[2391]: https://github.com/Gallopsled/pwntools/pull/2391
[2376]: https://github.com/Gallopsled/pwntools/pull/2376
Expand Down
7 changes: 7 additions & 0 deletions pwnlib/commandline/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ def main(file=sys.argv[0]):
name = os.path.splitext(os.path.basename(file))[0]
sys.argv.insert(1, name)
pwnlib.commandline.main.main()

def deprecated_main():
file=sys.argv[0]
name = os.path.splitext(os.path.basename(file))[0]
import warnings
warnings.warn("The '%s' command is deprecated and will be removed in a future version. Please use 'pwn %s' instead." % (name, name), DeprecationWarning, stacklevel=2)
main(file)
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
filename = os.path.basename(filename)
filename, ext = os.path.splitext(filename)

if ext != '.py' or '__init__' in filename:
if ext != '.py' or filename in ('__init__', 'common', 'main', 'update', 'version'):
continue

script = '%s=pwnlib.commandline.common:main' % filename
script = '%s=pwnlib.commandline.common:deprecated_main' % filename
if not flag:
console_scripts.append(script)

Expand Down Expand Up @@ -78,6 +78,5 @@
] + templates,
},
entry_points = {'console_scripts': console_scripts},
scripts = glob.glob("bin/*"),
**compat
)