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

[Reporting] Blacklist Transfer-Encoding HTTP header for PDF report generation. #20755

Merged

Conversation

azasypkin
Copy link
Member

@azasypkin azasypkin commented Jul 13, 2018

After #18951 base path proxy started to use Hapi v17 and h2o2 v8.1.2, that may add Transfer-Encoding: chunked HTTP header to requests that are being proxied. That sounds like a reasonable thing to do and not sure why previous versions didn't do that.

Transfer-Encoding is hop-by-hop header that is meaningful only for a single transport-level connection, and shouldn't be stored by caches or forwarded by proxies. This affected reporting since PDF generation forces underlying browser to re-transmit some of the headers from the original request that created PDF generation job with every request used during screenshotting, including Transfer-Encoding: chunked. That doesn't make any sense and gets worse when underlying browser adds Content-Length header and hence violates HTTP spec, makes Node to reject such requests and fail PDF generation job as a result.

It feels like it can happen in a wild even without the change introduced by the new platform, so I'm proposing to just blacklist Transfer-Encoding HTTP header.

To test, please try to generate PDF reports when Kibana is run in dev mode:

$ yarn start --xpack.reporting.kibanaServer.port=5601

Fixes #20724

@azasypkin azasypkin added bug Fixes for quality problems that affect the customer experience v6.4.0 (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead labels Jul 13, 2018
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

});

afterEach(() => generatePdfObservableFactory.mockReset());
Copy link
Member Author

Choose a reason for hiding this comment

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

note: we need this to make sure that every test tests what it should. E.g. omits blacklisted headers should fail if we add some header to blacklistedHeaders that's not blacklisted in real code, but it passed before this change since generatePdfObservable mock call history was shared between tests.

Copy link
Contributor

@kobelb kobelb left a comment

Choose a reason for hiding this comment

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

LGTM

@azasypkin azasypkin requested a review from chrisdavies July 13, 2018 11:47
Copy link
Contributor

@epixa epixa left a comment

Choose a reason for hiding this comment

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

LGTM

Code looks good. I tested a PDF report both with and without the basepath proxy.

Copy link
Contributor

@stacey-gammon stacey-gammon left a comment

Choose a reason for hiding this comment

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

lgtm, tested that a phantom pdf report can now be generated.

@azasypkin azasypkin merged commit 34a4428 into elastic:master Jul 13, 2018
@azasypkin azasypkin deleted the issue-20724-blacklist-transfer-encoding branch July 13, 2018 12:51
azasypkin added a commit to azasypkin/kibana that referenced this pull request Jul 13, 2018
@azasypkin
Copy link
Member Author

6.x/6.4: 31c633e

yankouskia pushed a commit to yankouskia/kibana that referenced this pull request Jul 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported bug Fixes for quality problems that affect the customer experience (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead v6.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants