diff --git a/.github/dapper-unfixed.json b/.github/dapper-unfixed.json index bf93a522..e76856a9 100644 --- a/.github/dapper-unfixed.json +++ b/.github/dapper-unfixed.json @@ -3857,6 +3857,50 @@ "officialSourcePackage": "libheif", "reason": "Official Ubuntu CVE tracker resolute_libheif: needed; no official fixed version. Exact existing disposable-builder package only; no general severity exemption.", "checkedAt": "2026-11-05" + }, + { + "id": "CVE-2026-82560", + "package": "libperl5.40", + "version": "5.40.1-7ubuntu0.3", + "purl": "pkg:deb/ubuntu/libperl5.40@5.40.1-7ubuntu0.3?arch=amd64&distro=ubuntu-26.04", + "severity": "MEDIUM", + "status": "no_official_fix", + "officialEvidence": "https://ubuntu.com/security/CVE-2026-82560", + "reason": "Ubuntu26.04 remains vulnerable without a released fix. Exact Dapper build-only package; Trivy Ubuntu severity MEDIUM. Upstream CVSS7.5 remains disclosed.", + "checkedAt": "2026-11-05" + }, + { + "id": "CVE-2026-82560", + "package": "perl", + "version": "5.40.1-7ubuntu0.3", + "purl": "pkg:deb/ubuntu/perl@5.40.1-7ubuntu0.3?arch=amd64&distro=ubuntu-26.04", + "severity": "MEDIUM", + "status": "no_official_fix", + "officialEvidence": "https://ubuntu.com/security/CVE-2026-82560", + "reason": "Ubuntu26.04 remains vulnerable without a released fix. Exact Dapper build-only package; Trivy Ubuntu severity MEDIUM. Upstream CVSS7.5 remains disclosed.", + "checkedAt": "2026-11-05" + }, + { + "id": "CVE-2026-82560", + "package": "perl-base", + "version": "5.40.1-7ubuntu0.3", + "purl": "pkg:deb/ubuntu/perl-base@5.40.1-7ubuntu0.3?arch=amd64&distro=ubuntu-26.04", + "severity": "MEDIUM", + "status": "no_official_fix", + "officialEvidence": "https://ubuntu.com/security/CVE-2026-82560", + "reason": "Ubuntu26.04 remains vulnerable without a released fix. Exact Dapper build-only package; Trivy Ubuntu severity MEDIUM. Upstream CVSS7.5 remains disclosed.", + "checkedAt": "2026-11-05" + }, + { + "id": "CVE-2026-82560", + "package": "perl-modules-5.40", + "version": "5.40.1-7ubuntu0.3", + "purl": "pkg:deb/ubuntu/perl-modules-5.40@5.40.1-7ubuntu0.3?arch=all&distro=ubuntu-26.04", + "severity": "MEDIUM", + "status": "no_official_fix", + "officialEvidence": "https://ubuntu.com/security/CVE-2026-82560", + "reason": "Ubuntu26.04 remains vulnerable without a released fix. Exact Dapper build-only package; Trivy Ubuntu severity MEDIUM. Upstream CVSS7.5 remains disclosed.", + "checkedAt": "2026-11-05" } ] } diff --git a/.github/workflows/security-release-gate.yml b/.github/workflows/security-release-gate.yml index 85571360..03cf8248 100644 --- a/.github/workflows/security-release-gate.yml +++ b/.github/workflows/security-release-gate.yml @@ -21,7 +21,7 @@ jobs: env: DAPPER_IMAGE: pasturestack/compose-cli-dapper:${{ github.sha }} TRIVY_IMAGE: aquasec/trivy:0.74.0@sha256:62b1e65e8869bc4b4c6aa4fa2b21595256c7c2f6018a9d9ad61caf87187c1969 - VERSION_OVERRIDE: 0.14.42 + VERSION_OVERRIDE: 0.14.43 PLATFORM_COMPAT_JAR_URL: https://github.com/PastureStack/orchestration-engine/releases/download/v0.183.281/orchestration-engine-0.183.281.jar PLATFORM_COMPAT_JAR_SHA256: da2a8a51562ed16e296f7e29e99482bb44042ff0834cca679bbe01d951ba1682 @@ -71,7 +71,7 @@ jobs: } run_ci - artifact="dist/artifacts/compose-executor-0.14.42-linux-amd64.gz" + artifact="dist/artifacts/compose-executor-0.14.43-linux-amd64.gz" test -s "$artifact" cp "$artifact" /tmp/compose-executor-first.gz @@ -83,7 +83,7 @@ jobs: mkdir -p evidence/product gzip -cd "$artifact" > evidence/product/compose-executor chmod +x evidence/product/compose-executor - evidence/product/compose-executor --version | grep -F '0.14.42' >/dev/null + evidence/product/compose-executor --version | grep -F '0.14.43' >/dev/null cp "$artifact" evidence/ ( cd evidence diff --git a/docs/releases/compose-executor-0.14.43.md b/docs/releases/compose-executor-0.14.43.md new file mode 100644 index 00000000..b4644af5 --- /dev/null +++ b/docs/releases/compose-executor-0.14.43.md @@ -0,0 +1,31 @@ +# Compose Executor v0.14.43 — release candidate + +This candidate is not published. The current published release remains +[v0.14.42](https://github.com/PastureStack/compose-cli/releases/tag/v0.14.42). + +Catalog preview and delegated creation now share one hash owner. It projects +only typed SDK response envelopes before hashing and hashes the owned Stack +binding symbolically, while the actual request retains its exact bound Stack. +This keeps the approved body stable across the native transform response and +Stack creation. The Engine's exact-body checks and authorization are unchanged. + +Business metadata, labels, environment, ports, volumes and security settings +remain intact. Empty hash-output maps are restored without changing user data. + +Ordinary and legacy Compose hash and serialization paths remain unchanged. +An explicit ordinary Compose `up` or `upgrade` that later takes over a service +created with the Catalog hash may detect one initial hash difference. This +does not trigger an automatic update or relax any permission check. + +Local focused source tests are not matching Server/Catalog runtime acceptance. +Publication requires the original CI artifact and component-bound security +qualification; no runtime result is claimed by this note. + +The disposable builder also records four exact Perl-package findings for +[CVE-2026-82560](https://ubuntu.com/security/CVE-2026-82560) at +`5.40.1-7ubuntu0.3`. Canonical still lists Ubuntu 26.04 as vulnerable without +a released package fix. Canonical priority and Ubuntu-sourced Trivy severity +are MEDIUM; the upstream CVSS 7.5 +High assessment remains disclosed. This build-only tracking is not a runtime +clean claim. Available fixes, severity increases and identity changes still +fail the existing security policy. diff --git a/platformapi/catalog_finalize.go b/platformapi/catalog_finalize.go index 453514b1..d0562c10 100644 --- a/platformapi/catalog_finalize.go +++ b/platformapi/catalog_finalize.go @@ -64,6 +64,6 @@ func CatalogFinalizeService(primary CatalogLaunchPart, secondaries []CatalogLaun if err := populateLbFields(&PlatformService{name: primary.Name, serviceConfig: primary.Config}, &launch, body); err != nil { return "", nil, err } - _, body, err = serviceConfigAndHash(body, &launch, secondaryLaunches) + _, body, err = catalogServiceConfigAndHash(body, &launch, secondaryLaunches) return typeName, body, err } diff --git a/platformapi/catalog_service_hash.go b/platformapi/catalog_service_hash.go new file mode 100644 index 00000000..10d6c078 --- /dev/null +++ b/platformapi/catalog_service_hash.go @@ -0,0 +1,63 @@ +package platformapi + +import ( + "bytes" + "encoding/json" + + "github.com/PastureStack/compose-cli/digest" + client "github.com/PastureStack/compose-cli/internal/rancherclient/v2" +) + +// Catalog hashes describe the approved typed request, before the owned Stack +// slot is bound. Native transform response envelopes and deployment-assigned +// Stack IDs must not change those hashes. Ordinary/legacy hashing is unchanged. +func catalogServiceConfigAndHash(service *CompositeService, launch *client.LaunchConfig, secondaries []client.SecondaryLaunchConfig) (digest.ServiceHash, *CompositeService, error) { + if service == nil || launch == nil { + return digest.ServiceHash{}, nil, errCatalogGraph + } + input := *service + input.LaunchConfig = launch + input.SecondaryLaunchConfigs = secondaries + wire, err := client.CatalogMutationRequest(&input) + if err != nil { + return digest.ServiceHash{}, nil, err + } + raw, err := json.Marshal(wire) + if err != nil { + return digest.ServiceHash{}, nil, err + } + var canonical CompositeService + decoder := json.NewDecoder(bytes.NewReader(raw)) + decoder.UseNumber() + if err := decoder.Decode(&canonical); err != nil { + return digest.ServiceHash{}, nil, err + } + launch = canonical.LaunchConfig + secondaries = canonical.SecondaryLaunchConfigs + if launch == nil { + return digest.ServiceHash{}, nil, errCatalogGraph + } + // JSON omitempty can drop empty maps. Restore only the maps this existing + // hash owner writes; business entries and numeric values remain unchanged. + if canonical.Metadata == nil { + canonical.Metadata = map[string]interface{}{} + } + if launch.Labels == nil { + launch.Labels = map[string]interface{}{} + } + for index := range secondaries { + if secondaries[index].Labels == nil { + secondaries[index].Labels = map[string]interface{}{} + } + } + canonical.LaunchConfig = nil + canonical.SecondaryLaunchConfigs = nil + boundStackID := canonical.StackId + canonical.StackId = "$createdStack" + hash, body, err := serviceConfigAndHash(&canonical, launch, secondaries) + if err != nil { + return digest.ServiceHash{}, nil, err + } + body.StackId = boundStackID + return hash, body, nil +} diff --git a/platformapi/catalog_service_hash_test.go b/platformapi/catalog_service_hash_test.go new file mode 100644 index 00000000..a26f5100 --- /dev/null +++ b/platformapi/catalog_service_hash_test.go @@ -0,0 +1,154 @@ +package platformapi + +import ( + "bytes" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "fmt" + "io" + "net/http" + "net/http/httptest" + "reflect" + "testing" + + "github.com/PastureStack/compose-cli/config" + "github.com/PastureStack/compose-cli/digest" + client "github.com/PastureStack/compose-cli/internal/rancherclient/v2" + "github.com/PastureStack/compose-cli/project" + "github.com/PastureStack/compose-cli/yaml" +) + +func TestCatalogHashEmptyMapsAndInvalidInputs(t *testing.T) { + for _, empty := range []bool{false, true} { + t.Run(fmt.Sprintf("explicitEmpty=%v", empty), func(t *testing.T) { + body := &CompositeService{Service: client.Service{Name: "app", StackId: "1st1600"}} + launch := &client.LaunchConfig{ImageUuid: "docker:busybox:1.37.0"} + secondaries := []client.SecondaryLaunchConfig{{Name: "side", ImageUuid: "docker:busybox:1.37.0"}} + if empty { + body.Metadata = map[string]interface{}{} + launch.Labels = map[string]interface{}{} + secondaries[0].Labels = map[string]interface{}{} + } + hash, result, err := catalogServiceConfigAndHash(body, launch, secondaries) + if err != nil || hash.Service == "" || hash.LaunchConfig == "" || result.StackId != "1st1600" || + result.Metadata[digest.ServiceHashKey] != hash.Service || result.LaunchConfig.Labels[digest.ServiceHashKey] != hash.LaunchConfig || + result.SecondaryLaunchConfigs[0].Labels[digest.ServiceHashKey] != hash.SecondaryLaunchConfigs["side"] { + t.Fatal("empty-map roundtrip did not produce writable owned hash slots") + } + if len(body.Metadata) != 0 || len(launch.Labels) != 0 || len(secondaries[0].Labels) != 0 { + t.Fatal("hash completion mutated the caller's empty business maps") + } + }) + } + for _, input := range []struct { + body *CompositeService + launch *client.LaunchConfig + }{ + {nil, &client.LaunchConfig{}}, {&CompositeService{}, nil}, + } { + if _, _, err := catalogServiceConfigAndHash(input.body, input.launch, nil); err == nil { + t.Fatal("missing typed service/launch input was accepted") + } + } +} + +func TestCatalogHashPreservesTypedBusinessMapsNumbersAndSource(t *testing.T) { + business := map[string]interface{}{"id": "business-id", "type": "business-type", "links": nil, + "actions": []interface{}{"business-action"}, "large": json.Number("9007199254740993"), "fraction": json.Number("1.25")} + header := client.Resource{Id: "response-id", Type: "container", Links: map[string]string{"self": "response-link"}, Actions: map[string]string{"act": "response-action"}} + body := &CompositeService{Service: client.Service{Name: "app", StackId: "1st1600", Metadata: business}} + launch := &client.LaunchConfig{Resource: header, ImageUuid: "docker:busybox:1.37.0", Labels: business, Environment: business, + Ports: []string{"8080:80/tcp"}, DataVolumes: []string{"/data"}, CapAdd: []string{"NET_BIND_SERVICE"}, SecurityOpt: []string{"no-new-privileges"}, + LogConfig: &client.LogConfig{Resource: header, Driver: "json-file", Config: business}} + secondaries := []client.SecondaryLaunchConfig{{Resource: header, Name: "side", ImageUuid: "docker:busybox:1.37.0", Labels: business}} + input := *body + input.LaunchConfig, input.SecondaryLaunchConfigs = launch, secondaries + before, _ := json.Marshal(&input) + want, err := client.CatalogMutationRequest(&input) + if err != nil { + t.Fatal("typed business fixture failed") + } + _, result, err := catalogServiceConfigAndHash(body, launch, secondaries) + if err != nil { + t.Fatal("Catalog hash rejected valid typed business fields") + } + got, err := client.CatalogMutationRequest(result) + if err != nil { + t.Fatal("hashed body is not a typed mutation") + } + delete(got["metadata"].(map[string]interface{}), digest.ServiceHashKey) + delete(got["launchConfig"].(map[string]interface{})["labels"].(map[string]interface{}), digest.ServiceHashKey) + for _, item := range got["secondaryLaunchConfigs"].([]interface{}) { + delete(item.(map[string]interface{})["labels"].(map[string]interface{}), digest.ServiceHashKey) + } + if !reflect.DeepEqual(want, got) { + t.Fatal("business keys, numbers or typed configuration changed beyond the owned hash slots") + } + after, _ := json.Marshal(&input) + if !bytes.Equal(before, after) { + t.Fatal("Catalog hash projection mutated the source DTO or business maps") + } +} + +// This golden is captured from the published 0.14.42 source with the same +// synthetic native transform. It covers both legacy/no-proof SDK callers. +func TestNonDelegatedFactoryKeeps042HashAndRequestBytes(t *testing.T) { + const expected042SHA256 = "50f022028ee449288ae7ffe5bf8600b01e5a3417141c8005e225c960ed853135" + var actual []byte + var server *httptest.Server + server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Header.Get(client.CatalogLaunchDelegationHeader) != "" { + t.Error("nondelegated caller acquired delegation authority") + } + w.Header().Set("Content-Type", "application/json") + switch r.URL.Path { + case "/schemas": + w.Header().Set("X-API-Schemas", server.URL+"/schemas") + fmt.Fprintf(w, `{"links":{"self":%q},"data":[{"id":"service","collectionMethods":["POST"],"links":{"collection":%q}}]}`, server.URL+"/schemas", server.URL+"/services") + case "/scripts/transform": + fmt.Fprint(w, `{"type":"container","links":{"self":"response-link"},"actions":{"act":"response-action"},"imageUuid":"docker:busybox:1.37.0","labels":{"id":"business-id"},"environment":{"type":"business-type"}}`) + case "/services": + actual, _ = io.ReadAll(io.LimitReader(r.Body, 1<<20)) + fmt.Fprint(w, `{}`) + default: + t.Error("nondelegated fixture received an unexpected route") + w.WriteHeader(http.StatusNotFound) + } + })) + defer server.Close() + c, err := client.NewRancherClient(&client.ClientOpts{Url: server.URL + "/schemas"}) + if err != nil { + t.Fatal("synthetic ordinary bootstrap failed") + } + cfg := &config.ServiceConfig{Image: "busybox:1.37.0", Labels: yaml.SliceorMap{}} + cfg.Metadata = map[string]interface{}{"type": "business-type"} + ctx := &Context{Client: c, Stack: &client.Stack{Resource: client.Resource{Id: "1st1600"}}} + p := project.NewProject(&ctx.Context) + ctx.Project = p + p.ServiceConfigs.Add("app", cfg) + ctx.SidekickInfo, err = NewSidekickInfo(p) + if err != nil { + t.Fatal("ordinary sidekick fixture failed") + } + worker := NewService("app", cfg, ctx) + factory := &NormalFactory{} + hash, err := factory.Hash(worker) + if err != nil || factory.Create(worker) != nil { + t.Fatal("ordinary factory path failed") + } + var posted client.Service + if json.Unmarshal(actual, &posted) != nil { + t.Fatal("ordinary SDK emitted invalid JSON") + } + stored, complete := digest.LookupHash(&posted) + if !complete || !hash.Equals(stored) || posted.LaunchConfig.Type != "container" || posted.LaunchConfig.Links["self"] != "response-link" { + t.Fatal("ordinary hash/update or original resource-envelope behavior changed") + } + sum := sha256.Sum256(actual) + gotSHA := hex.EncodeToString(sum[:]) + t.Logf("synthetic ordinary request SHA256 only: %s", gotSHA) + if gotSHA != expected042SHA256 { + t.Fatal("nondelegated request bytes differ from the published042 worker baseline") + } +} diff --git a/platformapi/catalog_worker_wire_test.go b/platformapi/catalog_worker_wire_test.go new file mode 100644 index 00000000..152c6da7 --- /dev/null +++ b/platformapi/catalog_worker_wire_test.go @@ -0,0 +1,226 @@ +package platformapi + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "reflect" + "sort" + "strings" + "testing" + + "github.com/PastureStack/compose-cli/config" + "github.com/PastureStack/compose-cli/digest" + client "github.com/PastureStack/compose-cli/internal/rancherclient/v2" + "github.com/PastureStack/compose-cli/project" + "github.com/PastureStack/compose-cli/project/options" + "github.com/PastureStack/compose-cli/utils" + "github.com/PastureStack/compose-cli/yaml" +) + +// No QA, Docker, credentials or external endpoint. This executes the real worker +// PlatformService.Create -> transform -> NormalFactory -> generated SDK POST, +// rather than sending a manually assembled Service directly to the SDK. +func TestCatalogWorkerCreateMatchesPreviewAfterNativeTransformResponse(t *testing.T) { + for _, envelope := range []bool{false, true} { + for _, actualStack := range []string{"$createdStack", "1st1600"} { + for _, changedApproval := range []bool{false, true} { + if changedApproval && (!envelope || actualStack == "$createdStack") { + continue + } + t.Run(fmt.Sprintf("nativeResourceEnvelope=%v/boundStack=%v/changedApproval=%v", envelope, actualStack != "$createdStack", changedApproval), func(t *testing.T) { + flat := map[string]interface{}{"imageUuid": "docker:busybox:1.37.0", "labels": map[string]interface{}{"business": "kept"}, + "environment": map[string]interface{}{"id": "business-id", "type": "business-type", "links": "business-links", "actions": "business-actions"}, + "logConfig": map[string]interface{}{"config": map[string]interface{}{}}, "ports": []string{"80/tcp"}} + transform := map[string]interface{}{} + for key, value := range flat { + transform[key] = value + } + if envelope { + // JsonResponseWriter wraps TransformInspect's InstanceRecord as a + // Resource; Engine's preview deliberately supplies getFields only. + transform["type"] = "container" + transform["links"] = map[string]interface{}{} + transform["actions"] = map[string]interface{}{} + } + flatBytes, _ := json.Marshal(flat) + newConfig := func() *config.ServiceConfig { + cfg := &config.ServiceConfig{Image: "busybox:1.37.0", Labels: yaml.SliceorMap{}, + Environment: yaml.MaporEqualSlice{"actions=business-actions", "id=business-id", "links=business-links", "type=business-type"}} + cfg.Metadata = map[string]interface{}{"id": "business-id", "links": "business-links"} + return cfg + } + kind, preview, err := CatalogFinalizeService(CatalogLaunchPart{Name: "app", Config: newConfig(), Transform: flatBytes}, nil, nil) + if err != nil { + t.Fatal("preview owner failed") + } + want, err := client.CatalogMutationRequest(CatalogServiceRequestPayload(kind, preview)) + if err != nil { + t.Fatal("preview wire projection failed") + } + want["stackId"] = actualStack // Same sole top-level binding as Engine graphs.bind. + var normalizedWant map[string]interface{} + b, _ := json.Marshal(want) + _ = json.Unmarshal(b, &normalizedWant) + if changedApproval { + normalizedWant["launchConfig"].(map[string]interface{})["environment"].(map[string]interface{})["type"] = "other-business-value" + } + posted := map[string]interface{}{} + sequence := []string{} + created := false + var server *httptest.Server + serviceRow := func() map[string]interface{} { + return map[string]interface{}{"id": "1s1", "name": "app", "state": "inactive", "stackId": actualStack, + "actions": map[string]string{"setservicelinks": server.URL + "/v2-beta/services/1s1?action=setservicelinks"}} + } + server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Header.Get(client.CatalogLaunchDelegationHeader) != "synthetic-event-proof" { + t.Error("actual worker lost delegation proof") + } + sequence = append(sequence, r.Method+" "+r.URL.Path) + w.Header().Set("Content-Type", "application/json") + switch r.URL.Path { + case "/v2-beta/schemas": + w.Header().Set("X-API-Schemas", server.URL+"/v2-beta/schemas") + fmt.Fprintf(w, `{"links":{"self":%q},"data":[{"id":"service","collectionMethods":["GET","POST"],"links":{"collection":%q}},{"id":"serviceConsumeMap","collectionMethods":["GET"],"links":{"collection":%q}}]}`, + server.URL+"/v2-beta/schemas", server.URL+"/v2-beta/services", server.URL+"/v2-beta/serviceConsumeMaps") + case "/v2-beta/scripts/transform": + if r.Method != "POST" { + t.Error("transform must be actual POST") + } + _ = json.NewEncoder(w).Encode(transform) + case "/v2-beta/services": + if r.Method == "POST" { + _ = json.NewDecoder(r.Body).Decode(&posted) + if !reflect.DeepEqual(normalizedWant, posted) { + w.WriteHeader(http.StatusForbidden) + fmt.Fprint(w, `{"code":"CatalogLaunchDelegationDenied"}`) + return + } + created = true + w.WriteHeader(http.StatusCreated) + _ = json.NewEncoder(w).Encode(serviceRow()) + } else if created { + _ = json.NewEncoder(w).Encode(map[string]interface{}{"data": []interface{}{serviceRow()}}) + } else { + fmt.Fprint(w, `{"data":[]}`) + } + case "/v2-beta/serviceConsumeMaps": + fmt.Fprint(w, `{"data":[]}`) + case "/v2-beta/services/1s1": + if r.Method != "POST" || r.URL.Query().Get("action") != "setservicelinks" { + t.Error("unexpected worker action") + } + _ = json.NewEncoder(w).Encode(serviceRow()) + default: + t.Error("unexpected closed worker route") + w.WriteHeader(http.StatusNotFound) + } + })) + defer server.Close() + c, err := client.NewRancherClient(&client.ClientOpts{Url: server.URL + "/v2-beta/schemas", CatalogLaunchDelegation: "synthetic-event-proof"}) + if err != nil { + t.Fatal("synthetic native schema bootstrap failed") + } + ctx := &Context{Client: c, Stack: &client.Stack{Resource: client.Resource{Id: actualStack}}, CatalogLaunchDelegation: "synthetic-event-proof"} + p := project.NewProject(&ctx.Context) + ctx.Project = p + cfg := newConfig() + p.ServiceConfigs.Add("app", cfg) + ctx.SidekickInfo, err = NewSidekickInfo(p) + if err != nil { + t.Fatal("worker sidekick owner setup failed") + } + err = NewService("app", cfg, ctx).Create(context.Background(), options.Create{}) + atTransform, atCreate := -1, -1 + for i, step := range sequence { + if step == "POST /v2-beta/scripts/transform" { + atTransform = i + } + if step == "POST /v2-beta/services" { + atCreate = i + } + } + if atTransform < 0 || atCreate != atTransform+1 { + t.Fatal("next worker request is not the actual service collection POST") + } + if changedApproval { + denied, ok := err.(*client.ApiError) + if !ok || denied.StatusCode != http.StatusForbidden || created || atCreate != len(sequence)-1 { + t.Fatal("changed approved business body did not fail closed before create/link") + } + return + } + if err != nil { + paths := differingSafePaths(normalizedWant, posted, "") + sort.Strings(paths) + t.Fatalf("full worker denied at structural paths only (no private values/digests): %s", strings.Join(paths, ",")) + } + if !reflect.DeepEqual(normalizedWant, posted) { + paths := differingSafePaths(normalizedWant, posted, "") + sort.Strings(paths) + t.Fatalf("approved-vs-actual structural paths only (no values/digests): %s", strings.Join(paths, ",")) + } + }) + } + } + } +} + +func TestCatalogWorkerHashBoundariesUseActualNestedYamlMaps(t *testing.T) { + cfg := &config.ServiceConfig{Labels: yaml.SliceorMap{}} + symbolic := serviceCreateFields("app", cfg, "$createdStack") + bound := serviceCreateFields("app", cfg, "1st1600") + var converted map[interface{}]interface{} + if utils.Convert(symbolic, &converted) != nil { + t.Fatal("actual YAML owner conversion failed") + } + nested, ok := converted["service"].(map[string]interface{}) + if !ok || nested["stack_id"] != "$createdStack" { + t.Fatal("actual nested YAML shape differs from hypothesis") + } + flat := &client.LaunchConfig{Labels: map[string]interface{}{}} + withResource := *flat + withResource.Resource = client.Resource{Type: "container", Links: map[string]string{}, Actions: map[string]string{}} + a, errA := digest.CreateServiceHash(symbolic, flat, nil) + b, errB := digest.CreateServiceHash(bound, flat, nil) + c, errC := digest.CreateServiceHash(symbolic, &withResource, nil) + if errA != nil || errB != nil || errC != nil { + t.Fatal("actual digest owner failed") + } + if a.Service == b.Service || a.LaunchConfig != b.LaunchConfig { + t.Fatal("bound Stack independence hypothesis is not reproduced") + } + if a.Service != c.Service || a.LaunchConfig == c.LaunchConfig { + t.Fatal("typed response envelope influence is not reproduced") + } +} + +func differingSafePaths(a, b interface{}, prefix string) []string { + if reflect.DeepEqual(a, b) { + return nil + } + am, aok := a.(map[string]interface{}) + bm, bok := b.(map[string]interface{}) + if !aok || !bok { + return []string{prefix} + } + keys := map[string]bool{} + for key := range am { + keys[key] = true + } + for key := range bm { + keys[key] = true + } + result := []string{} + for key := range keys { + path := key + if prefix != "" { + path = prefix + "." + key + } + result = append(result, differingSafePaths(am[key], bm[key], path)...) + } + return result +} diff --git a/platformapi/normal.go b/platformapi/normal.go index 69661724..0641900f 100644 --- a/platformapi/normal.go +++ b/platformapi/normal.go @@ -22,6 +22,9 @@ func (f *NormalFactory) configAndHash(r *PlatformService) (digest.ServiceHash, * if err != nil { return digest.ServiceHash{}, nil, err } + if r.Context().CatalogLaunchDelegation != "" { + return catalogServiceConfigAndHash(platformService, launchConfig, secondaryLaunchConfigs) + } return serviceConfigAndHash(platformService, launchConfig, secondaryLaunchConfigs) }