Skip to content

Commit 5e959bf

Browse files
jcrussellclaude
andcommitted
Restrict file permissions for sensitive health data
Tighten file permissions on output files and geocoding cache to prevent world-readable access to sensitive health information: - Output directory: 0755 → 0700 (owner-only access) - Output HTML files: implicit → 0600 (owner-only read/write) - Geocoding cache directory: 0755 → 0700 (owner-only access) - Geocoding cache file: 0644 → 0600 (owner-only read/write) These changes ensure that HTML dashboards containing medical records and cached geocoded facility addresses are only accessible by the file owner. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent e1f3067 commit 5e959bf

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pkg/cmd/generate/generate.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func runGenerate(opts *GenerateOptions) error {
149149
}
150150

151151
// 4. Generate Output
152-
if err := os.MkdirAll(opts.OutputDir, 0755); err != nil {
152+
if err := os.MkdirAll(opts.OutputDir, 0700); err != nil {
153153
return err
154154
}
155155

@@ -206,7 +206,12 @@ func runGenerate(opts *GenerateOptions) error {
206206

207207
// Wrap in closure to ensure proper defer scoping in loop
208208
if err := func() error {
209-
f, err := os.Create(filepath.Join(opts.OutputDir, filename))
209+
// Create HTML file with owner-only permissions (sensitive health data)
210+
f, err := os.OpenFile(
211+
filepath.Join(opts.OutputDir, filename),
212+
os.O_WRONLY|os.O_CREATE|os.O_TRUNC,
213+
0600,
214+
)
210215
if err != nil {
211216
return err
212217
}

pkg/geocode/geocode.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (g *NominatimGeocoder) SaveCache() error {
186186

187187
// Ensure cache directory exists
188188
cacheDir := filepath.Dir(g.cachePath)
189-
if err := os.MkdirAll(cacheDir, 0755); err != nil {
189+
if err := os.MkdirAll(cacheDir, 0700); err != nil {
190190
return fmt.Errorf("failed to create cache directory: %w", err)
191191
}
192192

@@ -220,7 +220,7 @@ func (g *NominatimGeocoder) SaveCache() error {
220220

221221
// Atomic write: write to temp file, then rename
222222
tempPath := g.cachePath + ".tmp"
223-
if err := os.WriteFile(tempPath, data, 0644); err != nil {
223+
if err := os.WriteFile(tempPath, data, 0600); err != nil {
224224
return fmt.Errorf("failed to write temp cache file: %w", err)
225225
}
226226

0 commit comments

Comments
 (0)