
## Review A dedicated reviewer checked the rule description successfully for: - [ ] logical errors and incorrect information - [ ] information gaps and missing content - [ ] text style and tone - [ ] PR summary and labels follow [the guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
87 lines
1.3 KiB
Plaintext
87 lines
1.3 KiB
Plaintext
include::../description.adoc[]
|
|
|
|
include::../ask-yourself.adoc[]
|
|
|
|
include::../recommended.adoc[]
|
|
|
|
== Sensitive Code Example
|
|
|
|
For https://pkg.go.dev/os#Chmod[Chmod() in the `os` package]:
|
|
|
|
[source,go,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
err := os.Chmod("/tmp/fs", 0777) // Sensitive
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
----
|
|
|
|
|
|
For https://pkg.go.dev/golang.org/x/sys@v0.11.0/unix#Umask[Umask() in the `syscall` package]:
|
|
|
|
[source,go,diff-id=2,diff-type=noncompliant]
|
|
----
|
|
import (
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func main() {
|
|
oldMask := unix.Umask(0) // Sensitive
|
|
}
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
For https://pkg.go.dev/os#Chmod[Chmod() in the `os` package]:
|
|
|
|
[source,go,diff-id=1,diff-type=compliant]
|
|
----
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
err := os.Chmod("/tmp/fs", 0770)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
----
|
|
|
|
For https://pkg.go.dev/syscall#Umask[`Umask()` in the `syscall` package]:
|
|
|
|
[source,go,diff-id=2,diff-type=compliant]
|
|
----
|
|
import (
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func main() {
|
|
oldMask := unix.Umask(0007)
|
|
}
|
|
----
|
|
|
|
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[]
|