Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ add_test(NAME print_backend COMMAND ${CMAKE_SOURCE_DIR}/tests/print_backend.sh $
add_test(NAME lemonade_hrx COMMAND ${CMAKE_SOURCE_DIR}/tests/lemonade_hrx.sh $<TARGET_FILE:onebit>)
add_test(NAME parallel_args COMMAND ${CMAKE_SOURCE_DIR}/tests/parallel_args.sh $<TARGET_FILE:onebit>)
add_test(NAME recipes_route COMMAND ${CMAKE_SOURCE_DIR}/tests/recipes_route.sh $<TARGET_FILE:onebit>)
# os/mini/release-check.sh --self-test: the shipped release gate's own verdict rows, asserted (engine#1596). It needs no
# build and no device - the subject is the row functions - so it is the one test here that takes no $<TARGET_FILE>, and
# it is here because nothing else runs it: the rows had 128 assertions and no runner. It names no add_executable, so it
# adds nothing to the set of test targets the CI --target list would have to build (the direction-B measurement, #1595).
add_test(NAME release_check_selftest COMMAND bash ${CMAKE_SOURCE_DIR}/os/mini/release-check.sh --self-test)
add_test(NAME template_pin COMMAND ${CMAKE_SOURCE_DIR}/tests/template_pin.sh $<TARGET_FILE:onebit>)
add_test(NAME greedy_shortcut COMMAND ${CMAKE_SOURCE_DIR}/tests/greedy_shortcut.sh $<TARGET_FILE:onebit>)
add_test(NAME device_route COMMAND ${CMAKE_SOURCE_DIR}/tests/device_route.sh $<TARGET_FILE:onebit>)
Expand Down
81 changes: 81 additions & 0 deletions os/mini/release-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,53 @@ payload_runpath_verdict() {
fi
}

# ── the payload's home-path LAYOUT (engine#1543, the fourth leak class) ─────────────────────────────────────────
# The first three classes are about CONTENT - a path compiled into a map or a debug string, a build tree packaged as
# bytes, a symbol table. The fourth is the path delivered as the FILESYSTEM LAYOUT: `bin/1bit` was an ABSOLUTE symlink
# to /home/<builder>/wt/issue-709-build/1bit, so the image shipped the builder's home as a directory and every content
# check passed. Discriminator measured on the shipped c33 SFS and on the leaking mini image: an absolute symlink whose
# target RESOLVES TO A FILE under home|Users|root (0 in c33, 1 in the leaking image). Targets that are a directory or
# absent are named but not failed - `root/spot -> /home/spot` is legitimate, and a payload scanned on a build host
# cannot tell an image directory from a missing one.
payload_home_layout_bad() { # <payload dir> -> "relpath|TARGET|file|dir|dangling" per absolute home-targeting link
python3 - "$1" 2>/dev/null <<'PYSCAN'
import os, sys
root = sys.argv[1]
HOMES = ('/home/', '/Users/', '/root/')
for dp, dns, fns in os.walk(root):
for n in sorted(dns + fns):
p = os.path.join(dp, n)
if not os.path.islink(p):
continue
t = os.readlink(p)
if not t.startswith('/') or not t.startswith(HOMES):
continue
kind = 'file' if os.path.isfile(p) else ('dir' if os.path.isdir(p) else 'dangling')
print('%s|%s|%s' % (os.path.relpath(p, root), t, kind))
PYSCAN
}

payload_home_layout_verdict() { # <links at a FILE or at NOTHING> <links at a DIRECTORY> [<sample>]
_bad=${1:-} _dir=${2:-} _s=${3:-}
case "${_bad}:${_dir}" in
*[!0-9:]*) printf 'FAIL the home-path links in the payload could not be counted (%s:%s)' "${_bad:-empty}" "${_dir:-empty}"; return 0 ;;
esac
# FAIL on a FILE target AND on a target that is NOT THERE. A dangling `bin/1bit -> /home/<builder>/wt/build/onebit`
# is the leak twice over: the disclosure IS the path (the image still ships the builder's username and workdir as its
# layout), and it is the worse failure to stand up - nothing to load, so the engine registers no device on an
# otherwise fine boot. Only a DIRECTORY target is a different, legitimate thing (`root/spot -> /home/spot`, a home
# on /data): measured on the shipped c33 image, the whole rootfs has exactly one of those and the payload has none.
if [ "$_bad" != 0 ]; then
printf 'FAIL %s absolute symlink(s) in the payload point into a home directory at a file or at nothing%s - the image ships the builder path as its layout and no content check can see it' \
"$_bad" "${_s:+: $_s}"
elif [ "$_dir" != 0 ]; then
printf 'PASS no payload symlink points at a builder file or at nothing (0); %s name a home DIRECTORY%s, which is a home on /data and not this class' \
"$_dir" "${_s:+: $_s}"
else
printf "PASS no absolute symlink in the payload points into a home directory: the payload's layout carries no builder path"
fi
}

# --self-test: assert the lemonade verdict on the cases that matter (tests/release_check_row.sh runs
# this in CI). The unprepared-stick case is the one that used to false-PASS: 200 with the key, an empty
# body and no status without it.
Expand Down Expand Up @@ -820,6 +867,17 @@ if [ "${1:-}" = --self-test ]; then
check FAIL "$(followup_verdict '{"choices":[{"finish_reason":"length"}]}' '{"choices":[{"message":{"content":"1BIT"}}]}' 0 0)"
check PASS "$(followup_verdict '{"choices":[{"finish_reason":"length"}]}' '{"choices":[{"message":{"content":"1BIT OK"},"finish_reason":"length"}]}' '' '')"
# the RUNPATH rule (2026-11-08 incident): $ORIGIN only, and RPATH is always a fail.
check PASS "$(payload_home_layout_verdict 0 0 '')"
check FAIL "$(payload_home_layout_verdict 1 0 'bin/1bit|/home/x/wt/issue-709-build/1bit|file')"
check FAIL "$(payload_home_layout_verdict 1 0 'bin/1bit|/home/x/wt/build/onebit|dangling')"
check PASS "$(payload_home_layout_verdict 0 1 'root/spot|/home/spot|dir')"
_hl_st=$(mktemp -d)
mkdir -p "$_hl_st/bin" "$_hl_st/opt"
ln -s /home/nonexistent-xyz/wt/build/1bit "$_hl_st/bin/leak" # the class: absolute, target absent
ln -s ../opt/1bit/1bit "$_hl_st/bin/rel" # relative: not this class
ln -s /home/nonexistent-xyz "$_hl_st/opt/home" # a home directory target: named, not failed
check "bin/leak|/home/nonexistent-xyz/wt/build/1bit|dangling" "$(payload_home_layout_bad "$_hl_st" | grep '^bin/leak|')"
rm -rf "$_hl_st"
check PASS "$(payload_runpath_verdict 0)"
check FAIL "$(payload_runpath_verdict 3 '/opt/1bit-package/1bit/1bit runs /home/x/wt/release-rc/work/build')"
check FAIL "$(payload_runpath_verdict 1)"
Expand Down Expand Up @@ -2139,6 +2197,29 @@ else
fi
fi

# The layout row gets the same subject check as the other payload rows (engine#1599 measured why): existence first,
# so a host that simply has no payload SKIPs, then the subject, so an empty or interrupted unpack FAILs rather than
# passing over nothing, and only then the row itself - once, in the else, so a subject failure never falls through.
_HL_DIR=${PAYLOAD_DIR:-/opt/1bit-package}
if [ ! -d "$_HL_DIR" ]; then
skip payload-home-layout "no $_HL_DIR on this system: the payload is not unpacked where an appliance keeps it, so its symlinks cannot be judged here - that is not evidence"
elif [ "$(find "$_HL_DIR" -mindepth 1 2>/dev/null | wc -l)" -lt 100 ]; then
fail payload-home-layout "the payload at $_HL_DIR holds fewer than 100 entries - an empty or interrupted unpack has no layout to judge, and a green row here would be a pass over nothing (c33: 263 entries)"
elif ! command -v python3 >/dev/null 2>&1; then
skip payload-home-layout "no python3 here, so the payload's symlinks cannot be read - that is not evidence"
else
_hl_bad=$(payload_home_layout_bad "$_HL_DIR" 2>/dev/null)
_hl_nf=$(printf '%s\n' "${_hl_bad:-}" | sed '/^$/d' | awk -F'|' '$3 != "dir"' | wc -l)
_hl_nd=$(printf '%s\n' "${_hl_bad:-}" | sed '/^$/d' | awk -F'|' '$3 == "dir"' | wc -l)
_hl_s=$(printf '%s\n' "${_hl_bad:-}" | sed '/^$/d' | awk -F'|' '$3 != "dir"' | head -3 | tr '\n' ' ')
[ "$_hl_nf" = 0 ] && [ -n "$(printf '%s\n' "${_hl_bad:-}" | sed '/^$/d')" ] && _hl_s=$(printf '%s\n' "${_hl_bad:-}" | sed '/^$/d' | head -2 | tr '\n' ' ')
HL=$(payload_home_layout_verdict "$_hl_nf" "$_hl_nd" "${_hl_s:-}")
case "$HL" in
PASS*) pass payload-home-layout "${HL#PASS }" ;;
*) fail payload-home-layout "${HL#FAIL }" ;;
esac
fi


# ── the NPU's locked memory in force (the driver asks for unlimited; this fleet's own 99- file can override ours) ──
MEMLOCK_PID=${MEMLOCK_PID:-}
Expand Down
Loading