fix(sandbox): harden enforcement validation and backup handling

This commit is contained in:
Chris Scott committed 2026-08-20 11:10:59 -04:00
1 parent f315dda3f3
commit 0481160f5e
13 files changed
+180 -101

No files matched your search

+14 -6
View File
@@ -42,12 +42,26 @@ grant_kvm_access() {
echo "Granted node access to $dev (group '$group_name', gid $dev_gid)"
}
MIN_OPENCODE_VERSION="1.0.137"
version_gte() {
printf '%s\n%s\n' "$2" "$1" | sort -V -C
}
install_opencode() {
local opencode_version="${OPENCODE_BUNDLED_VERSION:-}"
if [ -z "$opencode_version" ]; then
echo "ERROR: OPENCODE_BUNDLED_VERSION is not set; refusing to guess the pinned OpenCode build" >&2
return 1
fi
if [[ ! "$opencode_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: OPENCODE_BUNDLED_VERSION='$opencode_version' is not an X.Y.Z version; refusing to download it" >&2
return 1
fi
if ! version_gte "$opencode_version" "$MIN_OPENCODE_VERSION"; then
echo "ERROR: OPENCODE_BUNDLED_VERSION=$opencode_version is below the minimum supported $MIN_OPENCODE_VERSION; refusing to download it" >&2
return 1
fi
echo "Installing OpenCode ${opencode_version}..."
curl -fsSL "https://github.com/anomalyco/opencode/releases/download/v${opencode_version}/opencode-linux-$(uname -m | sed 's/x86_64/x64/; s/aarch64/arm64/').tar.gz" \
-o /tmp/opencode.tar.gz
@@ -77,12 +91,6 @@ fi
echo "Checking OpenCode installation..."
MIN_OPENCODE_VERSION="1.0.137"
version_gte() {
printf '%s\n%s\n' "$2" "$1" | sort -V -C
}
if ! command -v opencode >/dev/null 2>&1; then
echo "OpenCode not found. Installing..."
install_opencode