BlockBlob_Upload: should fail with 409 when upload to exist blob with write-only sas
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 393
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 36
Description
### Which service(blob, file, queue, table) does this issue concern?
blob
### Which version of the Azurite was used?
3.3.0-preview
### Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)
VS code
### What's the Node.js version?
v10.15.3
### What problem was encountered?
BlockBlob_Upload: should fail with 409 when upload to exist blob with write-only sas
### Steps to reproduce the issue?
See case
### Have you found a mitigation/solution?
No
Debug Log
```
2019-12-26T07:10:08.462Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobStorageContextMiddleware: RequestMethod=PUT RequestURL=http://127.0.0.1/devstoreaccount1/cb6d3e0ff1ca4474384df263d27a04fce/nd8b89152ed2f435c8716ec0c0c245625?sv=2019-02-02&sr=b&sig=IpXYDu8ARFLu7ZU0vlmS2YG2IUzz79G%2FX5OKNXt2McI%3D&st=2019-12-26T07%3A04%3A46Z&se=2019-12-26T07%3A39%3A46Z&sp=wd&api-version=2019-02-02& RequestHeaders:{"x-ms-blob-content-md5":"7oFC48MCNf0beZws+DmNqw==","x-ms-blob-type":"BlockBlob","if-none-match":"*","x-ms-client-request-id":"7b1b2d2c-46ef-4144-80a8-7cc1286338d9","user-agent":"Azure-Storage/11.1.1 (.NET Core; Win32NT 6.2.9200.0)","x-ms-version":"2019-02-02","content-length":"25165824","host":"127.0.0.1:10000"} ClientIP=127.0.0.1 Protocol=http HTTPVersion=1.1
2019-12-26T07:10:08.463Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobStorageContextMiddleware: Account=devstoreaccount1 Container=cb6d3e0ff1ca4474384df263d27a04fce Blob=nd8b89152ed2f435c8716ec0c0c245625
2019-12-26T07:10:08.464Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 verbose: DispatchMiddleware: Dispatching request...
2019-12-26T07:10:08.467Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: DispatchMiddleware: Operation=BlockBlob_Upload
2019-12-26T07:10:08.468Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 verbose: AuthenticationMiddlewareFactory:createAuthenticationMiddleware() Validating authentications.
2019-12-26T07:10:08.468Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: PublicAccessAuthenticator:validate() Start validation against public access.
2019-12-26T07:10:08.469Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: PublicAccessAuthenticator:validate() Getting account properties...
2019-12-26T07:10:08.470Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: PublicAccessAuthenticator:validate() Retrieved account name from context: devstoreaccount1, container: cb6d3e0ff1ca4474384df263d27a04fce, blob: nd8b89152ed2f435c8716ec0c0c245625
2019-12-26T07:10:08.471Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: PublicAccessAuthenticator:validate() Skip public access authentication. Cannot get public access type for container cb6d3e0ff1ca4474384df263d27a04fce
2019-12-26T07:10:08.471Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobSharedKeyAuthenticator:validate() Start validation against account shared key authentication.
2019-12-26T07:10:08.471Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobSharedKeyAuthenticator:validate() Request doesn't include valid authentication header. Skip shared key authentication.
2019-12-26T07:10:08.472Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: AccountSASAuthenticator:validate() Start validation against account Shared Access Signature pattern.
2019-12-26T07:10:08.472Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: AccountSASAuthenticator:validate() Getting account properties...
2019-12-26T07:10:08.472Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: AccountSASAuthenticator:validate() Retrieved account name from context: devstoreaccount1, container: cb6d3e0ff1ca4474384df263d27a04fce, blob: nd8b89152ed2f435c8716ec0c0c245625
2019-12-26T07:10:08.472Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: AccountSASAuthenticator:validate() Got account properties successfully.
2019-12-26T07:10:08.473Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: AccountSASAuthenticator:validate() Retrieved signature from URL parameter sig: IpXYDu8ARFLu7ZU0vlmS2YG2IUzz79G/X5OKNXt2McI=
2019-12-26T07:10:08.473Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: AccountSASAuthenticator:validate() Failed to get valid account SAS values from request.
2019-12-26T07:10:08.473Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobSASAuthenticator:validate() Start validation against blob service Shared Access Signature pattern.
2019-12-26T07:10:08.473Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: BlobSASAuthenticator:validate() Getting account properties...
2019-12-26T07:10:08.474Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: BlobSASAuthenticator:validate() Retrieved account name from context: devstoreaccount1, container: cb6d3e0ff1ca4474384df263d27a04fce, blob: nd8b89152ed2f435c8716ec0c0c245625
2019-12-26T07:10:08.474Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: BlobSASAuthenticator:validate() Got account properties successfully.
2019-12-26T07:10:08.474Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: BlobSASAuthenticator:validate() Retrieved signature from URL parameter sig: IpXYDu8ARFLu7ZU0vlmS2YG2IUzz79G/X5OKNXt2McI=
2019-12-26T07:10:08.474Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: BlobSASAuthenticator:validate() Signed resource type is b.
2019-12-26T07:10:08.475Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: BlobSASAuthenticator:validate() Successfully got valid blob service SAS values from request. {"version":"2019-02-02","startTime":"2019-12-26T07:04:46Z","expiryTime":"2019-12-26T07:39:46Z","permissions":"wd","containerName":"cb6d3e0ff1ca4474384df263d27a04fce","blobName":"nd8b89152ed2f435c8716ec0c0c245625","signedResource":"b"}
2019-12-26T07:10:08.475Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobSASAuthenticator:validate() Validate signature based account key1.
2019-12-26T07:10:08.475Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: BlobSASAuthenticator:validate() String to sign is: "wd\n2019-12-26T07:04:46Z\n2019-12-26T07:39:46Z\n/blob/devstoreaccount1/cb6d3e0ff1ca4474384df263d27a04fce/nd8b89152ed2f435c8716ec0c0c245625\n\n\n\n2019-02-02\nb\n\n\n\n\n\n"
2019-12-26T07:10:08.476Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: BlobSASAuthenticator:validate() Calculated signature is: IpXYDu8ARFLu7ZU0vlmS2YG2IUzz79G/X5OKNXt2McI=
2019-12-26T07:10:08.476Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobSASAuthenticator:validate() Signature based on key1 validation passed.
2019-12-26T07:10:08.476Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobSASAuthenticator:validate() Validate start and expiry time.
2019-12-26T07:10:08.476Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobSASAuthenticator:validate() Validate IP range.
2019-12-26T07:10:08.477Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobSASAuthenticator:validate() Validate request protocol.
2019-12-26T07:10:08.477Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: BlobSASAuthenticator:validate() Got permission requirements for operation BlockBlob_Upload - {"permission":"wc"}
2019-12-26T07:10:08.477Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobSASAuthenticator:validate() For BlockBlob_Upload, if blob exists, the permission must be Write.
2019-12-26T07:10:08.478Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: BlobSASAuthenticator:validate() Blob service SAS validation successfully.
2019-12-26T07:10:08.478Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 verbose: DeserializerMiddleware: Start deserializing...
2019-12-26T07:10:08.479Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: HandlerMiddleware: DeserializedParameters={"options":{"metadata":{},"requestId":"7b1b2d2c-46ef-4144-80a8-7cc1286338d9","blobHTTPHeaders":{"blobContentMD5":{"type":"Buffer","data":[238,129,66,227,195,2,53,253,27,121,156,44,248,57,141,171]}},"leaseAccessConditions":{},"cpkInfo":{},"modifiedAccessConditions":{"ifNoneMatch":"*"}},"contentLength":25165824,"version":"2019-02-02","blobType":"BlockBlob","body":"ReadableStream"}
2019-12-26T07:10:08.479Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: OperationQueue.operate() Schedule incoming job 23b8c604-0a09-499f-800b-c55d84013b05
2019-12-26T07:10:08.480Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: OperationQueue:execute() Current runningConcurrency:0 maxConcurrency:50 operations.length:1
2019-12-26T07:10:08.480Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: FSExtentStore:appendExtent() Select extent from idle location for extent append operation. LocationId:1 extentId:0f46bb43-fa72-4bb4-9e23-4848447eb5fd offset:51420187 MAX_EXTENT_SIZE:67108864
2019-12-26T07:10:08.480Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: FSExtentStore:appendExtent() Get fd:4 for extent:0f46bb43-fa72-4bb4-9e23-4848447eb5fd from cache.
2019-12-26T07:10:08.481Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: FSExtentStore:appendExtent() Created write stream for fd:4
2019-12-26T07:10:08.481Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: FSExtentStore:appendExtent() Start writing to extent 0f46bb43-fa72-4bb4-9e23-4848447eb5fd
2019-12-26T07:10:08.481Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: FSExtentStore:streamPipe() Start piping data to write stream
2019-12-26T07:10:08.654Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: FSExtentStore:streamPipe() Readable stream triggers close event, 25165824 bytes piped
2019-12-26T07:10:08.656Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: FSExtentStore:streamPipe() Invoke write stream end()
2019-12-26T07:10:08.656Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: FSExtentStore:streamPipe() Writable stream triggers finish event, after 25165824 bytes piped. Flush data to fd:4.
2019-12-26T07:10:09.051Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: FSExtentStore:streamPipe() Flush data to fd:4 successfully. Resolve streamPipe().
2019-12-26T07:10:09.052Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: FSExtentStore:appendExtent() Write finish, start updating extent metadata. extent:{"id":"0f46bb43-fa72-4bb4-9e23-4848447eb5fd","locationId":"Default","path":"0f46bb43-fa72-4bb4-9e23-4848447eb5fd","size":76586011,"lastModifiedInMS":1577344209052}
2019-12-26T07:10:09.053Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: FSExtentStore:appendExtent() Update extent metadata done. Resolve()
2019-12-26T07:10:09.053Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: OperationQueue.operate() Job 23b8c604-0a09-499f-800b-c55d84013b05 completes callback, resolve.
2019-12-26T07:10:09.054Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: OperationQueue.operate() Schedule incoming job 67b96d7d-5424-4282-b385-e20bfc9ac389
2019-12-26T07:10:09.055Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: OperationQueue:execute() Current runningConcurrency:0 maxConcurrency:100 operations.length:1
2019-12-26T07:10:09.055Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 verbose: FSExtentStore:readExtent() Creating read stream. LocationId:Default extentId:0f46bb43-fa72-4bb4-9e23-4848447eb5fd path:C:\code\azurite\__blobstorage__\0f46bb43-fa72-4bb4-9e23-4848447eb5fd offset:51420187 count:25165824 end:76586010
2019-12-26T07:10:09.056Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: OperationQueue.operate() Job 67b96d7d-5424-4282-b385-e20bfc9ac389 completes callback, resolve.
2019-12-26T07:10:09.056Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: OperationQueue:execute() Current runningConcurrency:0 maxConcurrency:50 operations.length:0
2019-12-26T07:10:09.057Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: OperationQueue:execute() return. Operation.length === 0
2019-12-26T07:10:09.058Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: OperationQueue:execute() Current runningConcurrency:0 maxConcurrency:100 operations.length:0
2019-12-26T07:10:09.059Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 debug: OperationQueue:execute() return. Operation.length === 0
2019-12-26T07:10:09.170Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 verbose: SerializerMiddleware: Start serializing...
2019-12-26T07:10:09.172Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 info: EndMiddleware: End response. TotalTimeInMS=710 StatusCode=201 StatusMessage=undefined Headers={"server":"Azurite-Blob/3.3.0-preview","etag":"\"d-Psfr+ZvhdiFYptc4ZZuGSt638jI\"","last-modified":"Thu, 26 Dec 2019 07:10:08 GMT","content-md5":"7oFC48MCNf0beZws+DmNqw==","x-ms-client-request-id":"7b1b2d2c-46ef-4144-80a8-7cc1286338d9","x-ms-request-id":"ec1e655f-f32c-4de6-9834-ea183b1e0ae5","x-ms-version":"2019-02-02","date":"Thu, 26 Dec 2019 07:10:08 GMT","x-ms-request-server-encrypted":"true"}
2019-12-26T07:10:09.173Z ec1e655f-f32c-4de6-9834-ea183b1e0ae5 verbose: FSExtentStore:readExtent() Read stream closed. LocationId:Default extentId:0f46bb43-fa72-4bb4-9e23-4848447eb5fd path:C:\code\azurite\__blobstorage__\0f46bb43-fa72-4bb4-9e23-4848447eb5fd offset:51420187 count:25165824 end:76586010
```
Test Case:
```
Test Name: CloudBlockUplodadTestUploadWithWriteOnlyServiceSAS
Test FullName: Microsoft.Azure.Storage.Blob.CloudBlockBlobTest.CloudBlockUplodadTestUploadWithWriteOnlyServiceSAS
Test Source: C:\code\azure-storage-net\Test\ClassLibraryCommon\Blob\CloudBlockBlobTest.cs : line 5124
Test Outcome: Failed
Test Duration: 0:00:26.6369669
Result StackTrace:
at Microsoft.Azure.Storage.TestHelper.ExpectedException(Action operation, String operationDescription, HttpStatusCode expectedStatusCode, String requestErrorCode) in C:\code\azure-storage-net\Test\ClassLibraryCommon\TestHelper.cs:line 46
at Microsoft.Azure.Storage.Blob.CloudBlockBlobTest.CloudBlockUplodadTestUploadWithWriteOnlyServiceSAS() in C:\code\azure-storage-net\Test\ClassLibraryCommon\Blob\CloudBlockBlobTest.cs:line 5152
Result Message: Assert.AreEqual failed. Expected:<409>. Actual:<500>. Http status code is unexpected.
```
```
Test Name: CloudBlockBlobUploadTestUploadWithWriteOnlyAccountSAS
Test FullName: Microsoft.Azure.Storage.Blob.CloudBlockBlobTest.CloudBlockBlobUploadTestUploadWithWriteOnlyAccountSAS
Test Source: C:\code\azure-storage-net\Test\ClassLibraryCommon\Blob\CloudBlockBlobTest.cs : line 4887
Test Outcome: Failed
Test Duration: 0:00:03.6608167
Result StackTrace:
at Microsoft.Azure.Storage.TestHelper.ExpectedException(Action operation, String operationDescription, HttpStatusCode expectedStatusCode, String requestErrorCode) in C:\code\azure-storage-net\Test\ClassLibraryCommon\TestHelper.cs:line 55
at Microsoft.Azure.Storage.Blob.CloudBlockBlobTest.CloudBlockBlobUploadTestUploadWithWriteOnlyAccountSAS() in C:\code\azure-storage-net\Test\ClassLibraryCommon\Blob\CloudBlockBlobTest.cs:line 4900
Result Message: Assert.Fail failed. No Storage exception received while expecting Conflict: Should fail as specified blob already exists.
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.