-
Notifications
You must be signed in to change notification settings - Fork 136
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
more validation for containerName and blobKey to avoid access escape #203
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,6 +187,7 @@ public boolean createContainerInLocation(String container, Location location, Cr | |
|
||
@Override | ||
public ContainerAccess getContainerAccess(String container) { | ||
filesystemContainerNameValidator.validate(container); | ||
File file = new File(buildPathStartingFromBaseDir(container)); | ||
if (!file.exists()) { | ||
throw new ContainerNotFoundException(container, "in getContainerAccess"); | ||
|
@@ -217,6 +218,7 @@ public ContainerAccess getContainerAccess(String container) { | |
|
||
@Override | ||
public void setContainerAccess(String container, ContainerAccess access) { | ||
filesystemContainerNameValidator.validate(container); | ||
Path path = new File(buildPathStartingFromBaseDir(container)).toPath(); | ||
|
||
if ( isWindows() ) { | ||
|
@@ -310,6 +312,7 @@ else if (object.isDirectory() && (optsPrefix.endsWith(File.separator) || isNullO | |
|
||
@Override | ||
public StorageMetadata getContainerMetadata(String container) { | ||
filesystemContainerNameValidator.validate(container); | ||
MutableStorageMetadata metadata = new MutableStorageMetadataImpl(); | ||
metadata.setName(container); | ||
metadata.setType(StorageType.CONTAINER); | ||
|
@@ -378,6 +381,8 @@ public String apply(String string) { | |
|
||
@Override | ||
public Blob getBlob(final String container, final String key) { | ||
filesystemContainerNameValidator.validate(container); | ||
filesystemBlobKeyValidator.validate(key); | ||
BlobBuilder builder = blobBuilders.get(); | ||
builder.name(key); | ||
File file = getFileForBlobKey(container, key); | ||
|
@@ -658,6 +663,8 @@ public void removeBlob(final String container, final String blobKey) { | |
|
||
@Override | ||
public BlobAccess getBlobAccess(String containerName, String blobName) { | ||
filesystemContainerNameValidator.validate(containerName); | ||
filesystemBlobKeyValidator.validate(blobName); | ||
if (!new File(buildPathStartingFromBaseDir(containerName)).exists()) { | ||
throw new ContainerNotFoundException(containerName, "in getBlobAccess"); | ||
} | ||
|
@@ -691,6 +698,8 @@ public BlobAccess getBlobAccess(String containerName, String blobName) { | |
|
||
@Override | ||
public void setBlobAccess(String container, String name, BlobAccess access) { | ||
filesystemContainerNameValidator.validate(container); | ||
filesystemBlobKeyValidator.validate(name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this also apply to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These methods have been applied by the validators. I just added some missing ones. |
||
Path path = new File(buildPathStartingFromBaseDir(container, name)).toPath(); | ||
if ( isWindows() ) { | ||
try { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this different than the container name validator? For robustness should this tokenize the path via
/
then check each component to see if one contains.
or..
? This would allow keys like..foo
to work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
..foo
should be allowed. I tried several object storage services, such as gcloud and aliyun oss, they all allow..foo
as object key.