carlos / platform Public

cli: ship --from-release checks the asset folders the console echoes

#1389 item 1, task 4 fix round 1. The answer to a copied release is now
checked by checkFromReleaseAnswer, which adds checkAssetsEcho to the
other echo checks, so a console that drops or changes the release's
asset folders fails the ship. TestLoadReleaseDirRefusesUnsafeNames now
places a matching ../x and asserts the unsafe-name refusal itself.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 429e6636cb522df3320d39945c8016de668a1799 parent 32bedc1
2 files changed, +70 −13
  • ship_from_release.go +28 −9
  • ship_from_release_test.go +42 −4

CI cancelled — superseded by a newer push — run details

CI log
=== gate ===
go: downloading go1.26.10 (linux/arm64)
go version go1.26.10 linux/arm64
opentofu: arm64, tofu 1.13.9, aws 6.73.0, archive 2.8.1
  tofu: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/tofu_1.13.9_linux_arm64.tar.gz
  tofu: downloaded, digest verified
  aws: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-aws_6.73.0_linux_arm64.zip
  aws: downloaded, digest verified
  archive: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-archive_2.8.1_linux_arm64.zip
  archive: downloaded, digest verified
  installed in /tmp/carlos-opentofu-f0fanQ
.amadan/test-gate.sh
go: downloading github.com/aws/aws-sdk-go-v2 v1.44.0
go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0
go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5
go: downloading github.com/aws/aws-sdk-go-v2/service/s3 v1.105.0
go: downloading github.com/aws/smithy-go v1.28.1
go: downloading github.com/benbjohnson/litestream v0.5.14
go: downloading github.com/superfly/ltx v0.5.1
go: downloading golang.org/x/net v0.62.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0
go: downloading golang.org/x/sys v0.49.0
go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2
go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0
go: downloading golang.org/x/crypto v0.58.0
go: downloading golang.org/x/mod v0.41.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/pion/transport/v4 v4.0.2
go: downloading github.com/pion/dtls/v3 v3.1.4
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/prometheus/client_golang v1.17.0
go: downloading github.com/lmittmann/tint v1.1.3
go: downloading github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.18
go: downloading github.com/wlynxg/anet v0.0.5
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/prometheus/common v0.45.0
go: downloading github.com/prometheus/client_model v0.5.0
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading github.com/cespare/xxhash/v2 v2.3.0
go: downloading github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0
go: downloading golang.org/x/text v0.43.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading modernc.org/memory v1.11.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec

amadan: job cancelled — a newer push superseded it

Intent

Human

<task-notification> <task-id>a6ec5c81d011f6c87</task-id> <tool-use-id>toolu_01XPe2pPryZ9voTaUT1uJ873</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/a88005ac-72e4-481c-884f-581940b8c2c5/tasks/a6ec5c81d011f6c87.output</output-file> <status>completed</status> <summary>Agent "Implement Task 4: ship --from-release" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE_WITH_CONCERNS Commit: 32bedc1d `cli: carlos ship --from-release ships a pulled release unchanged` Tests: all 9 new tests pass (5 two-console witnesses, including rootfs, plus 4 unit tests). Also passing: TestE2ECLIThroughConsole, TestReleasesPull, TestCLIGolden (golden updated), the internal/docsite tests, and darwin and windows builds and vet. `make code-health` fails only on the two known counts from Tasks 1 and 2 (handleAPIShip, server.go); runShip and the new files add nothing. Concerns: - I accept `-a` (the short form of `--app`) alongside `-d`, otherwise `-a shop` would be refused. - I added a few refusals the brief does not list. The important one: a manifest with no version is refused, because the console would make one up and the copy would land under a different name. - `checkAssetsEcho` is not called because the brief lists only four checks. An old console could drop the asset folders without saying so. - The new cli.md paragraph and the extra error strings have not been through copy-review. - The known packed-refs.lock warning appeared on commit, and the commit landed. - The rootfs witness needed only SeedScratchDir, so nothing was stubbed. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/release-copy-across-consoles/.superpowers/sdd/2026-11-25-release-copy-across-consoles/task-4-report.md</result> <usage><subagent_tokens>134107</subagent_tokens><tool_uses>47</tool_uses><duration_ms>519144</duration_ms></usage> </task-notification>

Attributed to this commit: 7.88 g CO₂e (929,223 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on release-copy-across-consoles, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/ship_from_release.go b/ship_from_release.go
index ef44128a3..6b057ae31 100644
--- a/ship_from_release.go
+++ b/ship_from_release.go
@@ -294,25 +294,44 @@ func (s *apiSession) shipFromRelease(ctx context.Context, a apiAcct, app string,
}
return apiShipResult{}, err
}
+ out, err := checkFromReleaseAnswer(m, body)
+ if err != nil {
+ return apiShipResult{}, err
+ }
+ return apiShipResult{NoOp: status == http.StatusOK, Version: out.Version, BuildProbe: out.BuildProbe}, nil
+}
+
+// fromReleaseAnswer is the part of a ship answer a copied release reads.
+type fromReleaseAnswer struct {
+ Version string `json:"version"`
+ BuildProbe string `json:"build_probe"`
+ Assets *release.Assets `json:"assets"`
+}
+
+// checkFromReleaseAnswer checks a successful ship answer for m: every echo
+// a plain ship checks, the asset folders, then the stored digests.
+func checkFromReleaseAnswer(m *release.Manifest, body []byte) (fromReleaseAnswer, error) {
+ var out fromReleaseAnswer
+ if err := json.Unmarshal(body, &out); err != nil {
+ return out, fmt.Errorf("ship: malformed response: %w", err)
+ }
+ var assets []string
+ if m.Assets != nil {
+ assets = m.Assets.Paths
+ }
for _, err := range []error{
checkCapabilitiesEcho(m.Capabilities, body),
checkStatelessEcho(m.Stateless, body),
checkMailEcho(m.Mail, body),
checkSwapEcho(m.Swap, body),
+ checkAssetsEcho(assets, out.Assets),
compareShippedArtifacts(m.Artifacts, body),
} {
if err != nil {
- return apiShipResult{}, err
+ return out, err
}
}
- var out struct {
- Version string `json:"version"`
- BuildProbe string `json:"build_probe"`
- }
- if err := json.Unmarshal(body, &out); err != nil {
- return apiShipResult{}, fmt.Errorf("ship: malformed response: %w", err)
- }
- return apiShipResult{NoOp: status == http.StatusOK, Version: out.Version, BuildProbe: out.BuildProbe}, nil
+ return out, nil
}
// compareShippedArtifacts refuses a ship answer whose artifacts differ from
diff --git a/ship_from_release_test.go b/ship_from_release_test.go
index 35a586f5d..96b9fa318 100644
--- a/ship_from_release_test.go
+++ b/ship_from_release_test.go
@@ -1,9 +1,12 @@
package main
import (
+ "crypto/sha256"
+ "encoding/hex"
"os"
"os/exec"
"path/filepath"
+ "strconv"
"strings"
"testing"
@@ -56,13 +59,48 @@ func TestCompareShippedArtifacts(t *testing.T) {
}
func TestLoadReleaseDirRefusesUnsafeNames(t *testing.T) {
- dir := t.TempDir()
- manifest := `{"schema":1,"app":"shop","version":"v12","kind":"binary","artifacts":{"linux-arm64":{"file":"../x","sha256":"` + strings.Repeat("a", 64) + `","size":1}}}`
+ // ../x exists beside dir and matches the manifest, so only the name
+ // check stands between the manifest and a file outside dir.
+ root := t.TempDir()
+ dir := filepath.Join(root, "release")
+ if err := os.Mkdir(dir, 0o755); err != nil {
+ t.Fatal(err)
+ }
+ outside := []byte("outside")
+ if err := os.WriteFile(filepath.Join(root, "x"), outside, 0o644); err != nil {
+ t.Fatal(err)
+ }
+ sum := sha256.Sum256(outside)
+ manifest := `{"schema":1,"app":"shop","version":"v12","kind":"binary","artifacts":{"linux-arm64":{"file":"../x","sha256":"` +
+ hex.EncodeToString(sum[:]) + `","size":` + strconv.Itoa(len(outside)) + `}}}`
if err := os.WriteFile(filepath.Join(dir, "manifest.json"), []byte(manifest), 0o644); err != nil {
t.Fatal(err)
}
- if _, _, err := loadReleaseDir(dir); err == nil {
- t.Fatal("loadReleaseDir accepted a file named ../x")
+ _, _, err := loadReleaseDir(dir)
+ if err == nil || !strings.Contains(err.Error(), `names a file "../x" that cannot be read safely`) {
+ t.Fatalf("loadReleaseDir of a manifest naming ../x = %v, want the unsafe-name refusal", err)
+ }
+}
+
+func TestCheckFromReleaseAnswerAssets(t *testing.T) {
+ sha := strings.Repeat("a", 64)
+ m := &release.Manifest{
+ Version: "v12", Kind: "binary", Assets: &release.Assets{Paths: []string{"/assets/", "/img/"}},
+ Artifacts: map[string]release.Artifact{"linux-arm64": {File: "linux-arm64", SHA256: sha, Size: 10}},
+ }
+ arts := `"artifacts":{"linux-arm64":{"sha256":"` + sha + `","size":10}}`
+ for _, tc := range []struct {
+ name, body string
+ ok bool
+ }{
+ {"same folders", `{"version":"v12",` + arts + `,"assets":{"paths":["/img/","/assets/"]}}`, true},
+ {"no assets echoed", `{"version":"v12",` + arts + `}`, false},
+ {"other folders", `{"version":"v12",` + arts + `,"assets":{"paths":["/assets/"]}}`, false},
+ } {
+ _, err := checkFromReleaseAnswer(m, []byte(tc.body))
+ if (err == nil) != tc.ok {
+ t.Fatalf("%s: err = %v, want ok %v", tc.name, err, tc.ok)
+ }
}
}