File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,12 @@ func validateVolume(src *v1.GitRepoVolumeSource) error {
261
261
if err := validateNonFlagArgument (src .Directory , "directory" ); err != nil {
262
262
return err
263
263
}
264
+ if (src .Revision != "" ) && (src .Directory != "" ) {
265
+ cleanedDir := filepath .Clean (src .Directory )
266
+ if strings .Contains (cleanedDir , "/" ) || (strings .Contains (cleanedDir , "\\ " )) {
267
+ return fmt .Errorf ("%q is not a valid directory, it must not contain a directory separator" , src .Directory )
268
+ }
269
+ }
264
270
return nil
265
271
}
266
272
Original file line number Diff line number Diff line change @@ -267,6 +267,20 @@ func TestPlugin(t *testing.T) {
267
267
},
268
268
isExpectedFailure : true ,
269
269
},
270
+ {
271
+ name : "invalid-revision-directory-combo" ,
272
+ vol : & v1.Volume {
273
+ Name : "vol1" ,
274
+ VolumeSource : v1.VolumeSource {
275
+ GitRepo : & v1.GitRepoVolumeSource {
276
+ Repository : gitURL ,
277
+ Revision : "main" ,
278
+ Directory : "foo/bar" ,
279
+ },
280
+ },
281
+ },
282
+ isExpectedFailure : true ,
283
+ },
270
284
}
271
285
272
286
for _ , scenario := range scenarios {
You can’t perform that action at this time.
0 commit comments