mirror of
https://github.com/siderolabs/talos.git
synced 2025-12-08 19:11:54 +01:00
feat: relax extensions file structure validation
* allow empty directories (I see no harm in having them) * allow symlinks See also https://github.com/talos-systems/extensions/pull/20 Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
parent
50594ab1a7
commit
cd4d4c6054
@ -76,10 +76,6 @@ func TestValidateFailures(t *testing.T) {
|
|||||||
name: "norootfs",
|
name: "norootfs",
|
||||||
loadError: "extension rootfs is missing",
|
loadError: "extension rootfs is missing",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "symlinks",
|
|
||||||
validateError: "symlinks are not allowed: \"/usr/local/b\"",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "badpaths",
|
name: "badpaths",
|
||||||
validateError: "path \"/boot/vmlinuz\" is not allowed in extensions",
|
validateError: "path \"/boot/vmlinuz\" is not allowed in extensions",
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
version: v1alpha1
|
|
||||||
metadata:
|
|
||||||
name: gvisor
|
|
||||||
version: 20220117.0-v1.0.0
|
|
||||||
author: Andrew Rynhard
|
|
||||||
description: >
|
|
||||||
This system extension provides gVisor using containerd's runtime handler.
|
|
||||||
compatibility:
|
|
||||||
talos:
|
|
||||||
version: ">= v1.0.0"
|
|
||||||
@ -1 +0,0 @@
|
|||||||
a
|
|
||||||
1
internal/pkg/extensions/testdata/good/extension1/rootfs/usr/local/lib/a.so.1
vendored
Symbolic link
1
internal/pkg/extensions/testdata/good/extension1/rootfs/usr/local/lib/a.so.1
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
a.so
|
||||||
@ -70,11 +70,6 @@ func (ext *Extension) validateContents() error {
|
|||||||
return fmt.Errorf("world-writeable files are not allowed: %q", itemPath)
|
return fmt.Errorf("world-writeable files are not allowed: %q", itemPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// no symlinks
|
|
||||||
if d.Type().Type() == os.ModeSymlink {
|
|
||||||
return fmt.Errorf("symlinks are not allowed: %q", itemPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
var st fs.FileInfo
|
var st fs.FileInfo
|
||||||
|
|
||||||
st, err = d.Info()
|
st, err = d.Info()
|
||||||
@ -88,24 +83,10 @@ func (ext *Extension) validateContents() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// no special files
|
// no special files
|
||||||
if !d.IsDir() && !d.Type().IsRegular() {
|
if !d.IsDir() && !d.Type().IsRegular() && d.Type().Type() != os.ModeSymlink {
|
||||||
return fmt.Errorf("special files are not allowed: %q", itemPath)
|
return fmt.Errorf("special files are not allowed: %q", itemPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// directories should be non-empty
|
|
||||||
if d.IsDir() {
|
|
||||||
var contents []fs.DirEntry
|
|
||||||
|
|
||||||
contents, err = os.ReadDir(path)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(contents) == 0 {
|
|
||||||
return fmt.Errorf("empty directories are not allowed: %q", itemPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// regular file: check for file path being whitelisted
|
// regular file: check for file path being whitelisted
|
||||||
if !d.IsDir() {
|
if !d.IsDir() {
|
||||||
dirPath := filepath.Dir(itemPath)
|
dirPath := filepath.Dir(itemPath)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user