Skip to content

Commit

Permalink
Sanitize script arguments
Browse files Browse the repository at this point in the history
See tox-dev/tox#1463 for details.
  • Loading branch information
i386x authored and tyll committed Nov 27, 2019
1 parent 5877eb7 commit ede025f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 26 deletions.
16 changes: 7 additions & 9 deletions .travis/custom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@

# This script is executed with two arguments passed to it:
#
# $1 - full path to environment python (python used inside virtual
# environment created by tox)
# $2 - full path to system python (python 3.x installed on the system)
# $1 - path to environment python (python used inside virtual environment
# created by tox)
# $2 - path to system python (python 3.x installed on the system)

set -ex
shopt
alias
env
set -e

ME=$(basename $0)
SCRIPTDIR=$(readlink -f $(dirname $0))
Expand All @@ -20,8 +17,9 @@ TOPDIR=$(readlink -f ${SCRIPTDIR}/..)
. ${SCRIPTDIR}/utils.sh
. ${SCRIPTDIR}/config.sh

ENVPYTHON=$1
SYSPYTHON=$2
# Sanitize arguments (see https://github.com/tox-dev/tox/issues/1463):
ENVPYTHON=$(readlink -f $1)
SYSPYTHON=$(readlink -f $2)
shift 2

# Write your custom commands here that should be run when `tox -e custom`:
Expand Down
8 changes: 5 additions & 3 deletions .travis/runblack.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
# SPDX-License-Identifier: MIT

# Run black (the Python formatter). The first script argument is a full path
# to Python interpreter, the rest of arguments are passed to black.
# Run black (the Python formatter). The first script argument is a path to
# Python interpreter, the rest of arguments are passed to black.

# Environment variables:
#
Expand Down Expand Up @@ -31,7 +31,9 @@ if [[ "${RUN_BLACK_DISABLED}" ]]; then
exit 0
fi

ENVPYTHON=$1
# Sanitize path in case if running within tox (see
# https://github.com/tox-dev/tox/issues/1463):
ENVPYTHON=$(readlink -f $1)
shift

DEFAULT_INCLUDE='^[^.].*\.py$'
Expand Down
9 changes: 5 additions & 4 deletions .travis/runcoveralls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Report coverage results using coveralls. The script is executed with these
# parameters:
#
# $1 - full path to environment python
# $2 - full path to system python
# $1 - path to environment python
# $2 - path to system python
#
# coveralls is executed only if $1 coincides with $2 and $1's environment is
# stable, i.e. TRAVIS_PYTHON_VERSION is of the form [:digit:] "." [:digit:]
Expand All @@ -32,8 +32,9 @@ if [[ -z "${LSR_PUBLISH_COVERAGE}" ]]; then
exit 0
fi

ENVPYTHON=$1
SYSPYTHON=$2
# Sanitize arguments (see https://github.com/tox-dev/tox/issues/1463):
ENVPYTHON=$(readlink -f $1)
SYSPYTHON=$(readlink -f $2)
shift 2

if lsr_compare_pythons ${ENVPYTHON} -ne ${SYSPYTHON}; then
Expand Down
8 changes: 5 additions & 3 deletions .travis/runflake8.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
# SPDX-License-Identifier: MIT

# Run flake8. The first script argument is a full path to Python interpreter,
# the rest of arguments are passed to flake8.
# Run flake8. The first script argument is a path to Python interpreter, the
# rest of arguments are passed to flake8.

# Environment variables:
#
Expand All @@ -23,7 +23,9 @@ if [[ "${RUN_FLAKE8_DISABLED}" ]]; then
exit 0
fi

ENVPYTHON=$1
# Sanitize path in case if running within tox (see
# https://github.com/tox-dev/tox/issues/1463):
ENVPYTHON=$(readlink -f $1)
shift

set -x
Expand Down
8 changes: 5 additions & 3 deletions .travis/runpytest.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
# SPDX-License-Identifier: MIT

# Wrapper around pytest. First argument is a full path to environment python,
# the rest of arguments are passed to pytest.
# Wrapper around pytest. First argument is a path to environment python, the
# rest of arguments are passed to pytest.

set -e

Expand All @@ -18,7 +18,9 @@ if [[ ! -d ${TOPDIR}/tests/unit ]]; then
exit 0
fi

ENVPYTHON=$1
# Sanitize path in case if running within tox (see
# https://github.com/tox-dev/tox/issues/1463):
ENVPYTHON=$(readlink -f $1)
shift

PYTEST_OPTS=()
Expand Down
9 changes: 5 additions & 4 deletions .travis/runsyspycmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# to system python libraries, especially C bindings. The script is run with
# these arguments:
#
# $1 - full path to environment python
# $2 - full path to system python
# $1 - path to environment python
# $2 - path to system python
# $3 - command runnable in Python (should be present in $PATH)
# ${@:4} - arguments passed to $3

Expand All @@ -23,8 +23,9 @@ TOPDIR=$(readlink -f ${SCRIPTDIR}/..)
# Run user defined hook from .travis/config.sh.
lsr_runsyspycmd_hook "$@"

ENVPYTHON=$1
SYSPYTHON=$2
# Sanitize arguments (see https://github.com/tox-dev/tox/issues/1463):
ENVPYTHON=$(readlink -f $1)
SYSPYTHON=$(readlink -f $2)
shift 2

if lsr_compare_pythons ${ENVPYTHON} -ne ${SYSPYTHON}; then
Expand Down

0 comments on commit ede025f

Please sign in to comment.