Skip to content

An open-source, faster Devin alternative

TypeScript

fix(deploy): verify attestation from writable temp

Igor Zalutski6ef4b8d43447
diff --git a/ci/test_flue_builder_substrate_probe.py b/ci/test_flue_builder_substrate_probe.py
index 5694bc88..62dfc434 100644
--- a/ci/test_flue_builder_substrate_probe.py
+++ b/ci/test_flue_builder_substrate_probe.py
@@ -26,6 +26,15 @@ class SandboxProbeTest(unittest.TestCase):
self.assertEqual(manifest["runtimeMemoryMB"], 1024)
self.assertEqual(PROBE.STARTER_REF, "5c51d7edbbf2472fbe48386c4f9b192279330c9b")
+ def test_runtime_attestation_compare_uses_a_writable_temp_file(self) -> None:
+ installer = (
+ PROBE.ROOT / "deploy" / "flue-builder" / "install-snapshot.sh"
+ ).read_text()
+ verify = installer.split("verify() {", 1)[1].split("\n}", 1)[0]
+
+ self.assertIn("expected_attestation=\"$(mktemp)\"", verify)
+ self.assertNotIn("/dev/stdout", verify)
+
def test_production_and_http_urls_require_separate_guards(self) -> None:
with mock.patch.dict(os.environ, {}, clear=True):
with self.assertRaises(PROBE.ProbeError):
diff --git a/deploy/flue-builder/README.md b/deploy/flue-builder/README.md
index 22ac45ac..864f9aef 100644
--- a/deploy/flue-builder/README.md
+++ b/deploy/flue-builder/README.md
@@ -13,7 +13,7 @@ changes to lower sandbox-platform layers.
`coordinate.json` is the reviewed logical coordinate. It pins:
-- snapshot name `flue-build-node22-19-0-oc-c39b315-r2` (never reuse it for a
+- snapshot name `flue-build-node22-19-0-oc-c39b315-r3` (never reuse it for a
different recipe or checkpoint);
- Ubuntu 22.04 / x86-64 platform assertion;
- Node 22.19.0 and its upstream archive digest;
@@ -80,8 +80,8 @@ export AGENT_BUILD_SNAPSHOT_ALLOW_CREATE=1
export AGENT_BUILD_SNAPSHOT_ALLOW_PRODUCTION=1
python3 deploy/flue-builder/snapshot.py create \
- --confirm-name flue-build-node22-19-0-oc-c39b315-r2 \
- --receipt /secure/operator-state/flue-build-node22-19-0-oc-c39b315-r2.json
+ --confirm-name flue-build-node22-19-0-oc-c39b315-r3 \
+ --receipt /secure/operator-state/flue-build-node22-19-0-oc-c39b315-r3.json
```
The command is idempotent only when an existing snapshot has the exact pinned
@@ -93,7 +93,7 @@ Store the receipt in non-secret release metadata. Do not commit environment
files or API keys. Configure the build worker from the coordinate and receipt:
```text
-AGENT_BUILD_SANDBOX_SNAPSHOT=flue-build-node22-19-0-oc-c39b315-r2
+AGENT_BUILD_SANDBOX_SNAPSHOT=flue-build-node22-19-0-oc-c39b315-r3
AGENT_BUILD_SANDBOX_CHECKPOINT_ID=<receipt checkpointId>
AGENT_BUILD_NODE_VERSION=22.19.0
AGENT_BUILD_NPM_VERSION=10.9.3
@@ -123,7 +123,7 @@ and prints only the sandbox ID for operator cleanup.
```bash
export OPENCOMPUTER_API_URL='https://app.opencomputer.dev'
export OPENCOMPUTER_API_KEY='...'
-export AGENT_BUILD_SANDBOX_SNAPSHOT='flue-build-node22-19-0-oc-c39b315-r2'
+export AGENT_BUILD_SANDBOX_SNAPSHOT='flue-build-node22-19-0-oc-c39b315-r3'
export AGENT_BUILD_SANDBOX_CHECKPOINT_ID='<receipt checkpointId>'
export AGENT_BUILD_NODE_VERSION='22.19.0'
export AGENT_BUILD_NPM_VERSION='10.9.3'
diff --git a/deploy/flue-builder/coordinate.json b/deploy/flue-builder/coordinate.json
index da1f3fc1..dbf3032f 100644
--- a/deploy/flue-builder/coordinate.json
+++ b/deploy/flue-builder/coordinate.json
@@ -1,20 +1,20 @@
{
"schemaVersion": 1,
"snapshot": {
- "name": "flue-build-node22-19-0-oc-c39b315-r2",
+ "name": "flue-build-node22-19-0-oc-c39b315-r3",
"builderMemoryMB": 4096,
"runtimeMemoryMB": 1024
},
"recipe": {
"installer": "install-snapshot.sh",
- "installerSha256": "6d66f04a958579940b865b9ef17bfbee89b8a8e87a3e9d78430f2e84ea3d47e1",
+ "installerSha256": "9295fa5c9ac50f090c37652eceebe47f966e46c11993a3c97311329e39537e45",
"imageTemplate": "image.json",
"imageTemplateSha256": "d1fc4f3cd27fd1248327f52d9d768a99c9a922d4f0fabf8bf0d6913e2d1e7cd2",
- "materializedManifestSha256": "a768a1c00e46c65540e485ac37ea1513ae6a2a9398941f782e26df5c312e69f9"
+ "materializedManifestSha256": "364643db99925025513d26674a1ee75e12f621686ff2d15d56aa5dc34020b773"
},
"attestation": {
"schemaVersion": 1,
- "snapshotName": "flue-build-node22-19-0-oc-c39b315-r2",
+ "snapshotName": "flue-build-node22-19-0-oc-c39b315-r3",
"baseImage": "base",
"platform": {
"osId": "ubuntu",
diff --git a/deploy/flue-builder/install-snapshot.sh b/deploy/flue-builder/install-snapshot.sh
index 0f9d22ae..699becb3 100755
--- a/deploy/flue-builder/install-snapshot.sh
+++ b/deploy/flue-builder/install-snapshot.sh
@@ -5,7 +5,7 @@ set -euo pipefail
# downloaded input immutable and verified: the resulting checkpoint is trusted
# to execute arbitrary repository lifecycle code without receiving credentials.
-SNAPSHOT_NAME="flue-build-node22-19-0-oc-c39b315-r2"
+SNAPSHOT_NAME="flue-build-node22-19-0-oc-c39b315-r3"
BASE_IMAGE="base"
OS_ID="ubuntu"
OS_VERSION_ID="22.04"
@@ -176,14 +176,20 @@ attest() {
}
verify() {
+ local expected_attestation
assert_platform
[[ "$(node --version)" == "v${NODE_VERSION}" ]] || die "Node verification failed"
[[ "$(npm --version)" == "$NPM_VERSION" ]] || die "npm verification failed"
printf '%s %s\n' "$OC_BINARY_SHA256" "$OC_BIN" | sha256sum --check --status \
|| die "oc digest verification failed"
[[ -f "$ATTESTATION" ]] || die "snapshot attestation is missing"
- cmp -s "$ATTESTATION" <(write_attestation /dev/stdout) \
- || die "snapshot attestation does not match the installer contract"
+ expected_attestation="$(mktemp)"
+ write_attestation "$expected_attestation"
+ if ! cmp -s "$ATTESTATION" "$expected_attestation"; then
+ rm -f "$expected_attestation"
+ die "snapshot attestation does not match the installer contract"
+ fi
+ rm -f "$expected_attestation"
}
case "${1:-}" in