Skip to content

Commit 8c88392

Browse files
authored
fix(amazonq): set owner-only permissions for chat history, prompts #6961
## Problem Chat history and saved prompt files are created with default global read permissions ## Solution Add owner only read/write permissions to newly created saved prompt and chat history files
1 parent 2f6d437 commit 8c88392

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Amazon Q Chat: Set owner-only permissions for chat history and saved prompt files"
4+
}

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ export class ChatController {
638638
title ? `${title}${promptFileExtension}` : `default${promptFileExtension}`
639639
)
640640
const newFileContent = new Uint8Array(Buffer.from(''))
641-
await fs.writeFile(newFilePath, newFileContent)
641+
await fs.writeFile(newFilePath, newFileContent, { mode: 0o600 })
642642
const newFileDoc = await vscode.workspace.openTextDocument(newFilePath)
643643
await vscode.window.showTextDocument(newFileDoc)
644644
telemetry.ui_click.emit({ elementId: 'amazonq_createSavedPrompt' })

packages/core/src/shared/db/chatDb/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class FileSystemAdapter implements LokiPersistenceAdapter {
142142
await this.ensureDirectory()
143143
const filename = path.join(this.directory, dbname)
144144

145-
await fs.writeFile(filename, dbstring, 'utf8')
145+
await fs.writeFile(filename, dbstring, { mode: 0o600, encoding: 'utf8' })
146146
callback(undefined)
147147
} catch (err: any) {
148148
callback(err)

0 commit comments

Comments
 (0)