From 5853d7700ff606974fd801f143e7b9d55f3fc253 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 7 Jul 2025 14:41:47 +0900 Subject: container/seccomp: move bpf hashes Filter programs are different across platforms. This representation is also much more readable. Signed-off-by: Ophestra --- container/seccomp/hash_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 container/seccomp/hash_test.go (limited to 'container/seccomp/hash_test.go') diff --git a/container/seccomp/hash_test.go b/container/seccomp/hash_test.go new file mode 100644 index 00000000..1d31ac0f --- /dev/null +++ b/container/seccomp/hash_test.go @@ -0,0 +1,28 @@ +package seccomp_test + +import ( + "encoding/hex" + + "hakurei.app/container/seccomp" +) + +type ( + bpfPreset = struct { + seccomp.ExportFlag + seccomp.FilterPreset + } + bpfLookup map[bpfPreset][]byte +) + +func toHash(s string) []byte { + if len(s) != 128 { + panic("bad sha512 string length") + } + if v, err := hex.DecodeString(s); err != nil { + panic(err.Error()) + } else if len(v) != 64 { + panic("unreachable") + } else { + return v + } +} -- cgit v1.3.1