@@ -84,6 +84,29 @@ const commandRegistry = {
8484 type : "text" ,
8585 } ,
8686 } ,
87+ setContent : {
88+ command : "Set-Content {{{arguments}}}" ,
89+ arguments : {
90+ 'Path' : { } ,
91+ 'Value' : { } ,
92+ 'Filter' : { } ,
93+ } ,
94+ } ,
95+ getContent : {
96+ command : "Get-Content {{{arguments}}}" ,
97+ arguments : {
98+ 'Path' : { } ,
99+ } ,
100+ return : {
101+ type : "text" ,
102+ } ,
103+ } ,
104+ removeItem : {
105+ command : "Remove-Item {{{arguments}}}" ,
106+ arguments : {
107+ 'Path' : { } ,
108+ } ,
109+ } ,
87110} ;
88111
89112
@@ -580,4 +603,53 @@ describe("test PSCommandService w/ o365CommandRegistry", function () {
580603 throw e ;
581604 }
582605 } ) ;
606+ it ( "Should test value bleeding" , async function ( ) {
607+ this . timeout ( 10000 ) ;
608+ const statefulProcessCommandProxy = new StatefulProcessCommandProxy ( {
609+ name : "Powershell pool" ,
610+ max : 1 ,
611+ min : 1 ,
612+ idleTimeoutMS : 30000 ,
613+
614+ logFunction : logFunction ,
615+ processCommand : "pwsh" ,
616+ processArgs : [ "-Command" , "-" ] ,
617+ processRetainMaxCmdHistory : 30 ,
618+ processCwd : null ,
619+ processEnvMap : null ,
620+ processUid : null ,
621+ processGid : null ,
622+ initCommands : initCommands ,
623+ validateFunction : ( processProxy ) => processProxy . isValid ( ) ,
624+ } ) ;
625+
626+ const psCommandService = new PSCommandService (
627+ statefulProcessCommandProxy ,
628+ commandRegistry ,
629+ myLogFunction
630+ ) ;
631+ try {
632+ const newResult = await psCommandService . execute ( "setContent" , {
633+ Path : "./test.txt" ,
634+ Value : "Test" ,
635+ Filter : ""
636+ } ) ;
637+ assert . equal ( newResult . command . trim ( ) , "Set-Content -Path './test.txt' -Value 'Test'" ) ;
638+ assert . equal ( newResult . stderr , "" ) ;
639+ const getResult = await psCommandService . execute ( "getContent" , {
640+ Path : "./test.txt" ,
641+ } ) ;
642+ assert . equal ( getResult . stderr , "" ) ;
643+ assert . equal ( getResult . stdout , "Test" ) ;
644+ } catch ( e ) {
645+ assert . fail ( e ) ;
646+ } finally {
647+ await psCommandService . execute ( "removeItem" , {
648+ Path : "./test.txt" ,
649+ } ) ;
650+ setTimeout ( ( ) => {
651+ statefulProcessCommandProxy . shutdown ( ) ;
652+ } , 5000 ) ;
653+ }
654+ } ) ;
583655} ) ;
0 commit comments