From 448289a41dce2009038d3bee06e59ca914ced148 Mon Sep 17 00:00:00 2001 From: Peter Paul Bakker Date: Fri, 20 Nov 2026 12:37:34 +0000 Subject: [PATCH] test: reject floating /latest/ URIs in the manifest Google replaces the content behind a floating URI without changing it, so the pinned sha256 breaks when the vendor republishes, and the packager reuses a stale cached download. Adds a short Version section to the Stackdriver profiler doc. --- docs/framework-google_stackdriver_profiler.md | 3 ++ src/java/frameworks/manifest_uris_test.go | 42 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/java/frameworks/manifest_uris_test.go diff --git a/docs/framework-google_stackdriver_profiler.md b/docs/framework-google_stackdriver_profiler.md index e10b98ca80..8c0b6b117b 100644 --- a/docs/framework-google_stackdriver_profiler.md +++ b/docs/framework-google_stackdriver_profiler.md @@ -16,6 +16,9 @@ The Google Stackdriver Profiler Framework causes an application to be automatica Tags are printed to standard output by the buildpack detect script +## Version +The agent version is the version of the Google release, `vX.Y.Z` of [GoogleCloudPlatform/cloud-profiler-java](https://github.com/GoogleCloudPlatform/cloud-profiler-java/releases). The default version pin `0.x` resolves to it. + ## User-Provided Service (Optional) Users may optionally provide their own Google Stackdriver Profiler service. A user-provided Google Stackdriver Profiler service must have a name or tag with `google-stackdriver-profiler` in it so that the Google Stackdriver Profiler Agent Framework will automatically configure the application to work with the service. diff --git a/src/java/frameworks/manifest_uris_test.go b/src/java/frameworks/manifest_uris_test.go new file mode 100644 index 0000000000..5d7ba5418a --- /dev/null +++ b/src/java/frameworks/manifest_uris_test.go @@ -0,0 +1,42 @@ +package frameworks_test + +import ( + "os" + "path/filepath" + "strings" + "testing" + + "go.yaml.in/yaml/v3" +) + +// A dependency URI must point to one fixed artifact. A floating URI such as +// .../latest/... changes content without changing the URI, so the pinned sha256 +// breaks whenever the vendor republishes, and the packager keeps reusing a stale +// download that is cached under the URI. +func TestManifestDependencyURIsAreNotFloating(t *testing.T) { + data, err := os.ReadFile(filepath.Join("..", "..", "..", "manifest.yml")) + if err != nil { + t.Fatalf("read manifest.yml: %v", err) + } + + var manifest struct { + Dependencies []struct { + Name string `yaml:"name"` + Version string `yaml:"version"` + URI string `yaml:"uri"` + } `yaml:"dependencies"` + } + if err := yaml.Unmarshal(data, &manifest); err != nil { + t.Fatalf("parse manifest.yml: %v", err) + } + if len(manifest.Dependencies) == 0 { + t.Fatal("no dependencies found in manifest.yml") + } + + for _, dependency := range manifest.Dependencies { + if strings.Contains(dependency.URI, "/latest/") { + t.Errorf("%s %s has a floating uri, use the versioned artifact instead: %s", + dependency.Name, dependency.Version, dependency.URI) + } + } +}