Files
prysm/tools/analyzers/properpermissions/testdata/regular_imports.go
Preston Van Loon 09499a732f gosec: Fix violations of G301 (#14980)
* gosec: Fix violations of G301

* Changelog fragment
2025-02-24 15:13:53 +00:00

27 lines
696 B
Go

package testdata
import (
"crypto/rand"
"fmt"
"math/big"
"os"
"path/filepath"
)
func tempDir() string {
d := os.Getenv("TEST_TMPDIR")
if d == "" {
return os.TempDir()
}
return d
}
// UseOsMkdirAllAndWriteFile --
func UseOsMkdirAllAndWriteFile() {
randPath, _ := rand.Int(rand.Reader, big.NewInt(1000000))
p := filepath.Join(tempDir(), fmt.Sprintf("/%d", randPath))
_ = 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"), 0600) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/file"
}