rspec/rules/S5527/kotlin/rule.adoc

25 lines
811 B
Plaintext
Raw Normal View History

include::../description.adoc[]
== Noncompliant Code Example
When using the https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/-builder/hostname-verifier/[okhttp library], a custom unsecure hostname verifier accepting every hostname is used:
----
val builder = OkHttpClient.Builder()
builder.hostnameVerifier(object : HostnameVerifier {
override fun verify(hostname: String?, session: SSLSession?): Boolean {
return true // Noncompliant (s5527)
}
})
----
== Compliant Solution
When using the https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/-builder/hostname-verifier/[okhttp library], if ``++hostnameVerifier++`` method is not used to set a verifier, then a built-in secure one will be used:
----
val builder = OkHttpClient.Builder()
----
include::../see.adoc[]