Skip to content

Commit 9211ecc

Browse files
authored
Merge branch 'main' into security/langchain-scope-chain-verification-538
2 parents 5456388 + 3736f74 commit 9211ecc

File tree

9 files changed

+4194
-374
lines changed

9 files changed

+4194
-374
lines changed

packages/agent-os/extensions/vscode/package-lock.json

Lines changed: 4120 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/agent-os/extensions/vscode/src/enterprise/auth/ssoProvider.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class EnterpriseAuthProvider {
5050
this._registerProviders();
5151
}
5252

53-
private _loadState(): void {
53+
private async _loadState(): Promise<void> {
5454
const savedState = this._context.globalState.get<AuthState>('agent-os.authState');
5555
if (savedState) {
5656
this._state = savedState;
@@ -59,6 +59,13 @@ export class EnterpriseAuthProvider {
5959
this._state = { isAuthenticated: false };
6060
}
6161
}
62+
// Restore token from SecretStorage
63+
if (this._state?.user) {
64+
const token = await this._context.secrets.get('agent-os.authToken');
65+
if (token) {
66+
this._state.user.token = token;
67+
}
68+
}
6269
}
6370

6471
private _registerProviders(): void {
@@ -185,7 +192,16 @@ export class EnterpriseAuthProvider {
185192
}
186193

187194
private async _saveState(): Promise<void> {
188-
await this._context.globalState.update('agent-os.authState', this._state);
195+
// Store token in SecretStorage, not globalState
196+
if (this._state?.user?.token) {
197+
await this._context.secrets.store('agent-os.authToken', this._state.user.token);
198+
}
199+
// Strip token from globalState persistence
200+
const safeState = this._state ? {
201+
...this._state,
202+
user: this._state.user ? { ...this._state.user, token: undefined } : undefined,
203+
} : null;
204+
await this._context.globalState.update('agent-os.authState', safeState);
189205
}
190206

191207
hasRole(role: string): boolean {

packages/agent-os/extensions/vscode/src/extension.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
import * as vscode from 'vscode';
13+
import * as crypto from 'crypto';
1314
import { PolicyEngine } from './policyEngine';
1415
import { CMVKClient } from './cmvkClient';
1516
import { AuditLogger } from './auditLogger';
@@ -481,7 +482,7 @@ async function reviewCodeWithCMVK(code: string, language: string): Promise<void>
481482
{ enableScripts: true }
482483
);
483484

484-
panel.webview.html = generateCMVKResultsHTML(result);
485+
panel.webview.html = generateCMVKResultsHTML(result, panel.webview);
485486

486487
// Log the review
487488
auditLogger.log({
@@ -501,7 +502,9 @@ async function reviewCodeWithCMVK(code: string, language: string): Promise<void>
501502
});
502503
}
503504

504-
function generateCMVKResultsHTML(result: any): string {
505+
function generateCMVKResultsHTML(result: any, webview: vscode.Webview): string {
506+
const nonce = crypto.randomBytes(16).toString('base64');
507+
const cspSource = webview.cspSource;
505508
const consensusColor = result.consensus >= 0.8 ? '#28a745'
506509
: result.consensus >= 0.5 ? '#ffc107'
507510
: '#dc3545';
@@ -522,6 +525,8 @@ function generateCMVKResultsHTML(result: any): string {
522525
<!DOCTYPE html>
523526
<html>
524527
<head>
528+
<meta charset="UTF-8">
529+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${cspSource} 'unsafe-inline'; script-src 'nonce-${nonce}'; img-src ${cspSource} https:; font-src ${cspSource};">
525530
<style>
526531
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; padding: 20px; }
527532
.consensus { font-size: 24px; font-weight: bold; color: ${consensusColor}; }

0 commit comments

Comments
 (0)