diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-07-07 14:41:47 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-07-07 14:41:47 +0900 |
| commit | 5853d7700ff606974fd801f143e7b9d55f3fc253 (patch) | |
| tree | 44e7320eb1ac6946b373acc946342247da2ca2e0 /container/seccomp/hash_test.go | |
| parent | d5c7523726550898b13500f8a169cf13cdc42e7a (diff) | |
container/seccomp: move bpf hashes
Filter programs are different across platforms. This representation is also much more readable.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/seccomp/hash_test.go')
| -rw-r--r-- | container/seccomp/hash_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
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 + } +} |
