@@ -70,9 +70,7 @@ suite('TerminalSandboxEngine', () => {
7070 const network = {
7171 defaultPolicy : policy . network ?. allowOutbound ? 'allow' : 'block' as 'allow' | 'block' ,
7272 ...( policy . network ?. allowLocalNetwork !== undefined ? { allowLocalNetwork : policy . network . allowLocalNetwork } : { } ) ,
73- ...( policy . network ?. allowedHosts ? { allowedHosts : policy . network . allowedHosts } : { } ) ,
74- ...( policy . network ?. blockedHosts ? { blockedHosts : policy . network . blockedHosts } : { } ) ,
75- ...( policy . network ? { enforcementMode : policy . network . allowedHosts ?. length || policy . network . blockedHosts ?. length ? 'both' as const : 'capabilities' as const } : { } ) ,
73+ ...( policy . network ? { enforcementMode : 'capabilities' as const } : { } ) ,
7674 } ;
7775 return {
7876 version : policy . version ,
@@ -88,7 +86,6 @@ suite('TerminalSandboxEngine', () => {
8886 timeout : policy . timeoutMs ?? 0 ,
8987 } ,
9088 processContainer : {
91- name : containerName ,
9289 leastPrivilege : false ,
9390 capabilities : policy . network ?. allowOutbound ? [ 'internetClient' ] : [ ] ,
9491 ui : {
@@ -527,10 +524,9 @@ suite('TerminalSandboxEngine', () => {
527524 strictEqual ( wrapped . isSandboxWrapped , true ) ;
528525 ok ( wrapped . command . startsWith ( `& 'C:\\app\\node_modules\\@microsoft\\mxc-sdk\\bin\\x64\\wxc-exec.exe'` ) , `Expected MXC executable. Actual: ${ wrapped . command } ` ) ;
529526 ok ( wrapped . command . includes ( ` '${ configPath } '` ) , `Expected wrapped command to pass the MXC config path. Actual: ${ wrapped . command } ` ) ;
530- strictEqual ( config . version , '0.4 .0-alpha' ) ;
527+ strictEqual ( config . version , '0.6 .0-alpha' ) ;
531528 strictEqual ( config . containment , 'process' ) ;
532- strictEqual ( config . processContainer . name , 'vscode-terminal-sandbox' ) ;
533- strictEqual ( config . process . commandLine , '"C:\\Program Files\\PowerShell\\7\\pwsh.exe" -NoProfile -ExecutionPolicy Bypass -Command "echo hello"' ) ;
529+ strictEqual ( config . process . commandLine , '"C:\\Program Files\\PowerShell\\7\\pwsh.exe" -NoProfile -Command "echo hello"' ) ;
534530 strictEqual ( normalizeWindowsPathForAssert ( config . process . cwd ) , 'c:/workspace' ) ;
535531 strictEqual ( config . ui . disable , false ) ;
536532 ok ( config . process . env . includes ( 'SystemRoot=C:\\Windows' ) , 'SystemRoot should be injected into the MXC process env' ) ;
@@ -579,6 +575,54 @@ suite('TerminalSandboxEngine', () => {
579575 ok ( ! config . filesystem . deniedPaths . some ( ( path : string ) => normalizeWindowsPathForAssert ( path ) === 'c:/users/user' ) , 'User home should not be denied by default on Windows' ) ;
580576 } ) ;
581577
578+ test ( 'deduplicates Windows filesystem paths regardless of case or separator' , async ( ) => {
579+ enableWindowsSandbox ( ) ;
580+ setSandboxSetting ( AgentSandboxSettingId . AgentSandboxWindowsFileSystem , {
581+ allowWrite : [ 'C:/configured/write' ] ,
582+ allowRead : [ 'C:\\configured\\read' ] ,
583+ denyRead : [ 'C:/configured/secret' , 'c:\\configured\\secret' ] ,
584+ } ) ;
585+ const host = createWindowsHost ( {
586+ getWindowsMxcFilesystemPolicy : ( ) => Promise . resolve ( {
587+ readwritePaths : [ 'c:\\configured\\write' ] ,
588+ readonlyPaths : [ 'c:/configured/read' ] ,
589+ } ) ,
590+ } ) ;
591+ const engine = store . add ( instantiationService . createInstance ( TerminalSandboxEngine , host ) ) ;
592+
593+ await engine . wrapCommand ( 'echo hello' , false , 'pwsh' ) ;
594+ const configPath = await engine . getSandboxConfigPath ( ) ;
595+ ok ( configPath , 'Config path should be defined' ) ;
596+ const config = JSON . parse ( createdFiles . get ( configPath ) ! ) ;
597+ const matchingPaths = ( paths : string [ ] , expectedPath : string ) => paths . filter ( path => normalizeWindowsPathForAssert ( path ) === expectedPath ) ;
598+
599+ deepStrictEqual ( {
600+ readwrite : matchingPaths ( config . filesystem . readwritePaths , 'c:/configured/write' ) ,
601+ readonly : matchingPaths ( config . filesystem . readonlyPaths , 'c:/configured/read' ) ,
602+ denied : matchingPaths ( config . filesystem . deniedPaths , 'c:/configured/secret' ) ,
603+ } , {
604+ readwrite : [ 'C:\\configured\\write' ] ,
605+ readonly : [ 'C:\\configured\\read' ] ,
606+ denied : [ 'C:\\configured\\secret' ] ,
607+ } ) ;
608+ } ) ;
609+
610+ test ( 'deduplicates resolved Windows paths regardless of case or separator' , async ( ) => {
611+ enableWindowsSandbox ( ) ;
612+ const engine = store . add ( instantiationService . createInstance ( TerminalSandboxEngine , createWindowsHost ( ) ) ) ;
613+ await engine . getOS ( ) ;
614+ const resolveFileSystemPaths = ( engine as unknown as { _resolveFileSystemPaths ( paths : string [ ] ) : Promise < string [ ] > } ) . _resolveFileSystemPaths . bind ( engine ) ;
615+
616+ deepStrictEqual ( await resolveFileSystemPaths ( [
617+ 'C:/configured/path' ,
618+ 'c:\\configured\\path' ,
619+ 'C:\\configured\\other-path' ,
620+ ] ) , [
621+ 'C:/configured/path' ,
622+ 'C:\\configured\\other-path' ,
623+ ] ) ;
624+ } ) ;
625+
582626 test ( 'wrapCommand applies configured Windows MXC schema version' , async ( ) => {
583627 enableWindowsSandbox ( ) ;
584628 setSandboxSetting ( AgentSandboxSettingId . AgentSandboxWindowsSchemaVersion , '0.5.0-alpha' ) ;
@@ -651,13 +695,13 @@ suite('TerminalSandboxEngine', () => {
651695 let configPath = await engine . getSandboxConfigPath ( ) ;
652696 ok ( configPath , 'Config path should be defined' ) ;
653697 const firstCommandLine = JSON . parse ( createdFiles . get ( configPath ) ! ) . process . commandLine ;
654- strictEqual ( firstCommandLine , '"C:\\Program Files\\PowerShell\\7\\pwsh.exe" -NoProfile -ExecutionPolicy Bypass - Command "echo first"' ) ;
698+ strictEqual ( firstCommandLine , '"C:\\Program Files\\PowerShell\\7\\pwsh.exe" -NoProfile -Command "echo first"' ) ;
655699
656700 await engine . wrapCommand ( 'echo second' , false , 'C:\\Program Files\\PowerShell\\7\\pwsh.exe' ) ;
657701 configPath = await engine . getSandboxConfigPath ( ) ;
658702 ok ( configPath , 'Config path should be defined' ) ;
659703 const secondCommandLine = JSON . parse ( createdFiles . get ( configPath ) ! ) . process . commandLine ;
660- strictEqual ( secondCommandLine , '"C:\\Program Files\\PowerShell\\7\\pwsh.exe" -NoProfile -ExecutionPolicy Bypass - Command "echo second"' ) ;
704+ strictEqual ( secondCommandLine , '"C:\\Program Files\\PowerShell\\7\\pwsh.exe" -NoProfile -Command "echo second"' ) ;
661705 } ) ;
662706
663707 test ( 'allowNetwork maps to MXC allow network config on Windows' , async ( ) => {
@@ -674,6 +718,21 @@ suite('TerminalSandboxEngine', () => {
674718 deepStrictEqual ( config . network , { defaultPolicy : 'allow' , enforcementMode : 'capabilities' } ) ;
675719 } ) ;
676720
721+ test ( 'Windows MXC config ignores unsupported network host lists' , async ( ) => {
722+ enableWindowsSandbox ( ) ;
723+ setSandboxSetting ( AgentNetworkDomainSettingId . AllowedNetworkDomains , [ 'example.com' ] ) ;
724+ setSandboxSetting ( AgentNetworkDomainSettingId . DeniedNetworkDomains , [ 'blocked.example.com' ] ) ;
725+ const host = createWindowsHost ( ) ;
726+ const engine = store . add ( instantiationService . createInstance ( TerminalSandboxEngine , host ) ) ;
727+
728+ await engine . wrapCommand ( 'curl https://example.com' , false , 'pwsh' ) ;
729+ const configPath = await engine . getSandboxConfigPath ( ) ;
730+ ok ( configPath , 'Config path should be defined' ) ;
731+ const config = JSON . parse ( createdFiles . get ( configPath ) ! ) ;
732+
733+ deepStrictEqual ( config . network , { defaultPolicy : 'allow' , enforcementMode : 'capabilities' } ) ;
734+ } ) ;
735+
677736 test ( 'uses OS-specific filesystem absolute path detection' , async ( ) => {
678737 const linuxEngine = store . add ( instantiationService . createInstance ( TerminalSandboxEngine , createHost ( ) ) ) ;
679738 await linuxEngine . getOS ( ) ;
0 commit comments