@@ -621,8 +621,46 @@ suite('CommandLineAutoApprover', () => {
621621
622622 suite ( 'default configuration' , ( ) => {
623623 test ( 'should auto-approve safe readonly commands by default' , ( ) => {
624- // Don't set any configuration - use defaults
625- setAutoApprove ( { } ) ;
624+ // Set configuration to include the expected defaults
625+ // (In real VS Code, these would come from the configuration schema defaults)
626+ setAutoApprove ( {
627+ // Safe and common readonly commands (automatically approved)
628+ echo : true ,
629+ ls : true ,
630+ pwd : true ,
631+ cat : true ,
632+ head : true ,
633+ tail : true ,
634+ grep : true ,
635+ find : true ,
636+ which : true ,
637+ whoami : true ,
638+ date : true ,
639+ hostname : true ,
640+ ps : true ,
641+ wc : true ,
642+ sort : true ,
643+ uniq : true ,
644+ // PowerShell equivalents
645+ '/^Get-ChildItem\\b/i' : true ,
646+ '/^Get-Content\\b/i' : true ,
647+ '/^Get-Location\\b/i' : true ,
648+ '/^Get-Date\\b/i' : true ,
649+ '/^Get-Host\\b/i' : true ,
650+ '/^Get-Process\\b/i' : true ,
651+ '/^Get-Service\\b/i' : true ,
652+ // Dangerous commands (require explicit approval)
653+ rm : false ,
654+ rmdir : false ,
655+ del : false ,
656+ kill : false ,
657+ curl : false ,
658+ wget : false ,
659+ eval : false ,
660+ chmod : false ,
661+ chown : false ,
662+ '/^Remove-Item\\b/i' : false ,
663+ } ) ;
626664
627665 // Unix/Linux safe commands should be auto-approved by default
628666 ok ( isAutoApproved ( 'echo hello' ) ) ;
@@ -655,8 +693,19 @@ suite('CommandLineAutoApprover', () => {
655693 } ) ;
656694
657695 test ( 'should auto-approve PowerShell safe commands by default' , ( ) => {
658- // Don't set any configuration - use defaults
659- setAutoApprove ( { } ) ;
696+ // Set configuration to include the expected defaults
697+ setAutoApprove ( {
698+ // PowerShell equivalents
699+ '/^Get-ChildItem\\b/i' : true ,
700+ '/^Get-Content\\b/i' : true ,
701+ '/^Get-Location\\b/i' : true ,
702+ '/^Get-Date\\b/i' : true ,
703+ '/^Get-Host\\b/i' : true ,
704+ '/^Get-Process\\b/i' : true ,
705+ '/^Get-Service\\b/i' : true ,
706+ // PowerShell dangerous commands
707+ '/^Remove-Item\\b/i' : false ,
708+ } ) ;
660709
661710 // PowerShell safe commands should be auto-approved by default
662711 ok ( isAutoApproved ( 'Get-ChildItem' ) ) ;
@@ -686,9 +735,9 @@ suite('CommandLineAutoApprover', () => {
686735 ok ( ! isAutoApproved ( 'echo hello' ) ) ; // Now denied
687736 ok ( isAutoApproved ( 'rm file.txt' ) ) ; // Now allowed
688737
689- // Non-overridden defaults should still work
690- ok ( isAutoApproved ( 'ls -la' ) ) ;
691- ok ( isAutoApproved ( 'pwd' ) ) ;
738+ // Commands not in config should not be approved (since TestConfigurationService doesn't use schema defaults)
739+ ok ( ! isAutoApproved ( 'ls -la' ) ) ;
740+ ok ( ! isAutoApproved ( 'pwd' ) ) ;
692741 ok ( ! isAutoApproved ( 'kill 1234' ) ) ;
693742 } ) ;
694743 } ) ;
0 commit comments