mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
feat: Add support for Linux Sandbox using Bubblewrap (#120)
* feat: Add support for bubblewrap sandbox * fix: Glob pattern expansion limit for linux * fix: Bug in glob pattern expansion for bwrap * fix: README on trust * fix: Multiple bubblewrap translator fix * test: Add E2E for linux sandbox * fix: Refactor bwrap sandbox to use common dangerous files * fix: Path test case * fix: Non-existent path handling bug * refactor: Misc cleanup * fix: Avoid bind mount for non-existentent deny protection * fix: Off by one bug in path depth handling * ci: Disable AppArmor on GHA runner * fix: Disable apparmor userns restrictions
This commit is contained in:
@@ -56,7 +56,12 @@ func ApplySandbox(ctx context.Context, cmd *exec.Cmd, pmName string, opts ...app
|
||||
|
||||
policy, err = registry.GetProfile(cfg.SandboxProfileOverride)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load override sandbox policy %s: %w", cfg.SandboxProfileOverride, err)
|
||||
return nil, usefulerror.Useful().
|
||||
WithCode("sandbox_policy_load_failed").
|
||||
WithHumanError(fmt.Sprintf("failed to load override sandbox policy %s: %s", cfg.SandboxProfileOverride, err)).
|
||||
WithHelp("Please check the sandbox profile path and try again.").
|
||||
WithAdditionalHelp("See more at: https://github.com/safedep/pmg/blob/main/docs/sandbox.md").
|
||||
Wrap(fmt.Errorf("failed to load override sandbox policy %s: %w", cfg.SandboxProfileOverride, err))
|
||||
}
|
||||
} else {
|
||||
log.Debugf("Looking up sandbox policy for %s", pmName)
|
||||
@@ -68,6 +73,7 @@ func ApplySandbox(ctx context.Context, cmd *exec.Cmd, pmName string, opts ...app
|
||||
policyRef, exists := cfg.Config.Sandbox.Policies[pmName]
|
||||
if !exists {
|
||||
return nil, usefulerror.Useful().
|
||||
WithCode("sandbox_policy_not_configured").
|
||||
WithHumanError(fmt.Sprintf("no sandbox policy configured for %s", pmName)).
|
||||
WithHelp("Please configure a sandbox policy for this package manager in the config file.").
|
||||
WithAdditionalHelp("See https://github.com/safedep/pmg/blob/main/docs/sandbox.md for more information.").
|
||||
@@ -123,7 +129,12 @@ func ApplySandbox(ctx context.Context, cmd *exec.Cmd, pmName string, opts ...app
|
||||
}
|
||||
|
||||
if !sb.IsAvailable() {
|
||||
return nil, fmt.Errorf("sandbox %s is required but not available", sb.Name())
|
||||
return nil, usefulerror.Useful().
|
||||
WithCode("sandbox_not_available").
|
||||
WithHumanError(fmt.Sprintf("sandbox %s is required but not available", sb.Name())).
|
||||
WithHelp("Please install the sandbox provider and try again.").
|
||||
WithAdditionalHelp("See more at: https://github.com/safedep/pmg/blob/main/docs/sandbox.md").
|
||||
Wrap(fmt.Errorf("sandbox %s is required but not available", sb.Name()))
|
||||
}
|
||||
|
||||
log.Debugf("Running %s in %s sandbox with policy %s", pmName, sb.Name(), policy.Name)
|
||||
|
||||
Reference in New Issue
Block a user