From 9ddf5794dd6eb5222fc1cccceb7d27c7cbd9c785 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 20 Mar 2025 19:04:10 +0900 Subject: 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 --- sandbox/vfs/mangle_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sandbox/vfs/mangle_test.go (limited to 'sandbox/vfs/mangle_test.go') 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) + } + }) + } +} -- cgit v1.3.1