From 120d3d32d183dc54852a62beff34d9ba62f8f325 Mon Sep 17 00:00:00 2001 From: itvi-1234 Date: Mon, 16 Nov 2026 13:18:46 +0530 Subject: [PATCH] Embed the core schema in the validator of release builds scripts/release-package.py builds the release binaries on its own and set only the core schema of the linked Go profiler. rc's validator reads its core schema from its own variable, so a released rc would have refused rc profile validate with 'no verified core profile schema'. The release build now sets both variables, as scripts/build.go does. --- internal/validate/embed_test.go | 24 ++++++++++++++++++++++++ scripts/release-package.py | 7 +++++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 internal/validate/embed_test.go diff --git a/internal/validate/embed_test.go b/internal/validate/embed_test.go new file mode 100644 index 0000000..7d59d47 --- /dev/null +++ b/internal/validate/embed_test.go @@ -0,0 +1,24 @@ +package validate + +import ( + "os" + "strings" + "testing" +) + +// Both ways of building rc embed the core schema through linker flags: scripts/build.go for local +// and CI builds, scripts/release-package.py for the release archives and packages. The release +// build once set only the Go profiler's variable, so a released rc refused to validate. CI builds +// with build.go only, so nothing else would notice that again. +func TestEveryBuildEmbedsTheCoreSchemaInTheValidator(t *testing.T) { + const variable = "github.com/runtimeconditions/rc-cli/internal/validate.coreSchemaBase64" + for _, script := range []string{"../../scripts/build.go", "../../scripts/release-package.py"} { + data, err := os.ReadFile(script) + if err != nil { + t.Fatal(err) + } + if !strings.Contains(string(data), variable) { + t.Errorf("%s does not set %s, so a build made with it cannot validate profiles", script, variable) + } + } +} diff --git a/scripts/release-package.py b/scripts/release-package.py index 4be3094..45818bc 100644 --- a/scripts/release-package.py +++ b/scripts/release-package.py @@ -125,9 +125,12 @@ def main(): env = dict(os.environ, CGO_ENABLED="0", GOOS=goos, GOARCH=goarch) binary = work / target / "bin/rc" binary.parent.mkdir(parents=True) + # The core schema is embedded twice: for the linked Go profiler and for rc's own validator. + # scripts/build.go sets the same two variables. + encoded_schema = base64.b64encode(core_schema).decode("ascii") linker_flags = "-X main.version=" + args.version + " -X main.commit=" + args.commit + \ - " -X github.com/runtimeconditions/go-rc-profiler/extensioncheck.installedCoreSchemaBase64=" + \ - base64.b64encode(core_schema).decode("ascii") + " -X github.com/runtimeconditions/go-rc-profiler/extensioncheck.installedCoreSchemaBase64=" + encoded_schema + \ + " -X github.com/runtimeconditions/rc-cli/internal/validate.coreSchemaBase64=" + encoded_schema run(["go", "build", "-trimpath", "-buildvcs=false", "-ldflags", linker_flags, "-o", str(binary), "./cmd/rc"], env=env) prefix = work / target / "prefix"