diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-29 19:33:17 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-29 19:33:17 +0900 |
| commit | 8b62e08b44d255fcb15e94bd2ed721f34c65a726 (patch) | |
| tree | f46d60837818f678bfa1ca6934f7ccb60c2b2bf5 /test/main.go | |
| parent | 72c59f92298cf6ec872bb0c93e44bea4efd72aec (diff) | |
test: build test program in nixos config
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'test/main.go')
| -rw-r--r-- | test/main.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/main.go b/test/main.go new file mode 100644 index 00000000..4c639b28 --- /dev/null +++ b/test/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "log" + "os" + "strconv" + "strings" + + "git.gensokyo.uk/security/fortify/test/sandbox" +) + +func main() { + log.SetFlags(0) + log.SetPrefix("test: ") + + if len(os.Args) < 2 { + log.Fatal("invalid argument") + } + + switch os.Args[1] { + case "filter": + if len(os.Args) != 4 { + log.Fatal("invalid argument") + } + + if pid, err := strconv.Atoi(strings.TrimSpace(os.Args[2])); err != nil { + log.Fatalf("%s", err) + } else if pid < 1 { + log.Fatalf("%d out of range", pid) + } else { + sandbox.MustCheckFilter(pid, os.Args[3]) + return + } + + default: + (&sandbox.T{FS: os.DirFS("/")}).MustCheckFile(os.Args[1], "/tmp/sandbox-ok") + return + } +} |
