rspec/rules/S5527/kotlin/rule.adoc
2022-02-04 16:28:24 +00:00

42 lines
1.1 KiB
Plaintext

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:
[source,kotlin]
----
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:
[source,kotlin]
----
val builder = OkHttpClient.Builder()
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]