@@ -812,6 +812,7 @@ describe("buildQaRuntimeEnv", () => {
812812 OPENCLAW_QA_TELEGRAM_GROUP_ID : "-1001234567890" ,
813813 OPENCLAW_QA_TELEGRAM_DRIVER_BOT_TOKEN : "driver-token" ,
814814 OPENCLAW_QA_TELEGRAM_SUT_BOT_TOKEN : "sut-token" ,
815+ "BASH_FUNC_sudo%%" : "() { printf imported; }" ,
815816 } ,
816817 } ) ;
817818
@@ -823,13 +824,15 @@ describe("buildQaRuntimeEnv", () => {
823824 expect ( env . OPENCLAW_QA_TELEGRAM_GROUP_ID ) . toBeUndefined ( ) ;
824825 expect ( env . OPENCLAW_QA_TELEGRAM_DRIVER_BOT_TOKEN ) . toBeUndefined ( ) ;
825826 expect ( env . OPENCLAW_QA_TELEGRAM_SUT_BOT_TOKEN ) . toBeUndefined ( ) ;
827+ expect ( env [ "BASH_FUNC_sudo%%" ] ) . toBeUndefined ( ) ;
826828 } ) ;
827829
828830 it . runIf ( process . platform === "linux" ) (
829831 "scrubs inherited shell startup env before the workflow allowlist runs" ,
830832 async ( ) => {
831833 const tempRoot = await tempDirs . makeTempDir ( "qa-shell-startup-env-" ) ;
832834 const markerPath = path . join ( tempRoot , "bash-env-ran" ) ;
835+ const functionMarkerPath = path . join ( tempRoot , "bash-function-ran" ) ;
833836 const bashEnvPath = path . join ( tempRoot , "malicious-bash-env" ) ;
834837 const allowlistProbePath = path . join ( tempRoot , "allowlist-probe.sh" ) ;
835838 await writeFile ( bashEnvPath , `printf 'ran' > ${ JSON . stringify ( markerPath ) } \n` , "utf8" ) ;
@@ -858,12 +861,14 @@ describe("buildQaRuntimeEnv", () => {
858861 BASHOPTS : "checkwinsize" ,
859862 ENV : bashEnvPath ,
860863 SHELLOPTS : "braceexpand" ,
864+ "BASH_FUNC_compgen%%" : `() { printf 'ran' > ${ JSON . stringify ( functionMarkerPath ) } ; builtin compgen "$@"; }` ,
861865 } ,
862866 } ) ;
863867
864868 for ( const key of [ "BASH_ENV" , "BASHOPTS" , "ENV" , "SHELLOPTS" ] ) {
865869 expect ( env [ key ] ) . toBeUndefined ( ) ;
866870 }
871+ expect ( env [ "BASH_FUNC_compgen%%" ] ) . toBeUndefined ( ) ;
867872
868873 const result = spawnSync ( "/bin/bash" , [ "--noprofile" , "--norc" , allowlistProbePath ] , {
869874 encoding : "utf8" ,
@@ -873,6 +878,7 @@ describe("buildQaRuntimeEnv", () => {
873878 expect ( result . status , result . stderr ) . toBe ( 0 ) ;
874879 expect ( result . stdout ) . toBe ( "allowlist-survived" ) ;
875880 await expect ( readFile ( markerPath , "utf8" ) ) . rejects . toMatchObject ( { code : "ENOENT" } ) ;
881+ await expect ( readFile ( functionMarkerPath , "utf8" ) ) . rejects . toMatchObject ( { code : "ENOENT" } ) ;
876882 } ,
877883 ) ;
878884
0 commit comments