Skip to content

Properly reject non-json FromBody parameter binding #35976

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

Merged
merged 4 commits into from
Sep 2, 2021

Conversation

BrennanConroy
Copy link
Member

Fixes #35856

@BrennanConroy BrennanConroy added feature-minimal-actions Controller-like actions for endpoint routing old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Aug 31, 2021
@ghost ghost added the area-runtime label Aug 31, 2021
@BrennanConroy
Copy link
Member Author

Did someone click "re-run failed jobs"?

@@ -2393,7 +2451,7 @@ private class CustomTodo : Todo
Assert.Equal(typeof(CustomTodo), parameter.ParameterType);
Assert.Equal("customTodo", parameter.Name);

var body = await context.Request.ReadFromJsonAsync<CustomTodo>();
var body = await JsonSerializer.DeserializeAsync<CustomTodo>(context.Request.Body);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReadFromJsonAsync throws for non json content type, and for testing I am sending Json without a json content type. I can make a separate type for the test to make it more focused.

@BrennanConroy BrennanConroy merged commit bee3290 into main Sep 2, 2021
@BrennanConroy BrennanConroy deleted the brecon/contenttype branch September 2, 2021 22:00
@ghost ghost added this to the 7.0-preview1 milestone Sep 2, 2021
@BrennanConroy
Copy link
Member Author

/backport to release/6.0

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2021

Started backporting to release/6.0: https://github.com/dotnet/aspnetcore/actions/runs/1195893192

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2021

@BrennanConroy backporting to release/6.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Properly reject non-json FromBody parameter binding
Using index info to reconstruct a base tree...
M	src/Http/Http.Extensions/src/RequestDelegateFactory.cs
M	src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs
Auto-merging src/Http/Http.Extensions/src/RequestDelegateFactory.cs
CONFLICT (content): Merge conflict in src/Http/Http.Extensions/src/RequestDelegateFactory.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Properly reject non-json FromBody parameter binding
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@BrennanConroy
Copy link
Member Author

/backport to release/6.0

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2021

Started backporting to release/6.0: https://github.com/dotnet/aspnetcore/actions/runs/1196025743

@amcasey amcasey added area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-runtime labels Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-minimal-actions Controller-like actions for endpoint routing old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Projects
None yet
4 participants