diff --git a/browse/src/audit.ts b/browse/src/audit.ts index b6e546388..f93b47fb0 100644 --- a/browse/src/audit.ts +++ b/browse/src/audit.ts @@ -13,7 +13,7 @@ * All writes are best-effort — audit failures never cause command failures. */ -import * as fs from 'fs'; +import { appendSecureFile } from './file-permissions'; export interface AuditEntry { ts: string; @@ -62,7 +62,7 @@ export function writeAuditEntry(entry: AuditEntry): void { if (entry.aliasOf) record.aliasOf = entry.aliasOf; if (truncatedError) record.error = truncatedError; - fs.appendFileSync(auditPath, JSON.stringify(record) + '\n'); + appendSecureFile(auditPath, JSON.stringify(record) + '\n'); } catch { // Audit write failures are silent — never block command execution } diff --git a/browse/src/server.ts b/browse/src/server.ts index f4194bf0c..466c6f212 100644 --- a/browse/src/server.ts +++ b/browse/src/server.ts @@ -26,7 +26,7 @@ import { } from './content-security'; import { getStatus as getSecurityStatus } from './security'; import { isSidecarAvailable, scanWithSidecar } from './security-sidecar-client'; -import { writeSecureFile, mkdirSecure } from './file-permissions'; +import { writeSecureFile, mkdirSecure, appendSecureFile } from './file-permissions'; import { handleSnapshot, SNAPSHOT_FLAGS } from './snapshot'; import { initRegistry, validateToken as validateScopedToken, checkScope, checkDomain, @@ -586,7 +586,7 @@ async function flushBuffers() { const lines = entries.map(e => `[${new Date(e.timestamp).toISOString()}] [${e.level}] ${e.text}` ).join('\n') + '\n'; - fs.appendFileSync(CONSOLE_LOG_PATH, lines); + appendSecureFile(CONSOLE_LOG_PATH, lines); lastConsoleFlushed = consoleBuffer.totalAdded; } @@ -597,7 +597,7 @@ async function flushBuffers() { const lines = entries.map(e => `[${new Date(e.timestamp).toISOString()}] ${e.method} ${e.url} → ${e.status || 'pending'} (${e.duration || '?'}ms, ${e.size || '?'}B)` ).join('\n') + '\n'; - fs.appendFileSync(NETWORK_LOG_PATH, lines); + appendSecureFile(NETWORK_LOG_PATH, lines); lastNetworkFlushed = networkBuffer.totalAdded; } @@ -608,7 +608,7 @@ async function flushBuffers() { const lines = entries.map(e => `[${new Date(e.timestamp).toISOString()}] [${e.type}] "${e.message}" → ${e.action}${e.response ? ` "${e.response}"` : ''}` ).join('\n') + '\n'; - fs.appendFileSync(DIALOG_LOG_PATH, lines); + appendSecureFile(DIALOG_LOG_PATH, lines); lastDialogFlushed = dialogBuffer.totalAdded; } } catch (err: any) {