mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
gitRepo volume: directory must be max 1 level deep
More details on Hackerone #2266560
This commit is contained in:
parent
8a9031f9c9
commit
c7846fd24c
@ -261,6 +261,12 @@ func validateVolume(src *v1.GitRepoVolumeSource) error {
|
||||
if err := validateNonFlagArgument(src.Directory, "directory"); err != nil {
|
||||
return err
|
||||
}
|
||||
if (src.Revision != "") && (src.Directory != "") {
|
||||
cleanedDir := filepath.Clean(src.Directory)
|
||||
if strings.Contains(cleanedDir, "/") || (strings.Contains(cleanedDir, "\\")) {
|
||||
return fmt.Errorf("%q is not a valid directory, it must not contain a directory separator", src.Directory)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -267,6 +267,20 @@ func TestPlugin(t *testing.T) {
|
||||
},
|
||||
isExpectedFailure: true,
|
||||
},
|
||||
{
|
||||
name: "invalid-revision-directory-combo",
|
||||
vol: &v1.Volume{
|
||||
Name: "vol1",
|
||||
VolumeSource: v1.VolumeSource{
|
||||
GitRepo: &v1.GitRepoVolumeSource{
|
||||
Repository: gitURL,
|
||||
Revision: "main",
|
||||
Directory: "foo/bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
isExpectedFailure: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, scenario := range scenarios {
|
||||
|
Loading…
Reference in New Issue
Block a user