-
Couldn't load subscription status.
- Fork 69
Feat: review and deprecate ssl protocol/cipher settings #151
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, with deprecated config settings and the plugin starts cleanly with only the warnings, it doesn't create any breakage.
I've requested changes to know your opinion on those, if you feel it's worthwhile to simplify.
lib/logstash/inputs/http.rb
Outdated
| if @ssl && (original_params.key?('cipher_suites') && original_params.key?('ssl_cipher_suites')) | ||
| raise LogStash::ConfigurationError, "Both `ssl_cipher_suites` and (deprecated) `cipher_suites` were set. Use only `ssl_cipher_suites`." | ||
| elsif original_params.key?('cipher_suites') | ||
| @ssl_cipher_suites_final = @cipher_suites | ||
| else | ||
| @ssl_cipher_suites_final = @ssl_cipher_suites | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that if @ssl is false then @ssl_cipher_suites_final end in:
- empty list if the user configured
cipher_suites. SslSimpleBuilder.getDefaultCiphersif the user in any other case.
I think that ifssl => falseit shouldn't set anything related to the ciphers
I know that the method build_ssl_params has a guard:
return nil unless @sslMaybe isolating the fragment with an if @sslshould help.
| if @ssl && (original_params.key?('cipher_suites') && original_params.key?('ssl_cipher_suites')) | |
| raise LogStash::ConfigurationError, "Both `ssl_cipher_suites` and (deprecated) `cipher_suites` were set. Use only `ssl_cipher_suites`." | |
| elsif original_params.key?('cipher_suites') | |
| @ssl_cipher_suites_final = @cipher_suites | |
| else | |
| @ssl_cipher_suites_final = @ssl_cipher_suites | |
| end | |
| if @ssl | |
| if original_params.key?('cipher_suites') && original_params.key?('ssl_cipher_suites') | |
| raise LogStash::ConfigurationError, "Both `ssl_cipher_suites` and (deprecated) `cipher_suites` were set. Use only `ssl_cipher_suites`." | |
| @ssl_cipher_suites_final = original_params.key?('cipher_suites') ? | |
| @cipher_suites : | |
| @ssl_cipher_suites | |
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ssl_cipher_suites_final won't be used since build_ssl_params isn't called.
the reason why I have it this way is due existing convention above:
# ...
elsif original_params.key?("verify_mode")
@ssl_verify_mode_final = @verify_mode
else
@ssl_verify_mode_final = @ssl_verify_mode
lib/logstash/inputs/http.rb
Outdated
| if @ssl && (original_params.key?('tls_min_version') && original_params.key?('ssl_supported_protocols')) | ||
| raise LogStash::ConfigurationError, "Both `ssl_supported_protocols` and (deprecated) `tls_min_ciphers` were set. Use only `ssl_supported_protocols`." | ||
| elsif @ssl && (original_params.key?('tls_max_version') && original_params.key?('ssl_supported_protocols')) | ||
| raise LogStash::ConfigurationError, "Both `ssl_supported_protocols` and (deprecated) `tls_max_ciphers` were set. Use only `ssl_supported_protocols`." | ||
| else | ||
| if @ssl && (original_params.key?('tls_min_version') || original_params.key?('tls_max_version')) | ||
| @ssl_supported_protocols_final = TLS.get_supported(tls_min_version..tls_max_version).map(&:name) | ||
| else | ||
| @ssl_supported_protocols_final = @ssl_supported_protocols | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same observation as the one above, protect with an if @ssl could make it more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the attr is not set @ssl_supported_protocols_final = @ssl_supported_protocols is just nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's a compromise refactoring: db159bb ... wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compromise is almost good, I would made it more "assertive", I mean that if an if statement return in the positive branch then simplify the negative branch.
so
if !@ssl
@logger.warn("SSL Certificate will not be used") if @ssl_certificate
@logger.warn("SSL Key will not be used") if @ssl_key
@logger.warn("SSL Java Key Store will not be used") if @keystore
return # code bellow assumes `ssl => true`
elsif !(ssl_key_configured? || ssl_jks_configured?)
raise LogStash::ConfigurationError, "Certificate or JKS must be configured"
endbecomes:
if !@ssl
@logger.warn("SSL Certificate will not be used") if @ssl_certificate
@logger.warn("SSL Key will not be used") if @ssl_key
@logger.warn("SSL Java Key Store will not be used") if @keystore
return
end
# code below assumes `ssl => true`
if !(ssl_key_configured? || ssl_jks_configured?)
raise LogStash::ConfigurationError, "Certificate or JKS must be configured"
endThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left just maybe a nitpick at #151 (comment) but I think it makes the code more readable.
Everything else seems ok to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Merge in THOT/logstash-input-http from dev-edefaria to prod * commit '476e106429ff76ad4fa6a55a1fba15c182d815cf': Doc: Update deprecation notices to standard (logstash-plugins#154) Feat: review and deprecate ssl protocol/cipher settings (logstash-plugins#151) Codec pipeline context (logstash-plugins#153) ensure execution_context is propagated to additional_codecs (logstash-plugins#152) Doc: Clarify description and make minor grammar fixes (logstash-plugins#150) Feat: TLSv1.3 support (logstash-plugins#146) Build: do not package log4j-api dependency (logstash-plugins#149) Update log4j version to 2.17.0 (logstash-plugins#148)
following up on #146:
cipher_suitesin favor ofssl_cipher_suites(with better validation of the supported cipher set)ssl_supported_protocolsas a replacement fortls_min_version/tls_max_version