From 7687b094c8c6dc12d47fc99cc6b4dfbc71c02a19 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Fri, 22 Dec 2023 16:00:54 +0100 Subject: [PATCH] Changed os.ModePerm (777) file permissions to 644 and 755 --- CHANGELOG.md | 1 + internal/app/app.go | 4 ++-- internal/app/app_settings.go | 3 +-- internal/app/collection_find_queries.go | 3 +-- internal/app/host_shell.go | 6 +++--- internal/app/hosts.go | 3 +-- internal/app/views.go | 3 +-- internal/logger.go | 2 +- 8 files changed, 11 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cd696d..535c72b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Patches: * Preserve state after switching to another tab (#56). * Find view: ask for confirmation before negligently deleting documents when the user has clicked the '-' button (#58). * Set a deadline for counting documents, and added a button to count documents if the deadline has been exceeded. +* Changed os.ModePerm (777) file permissions to 644 and 755. * UI improvements. Bugfixes: diff --git a/internal/app/app.go b/internal/app/app.go index 682122d..cff798f 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -75,8 +75,8 @@ func NewApp(version string) *App { panic(errors.New("unsupported platform")) } - os.MkdirAll(a.Env.DataDirectory, os.ModePerm) - os.MkdirAll(a.Env.LogDirectory, os.ModePerm) + os.MkdirAll(a.Env.DataDirectory, 0755) + os.MkdirAll(a.Env.LogDirectory, 0755) return a } diff --git a/internal/app/app_settings.go b/internal/app/app_settings.go index 561dcfe..dd5803d 100644 --- a/internal/app/app_settings.go +++ b/internal/app/app_settings.go @@ -3,7 +3,6 @@ package app import ( "encoding/json" "io/ioutil" - "os" "path" "github.com/wailsapp/wails/v2/pkg/runtime" @@ -77,7 +76,7 @@ func (a *App) UpdateSettings(jsonData string) Settings { } filePath := path.Join(a.Env.DataDirectory, "settings.json") - err = ioutil.WriteFile(filePath, newJson, os.ModePerm) + err = ioutil.WriteFile(filePath, newJson, 0644) if err != nil { runtime.LogErrorf(a.ctx, "Could not update host list: %s", err.Error()) runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ diff --git a/internal/app/collection_find_queries.go b/internal/app/collection_find_queries.go index 5bfcb49..82de494 100644 --- a/internal/app/collection_find_queries.go +++ b/internal/app/collection_find_queries.go @@ -3,7 +3,6 @@ package app import ( "encoding/json" "io/ioutil" - "os" "path" "github.com/wailsapp/wails/v2/pkg/runtime" @@ -25,7 +24,7 @@ func updateQueryFile(a *App, newData map[string]SavedQuery) error { return err } - err = ioutil.WriteFile(filePath, jsonData, os.ModePerm) + err = ioutil.WriteFile(filePath, jsonData, 0644) return err } diff --git a/internal/app/host_shell.go b/internal/app/host_shell.go index ae271e0..932a0ff 100644 --- a/internal/app/host_shell.go +++ b/internal/app/host_shell.go @@ -142,7 +142,7 @@ func (a *App) SaveShellScript(hostKey, dbKey, collKey, script string, temp bool) scriptHeader = scriptHeader + "\n" script = scriptHeader + strings.TrimLeft(strings.TrimRight(script, " \t\n"), "\n") - if err := os.WriteFile(result.Fname, []byte(script), os.ModePerm); err != nil { + if err := os.WriteFile(result.Fname, []byte(script), 0755); err != nil { runtime.LogWarningf(a.ctx, "Shell: failed to write script to %s: %s", result.Fname, err.Error()) result.ErrorTitle = "Could not create temporary script file" result.ErrorDescription = err.Error() @@ -154,7 +154,7 @@ func (a *App) SaveShellScript(hostKey, dbKey, collKey, script string, temp bool) func (a *App) OpenShellScript() string { dir := path.Join(a.Env.DataDirectory, "Shell Scripts") - os.MkdirAll(dir, os.ModePerm) + os.MkdirAll(dir, 0755) fname, err := runtime.OpenFileDialog(a.ctx, runtime.OpenDialogOptions{ DefaultDirectory: path.Join(a.Env.DataDirectory, "Shell Scripts"), @@ -200,7 +200,7 @@ func (a *App) SaveShellOuput(output string) { }) } - if err := os.WriteFile(fname, []byte(output), os.ModePerm); err != nil { + if err := os.WriteFile(fname, []byte(output), 0755); err != nil { runtime.LogWarningf(a.ctx, "Shell: error writing shell output to %s: %s", fname, err.Error()) runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ Title: "Error writing shell output", diff --git a/internal/app/hosts.go b/internal/app/hosts.go index 1f220e4..870a6ea 100644 --- a/internal/app/hosts.go +++ b/internal/app/hosts.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "io/ioutil" - "os" "path" "github.com/google/uuid" @@ -23,7 +22,7 @@ func updateHostsFile(a *App, newData map[string]Host) error { return err } - err = ioutil.WriteFile(filePath, jsonData, os.ModePerm) + err = ioutil.WriteFile(filePath, jsonData, 0644) return err } diff --git a/internal/app/views.go b/internal/app/views.go index 27ffe65..12a76fa 100644 --- a/internal/app/views.go +++ b/internal/app/views.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "io/ioutil" - "os" "path" "github.com/wailsapp/wails/v2/pkg/runtime" @@ -63,7 +62,7 @@ func updateViewStore(a *App, newData ViewStore) error { return err } - err = ioutil.WriteFile(filePath, jsonData, os.ModePerm) + err = ioutil.WriteFile(filePath, jsonData, 0644) return err } diff --git a/internal/logger.go b/internal/logger.go index 17b289a..bea9541 100644 --- a/internal/logger.go +++ b/internal/logger.go @@ -21,7 +21,7 @@ func NewAppLogger(directory, filename string) *AppLogger { } func (l *AppLogger) Print(message string) { - os.MkdirAll(l.directory, os.ModePerm) + os.MkdirAll(l.directory, 0755) f, _ := os.OpenFile(l.filepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) f.WriteString(message) f.Close()