forked from hefanbo/code-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Audit changes #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Daywin67
wants to merge
1
commit into
officialmain
Choose a base branch
from
main
base: officialmain
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,282
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| AI: store secrets on remote for VS Code Web | ||
| Index: code-server/lib/vscode/src/vs/platform/secrets/common/secrets.ts | ||
| =================================================================== | ||
| --- code-server.orig/lib/vscode/src/vs/platform/secrets/common/secrets.ts | ||
| +++ code-server/lib/vscode/src/vs/platform/secrets/common/secrets.ts | ||
| @@ -139,8 +139,13 @@ export class BaseSecretStorageService ex | ||
| return await readEncryptedSecret( | ||
| key, | ||
| (fullKey) => this.getValueFromStorage(key, fullKey, storageService), | ||
| - // If the storage service is in-memory, we don't need to decrypt | ||
| - this._type === 'in-memory' ? (v) => Promise.resolve(v) : (v) => this._encryptionService.decrypt(v), | ||
| + // Don't decrypt if storage is in-memory or if encryption service is not available | ||
| + async (v) => { | ||
| + if (this._type === 'in-memory' || !await this._encryptionService.isEncryptionAvailable()) { | ||
| + return v; | ||
| + } | ||
| + return this._encryptionService.decrypt(v); | ||
| + }, | ||
| this._logService, | ||
| ); | ||
| } catch (e) { | ||
| @@ -160,8 +165,13 @@ export class BaseSecretStorageService ex | ||
| key, | ||
| value, | ||
| (fullKey, encrypted) => this.setValueInStorage(key, fullKey, encrypted, storageService), | ||
| - // If the storage service is in-memory, we don't need to encrypt | ||
| - this._type === 'in-memory' ? (v) => Promise.resolve(v) : (v) => this._encryptionService.encrypt(v), | ||
| + // Don't encrypt if storage is in-memory or if encryption service is not available | ||
| + async (v) => { | ||
| + if (this._type === 'in-memory' || !await this._encryptionService.isEncryptionAvailable()) { | ||
| + return v; | ||
| + } | ||
| + return this._encryptionService.encrypt(v); | ||
| + }, | ||
| this._logService, | ||
| ); | ||
| } catch (e) { | ||
| @@ -194,8 +204,9 @@ export class BaseSecretStorageService ex | ||
|
|
||
| private async initialize(): Promise<IStorageService> { | ||
| let storageService; | ||
| - if (!this._useInMemoryStorage && await this._encryptionService.isEncryptionAvailable()) { | ||
| - this._logService.trace(`[SecretStorageService] Encryption is available, using persisted storage`); | ||
| + if (!this._useInMemoryStorage) { | ||
| + // Use persisted storage when not forced to use in-memory | ||
| + this._logService.trace(`[SecretStorageService] Using persisted storage`); | ||
| this._type = 'persisted'; | ||
| storageService = this._storageService; | ||
| } else { | ||
| @@ -203,7 +214,7 @@ export class BaseSecretStorageService ex | ||
| if (this._type === 'in-memory') { | ||
| return this._storageService; | ||
| } | ||
| - this._logService.trace('[SecretStorageService] Encryption is not available, falling back to in-memory storage'); | ||
| + this._logService.trace('[SecretStorageService] Falling back to in-memory storage'); | ||
| this._type = 'in-memory'; | ||
| storageService = this._register(new InMemoryStorageService()); | ||
| } | ||
| Index: code-server/lib/vscode/src/vs/workbench/services/secrets/browser/secretStorageService.ts | ||
| =================================================================== | ||
| --- code-server.orig/lib/vscode/src/vs/workbench/services/secrets/browser/secretStorageService.ts | ||
| +++ code-server/lib/vscode/src/vs/workbench/services/secrets/browser/secretStorageService.ts | ||
| @@ -22,9 +22,9 @@ export class BrowserSecretStorageService | ||
| @IBrowserWorkbenchEnvironmentService environmentService: IBrowserWorkbenchEnvironmentService, | ||
| @ILogService logService: ILogService | ||
| ) { | ||
| - // We don't have encryption in the browser so instead we use the | ||
| - // in-memory base class implementation instead. | ||
| - super(true, storageService, encryptionService, logService); | ||
| + // Use remote storage if enabled, otherwise use in-memory storage | ||
| + const useRemoteStorage = environmentService.options?.remoteStorageEnabled ?? false; | ||
| + super(!useRemoteStorage, storageService, encryptionService, logService); | ||
|
|
||
| if (environmentService.options?.secretStorageProvider) { | ||
| this._secretStorageProvider = environmentService.options.secretStorageProvider; | ||
| Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts | ||
| =================================================================== | ||
| --- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.ts | ||
| +++ code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts | ||
| @@ -625,2 +625,2 @@ | ||
| - secretStorageProvider: config.remoteAuthority && !secretStorageKeyPath | ||
| - ? undefined /* with a remote without embedder-preferred storage, store on the remote */ | ||
| + secretStorageProvider: config.remoteStorageEnabled || (config.remoteAuthority && !secretStorageKeyPath) | ||
| + ? undefined /* with remote storage enabled, or without embedder-prefered storage, store on the remote */ | ||
| }); | ||
| })(); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
--enable-remote-storageis used in the browser,IEncryptionService.isEncryptionAvailable()is normally false, but this branch now selects persisted storage anyway; combined with the new encrypt/decrypt callbacks that return the value unchanged when encryption is unavailable, extension secrets such as GitHub or Copilot tokens are written as cleartextsecret://entries into the remote/browser storage database. The previous guard kept secrets in memory unless encryption was available, so this should either keep the in-memory fallback or route secrets through a server-side encrypted secret provider.Useful? React with 👍 / 👎.