Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ export class TerminalSandboxService extends Disposable implements ITerminalSandb
}

private _updateAllowReadPathsWithAllowWrite(configuredAllowRead: string[] | undefined, allowWrite: string[]): string[] {
return [...new Set([...(configuredAllowRead ?? []), ...getTerminalSandboxReadAllowListForCommands(this._os, this._commandReadAllowKeywords), ...this._getSandboxRuntimeReadPaths(), ...allowWrite])];
return [...new Set([...(configuredAllowRead ?? []), ...getTerminalSandboxReadAllowListForCommands(this._os, this._commandReadAllowKeywords), ...this._getSandboxRuntimeReadPaths(), ...this._getWorkspaceStorageReadPaths(), ...allowWrite])];
}

private _resolveLinuxFileSystemPaths(paths: string[] | undefined): string[] {
Expand Down Expand Up @@ -704,6 +704,12 @@ export class TerminalSandboxService extends Disposable implements ITerminalSandb
return path === this._appRoot || path.startsWith(`${this._appRoot}${this._os === OperatingSystem.Windows ? win32.sep : posix.sep}`);
}

private _getWorkspaceStorageReadPaths(): string[] {
const workspaceStorageHome = this._remoteEnvDetails?.workspaceStorageHome ?? this._environmentService.workspaceStorageHome;
const workspaceId = this._workspaceContextService.getWorkspace().id;
return [URI.joinPath(workspaceStorageHome, workspaceId).path];
}

private _getUserHomePath(): string | undefined {
const nativeEnv = this._environmentService as IEnvironmentService & { userHome?: URI };
return this._remoteEnvDetails?.userHome?.path ?? nativeEnv.userHome?.path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,26 @@ suite('TerminalSandboxService - network domains', () => {
ok(!config.filesystem.allowRead.includes('/app/node_modules/@vscode/ripgrep'), 'Sandbox config should not redundantly include app root child paths');
});

test('should reallow reads from workspace storage', async () => {
remoteAgentService.remoteEnvironment = {
...remoteAgentService.remoteEnvironment!,
workspaceStorageHome: URI.file('/home/user/.vscode-server/data/User/workspaceStorage')
};

const sandboxService = store.add(instantiationService.createInstance(TerminalSandboxService));
const configPath = await sandboxService.getSandboxConfigPath();

ok(configPath, 'Config path should be defined');
const configContent = createdFiles.get(configPath);
ok(configContent, 'Config file should be created');

const config = JSON.parse(configContent);
const expectedWorkspaceStoragePath = URI.joinPath(remoteAgentService.remoteEnvironment.workspaceStorageHome, workspaceContextService.getWorkspace().id).path;

ok(config.filesystem.denyRead.includes('/home/user'), 'Sandbox config should deny arbitrary reads from the user home');
ok(config.filesystem.allowRead.includes(expectedWorkspaceStoragePath), 'Sandbox config should re-allow reads from workspace storage');
});

test('should only add command-specific allowRead paths for the current command keywords', async () => {
const sandboxService = store.add(instantiationService.createInstance(TerminalSandboxService));
const configPath = await sandboxService.getSandboxConfigPath();
Expand Down
Loading