Skip to content

Commit

Permalink
fix: relax file permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
nrwiersma committed Apr 13, 2023
1 parent 32dcc1e commit 104e4e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/config/config.go
Expand Up @@ -383,7 +383,7 @@ func checkFilePerms(files ...string) error {
// Assume unix based system (MacOS and Linux)
// the bit mask is calculated using the umask command which tells which permissions
// should not be allowed for a particular user, group or world
if fInfo.Mode()&0o077 != 0 && runtime.GOOS != "windows" {
if fInfo.Mode()&0o033 != 0 && runtime.GOOS != "windows" {
return errors.E(op, f+" should have at most rwx,-, - (bit mask 077) as permission")
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/config/config_test.go
Expand Up @@ -409,7 +409,7 @@ func Test_checkFilePerms(t *testing.T) {
t.Skipf("Chmod is not supported in windows, so not possible to test. Ref: https://github.com/golang/go/blob/master/src/os/os_test.go#L1031\n")
}

incorrectPerms := []os.FileMode{0777, 0610, 0660}
incorrectPerms := []os.FileMode{0o777, 0o610, 0o660}
var incorrectFiles = make([]string, len(incorrectPerms))

for i := range incorrectPerms {
Expand All @@ -421,7 +421,7 @@ func Test_checkFilePerms(t *testing.T) {
defer os.Remove(f)
}

correctPerms := []os.FileMode{0600, 0400}
correctPerms := []os.FileMode{0o600, 0o400, 0o644}
var correctFiles = make([]string, len(correctPerms))

for i := range correctPerms {
Expand All @@ -441,8 +441,8 @@ func Test_checkFilePerms(t *testing.T) {

tests := []test{
{
"should not have an error on 0600, 0400, 0640",
[]string{correctFiles[0], correctFiles[1]},
"should not have an error on 0600, 0400, 0644",
[]string{correctFiles[0], correctFiles[1], correctFiles[2]},
false,
},
{
Expand Down

0 comments on commit 104e4e5

Please sign in to comment.