mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
* client: sandbox go-getter subprocess with landlock This PR re-implements the getter package for artifact downloads as a subprocess. Key changes include On all platforms, run getter as a child process of the Nomad agent. On Linux platforms running as root, run the child process as the nobody user. On supporting Linux kernels, uses landlock for filesystem isolation (via go-landlock). On all platforms, restrict environment variables of the child process to a static set. notably TMP/TEMP now points within the allocation's task directory kernel.landlock attribute is fingerprinted (version number or unavailable) These changes make Nomad client more resilient against a faulty go-getter implementation that may panic, and more secure against bad actors attempting to use artifact downloads as a privilege escalation vector. Adds new e2e/artifact suite for ensuring artifact downloading works. TODO: Windows git test (need to modify the image, etc... followup PR) * landlock: fixup items from cr * cr: fixup tests and go.mod file
38 lines
774 B
Go
38 lines
774 B
Go
//go:build windows
|
|
|
|
package getter
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"syscall"
|
|
)
|
|
|
|
// attributes returns the system process attributes to run
|
|
// the sandbox process with
|
|
func attributes() *syscall.SysProcAttr {
|
|
return &syscall.SysProcAttr{}
|
|
}
|
|
|
|
func credentials() (uint32, uint32) {
|
|
return 0, 0
|
|
}
|
|
|
|
// lockdown has no effect on windows
|
|
func lockdown(string) error {
|
|
return nil
|
|
}
|
|
|
|
func minimalVars(taskDir string) []string {
|
|
tmpDir := filepath.Join(taskDir, "tmp")
|
|
return []string{
|
|
fmt.Sprintf("HOMEPATH=%s", os.Getenv("HOMEPATH")),
|
|
fmt.Sprintf("HOMEDRIVE=%s", os.Getenv("HOMEDRIVE")),
|
|
fmt.Sprintf("USERPROFILE=%s", os.Getenv("USERPROFILE")),
|
|
fmt.Sprintf("PATH=%s", os.Getenv("PATH")),
|
|
fmt.Sprintf("TMP=%s", tmpDir),
|
|
fmt.Sprintf("TEMP=%s", tmpDir),
|
|
}
|
|
}
|