prysm-pulse/tools/analyzers/properpermissions/testdata/custom_imports.go
Raul Jordan d4c954648c
Prevent Usage of Stdlib File/Dir Writing With Static Analysis (#7685)
* write file and mkdirall analyzers

* include analyzer in build bazel

* comments to the single entrypoint and fix validator references

* enforce 600 for files, 700 for dirs

* pass validator tests

* add to nogo

* remove references

* beaconfuzz

* docker img

* fix up kv issue

* mkdir if not exists

* radek comments

* final comments

* Try to fix file problem

Co-authored-by: Ivan Martinez <ivanthegreatdev@gmail.com>
2020-11-09 14:27:03 -06:00

19 lines
621 B
Go

package testdata
import (
"crypto/rand"
"fmt"
ioAlias "io/ioutil"
"math/big"
osAlias "os"
"path/filepath"
)
func UseAliasedPackages() {
randPath, _ := rand.Int(rand.Reader, big.NewInt(1000000))
p := filepath.Join(tempDir(), fmt.Sprintf("/%d", randPath))
_ = osAlias.MkdirAll(p, osAlias.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/fileutil"
someFile := filepath.Join(p, "some.txt")
_ = ioAlias.WriteFile(someFile, []byte("hello"), osAlias.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/fileutil"
}