Skip to content

Commit

Permalink
more secure ssh copy (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankrb authored Nov 15, 2024
1 parent b6e35c4 commit 809d847
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/anemoi/utils/remote/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def _parse_target(self, target):
hostnames = hostname.split("+")
hostname = hostnames[random.randint(0, len(hostnames) - 1)]

if ".." in path.split("/"):
raise Exception("Path contains suspicious '..' : {target}")

return hostname, path

def get_temporary_target(self, target, pattern):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_transfer_local_to_s3_to_local(path):


@pytest.mark.skipif(IN_CI, reason="Test requires ssh access to localhost")
@pytest.mark.parametrize("path", ["directory", "directory/", "file"])
@pytest.mark.parametrize("path", ["directory", "file"])
@pytest.mark.parametrize("temporary_target", [True, False])
def test_transfer_local_to_ssh(path, temporary_target):
local = LOCAL_TEST_DATA + "/" + path
Expand Down

0 comments on commit 809d847

Please sign in to comment.