Merge pull request 'fix(bugseti): update config file permissions to 0600' (#57) from fix/bugseti-config-perms into new
This commit is contained in:
commit
9fe4d5f063
2 changed files with 38 additions and 1 deletions
|
|
@ -149,7 +149,7 @@ func (c *ConfigService) saveUnsafe() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(c.path, data, 0644)
|
||||
return os.WriteFile(c.path, data, 0600)
|
||||
}
|
||||
|
||||
// mergeDefaults fills in default values for any unset fields.
|
||||
|
|
|
|||
37
internal/bugseti/config_test.go
Normal file
37
internal/bugseti/config_test.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package bugseti
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConfigPermissions(t *testing.T) {
|
||||
// Get a temporary file path
|
||||
f, err := os.CreateTemp("", "bugseti-config-*.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
name := f.Name()
|
||||
f.Close()
|
||||
os.Remove(name) // Ensure it doesn't exist
|
||||
defer os.Remove(name)
|
||||
|
||||
c := &ConfigService{
|
||||
path: name,
|
||||
config: &Config{},
|
||||
}
|
||||
|
||||
if err := c.Save(); err != nil {
|
||||
t.Fatalf("Save failed: %v", err)
|
||||
}
|
||||
|
||||
info, err := os.Stat(name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
mode := info.Mode().Perm()
|
||||
if mode != 0600 {
|
||||
t.Errorf("expected file permissions 0600, got %04o", mode)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue