mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-03 10:52:53 -05:00
Merge pull request #1156 from rbenv/no-dir-traversal
Disallow path segments and directory traversal in `.ruby-version` files
This commit is contained in:
commit
4e923221ce
2 changed files with 19 additions and 1 deletions
|
@ -11,7 +11,9 @@ if [ -e "$VERSION_FILE" ]; then
|
||||||
words=( $(cut -b 1-1024 "$VERSION_FILE") )
|
words=( $(cut -b 1-1024 "$VERSION_FILE") )
|
||||||
version="${words[0]}"
|
version="${words[0]}"
|
||||||
|
|
||||||
if [ -n "$version" ]; then
|
if [ "$version" = ".." ] || [[ $version == */* ]]; then
|
||||||
|
echo "rbenv: invalid version in \`$VERSION_FILE'" >&2
|
||||||
|
elif [ -n "$version" ]; then
|
||||||
echo "$version"
|
echo "$version"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -70,3 +70,19 @@ IN
|
||||||
run rbenv-version-file-read my-version
|
run rbenv-version-file-read my-version
|
||||||
assert_success "1.9.3"
|
assert_success "1.9.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "prevents directory traversal" {
|
||||||
|
cat > my-version <<<".."
|
||||||
|
run rbenv-version-file-read my-version
|
||||||
|
assert_failure "rbenv: invalid version in \`my-version'"
|
||||||
|
|
||||||
|
cat > my-version <<<"../foo"
|
||||||
|
run rbenv-version-file-read my-version
|
||||||
|
assert_failure "rbenv: invalid version in \`my-version'"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "disallows path segments in version string" {
|
||||||
|
cat > my-version <<<"foo/bar"
|
||||||
|
run rbenv-version-file-read my-version
|
||||||
|
assert_failure "rbenv: invalid version in \`my-version'"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue