Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path normalization will make some valid s3 keys inaccessible #19

Open
bogovicj opened this issue Jul 3, 2023 · 0 comments
Open

Path normalization will make some valid s3 keys inaccessible #19

bogovicj opened this issue Jul 3, 2023 · 0 comments
Labels

Comments

@bogovicj
Copy link
Contributor

bogovicj commented Jul 3, 2023

... and that's okay by me.

Object keys names in s3 can be weird.

For example, it is possible to have an object at key a/../obj inside some bucket. where .. is part of the object key and does not indicate the parent folder as it would on a usual local file system. In other words, on s3 a/../obj != obj where on a local filesystem a/../obj == obj. As well, keys may contain . or "" (empty string) delimited by slashes, akin to having a folder called "." or "". See the examples below.

Normalization of paths in n5 currently treats the following as equivalent:

  • a/obj
  • /a/obj
  • a/./obj
  • ./a/obj
  • a/b/../obj
  • ././/a/.///obj

but these are all potentially unique keys in an s3 bucket. I don't see a compelling reason to try to make this work right now. Rather, we'll strongly recommend not to use ., .., or `` (empty string) in keys as in the above examples.

ping @cmhulbert

touch obj # Make an empty file

# Put obj in the bucket root
$ aws s3 cp obj s3://n5-zarr-tests/
upload: ./obj to s3://n5-zarr-tests/obj

# Put obj at the key '/obj'
# think: obj is in a folder named "" (empty string) inside the bucket root
$ aws s3 cp obj s3://n5-zarr-tests//
upload: ./obj to s3://n5-zarr-tests//obj

# Put obj at the key './obj'
# think: obj is in a folder named "." (dot) inside the bucket root
$ aws s3 cp obj s3://n5-zarr-tests/./ 
upload: ./obj to s3://n5-zarr-tests/./obj

# S3 not happy
$ aws s3 cp obj s3://n5-zarr-tests/../
upload failed: ./obj to s3://n5-zarr-tests/../obj An error occurred (400) when calling the PutObject operation: Bad Request

# Put obj at the key 'a/../obj'
$ aws s3 cp obj s3://n5-zarr-tests/a/../
upload: ./obj to s3://n5-zarr-tests/a/../obj

# Make keys with two different empty strings
aws s3 cp obj 's3://n5-zarr-tests/a/ /'
aws s3 cp obj 's3://n5-zarr-tests/a/  /'

# The results of the above
$ aws s3 ls --recursive s3://n5-zarr-tests
2023-07-03 11:01:13          0 ./obj
2023-07-03 11:01:02          0 /obj
2023-07-03 11:02:36          0 a/  /obj
2023-07-03 11:02:01          0 a/ /obj
2023-07-03 11:01:32          0 a/../obj
2023-07-03 11:00:35          0 obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant