@@ -157,22 +157,32 @@ describe("withRunnerSeccompProfile", () => {
157157
158158describe ( "runnerSecurityContext" , ( ) => {
159159 it ( "sets nothing when off" , ( ) => {
160- expect ( runnerSecurityContext ( "off" , 1000 ) ) . toBeUndefined ( ) ;
160+ expect ( runnerSecurityContext ( "off" , 1000 , "node-24" ) ) . toBeUndefined ( ) ;
161161 } ) ;
162162
163163 it ( "drops all capabilities and blocks escalation at baseline" , ( ) => {
164- expect ( runnerSecurityContext ( "baseline" , 1000 ) ) . toEqual ( {
164+ expect ( runnerSecurityContext ( "baseline" , 1000 , "node-24" ) ) . toEqual ( {
165165 allowPrivilegeEscalation : false ,
166166 capabilities : { drop : [ "ALL" ] } ,
167167 } ) ;
168168 } ) ;
169169
170- it ( "additionally requires a non-root image when restricted" , ( ) => {
171- expect ( runnerSecurityContext ( "restricted" , 1000 ) ) . toEqual ( {
170+ it ( "pins the configured uid when restricted" , ( ) => {
171+ expect ( runnerSecurityContext ( "restricted" , 1000 , "node-24" ) ) . toEqual ( {
172172 allowPrivilegeEscalation : false ,
173173 capabilities : { drop : [ "ALL" ] } ,
174174 runAsNonRoot : true ,
175175 runAsUser : 1000 ,
176176 } ) ;
177177 } ) ;
178+
179+ it ( "pins bun's own uid, which differs from node's" , ( ) => {
180+ expect ( runnerSecurityContext ( "restricted" , 1000 , "bun" ) ?. runAsUser ) . toBe ( 1001 ) ;
181+ } ) ;
182+
183+ it ( "falls back to the configured uid when the runtime is unknown" , ( ) => {
184+ for ( const runtime of [ undefined , null , "" , "node" , "node-22" , "node-26" ] ) {
185+ expect ( runnerSecurityContext ( "restricted" , 1000 , runtime ) ?. runAsUser ) . toBe ( 1000 ) ;
186+ }
187+ } ) ;
178188} ) ;
0 commit comments