mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
gosec: Fix violations of G301 (#14980)
* gosec: Fix violations of G301 * Changelog fragment
This commit is contained in:
3
changelog/pvl_g301.md
Normal file
3
changelog/pvl_g301.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Fixed
|
||||
|
||||
- Fixed violations of gosec G301. This is a check that created files and directories have file permissions 0750 and 0600 respectively.
|
||||
@@ -288,7 +288,7 @@ func generateGenesis(ctx context.Context) (state.BeaconState, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := os.WriteFile(f.GethGenesisJsonOut, gbytes, os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(f.GethGenesisJsonOut, gbytes, 0600); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to write %s", f.GethGenesisJsonOut)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ random:
|
||||
- "Takoyaki"
|
||||
`)
|
||||
f := filepath.Join(testDir, "graffiti.yaml")
|
||||
if err := os.WriteFile(f, b, os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(f, b, 0600); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return f, nil
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user