Fix the TLS settings check for a payments client

Review the AI's codeEasy10 minStripe style

Your task

Asked to fix connection errors to a payments API, an AI turned off certificate and hostname verification in the client, and the errors went away. You are adding a review rule that flags TLS client settings like that before they merge.

An assistant wrote review_tls_settings(settings). It is in the editor. It has a bug. Find it and fix it.

Input and output:

  • settings: the client's TLS settings, one "key=value" string each.
  • Return the findings as a list of strings.

Rules the tests check:

  • Skip a line with no =. Otherwise split it at the first =.
  • Trim spaces from the key and the value, and compare both without regard to case.
  • The findings are:
    • "hostname_check_disabled": key check_hostname with value false.
    • "cert_verification_disabled": key verify_mode with value cert_none.
    • "missing_ca_bundle": key ca_bundle with an empty value.
    • "weak_tls_version": key min_tls_version with value 1.0, 1.1 or ssl3.
  • Any other key or value is not a finding.
  • Return each finding once, sorted in ascending order.

Examples

review_tls_settings(settings: list[str]) -> list[str]
Example 1
Inputreview_tls_settings(["check_hostname=false", "verify_mode=CERT_NONE", "ca_bundle=/etc/ssl/certs/ca.pem", "min_tls_version=1.2"])
Output["cert_verification_disabled", "hostname_check_disabled"]
Example 2
Inputreview_tls_settings(["check_hostname=true", "verify_mode=CERT_REQUIRED", "ca_bundle=/etc/ssl/certs/ca.pem", "min_tls_version=1.3"])
Output[]
Example 3
Inputreview_tls_settings(["min_tls_version=1.0", "ca_bundle="])
Output["missing_ca_bundle", "weak_tls_version"]