This product is not supported for your selected
Datadog site . (
).
이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우
언제든지 연락주시기 바랍니다.
이 규칙을 사용해 보세요 ID: go-security/chmod-permissions
Language: Go
Severity: Warning
Category: Security
CWE : 284
Description Granting write access to a file is a security since other users can modify the content of the file. The issue is amplified for executable files that can be easily compromised (like scripts). Avoid giving write permissions to others to files.
Learn More Non-Compliant Code Examples package main
import (
"fmt"
"os"
)
func main () {
err := os . Chmod ( "/tmp/somefile" , 0777 )
if err != nil {
fmt . Println ( "Error when changing file permissions!" )
return
}
}
package main
import (
"fmt"
"os"
)
func main () {
_ , err := os . OpenFile ( "/tmp/thing" , os . O_CREATE | os . O_WRONLY , 0666 )
if err != nil {
fmt . Println ( "Cannot create file" )
return
}
}
Compliant Code Examples package main
import (
"fmt"
"os"
)
func main () {
err := os . Chmod ( "/tmp/somefile" , 0770 )
if err != nil {
fmt . Println ( "Error when changing file permissions!" )
return
}
}
package main
import (
"fmt"
"os"
)
func main () {
_ , err := os . OpenFile ( "/tmp/thing" , os . O_CREATE | os . O_WRONLY , 0660 )
if err != nil {
fmt . Println ( "Cannot create file" )
return
}
}
원활한 통합. Datadog Code Security를 경험해 보세요