eBPF-based security platform
testing: build the image seal with and without seccomp
KP Singhd0967ebd3c63
diff --git a/.gitignore b/.gitignoreindex cf857309..8b41493a 100644--- a/.gitignore+++ b/.gitignore@@ -51,6 +51,7 @@!/testing/helper/otel-s3-mock.py!/testing/helper/test-bpm-key.py!/testing/helper/test-bpm-info.py+!/testing/helper/test-seal-seccomp.py# libFuzzer targets and the inputs that crashed them/testing/fuzz/fuzz-*diff --git a/testing/helper/test-seal-seccomp.py b/testing/helper/test-seal-seccomp.pynew file mode 100644index 00000000..0ccd84a0--- /dev/null+++ b/testing/helper/test-seal-seccomp.py@@ -0,0 +1,31 @@+# SPDX-License-Identifier: BSD-2-Clause+# Copyright (c) 2026 Authors of shirudo++import os+from pathlib import Path+import re+import shlex+import subprocess+import sys+import tempfile++root = Path(__file__).resolve().parents[2]+header = (root / "vendor/linux/vmlinux.h").read_text()+fields = {"enabled": "\tint mode;\n", "disabled": ""}[sys.argv[1]]+header, count = re.subn(r"(?ms)^struct seccomp \{[^}]*\};",+ "struct seccomp {\n" + fields + "};", header)+assert count == 1, "vmlinux.h must define struct seccomp"++with tempfile.TemporaryDirectory(prefix="shirudo-seal-seccomp-") as directory:+ work = Path(directory)+ (work / "vmlinux.h").write_text(header)+ command = shlex.split(os.environ.get("CLANG", "clang"))+ command += ["-target", "bpf", "-O2", "-g", "-Wall", "-Wextra", "-Werror",+ "-Wno-missing-declarations", "-Wno-unused-parameter",+ "-Wdeclaration-after-statement", "-I" + str(work),+ "-I" + str(root / "bpf/lib"),+ "-I" + str(root / "vendor/libbpf"),+ "-I" + str(root / "vendor/libbpf/include/uapi"),+ "-c", str(root / "bpf/seal_verity.c"),+ "-o", str(work / "seal_verity.bpf.o")]+ subprocess.run(command, check=True)diff --git a/testing/t0055-seal-seccomp.sh b/testing/t0055-seal-seccomp.shnew file mode 100755index 00000000..b64f4d27--- /dev/null+++ b/testing/t0055-seal-seccomp.sh@@ -0,0 +1,16 @@+#!/bin/sh+# SPDX-License-Identifier: BSD-2-Clause+# Copyright (c) 2026 Authors of shirudo++cd "$(dirname "$0")"+. ./test-lib.sh++test_expect_success 'image seal builds with seccomp fields in vmlinux.h' '+ python3 helper/test-seal-seccomp.py enabled+'++test_expect_success 'image seal builds with an empty seccomp type in vmlinux.h' '+ python3 helper/test-seal-seccomp.py disabled+'++test_done