Skip to content

eBPF-based security platform

testing: use signed config images for telemetry checks

KP Singh20b02af11de3
diff --git a/contrib/verity-vm-config-fixtures.sh b/contrib/verity-vm-config-fixtures.sh
index 7c4fc49a..cc13fad1 100755
--- a/contrib/verity-vm-config-fixtures.sh
+++ b/contrib/verity-vm-config-fixtures.sh
@@ -66,7 +66,7 @@ cp "$keys_dir/cert.der" "$output/public/primary.der"
for name in config-boot-keys config-live-new-key config-a config-b config-bad config-revoke \
config-tree-stable config-tree-updated config-tree-deleted config-tree-restored \
- config-otel config-interrupted config-builtin; do
+ config-otel config-jsonl config-jsonl-bad config-interrupted config-builtin; do
[ "$name" != config-builtin ] || [ -n "$builtin_key" ] || continue
root="$output/source/$name"
mkdir -p "$root/etc/shirudo" "$root/keys/trusted" "$root/keys/revoked"
@@ -83,6 +83,9 @@ for name in config-boot-keys config-live-new-key config-a config-b config-bad co
config-otel)
cp "$templates/otel.conf" "$root/etc/shirudo/shirudo.conf"
;;
+ config-jsonl|config-jsonl-bad)
+ cp "$templates/${name#config-}.conf" "$root/etc/shirudo/shirudo.conf"
+ ;;
esac
cp "$output/public/boot.der" "$root/keys/trusted/$boot_fp.der"
"$builder" keys vouch "$output/public/boot.der" \
diff --git a/contrib/verity-vm/jsonl-bad.conf b/contrib/verity-vm/jsonl-bad.conf
new file mode 100644
index 00000000..45203f15
--- /dev/null
+++ b/contrib/verity-vm/jsonl-bad.conf
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+eventlog.max_bytes = 0
+map_export.json_path = /tmp/shirudo-test-jsonl/missing/maps.ndjson
diff --git a/contrib/verity-vm/jsonl.conf b/contrib/verity-vm/jsonl.conf
new file mode 100644
index 00000000..991c551f
--- /dev/null
+++ b/contrib/verity-vm/jsonl.conf
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+eventlog.max_bytes = 0
+map_export.json_path = /tmp/shirudo-test-jsonl/maps.ndjson
diff --git a/testing/otel/t1115-map-export-all.sh b/testing/otel/t1115-map-export-all.sh
index de69d7a0..30035543 100644
--- a/testing/otel/t1115-map-export-all.sh
+++ b/testing/otel/t1115-map-export-all.sh
@@ -14,9 +14,11 @@ PIN="/run/shirudo/bpffs/upatches/$NAME/link"
CONFIG=/etc/shirudo/shirudo.conf
WORK=$(mktemp -d)
SERVER=""
+JSON_DIR="$WORK/jsonl"
CONFIG_EXISTED=0
if [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ]; then
export SHIRUDO_TEST_OTEL_PORT=5444
+ JSON_DIR=/tmp/shirudo-test-jsonl
elif [ -e "$CONFIG" ]; then
cp "$CONFIG" "$WORK/config"
CONFIG_EXISTED=1
@@ -28,9 +30,10 @@ restore() {
if [ "${SHIRUDO_TEST_MODE:-legacy}" != verity ]; then
if [ "$CONFIG_EXISTED" -eq 1 ]; then cp "$WORK/config" "$CONFIG"; else rm -f "$CONFIG"; fi
fi
- rm -rf "$WORK"
+ rm -rf "$JSON_DIR" "$WORK"
}
trap restore EXIT
+mkdir "$JSON_DIR" || exit 1
[ -s "$LOAD" ] || test_skip_all "missing map-export fixture"
[ -s "$UNLOAD" ] || test_skip_all "missing map-export unload fixture"
@@ -77,10 +80,14 @@ test_expect_success '--all exports one detailed JSON record per loaded map' '
'
test_expect_success 'configured JSON-lines output appends one valid record per map' '
- printf "map_export.json_path = %s\n" "$WORK/configured.ndjson" >"$CONFIG" &&
+ if [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ]; then
+ "$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-jsonl"
+ else
+ printf "map_export.json_path = %s\n" "$JSON_DIR/maps.ndjson" >"$CONFIG"
+ fi &&
"$SHIRUDO_BIN" upatch map --all &&
"$SHIRUDO_BIN" upatch map --all &&
- python3 - "$WORK/configured.ndjson" <<'\''PY'\''
+ python3 - "$JSON_DIR/maps.ndjson" <<'\''PY'\''
import json, sys
records = [json.loads(line) for line in open(sys.argv[1], encoding="utf-8")]
assert len(records) == 4
@@ -91,7 +98,11 @@ PY
'
test_expect_success 'configured JSON-lines output reports an unwritable destination' '
- printf "map_export.json_path = %s\n" "$WORK/missing/maps.ndjson" >"$CONFIG" &&
+ if [ "${SHIRUDO_TEST_MODE:-legacy}" = verity ]; then
+ "$SHIRUDO_BIN" image update "$SHIRUDO_TEST_KEY_FIXTURES/config-jsonl-bad"
+ else
+ printf "map_export.json_path = %s\n" "$JSON_DIR/missing/maps.ndjson" >"$CONFIG"
+ fi &&
! "$SHIRUDO_BIN" upatch map --all >/dev/null 2>&1
'
diff --git a/testing/otel/t1116-otel-backend.sh b/testing/otel/t1116-otel-backend.sh
index d6f76599..e7d96d0b 100644
--- a/testing/otel/t1116-otel-backend.sh
+++ b/testing/otel/t1116-otel-backend.sh
@@ -91,7 +91,7 @@ test_expect_success 'map-export timer does not overlap a running export' '
systemctl stop shirudo-map-export.timer >/dev/null 2>&1 || true
systemctl stop shirudo-map-export.service >/dev/null 2>&1 || true
cat >"$WORK/slow-otel.py" <<'PY'
-import http.server, json, pathlib, sys, threading, time
+import http.server, json, os, pathlib, sys, threading, time
port_file, meta_file = map(pathlib.Path, sys.argv[1:3])
state = {"active": 0, "max_active": 0, "paths": [], "times": [], "completed": 0}
lock = threading.Lock()
@@ -114,7 +114,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
state["completed"] += 1
meta_file.write_text(json.dumps(state))
def log_message(self, *args): pass
-server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Handler)
+server = http.server.ThreadingHTTPServer(("127.0.0.1", int(os.environ.get("SHIRUDO_TEST_OTEL_PORT", "0"))), Handler)
server.daemon_threads = True
port_file.write_text(str(server.server_port))
while state["completed"] < 4:
diff --git a/testing/run-target-verity-tests.sh b/testing/run-target-verity-tests.sh
index 5e517f51..c4e3b347 100755
--- a/testing/run-target-verity-tests.sh
+++ b/testing/run-target-verity-tests.sh
@@ -18,7 +18,7 @@ export SHIRUDO_TEST_MODE=verity
}
for name in config-boot-keys config-live-new-key config-a config-b config-bad config-revoke \
config-tree-stable config-tree-updated config-tree-deleted config-tree-restored \
- config-otel config-interrupted; do
+ config-otel config-jsonl config-jsonl-bad config-interrupted; do
for suffix in img verity roothash p7s; do
[ -s "$SHIRUDO_TEST_KEY_FIXTURES/$name.$suffix" ] &&
[ -s "/var/lib/shirudo/images/$name.$suffix" ] || {
diff --git a/testing/tamperproof/t1154-verity-config.py b/testing/tamperproof/t1154-verity-config.py
index d9944ca8..7e8cabc8 100644
--- a/testing/tamperproof/t1154-verity-config.py
+++ b/testing/tamperproof/t1154-verity-config.py
@@ -24,7 +24,8 @@ JOURNAL = Path("/var/lib/shirudo/config-update")
RESULTS = Path(sys.argv[2]).resolve()
NAMES = ("config-a", "config-b", "config-boot-keys", "config-revoke",
"config-tree-stable", "config-tree-updated", "config-tree-deleted",
- "config-tree-restored", "config-otel", "config-interrupted", "config-builtin")
+ "config-tree-restored", "config-otel", "config-jsonl", "config-jsonl-bad",
+ "config-interrupted", "config-builtin")
def require(condition, message):