• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Gallopsled / pwntools / 11519345748

25 Oct 2024 01:39PM UTC coverage: 73.587% (+0.008%) from 73.579%
11519345748

Pull #2364

github

web-flow
Merge 72f6a6170 into 61804b169
Pull Request #2364: Deprecate direct commandline scripts invocation and exclude nonsense ones

3768 of 6362 branches covered (59.23%)

1 of 6 new or added lines in 1 file covered. (16.67%)

13245 of 17999 relevant lines covered (73.59%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.05
/pwnlib/commandline/common.py
1
import argparse
1✔
2
import os
1✔
3
import sys
1✔
4

5
import pwnlib
1✔
6
from pwnlib.context import context
1✔
7

8
choices = list(map(str, [16,32,64]))
1✔
9
choices += list(context.oses)
1✔
10
choices += list(context.architectures)
1✔
11
choices += list(context.endiannesses)
1✔
12

13
def context_arg(arg):
1✔
14
    try: context.arch = arg
1✔
15
    except Exception: pass
1✔
16
    try: context.os = arg
1✔
17
    except Exception: pass
1✔
18
    try: context.bits = int(arg)
1✔
19
    except Exception: arg
1✔
20
    try: context.endian = arg
1✔
21
    except Exception: pass
1✔
22
    return arg
1✔
23

24
parser = argparse.ArgumentParser(description='Pwntools Command-line Interface',
1✔
25
                                 prog='pwn')
26
parser_commands = parser.add_subparsers(dest='command')
1✔
27

28
def main(file=sys.argv[0], command_main=None):
1✔
29
    name = os.path.splitext(os.path.basename(file))[0]
1✔
30
    if command_main is None:
1!
31
        import importlib
×
32
        command_main = importlib.import_module('pwnlib.commandline.%s' % name).main
×
33
    sys.argv.insert(1, name)
1✔
34
    entrypoint({name: command_main})
1✔
35

36
def deprecated_main():
1✔
NEW
37
    file=sys.argv[0]
×
NEW
38
    name = os.path.splitext(os.path.basename(file))[0]
×
NEW
39
    import warnings
×
NEW
40
    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)
×
NEW
41
    main(file)
×
42

43
def entrypoint(commands):
1✔
44
    if len(sys.argv) < 2:
1!
45
        parser.print_usage()
×
46
        sys.exit()
×
47
    args = parser.parse_args()
1✔
48
    with context.local(log_console = sys.stderr):
1✔
49
        commands[args.command](args)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc