-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Feature/storage/blob base client request validation #22136
Merged
seanmcc-msft
merged 9 commits into
Azure:main
from
seanmcc-msft:feature/storage/BlobBaseClientRequestValidation
Jun 24, 2021
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dd8da57
Added BlobRequestConditions validation to BlobBaseClient
seanmcc-msft 84d079b
GetTags
seanmcc-msft 7140f8b
SetAccessTier
seanmcc-msft 3ae4f93
SetTags
seanmcc-msft 5062f83
StartCopyFromUri
seanmcc-msft 9fa3f39
SyncCopyFromUri
seanmcc-msft 540b888
update
seanmcc-msft 7e216e5
Update
seanmcc-msft 0e7d7ec
update
seanmcc-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1132,6 +1132,12 @@ private async Task<Response<BlobDownloadStreamingResult>> StartDownloadAsync( | |
|
||
ResponseWithHeaders<Stream, BlobDownloadHeaders> response; | ||
|
||
// All BlobRequestConditions are valid. | ||
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. if this is the case, is this just here just in case of the future that there are conditions added that are invalid? 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. Yep! |
||
conditions.ValidateConditionsNotPresent( | ||
invalidConditions: BlobRequestConditionProperty.None, | ||
operationName: nameof(BlobBaseClient.Download), | ||
parameterName: nameof(conditions)); | ||
|
||
if (async) | ||
{ | ||
response = await BlobRestClient.DownloadAsync( | ||
|
@@ -2546,6 +2552,18 @@ private async Task<Response<BlobCopyInfo>> StartCopyFromUriInternal( | |
|
||
DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope($"{nameof(BlobBaseClient)}.{nameof(StartCopyFromUri)}"); | ||
|
||
// All BlobRequestConditions are valid. | ||
destinationConditions.ValidateConditionsNotPresent( | ||
invalidConditions: BlobRequestConditionProperty.None, | ||
operationName: nameof(BlobBaseClient.StartCopyFromUri), | ||
parameterName: nameof(destinationConditions)); | ||
|
||
sourceConditions.ValidateConditionsNotPresent( | ||
invalidConditions: | ||
BlobRequestConditionProperty.LeaseId, | ||
operationName: nameof(BlobBaseClient.StartCopyFromUri), | ||
parameterName: nameof(sourceConditions)); | ||
|
||
try | ||
{ | ||
scope.Start(); | ||
|
@@ -2746,6 +2764,16 @@ private async Task<Response> AbortCopyFromUriInternal( | |
|
||
DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope($"{nameof(BlobBaseClient)}.{nameof(AbortCopyFromUri)}"); | ||
|
||
conditions.ValidateConditionsNotPresent( | ||
invalidConditions: | ||
BlobRequestConditionProperty.IfModifiedSince | ||
| BlobRequestConditionProperty.IfUnmodifiedSince | ||
| BlobRequestConditionProperty.IfMatch | ||
| BlobRequestConditionProperty.IfNoneMatch | ||
| BlobRequestConditionProperty.TagConditions, | ||
operationName: nameof(BlobBaseClient.AbortCopyFromUri), | ||
parameterName: nameof(conditions)); | ||
|
||
try | ||
{ | ||
scope.Start(); | ||
|
@@ -2974,6 +3002,17 @@ private async Task<Response<BlobCopyInfo>> SyncCopyFromUriInternal( | |
{ | ||
DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope($"{nameof(BlobBaseClient)}.{nameof(SyncCopyFromUri)}"); | ||
|
||
// All BlobRequestConditions are valid for destinationConditions. | ||
destinationConditions.ValidateConditionsNotPresent( | ||
invalidConditions: BlobRequestConditionProperty.None, | ||
operationName: nameof(BlobBaseClient.SyncCopyFromUri), | ||
parameterName: nameof(destinationConditions)); | ||
|
||
sourceConditions.ValidateConditionsNotPresent( | ||
invalidConditions: BlobRequestConditionProperty.LeaseId, | ||
operationName: nameof(BlobBaseClient.SyncCopyFromUri), | ||
parameterName: nameof(sourceConditions)); | ||
|
||
try | ||
{ | ||
ClientConfiguration.Pipeline.LogMethodEnter( | ||
|
@@ -3363,6 +3402,12 @@ private async Task<Response> DeleteInternal( | |
operationName ??= $"{nameof(BlobBaseClient)}.{nameof(Delete)}"; | ||
DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope(operationName); | ||
|
||
// All BlobRequestConditions are valid. | ||
conditions.ValidateConditionsNotPresent( | ||
invalidConditions: BlobRequestConditionProperty.None, | ||
operationName: nameof(BlobBaseClient.Delete), | ||
parameterName: nameof(conditions)); | ||
|
||
try | ||
{ | ||
scope.Start(); | ||
|
@@ -3767,6 +3812,12 @@ internal async Task<Response<BlobProperties>> GetPropertiesInternal( | |
operationName ??= $"{nameof(BlobBaseClient)}.{nameof(GetProperties)}"; | ||
DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope(operationName); | ||
|
||
// All BlobRequestConditions are valid. | ||
conditions.ValidateConditionsNotPresent( | ||
invalidConditions: BlobRequestConditionProperty.None, | ||
operationName: nameof(BlobBaseClient.GetProperties), | ||
parameterName: nameof(conditions)); | ||
|
||
try | ||
{ | ||
scope.Start(); | ||
|
@@ -3946,6 +3997,12 @@ private async Task<Response<BlobInfo>> SetHttpHeadersInternal( | |
|
||
DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope($"{nameof(BlobBaseClient)}.{nameof(SetHttpHeaders)}"); | ||
|
||
// All BlobRequestConditions are valid. | ||
conditions.ValidateConditionsNotPresent( | ||
invalidConditions: BlobRequestConditionProperty.None, | ||
operationName: nameof(BlobBaseClient.SetHttpHeaders), | ||
parameterName: nameof(conditions)); | ||
|
||
try | ||
{ | ||
scope.Start(); | ||
|
@@ -4129,6 +4186,12 @@ private async Task<Response<BlobInfo>> SetMetadataInternal( | |
|
||
DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope($"{nameof(BlobBaseClient)}.{nameof(SetMetadata)}"); | ||
|
||
// All BlobRequestConditions are valid. | ||
conditions.ValidateConditionsNotPresent( | ||
invalidConditions: BlobRequestConditionProperty.None, | ||
operationName: nameof(BlobBaseClient.SetMetadata), | ||
parameterName: nameof(conditions)); | ||
|
||
try | ||
{ | ||
scope.Start(); | ||
|
@@ -4310,6 +4373,12 @@ private async Task<Response<BlobSnapshotInfo>> CreateSnapshotInternal( | |
|
||
DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope($"{nameof(BlobBaseClient)}.{nameof(CreateSnapshot)}"); | ||
|
||
// All BlobRequestConditions are valid. | ||
conditions.ValidateConditionsNotPresent( | ||
invalidConditions:BlobRequestConditionProperty.None, | ||
operationName: nameof(BlobBaseClient.CreateSnapshot), | ||
parameterName: nameof(conditions)); | ||
|
||
try | ||
{ | ||
scope.Start(); | ||
|
@@ -4533,6 +4602,15 @@ private async Task<Response> SetAccessTierInternal( | |
|
||
DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope($"{nameof(BlobBaseClient)}.{nameof(SetAccessTier)}"); | ||
|
||
conditions.ValidateConditionsNotPresent( | ||
invalidConditions: | ||
BlobRequestConditionProperty.IfModifiedSince | ||
| BlobRequestConditionProperty.IfUnmodifiedSince | ||
| BlobRequestConditionProperty.IfMatch | ||
| BlobRequestConditionProperty.IfNoneMatch, | ||
operationName: nameof(BlobBaseClient.SetAccessTier), | ||
parameterName: nameof(conditions)); | ||
|
||
try | ||
{ | ||
scope.Start(); | ||
|
@@ -4680,6 +4758,15 @@ private async Task<Response<GetBlobTagResult>> GetTagsInternal( | |
|
||
DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope($"{nameof(BlobBaseClient)}.{nameof(GetTags)}"); | ||
|
||
conditions.ValidateConditionsNotPresent( | ||
invalidConditions: | ||
BlobRequestConditionProperty.IfModifiedSince | ||
| BlobRequestConditionProperty.IfUnmodifiedSince | ||
| BlobRequestConditionProperty.IfMatch | ||
| BlobRequestConditionProperty.IfNoneMatch, | ||
operationName: nameof(BlobBaseClient.GetTags), | ||
parameterName: nameof(conditions)); | ||
|
||
try | ||
{ | ||
scope.Start(); | ||
|
@@ -4855,6 +4942,15 @@ private async Task<Response> SetTagsInternal( | |
|
||
DiagnosticScope scope = ClientConfiguration.ClientDiagnostics.CreateScope($"{nameof(BlobBaseClient)}.{nameof(SetTags)}"); | ||
|
||
conditions.ValidateConditionsNotPresent( | ||
invalidConditions: | ||
BlobRequestConditionProperty.IfModifiedSince | ||
| BlobRequestConditionProperty.IfUnmodifiedSince | ||
| BlobRequestConditionProperty.IfMatch | ||
| BlobRequestConditionProperty.IfNoneMatch, | ||
operationName: nameof(BlobBaseClient.SetTags), | ||
parameterName: nameof(conditions)); | ||
|
||
try | ||
{ | ||
scope.Start(); | ||
|
3 changes: 3 additions & 0 deletions
3
sdk/storage/Azure.Storage.Blobs/src/Models/Internal/BlobRequestConditionProperty.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we should mention compat switch in changelog.
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.
compat switch?