Skip to content

Commit cb8bbc5

Browse files
authored
fix: move back to permission numbers (#240)
1 parent 294a94a commit cb8bbc5

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

.golangci.yml

+28-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ linters:
55

66
disable:
77
- cyclop # some functions need refactoring, I'll deal with that later
8-
- depguard # I'm not that pedantic
98
- exhaustruct # it's ok not to specify all the fields in a struct definition
109
- godox # I like leaving TODOs in the code
1110
- nlreturn # keeps the code concise
@@ -46,6 +45,34 @@ linters-settings:
4645
- default
4746
- localmodule
4847

48+
mnd:
49+
ignored-numbers:
50+
# UNIX permissions mask
51+
- "0o700" # rwx------
52+
- "0o600" # rw-------
53+
54+
ignored-functions:
55+
# Functions that require a UNIX permissions mask
56+
- "os.WriteFile"
57+
- "os.OpenFile"
58+
- "os.MkdirAll"
59+
60+
depguard:
61+
rules:
62+
main:
63+
files:
64+
- $all
65+
allow:
66+
- $gostd
67+
- github.com/cli/go-gh
68+
- github.com/nobe4/gh-not
69+
- github.com/charmbracelet/bubbletea
70+
- github.com/charmbracelet/bubbles
71+
- github.com/charmbracelet/lipgloss
72+
- github.com/spf13/cobra
73+
- github.com/spf13/viper
74+
- github.com/itchyny/gojq
75+
4976
revive:
5077
enable-all-rules: true
5178
rules:

internal/cache/cache.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"log/slog"
1515
"os"
1616
"path/filepath"
17-
"syscall"
1817
"time"
1918
)
2019

@@ -98,18 +97,11 @@ func (c *File) Write(in any) error {
9897
return fmt.Errorf("failed to marshal cache: %w", err)
9998
}
10099

101-
if err := os.MkdirAll(
102-
filepath.Dir(c.path),
103-
syscall.S_IRUSR|syscall.S_IWUSR|syscall.S_IXUSR,
104-
); err != nil {
100+
if err := os.MkdirAll(filepath.Dir(c.path), 0o700); err != nil {
105101
return fmt.Errorf("failed to create cache directory: %w", err)
106102
}
107103

108-
if err := os.WriteFile(
109-
c.path,
110-
marshaled,
111-
syscall.S_IRUSR|syscall.S_IWUSR,
112-
); err != nil {
104+
if err := os.WriteFile(c.path, marshaled, 0o600); err != nil {
113105
return fmt.Errorf("failed to write cache: %w", err)
114106
}
115107

internal/logger/logger.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import (
55
"io"
66
"log/slog"
77
"os"
8-
"syscall"
98
)
109

1110
func Init(verbosity int) {
1211
initWithWriter(os.Stderr, verbosity)
1312
}
1413

1514
func InitWithFile(verbosity int, path string) (*os.File, error) {
16-
f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, syscall.S_IRUSR|syscall.S_IWUSR)
15+
f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600)
1716
if err != nil {
1817
return nil, fmt.Errorf("error opening file for logging: %w", err)
1918
}

0 commit comments

Comments
 (0)