aboutsummaryrefslogtreecommitdiffhomepage
path: root/sandbox/vfs/mangle_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-20 19:04:10 +0900
committerOphestra <cat@gensokyo.uk>2025-03-21 00:35:49 +0900
commit9ddf5794dd6eb5222fc1cccceb7d27c7cbd9c785 (patch)
tree261224f8438bbf3149a3b6cc0b1d155834085292 /sandbox/vfs/mangle_test.go
parentb74a08dda968a161e066c92c1bf5b4489e5a4fbd (diff)
sandbox/vfs: implement proc_pid_mountinfo(5) parser
Test cases are mostly taken from util-linux. This implementation is more correct and slightly faster than the one found in github:kubernetes/utils. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'sandbox/vfs/mangle_test.go')
-rw-r--r--sandbox/vfs/mangle_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/sandbox/vfs/mangle_test.go b/sandbox/vfs/mangle_test.go
new file mode 100644
index 00000000..eccf51d7
--- /dev/null
+++ b/sandbox/vfs/mangle_test.go
@@ -0,0 +1,27 @@
+package vfs_test
+
+import (
+ "testing"
+
+ "git.gensokyo.uk/security/fortify/sandbox/vfs"
+)
+
+func TestUnmangle(t *testing.T) {
+ testCases := []struct {
+ want string
+ sample string
+ }{
+ {`\, `, `\134\054\040`},
+ {`(10) source -- maybe empty string`, `(10)\040source\040--\040maybe empty string`},
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.want, func(t *testing.T) {
+ got := vfs.Unmangle(tc.sample)
+ if got != tc.want {
+ t.Errorf("Unmangle: %q, want %q",
+ got, tc.want)
+ }
+ })
+ }
+}