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

Fixed crashes on some SOAP 1.2 requests when using GetBufferedInputStream #1811

Merged
merged 6 commits into from
Sep 13, 2022
Merged

Conversation

theiji
Copy link
Contributor

@theiji theiji commented Sep 6, 2022

This fixes issue 1759 crashes on some SOAP 1.2 requests when using GetBufferedInputStream

@theiji theiji changed the title #1759 Fixed crashes on some SOAP 1.2 requests when using GetBufferedInputStream Fixed crashes on some SOAP 1.2 requests when using GetBufferedInputStream Sep 6, 2022
@apmmachine
Copy link
Contributor

apmmachine commented Sep 6, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-09-13T17:44:04.444+0000

  • Duration: 65 min 52 sec

Test stats 🧪

Test Results
Failed 0
Passed 16518
Skipped 164
Total 16682

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run benchmark tests : Run the benchmark test.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@z1c0 z1c0 requested review from gregkalapos and z1c0 September 7, 2022 06:05
@z1c0
Copy link
Contributor

z1c0 commented Sep 7, 2022

Thanks for your contribution @theiji!
May I ask you to add a reproducer/test to your PR, please?
You can find existing tests for SOAP requests here.

Update:

I'm currently working on Request Body capturing for .NET Framework (#379) and the underlying issue here is an interesting test case in this scenario (see also #1759 (comment)).
A reproducer or test case would be highly appreciated so we can include this PR as part of the mentioned feature (#379).

@z1c0 z1c0 self-assigned this Sep 7, 2022
@z1c0
Copy link
Contributor

z1c0 commented Sep 12, 2022

@theiji I was able to verify your fix - thanks again!
I think I could simply the code a little bit and added an additional test (small & large payload).
May I ask to to update your PR the way I suggested in my branch https://github.com/elastic/apm-agent-dotnet/tree/1759-bug-elasticapmaspnetfullframework-crashes-on-some-soap-requests-to-asp-net-web-service?

@z1c0
Copy link
Contributor

z1c0 commented Sep 12, 2022

FYI @gregkalapos - I was able to reproduce the issue and verify the fix provided here.
The underlying problem is that in GetSoap12ActionFromInputStream we use an XmlReader to read the posted payload data. For large payloads, we end up in a situation where the XmlReader only reads part of the stream (as large as its internal buffer size).

image

This leaves the underlying stream in a "half-read" state that, later on, causes the internal server error. By making sure that the stream is read to the end at all times, this issue is fixed.

@cla-checker-service
Copy link

cla-checker-service bot commented Sep 12, 2022

💚 CLA has been signed

Copy link
Contributor

@z1c0 z1c0 left a comment

Choose a reason for hiding this comment

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

LGTM!
(It looks like you still need to sign the CLA though @theiji)

@z1c0 z1c0 modified the milestone: 8.5 Sep 12, 2022
Copy link
Contributor

@gregkalapos gregkalapos left a comment

Choose a reason for hiding this comment

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

LGTM as well.

@theiji please make sure you use the same e-mail address that you used for your commits when you sign the CLA - it’s here in the 2. line.

We can merge once the CLA is signed.

@theiji
Copy link
Contributor Author

theiji commented Sep 12, 2022

@gregkalapos @z1c0 sorry. CLA signed

@gregkalapos gregkalapos self-requested a review September 13, 2022 17:28
Copy link
Contributor

@gregkalapos gregkalapos left a comment

Choose a reason for hiding this comment

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

Thanks for signing the CLA @theiji.

There is one minor issue with the changed test - details below. Sorry for missing that previously; I just noticed that after CI ran the PR (it wasn't running the PR previously due to the missing CLA).

@@ -26,12 +26,15 @@ public SoapRequestTests(ITestOutputHelper xUnitOutputHelper)
/// to parse the parameters for the web method.
/// </summary>
[AspNetFullFrameworkFact]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[AspNetFullFrameworkFact]
[AspNetFullFrameworkTheory]

Currently it fails:

System.InvalidOperationException : [Fact] methods are not allowed to have parameters. Did you mean to use [Theory]?

Due to the new parameter, it needs to be AspNetFullFrameworkTheory

@theiji
Copy link
Contributor Author

theiji commented Sep 13, 2022

@gregkalapos done

@theiji theiji requested a review from gregkalapos September 13, 2022 17:45
@z1c0
Copy link
Contributor

z1c0 commented Sep 13, 2022

Thanks for hanging on @theiji - merge is imminent :-)

Copy link
Contributor

@gregkalapos gregkalapos left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @theiji!

@gregkalapos gregkalapos merged commit d9b65ea into elastic:main Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants