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

Validate monitoring header overrides at parse time #47848

Merged
merged 4 commits into from
Nov 4, 2019

Conversation

danhermann
Copy link
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.

@elasticmachine
Copy link
Collaborator

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

Copy link
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
Contributor Author

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

@danhermann
Copy link
Contributor Author

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

Copy link
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
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
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
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
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
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
Contributor Author

@elasticmachine update branch

@danhermann
Copy link
Contributor Author

@elasticmachine update branch

Copy link
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.

None yet

5 participants