aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/bwrap/config_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-02-14 18:13:06 +0900
committerOphestra <cat@gensokyo.uk>2025-02-14 18:13:06 +0900
commitace97952ccd08afe74737659794f43233d28596e (patch)
tree58fd7ec1671d08af44145cba73fae15d83dbb350 /helper/bwrap/config_test.go
parent73146ea7fa9ace10e14d2ba693e3cddda64183c8 (diff)
helper/bwrap: merge Args and FDArgs
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'helper/bwrap/config_test.go')
-rw-r--r--helper/bwrap/config_test.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/helper/bwrap/config_test.go b/helper/bwrap/config_test.go
index 7cf1b791..64d783cf 100644
--- a/helper/bwrap/config_test.go
+++ b/helper/bwrap/config_test.go
@@ -6,9 +6,15 @@ import (
"testing"
"git.gensokyo.uk/security/fortify/helper/bwrap"
+ "git.gensokyo.uk/security/fortify/helper/proc"
+ "git.gensokyo.uk/security/fortify/helper/seccomp"
+ "git.gensokyo.uk/security/fortify/internal/fmsg"
)
func TestConfig_Args(t *testing.T) {
+ seccomp.CPrintln = fmsg.Println
+ t.Cleanup(func() { seccomp.CPrintln = nil })
+
testCases := []struct {
name string
conf *bwrap.Config
@@ -137,13 +143,14 @@ func TestConfig_Args(t *testing.T) {
},
},
{
- name: "hostname chdir setenv unsetenv lockfile chmod",
+ name: "hostname chdir setenv unsetenv lockfile chmod syscall",
conf: &bwrap.Config{
Hostname: "fortify",
Chdir: "/.fortify",
SetEnv: map[string]string{"FORTIFY_INIT": "/.fortify/sbin/init"},
UnsetEnv: []string{"HOME", "HOST"},
LockFile: []string{"/.fortify/lock"},
+ Syscall: new(bwrap.SyscallPolicy),
Chmod: map[string]os.FileMode{"/.fortify/sbin/init": 0755},
},
want: []string{
@@ -160,6 +167,8 @@ func TestConfig_Args(t *testing.T) {
"--lock-file", "/.fortify/lock",
// SetEnv: map[string]string{"FORTIFY_INIT": "/.fortify/sbin/init"}
"--setenv", "FORTIFY_INIT", "/.fortify/sbin/init",
+ // Syscall: new(bwrap.SyscallPolicy),
+ "--seccomp", "3",
// Chmod: map[string]os.FileMode{"/.fortify/sbin/init": 0755}
"--chmod", "755", "/.fortify/sbin/init",
},
@@ -167,12 +176,7 @@ func TestConfig_Args(t *testing.T) {
{
name: "xdg-dbus-proxy constraint sample",
- conf: (&bwrap.Config{
- Unshare: nil,
- UserNS: false,
- Clearenv: true,
- DieWithParent: true,
- }).
+ conf: (&bwrap.Config{Clearenv: true, DieWithParent: true}).
Symlink("usr/bin", "/bin").
Symlink("var/home", "/home").
Symlink("usr/lib", "/lib").
@@ -227,7 +231,7 @@ func TestConfig_Args(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
- if got := tc.conf.Args(); !slices.Equal(got, tc.want) {
+ if got := tc.conf.Args(nil, new(proc.ExtraFilesPre), new([]proc.File)); !slices.Equal(got, tc.want) {
t.Errorf("Args() = %#v, want %#v", got, tc.want)
}
})