blob: d24ca97f2ea664f771e3aa4a5cb36d05aa456b68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package seccomp_test
import (
"crypto/sha512"
"encoding/base64"
"fmt"
"hakurei.app/container/seccomp"
"hakurei.app/container/std"
)
type (
// bpfPreset represents a preset to validate.
bpfPreset = struct {
seccomp.ExportFlag
std.FilterPreset
}
// bpfLookup are bpf presets and their corresponding filter checksum.
bpfLookup = map[bpfPreset][sha512.Size384]byte
)
// mustParse parses [base64.StdEncoding] representations of a sha512 checksum.
func mustParse(s string) [sha512.Size384]byte {
if v, err := base64.StdEncoding.DecodeString(s); err != nil {
panic(err)
} else if len(v) != sha512.Size384 {
panic(fmt.Sprintf("bad checksum of %d bytes", len(v)))
} else {
return ([sha512.Size384]byte)(v)
}
}
|