Create rule S6437: Credentials should not be hard-coded (#4641)

* Add go to rule S6437

* Add description for S6437 for Go

---------

Co-authored-by: daniel-teuchert-sonarsource <daniel-teuchert-sonarsource@users.noreply.github.com>
Co-authored-by: Daniel Teuchert <daniel.teuchert@sonarsource.com>
This commit is contained in:
github-actions[bot] 2025-02-17 15:53:59 +01:00 committed by GitHub
parent a2320f1b8d
commit e2133270e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 78 additions and 0 deletions

View File

@ -0,0 +1,2 @@
{
}

76
rules/S6437/go/rule.adoc Normal file
View File

@ -0,0 +1,76 @@
include::../../../shared_content/secrets/description.adoc[]
== Why is this an issue?
include::../../../shared_content/secrets/rationale.adoc[]
=== What is the potential impact?
include::../common/impact/rationale.adoc[]
include::../../../shared_content/secrets/impact/financial_loss.adoc[]
include::../../../shared_content/secrets/impact/security_downgrade.adoc[]
== How to fix it
include::../../../shared_content/secrets/fix/revoke.adoc[]
include::../../../shared_content/secrets/fix/recent_use.adoc[]
include::../../../shared_content/secrets/fix/vault.adoc[]
=== Code examples
include::../common/fix/code-rationale.adoc[]
==== Noncompliant code example
[source,go,diff-id=1,diff-type=noncompliant]
----
import (
"net/url"
)
func main() {
url.UserPassword("user", "password") // Noncompliant
}
----
==== Compliant solution
[source,go,diff-id=1,diff-type=compliant]
----
import (
"net/url"
"os"
)
func main() {
url.UserPassword(os.Getenv("USER"), os.Getenv("PASSWORD"))
}
----
include::../common/fix/how-it-works.adoc[]
== Resources
include::../common/resources/documentation.adoc[]
include::../common/resources/standards.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Revoke and change this password, as it is compromised.
=== Highlighting
Highlight the credential use and its initialization.
'''
endif::env-github,rspecator-view[]