Skip to content

Commit

Permalink
Fix G302 gosec issues (#10378)
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
  • Loading branch information
dimitarvdimitrov authored Jan 9, 2025
1 parent 33ca7b5 commit d68b6ad
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ linters-settings:
- G109
- G112
- G114
- G302

run:
timeout: 10m
Expand Down
2 changes: 1 addition & 1 deletion pkg/mimirtool/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (c *ConfigCommand) output(yamlContents []byte, flags []string, notices conf
if path == "" {
return defaultWriter, func() {}, nil
}
outWriter, err := os.OpenFile(path, os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0666)
outWriter, err := os.OpenFile(path, os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
return nil, nil, errors.Wrap(err, "could not open "+path)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/activitytracker/activity_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func trimEntryToSize(entry string, size int) string {
}

func getMappedFile(filename string, filesize int) (*os.File, mmap.MMap, error) {
file, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0666)
file, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0600)
if err != nil {
return nil, nil, errors.Wrap(err, "failed to create activity file")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/shutdownmarker/shutdown_marker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Remove(p string) error {
return err
}

dir, err := os.OpenFile(path.Dir(p), os.O_RDONLY, 0777)
dir, err := os.OpenFile(path.Dir(p), os.O_RDONLY, 0600) // mode doesn't matter since we're not passing os.O_CREATE
if err != nil {
return err
}
Expand Down

0 comments on commit d68b6ad

Please sign in to comment.