Fix gosec warnings: tighten file permissions and add exclusions (bd-b47c034e)
This commit is contained in:
@@ -38,6 +38,11 @@ linters:
|
||||
linters:
|
||||
- gosec
|
||||
text: "G304"
|
||||
# G306: File permissions 0644 in tests are acceptable (test fixtures)
|
||||
- path: '_test\.go'
|
||||
linters:
|
||||
- gosec
|
||||
text: "G306"
|
||||
# G304: Safe file reads from known JSONL and error paths
|
||||
- path: 'cmd/bd/autoflush\.go|internal/daemon/discovery\.go|internal/daemonrunner/sync\.go'
|
||||
linters:
|
||||
|
||||
@@ -46,7 +46,7 @@ func findJSONLPath() string {
|
||||
// Ensure the directory exists (important for new databases)
|
||||
// This is the only difference from the public API - we create the directory
|
||||
dbDir := filepath.Dir(dbPath)
|
||||
if err := os.MkdirAll(dbDir, 0755); err != nil {
|
||||
if err := os.MkdirAll(dbDir, 0750); err != nil {
|
||||
// If we can't create the directory, return discovered path anyway
|
||||
// (the subsequent write will fail with a clearer error)
|
||||
return jsonlPath
|
||||
|
||||
@@ -34,7 +34,7 @@ func NewRegistry() (*Registry, error) {
|
||||
}
|
||||
|
||||
beadsDir := filepath.Join(home, ".beads")
|
||||
if err := os.MkdirAll(beadsDir, 0755); err != nil {
|
||||
if err := os.MkdirAll(beadsDir, 0750); err != nil {
|
||||
return nil, fmt.Errorf("failed to create .beads directory: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ func TestDetermineDatabasePath(t *testing.T) {
|
||||
beadsDir := filepath.Join(tmpDir, ".beads")
|
||||
dbPath := filepath.Join(beadsDir, "beads.db")
|
||||
|
||||
if err := os.MkdirAll(beadsDir, 0755); err != nil {
|
||||
if err := os.MkdirAll(beadsDir, 0750); err != nil {
|
||||
t.Fatalf("Failed to create beads dir: %v", err)
|
||||
}
|
||||
if err := os.WriteFile(dbPath, []byte("test"), 0644); err != nil {
|
||||
if err := os.WriteFile(dbPath, []byte("test"), 0600); err != nil {
|
||||
t.Fatalf("Failed to create db file: %v", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestShouldSkipDatabase(t *testing.T) {
|
||||
Version: "1.0.0",
|
||||
}
|
||||
data, _ := json.Marshal(lock)
|
||||
if err := os.WriteFile(lockPath, data, 0644); err != nil {
|
||||
if err := os.WriteFile(lockPath, data, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(lockPath)
|
||||
@@ -69,7 +69,7 @@ func TestShouldSkipDatabase(t *testing.T) {
|
||||
Version: "1.0.0",
|
||||
}
|
||||
data, _ := json.Marshal(lock)
|
||||
if err := os.WriteFile(lockPath, data, 0644); err != nil {
|
||||
if err := os.WriteFile(lockPath, data, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(lockPath)
|
||||
@@ -115,7 +115,7 @@ func TestShouldSkipDatabase(t *testing.T) {
|
||||
Version: "1.0.0",
|
||||
}
|
||||
data, _ := json.Marshal(lock)
|
||||
if err := os.WriteFile(lockPath, data, 0644); err != nil {
|
||||
if err := os.WriteFile(lockPath, data, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(lockPath)
|
||||
@@ -142,7 +142,7 @@ func TestShouldSkipDatabase(t *testing.T) {
|
||||
Version: "1.0.0",
|
||||
}
|
||||
data, _ := json.Marshal(lock)
|
||||
if err := os.WriteFile(lockPath, data, 0644); err != nil {
|
||||
if err := os.WriteFile(lockPath, data, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(lockPath)
|
||||
|
||||
Reference in New Issue
Block a user