Skip to content

Validate monitoring header overrides at parse time#47848

Merged
danhermann merged 4 commits intoelastic:masterfrom
danhermann:47711_headers
Nov 4, 2019
Merged

Validate monitoring header overrides at parse time#47848
danhermann merged 4 commits intoelastic:masterfrom
danhermann:47711_headers

Conversation

@danhermann
Copy link
Copy Markdown
Contributor

@danhermann danhermann commented Oct 10, 2019

Provides parse-time validation for HEADERS_SETTING as described in #47711.

Also changes the check for blacklisted header overrides to be case-insensitive.

@danhermann danhermann added the :Core/Infra/Monitoring DEPRECATED, DO NOT USE label Oct 10, 2019
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Monitoring)

Copy link
Copy Markdown
Contributor

@jakelandis jakelandis left a comment

Choose a reason for hiding this comment

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

LGTM assuming there are pre-existing tests that cover this.

@danhermann
Copy link
Copy Markdown
Contributor Author

Thanks, @jakelandis, there are existing tests for this setting.

@danhermann
Copy link
Copy Markdown
Contributor Author

@elastic/es-core-infra, this work covers both monitoring and settings if you want to review it.

Copy link
Copy Markdown
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

One comment

final Set<String> names = settings.names();
for (String name : names) {
final String fullSetting = key + "." + name;
if (HttpExporter.BLACKLISTED_HEADERS.stream().anyMatch(name::equalsIgnoreCase)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why use equalsIgnoreCase? I don't see where we've been case insensitive in setting names before, and I'm not sure we should change behavior here while trying to add validation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

HTTP headers are supposed to be case insensitive, so without the case insensitive check, a user could supply an override for "content-length" even though "Content-Length" is on the header override blacklist. If that's not a concern here or this is the wrong place to check that, I can make it a case sensitive check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rjernst, would you prefer the HTTP header name check here remain case-sensitive?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm open to it being case-insensitive, but changing that behavior should be separate PR. This PR is just about adding validation to the parsing as it currently exists.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rjernst, I've restored the original case-sensitive check here.

@danhermann
Copy link
Copy Markdown
Contributor Author

@elasticmachine update branch

@danhermann
Copy link
Copy Markdown
Contributor Author

@elasticmachine update branch

Copy link
Copy Markdown
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

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.

5 participants