Conversation
There was a problem hiding this comment.
Pull request overview
Adds persistence for the MSSQL Query History tree so entries can be restored across VS Code sessions (partial progress toward #21196).
Changes:
- Persist/restore query history via
ExtensionContext.secretsinQueryHistoryProvider, with versioned payload + bounds on stored nodes/query length. - Wire
ExtensionContextintoQueryHistoryProviderfromMainControllerand add a dedicated SecretStorage key constant. - Add unit tests covering persistence/restore behavior and edge cases; expose
isSuccessgetter onQueryHistoryNode.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/mssql/src/queryHistory/queryHistoryProvider.ts | Implements query history persistence/restore and adjusts node handling/sorting. |
| extensions/mssql/src/controllers/mainController.ts | Passes ExtensionContext into QueryHistoryProvider. |
| extensions/mssql/src/constants/constants.ts | Adds queryHistorySecretStorageKey constant for persistence. |
| extensions/mssql/src/queryHistory/queryHistoryNode.ts | Adds isSuccess getter used by persistence/tests. |
| extensions/mssql/test/unit/queryHistoryProvider.test.ts | Adds unit test coverage for persistence/restore and related behaviors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Changes
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #21544 +/- ##
==========================================
+ Coverage 72.67% 72.80% +0.12%
==========================================
Files 331 332 +1
Lines 98489 98802 +313
Branches 5462 5495 +33
==========================================
+ Hits 71580 71934 +354
+ Misses 26909 26868 -41
🚀 New features to boost your workflow:
|
- Added encryptionUtils.ts for data encryption and decryption using AES-256-GCM. - Implemented functions to generate encryption keys, encrypt data, and decrypt data. - Created unit tests for encryption utilities to ensure functionality and security. - Updated queryHistoryProvider tests to utilize encrypted storage for query history. - Ensured sensitive data, such as passwords, are handled securely during storage and retrieval.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const persistedCredentials = { ...credentials }; | ||
| if ((credentials as IConnectionProfile).savePassword === false) { | ||
| persistedCredentials.password = ""; | ||
| } | ||
|
|
There was a problem hiding this comment.
sanitizeCredentialsForPersistence currently persists the entire IConnectionInfo object (including fields like azureAccountToken/expiresOn and potentially connectionString, which may embed credentials). Even though the file is encrypted, persisting access tokens/connection strings extends the lifetime of secrets and increases exposure risk. Consider persisting a minimal, explicit allow-list (e.g., server/database/authenticationType/user and only password when savePassword=true), and explicitly omit azureAccountToken/expiresOn/connectionString (or scrub secrets from it) before writing.
| const persistedCredentials = { ...credentials }; | |
| if ((credentials as IConnectionProfile).savePassword === false) { | |
| persistedCredentials.password = ""; | |
| } | |
| const savePassword = (credentials as IConnectionProfile).savePassword; | |
| const passwordToPersist = | |
| savePassword === false ? "" : (credentials as vscodeMssql.IConnectionInfo).password; | |
| // Explicitly allow-list non-sensitive fields needed to restore context. | |
| // Do not persist access tokens, expiry times, or connection strings. | |
| const persistedCredentials = { | |
| server: credentials.server, | |
| database: credentials.database, | |
| authenticationType: credentials.authenticationType, | |
| user: (credentials as vscodeMssql.IConnectionInfo).user, | |
| password: passwordToPersist, | |
| } as vscodeMssql.IConnectionInfo; |
… test expectations
bd83c7b
Description
Partially address: #21196
Query history is now restored from and written to an AES-256-GCM encrypted file in extension global storage, with the encryption key kept in SecretStorage.
Code Changes Checklist
npm run test)Reviewers: Please read our reviewer guidelines