Skip to content
Draft
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
42 changes: 42 additions & 0 deletions .github/scripts/sandbox-image-digests-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Focused check for digest validation and safe workflow diagnostics.
set -euo pipefail

source .github/scripts/sandbox-image-digests.sh

valid_digest="sha256:$(printf '%064d' 0 | tr '0' 'a')"
if ! sandbox_image_require_digest "$valid_digest" >/dev/null; then
echo "valid digest was rejected" >&2
exit 1
fi

for invalid_digest in \
"" \
"sha256:abc" \
"sha256:$(printf '%064d' 0 | tr '0' 'A')" \
"sha256:$(printf '%064d' 0 | tr '0' 'a')/extra"; do
if sandbox_image_require_digest "$invalid_digest" >/dev/null 2>&1; then
echo "invalid digest was accepted: $(printf '%q' "$invalid_digest")" >&2
exit 1
fi
done

injected_value=$'bad%value\r\n::error::injected-command'
if diagnostic=$(sandbox_image_require_digest "$injected_value" 2>&1); then
echo "malformed injection value was accepted" >&2
exit 1
fi
if [[ "$diagnostic" != $'::error::Sandbox image validation failed\n'* ]]; then
echo "diagnostic did not use the static workflow annotation" >&2
exit 1
fi
if [[ "$diagnostic" == *$'\r'* || "$diagnostic" == *$'\n::error::injected-command'* ]]; then
echo "diagnostic contains raw control characters or an injected command" >&2
exit 1
fi
if [[ "$diagnostic" != *'bad%value\r\n::error::injected-command'* ]]; then
echo "diagnostic did not safely render the malformed value" >&2
exit 1
fi

echo "sandbox image digest checks passed"
22 changes: 22 additions & 0 deletions .github/scripts/sandbox-image-digests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Helpers shared by the sandbox image publishing workflow and its local check.

sandbox_image_error() {
# Keep workflow commands static. Render untrusted details as one shell-escaped
# line on stderr so percent signs and control characters cannot add commands.
printf '::error::Sandbox image validation failed\n'
printf 'detail: %q\n' "$*" >&2
}

sandbox_image_is_digest() {
[[ "${1-}" =~ ^sha256:[0-9a-f]{64}$ ]]
}

sandbox_image_require_digest() {
local digest="${1-}"
if sandbox_image_is_digest "$digest"; then
return 0
fi
sandbox_image_error "invalid sha256 image digest: $digest"
return 1
}
165 changes: 152 additions & 13 deletions .github/workflows/sandbox-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
# version. Branch pushes and PRs still respect the paths filter.

# Each platform builds on a native runner and pushes by digest only;
# the merge jobs then publish the multi-arch index under the tags below.
# the merge job then publishes the multi-arch indexes under the tags below.
# No step pulls from Docker Hub, whose anonymous rate limit failed
# release builds (#8289): there is no QEMU (tonistiigi/binfmt), and the
# docker-container buildx driver runs BuildKit from mirror.gcr.io
Expand All @@ -36,6 +36,7 @@ on:
env:
BUILDKIT_IMAGE: mirror.gcr.io/moby/buildkit:v0.34.0@sha256:b059f8d7226d0b326bc871af489a5dddf65e36af4d20d14251b072974d9ee87c
BASE_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/fullsend-sandbox
TOOLS_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/fullsend-sandbox-tools
CODE_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/fullsend-code
# Shared by every metadata step, so the per-platform labels and the
# merged index tags come from one definition.
Expand Down Expand Up @@ -103,14 +104,91 @@ jobs:
env:
DIGEST: ${{ steps.push.outputs.digest }}
run: |
source "$GITHUB_WORKSPACE/.github/scripts/sandbox-image-digests.sh"
sandbox_image_require_digest "$DIGEST" || exit 1
mkdir -p "${RUNNER_TEMP}/digests"
touch "${RUNNER_TEMP}/digests/${DIGEST#sha256:}"

- name: Upload digest
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: digests-sandbox-${{ matrix.arch }}
name: digests-sandbox-base-${{ matrix.arch }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 7

# Publish the same pinned tools in an OCI root that can be mounted at
# /opt/fullsend. The tools target removes the regular image's /opt/fullsend/usr
# compatibility symlink so the mounted image's own /usr tree is visible.
build-tools:
needs: build-base
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- platform: linux/amd64
arch: amd64
runner: ubuntu-24.04
- platform: linux/arm64
arch: arm64
runner: ubuntu-24.04-arm
timeout-minutes: 30
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Log in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
with:
driver-opts: image=${{ env.BUILDKIT_IMAGE }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.TOOLS_IMAGE_NAME }}
tags: ${{ env.IMAGE_TAGS }}

- name: Build and push by digest
id: push
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: images/sandbox
file: images/sandbox/Containerfile
target: fullsend-sandbox-tools
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.TOOLS_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
cache-from: |
type=gha,scope=sandbox-${{ matrix.arch }}
type=gha,scope=sandbox-tools-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=sandbox-tools-${{ matrix.arch }}

- name: Export digest
if: github.event_name != 'pull_request'
env:
DIGEST: ${{ steps.push.outputs.digest }}
run: |
source "$GITHUB_WORKSPACE/.github/scripts/sandbox-image-digests.sh"
sandbox_image_require_digest "$DIGEST" || exit 1
mkdir -p "${RUNNER_TEMP}/digests"
touch "${RUNNER_TEMP}/digests/${DIGEST#sha256:}"

- name: Upload digest
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: digests-sandbox-tools-${{ matrix.arch }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 7
Expand All @@ -121,7 +199,7 @@ jobs:
# On PR: the :dev tag (multi-arch, published by non-PR builds) so that
# both platform legs of build-code can resolve a base image.
merge-base:
needs: build-base
needs: [build-base, build-tools]
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
Expand All @@ -130,12 +208,22 @@ jobs:
outputs:
image-ref: ${{ steps.ref.outputs.value }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Download digests
if: github.event_name != 'pull_request'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: ${{ runner.temp }}/digests
pattern: digests-sandbox-*
pattern: digests-sandbox-base-*
merge-multiple: true

- name: Download tool image digests
if: github.event_name != 'pull_request'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: ${{ runner.temp }}/tool-digests
pattern: digests-sandbox-tools-*
merge-multiple: true

- name: Log in to GitHub Container Registry
Expand All @@ -154,6 +242,14 @@ jobs:
images: ${{ env.BASE_IMAGE_NAME }}
tags: ${{ env.IMAGE_TAGS }}

- name: Extract tool image metadata
if: github.event_name != 'pull_request'
id: tools-meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.TOOLS_IMAGE_NAME }}
tags: ${{ env.IMAGE_TAGS }}

- name: Create and push manifest list
if: github.event_name != 'pull_request'
id: index
Expand All @@ -162,15 +258,15 @@ jobs:
IMAGE_NAME: ${{ env.BASE_IMAGE_NAME }}
META_JSON: ${{ steps.meta.outputs.json }}
run: |
source "$GITHUB_WORKSPACE/.github/scripts/sandbox-image-digests.sh"
# Never publish a partial index.
count=$(find . -maxdepth 1 -type f | wc -l)
if [ "${count}" -ne 2 ]; then
echo "::error::expected 2 platform digests, found ${count}"
sandbox_image_error "expected 2 platform digests, found ${count}"
exit 1
fi
for hex in *; do
if ! grep -Eqx '[0-9a-f]{64}' <<<"${hex}"; then
echo "::error::not a sha256 digest: ${hex}"
if ! sandbox_image_require_digest "sha256:${hex}"; then
exit 1
fi
done
Expand All @@ -184,9 +280,9 @@ jobs:
# runs can move dev/latest, but only this commit sets this tag.
sha_tag="${IMAGE_NAME}:${GITHUB_SHA::7}"
jq -e --arg t "${sha_tag}" 'any(.tags[]; . == $t)' <<<"${META_JSON}" >/dev/null \
|| { echo "::error::${sha_tag} is not among the published tags"; exit 1; }
|| { sandbox_image_error "${sha_tag} is not among the published tags"; exit 1; }
digest=$(docker buildx imagetools inspect "${sha_tag}" --format '{{json .Manifest}}' | jq -r '.digest')
[[ "${digest}" =~ ^sha256:[0-9a-f]{64}$ ]] || { echo "::error::no index digest for ${sha_tag}"; exit 1; }
sandbox_image_require_digest "${digest}" || exit 1
# Another run of the same commit (a release tag on an rc commit)
# can move the sha tag. Fail unless the index read back holds
# exactly the platform images this run pushed.
Expand All @@ -197,11 +293,50 @@ jobs:
done | sort)
got=$(docker buildx imagetools inspect --raw "${IMAGE_NAME}@${digest}" | jq -r --arg self "${digest}" "${platform_digests}" | sort)
if [ "${want}" != "${got}" ]; then
echo "::error::${sha_tag} was moved by another run; expected ${want//$'\n'/ }, got ${got//$'\n'/ }"
sandbox_image_error "${sha_tag} was moved by another run; expected ${want//$'\n'/ }, got ${got//$'\n'/ }"
exit 1
fi
echo "digest=${digest}" >> "${GITHUB_OUTPUT}"

- name: Create and push tool image manifest list
if: github.event_name != 'pull_request'
working-directory: ${{ runner.temp }}/tool-digests
env:
IMAGE_NAME: ${{ env.TOOLS_IMAGE_NAME }}
META_JSON: ${{ steps.tools-meta.outputs.json }}
run: |
source "$GITHUB_WORKSPACE/.github/scripts/sandbox-image-digests.sh"
count=$(find . -maxdepth 1 -type f | wc -l)
if [ "${count}" -ne 2 ]; then
sandbox_image_error "expected 2 tool image platform digests, found ${count}"
exit 1
fi
for hex in *; do
if ! sandbox_image_require_digest "sha256:${hex}"; then
exit 1
fi
done
mapfile -t tag_args < <(jq -r '.tags[] | "--tag=" + .' <<<"${META_JSON}")
sources=()
for hex in *; do
sources+=("${IMAGE_NAME}@sha256:${hex}")
done
docker buildx imagetools create "${tag_args[@]}" "${sources[@]}"
sha_tag="${IMAGE_NAME}:${GITHUB_SHA::7}"
jq -e --arg t "${sha_tag}" 'any(.tags[]; . == $t)' <<<"${META_JSON}" >/dev/null \
|| { sandbox_image_error "${sha_tag} is not among the published tags"; exit 1; }
digest=$(docker buildx imagetools inspect "${sha_tag}" --format '{{json .Manifest}}' | jq -r '.digest')
sandbox_image_require_digest "${digest}" || exit 1
platform_digests='if .manifests then [.manifests[] | select(.platform.os != "unknown") | .digest] else [$self] end | .[]'
want=$(for src in "${sources[@]}"; do
docker buildx imagetools inspect --raw "${src}" | jq -r --arg self "${src#*@}" "${platform_digests}"
done | sort)
got=$(docker buildx imagetools inspect --raw "${IMAGE_NAME}@${digest}" | jq -r --arg self "${digest}" "${platform_digests}" | sort)
if [ "${want}" != "${got}" ]; then
sandbox_image_error "${sha_tag} was moved by another run; expected ${want//$'\n'/ }, got ${got//$'\n'/ }"
exit 1
fi

- name: Compute base image ref
id: ref
env:
Expand Down Expand Up @@ -296,6 +431,8 @@ jobs:
env:
DIGEST: ${{ steps.push.outputs.digest }}
run: |
source "$GITHUB_WORKSPACE/.github/scripts/sandbox-image-digests.sh"
sandbox_image_require_digest "$DIGEST" || exit 1
mkdir -p "${RUNNER_TEMP}/digests"
touch "${RUNNER_TEMP}/digests/${DIGEST#sha256:}"

Expand All @@ -319,6 +456,8 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Download digests
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
Expand Down Expand Up @@ -346,15 +485,15 @@ jobs:
IMAGE_NAME: ${{ env.CODE_IMAGE_NAME }}
META_JSON: ${{ steps.meta.outputs.json }}
run: |
source "$GITHUB_WORKSPACE/.github/scripts/sandbox-image-digests.sh"
# Never publish a partial index.
count=$(find . -maxdepth 1 -type f | wc -l)
if [ "${count}" -ne 2 ]; then
echo "::error::expected 2 platform digests, found ${count}"
sandbox_image_error "expected 2 platform digests, found ${count}"
exit 1
fi
for hex in *; do
if ! grep -Eqx '[0-9a-f]{64}' <<<"${hex}"; then
echo "::error::not a sha256 digest: ${hex}"
if ! sandbox_image_require_digest "sha256:${hex}"; then
exit 1
fi
done
Expand Down
22 changes: 22 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ inputs:
description: GCP project ID, used only when the selected agent resolves to Vertex inference.
required: false
default: ""
allow-image-mounts:
description: >-
Opt in to read-only Podman image mounts on the action's locally generated
OpenShell gateway. This enables caller driver config and disables Podman
resource admission for that local gateway. It does not change remote gateways.
required: false
default: "false"
runner_secrets:
description: >-
JSON object of name → value (the FULLSEND_GITHUB_RUNNER_SECRETS secret).
Expand Down Expand Up @@ -475,7 +482,14 @@ runs:
- name: Configure OpenShell gateway
if: steps.sandbox-host.outputs.local == 'true'
shell: bash
env:
ALLOW_IMAGE_MOUNTS: ${{ inputs.allow-image-mounts }}
run: |
set -euo pipefail
case "${ALLOW_IMAGE_MOUNTS}" in
true|false) ;;
*) echo "::error::allow-image-mounts must be true or false"; exit 1 ;;
esac
source "$GITHUB_ACTION_PATH/.github/scripts/openshell-version.sh"
mkdir -p $HOME/.config/openshell/
cat > $HOME/.config/openshell/gateway.env << EOF
Expand All @@ -492,6 +506,14 @@ runs:
supervisor_image = "ghcr.io/nvidia/openshell/supervisor:${OPENSHELL_VERSION}"
health_check_interval_secs = 10
EOF
if [[ "${ALLOW_IMAGE_MOUNTS}" == "true" ]]; then
cat >> "$HOME/.config/openshell/gateway.toml" << EOF
allow_driver_config = true

[openshell.drivers.podman.resource_admission]
enabled = false
EOF
fi

# The upstream installer needs sudo and starts a local gateway service, so
# a remote-gateway runner that already has the CLI skips it.
Expand Down
4 changes: 4 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ each target repository's **`.fullsend/`** directory
**Decided:**

- Provider-backed policy composition: network access is granted through provider profiles declared in harness files. Policy files define only non-composable sandbox restrictions (filesystem, landlock, process). A single `base.yaml` replaces per-agent policy files in the scaffold. Inline `network_policies` continue to work but providers are the recommended approach ([ADR 0065](ADRs/0065-provider-backed-policy-composition.md)).
- Project tool images: harnesses may mount user-selected OCI images read-only
in the sandbox, separately from the sandbox image, so repositories can
provide coding tools without composing them with Fullsend's dependencies
([ADR 0173](ADRs/0173-compose-multiple-images-into-agent-sandboxes.md)).

## Agent Harness

Expand Down
Loading
Loading