Skip to content

Commit

Permalink
Merge pull request #31 from asottile/parent_directories
Browse files Browse the repository at this point in the history
Correctly check parent directories
  • Loading branch information
chriskuehl authored Jan 25, 2019
2 parents cca5e54 + 77a07c8 commit 906b645
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions aactivator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def insecure(path):


def search_parent_paths(path):
path = os.path.abspath(path)
original_fs_id = fs_id = get_filesystem_id(path)
previous_path = None
while original_fs_id == fs_id and path != previous_path:
Expand Down
24 changes: 24 additions & 0 deletions tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,30 @@ def test_complains_when_not_activated(activate, venv_path, tmpdir, shell):
run_test(shell, test, tmpdir)


def test_complains_parent_directory_insecure(venv_path, tmpdir, shell):
make_venv_in_tempdir(tmpdir)
venv_path.chmod(0o777)

test = '''\
TEST> eval "$(aactivator init)"
TEST> echo
TEST> cd {venv_path}
aactivator will source .activate.sh and .deactivate.sh at {venv_path}.
Acceptable? (y)es (n)o (N)ever: INPUT> y
aactivator will remember this: ~/.cache/aactivator/allowed
aactivator: Cowardly refusing to source .activate.sh because writeable by others: .
TEST> echo
aactivator: Cowardly refusing to source .activate.sh because writeable by others: .
TEST> cd /
TEST> echo
'''
test = test.format(venv_path=str(venv_path))
run_test(shell, test, tmpdir)


def test_activate_but_no_deactivate(venv_path, tmpdir, deactivate, shell):
make_venv_in_tempdir(tmpdir)
deactivate.remove()
Expand Down

0 comments on commit 906b645

Please sign in to comment.