Skip to content

Commit

Permalink
Move fix it section into the main adoc
Browse files Browse the repository at this point in the history
  • Loading branch information
teemu-rytilahti-sonarsource committed Feb 11, 2025
1 parent a213bf7 commit 7b6e40f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 37 deletions.
36 changes: 0 additions & 36 deletions rules/S5527/go/how-to-fix-it/std.adoc

This file was deleted.

37 changes: 36 additions & 1 deletion rules/S5527/go/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,42 @@ include::../impact.adoc[]

// How to fix it section

include::how-to-fix-it/std.adoc[]
== How to fix it

=== Code examples

include::../common/fix/code-rationale.adoc[]

Hostname validation is disabled if ``++InsecureSkipVerify++`` is set to `true` for ``++TLSClientConfig++`` used for the transport class.

For HTTPS, it is recommended to use high-level interfaces (like ``++http.Get()++``), which perform the certificate validation instead of using ``++http.Client++`` directly.

==== Noncompliant code example

[source,go,diff-id=1,diff-type=noncompliant]
----
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, // Non-compliant
},
},
}
client.Get("https://example.com")
----

==== Compliant solution

Usage of high-level interfaces is recommended:
[source,go,diff-id=1,diff-type=compliant]
----
http.Get("https://example.com")
----

=== How does this work?

include::../common/fix/validation.adoc[]

== Resources

Expand Down

0 comments on commit 7b6e40f

Please sign in to comment.