Skip to content

Commit

Permalink
Reduce file permissions in y.go (#1056)
Browse files Browse the repository at this point in the history
one of the issues listed in
https://deepsource.io/gh/jaipradeesh/badger/issues/ is excessive
permissions. The functions in y.go are opening files with 0666
permissions. This PR changes them to 0600 for improved security.
  • Loading branch information
martinmr committed Sep 30, 2019
1 parent 50ddf21 commit f313f0c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions y/y.go
Expand Up @@ -75,7 +75,7 @@ func CreateSyncedFile(filename string, sync bool) (*os.File, error) {
if sync {
flags |= datasyncFileFlag
}
return os.OpenFile(filename, flags, 0666)
return os.OpenFile(filename, flags, 0600)
}

// OpenSyncedFile creates the file if one doesn't exist.
Expand All @@ -84,7 +84,7 @@ func OpenSyncedFile(filename string, sync bool) (*os.File, error) {
if sync {
flags |= datasyncFileFlag
}
return os.OpenFile(filename, flags, 0666)
return os.OpenFile(filename, flags, 0600)
}

// OpenTruncFile opens the file with O_RDWR | O_CREATE | O_TRUNC
Expand All @@ -93,7 +93,7 @@ func OpenTruncFile(filename string, sync bool) (*os.File, error) {
if sync {
flags |= datasyncFileFlag
}
return os.OpenFile(filename, flags, 0666)
return os.OpenFile(filename, flags, 0600)
}

// SafeCopy does append(a[:0], src...).
Expand Down

0 comments on commit f313f0c

Please sign in to comment.