gosec: Fix violations of G301 (#14980)

* gosec: Fix violations of G301

* Changelog fragment
This commit is contained in:
Preston Van Loon
2025-02-24 09:13:53 -06:00
committed by GitHub
parent 2ee015452c
commit 09499a732f
5 changed files with 8 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ func tempDir() string {
func UseOsMkdirAllAndWriteFile() {
randPath, _ := rand.Int(rand.Reader, big.NewInt(1000000))
p := filepath.Join(tempDir(), fmt.Sprintf("/%d", randPath))
_ = os.MkdirAll(p, os.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/file"
_ = os.MkdirAll(p, 0750) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/file"
someFile := filepath.Join(p, "some.txt")
_ = os.WriteFile(someFile, []byte("hello"), os.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/file"
_ = os.WriteFile(someFile, []byte("hello"), 0600) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/file"
}

View File

@@ -78,5 +78,5 @@ func getAndSaveFile(specDocUrl, outFilePath string) error {
}
func prepareDir(dirPath string) error {
return os.MkdirAll(dirPath, os.ModePerm)
return os.MkdirAll(dirPath, 0750)
}