Skip to content

Commit

Permalink
Merge pull request #346 from PyAr/exec-only-from-venv
Browse files Browse the repository at this point in the history
Verify that a path was not given to --exec. Fixes #331.
  • Loading branch information
gilgamezh committed Feb 3, 2019
2 parents e2ec15a + 95ca550 commit f6348f6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ script stderr is not polluted at all.

Sometimes, you want to run a script provided by one of the dependencies
installed into the virtualenv. *fades* supports this via the ``-x`` (
or ``--exec`` argument).
or ``--exec`` argument). The parameter given to this option needs to be just
the executable name; it's an error to use this to execute anything outside
the venv's bin directory, just don't use this option and pass the executable
directly if you want that.

If you want to use IPython shell you need to call *fades* with ``-i`` or
``--ipython`` option. This option will add IPython as a dependency to *fades*
Expand Down
7 changes: 7 additions & 0 deletions fades/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ def go():
logger.warning('No virtualenv found with uuid: %s.', uuid)
return 0

# if --exec given, check that it's just the executable name, not absolute or relative paths
if args.executable and os.path.sep in args.child_program:
logger.error(
"The parameter to --exec must be a file name (to be found "
"inside venv's bin directory), not a file path: %r", args.child_program)
raise FadesError("File path given to --exec parameter")

# decided which the child program really is
analyzable_child_program, child_program = decide_child_program(
args.executable, args.child_program)
Expand Down
4 changes: 3 additions & 1 deletion man/fades.1
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ The dependencies can be indicated in multiple places (in the Python source file,

.TP
.BR -x ", " --exec
Execute the \fIchild_program\fR inside the virtualenv.
Execute the \fIchild_program\fR inside the virtualenv (so the parameter given needs to be just
the executable name). It's an error to use this option to execute anything outside the venv's bin
directory, just stop using this option for that case.

The \fIchild_program\fR \fBmust\fR be found in the virtualenv's \fIbin\fR directory.

Expand Down

0 comments on commit f6348f6

Please sign in to comment.