Files
pmg/sandbox/platform/bubblewrap_render_linux.go
Abhisek DattaandGitHub b8588e3df4 feat: Add Sandbox Inspection and Debugging Commands (#261)
* feat: add sandbox DX commands

* fix: Linter errors

* fix: Sandbox deny log parsing

* fix: Sandbox docs

* refactor: Maintain SSOT across pkg dependencies

* fix: Linter errors
2026-05-19 14:40:54 +05:30

36 lines
1.0 KiB
Go

//go:build linux
// +build linux
package platform
import (
"fmt"
"strings"
"github.com/safedep/pmg/sandbox"
)
// RenderBubblewrap translates a SandboxPolicy into the bwrap argv that the
// Bubblewrap driver would invoke at runtime, encoded as one argument per
// line. One-arg-per-line is chosen over shell-quoted joining because bwrap
// arguments routinely contain absolute paths and option flags that would
// require non-trivial shell quoting; the per-line form is unambiguous and
// trivially round-trippable.
//
// This is a thin wrapper over the internal bubblewrap translator and is
// intended for inspection use cases such as
// `pmg setup sandbox profile show --driver=bwrap`.
func RenderBubblewrap(policy *sandbox.SandboxPolicy) ([]byte, error) {
if policy == nil {
return nil, fmt.Errorf("policy is nil")
}
t := newBubblewrapPolicyTranslator(newDefaultBubblewrapConfig())
args, err := t.translate(policy)
if err != nil {
return nil, err
}
return []byte(strings.Join(args, "\n") + "\n"), nil
}