From 5e2917ce2416f6b11d378c8f2706f0b3e0b2c964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Wed, 25 Nov 2026 07:18:14 +0100 Subject: [PATCH 1/4] fix(automation): fill the bump PR body in a single pass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The renderer scanned each line again after a substitution and looked up any {{UPPER_CASE}} key in ENVIRON. Text inside an inserted value, such as the upstream proto diff, could therefore pull in any variable of the core-watch step, including GH_TOKEN, and publish it in the PR body. Substitute left to right and never rescan inserted text, and accept only the keys the template uses. An unknown placeholder in the template now fails the run. Signed-off-by: Roland Huß --- hack/automation/open-bump-pr.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/hack/automation/open-bump-pr.sh b/hack/automation/open-bump-pr.sh index 990267c..dc7c38f 100755 --- a/hack/automation/open-bump-pr.sh +++ b/hack/automation/open-bump-pr.sh @@ -151,15 +151,29 @@ fixtures=$(cat "$work/fixtures.txt") # A fresh tag's images may not be pushed yet; new releases go to Quay. registry=$(core_registry "${tag#v}") || registry=quay.io/ai-openshell body="$work/body.md" +# Fill the template in one pass over each template line. Inserted values are +# never scanned again, so upstream text such as "{{GH_TOKEN}}" in the proto +# diff stays literal, and only the keys listed here are read from ENVIRON. OLD="$old" NEW="$tag" KIND="$kind" COMPARE_URL="$compare_url" IMAGE="$registry/gateway:${tag#v}" \ GENERATED="${generated:-no generated files changed}" FIXTURES="${fixtures:-- no fixture changes}" \ PROTO_DIFF="$proto_section" \ - awk '{ - while (match($0, /\{\{[A-Z_]+\}\}/)) { - key = substr($0, RSTART + 2, RLENGTH - 4) - $0 = substr($0, 1, RSTART - 1) ENVIRON[key] substr($0, RSTART + RLENGTH) + awk 'BEGIN { + n = split("OLD NEW KIND COMPARE_URL IMAGE GENERATED FIXTURES PROTO_DIFF", keys, " ") + for (i = 1; i <= n; i++) allowed[keys[i]] = 1 + } + { + rest = $0 + out = "" + while (match(rest, /\{\{[A-Z_]+\}\}/)) { + key = substr(rest, RSTART + 2, RLENGTH - 4) + if (!(key in allowed)) { + printf "ERROR: unknown placeholder {{%s}} in %s\n", key, FILENAME > "/dev/stderr" + exit 1 + } + out = out substr(rest, 1, RSTART - 1) ENVIRON[key] + rest = substr(rest, RSTART + RLENGTH) } - print + print out rest }' "$body_tmpl" >"$body" echo "Proposal for $tag ($kind), pin $old -> $tag:" From 6b7a1af80d3186817109f15df3de0a89bdeabfec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Wed, 25 Nov 2026 09:32:49 +0100 Subject: [PATCH 2/4] fix(automation): share the template renderer and test it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the single-pass renderer into fill-template.awk behind fill-template.sh, which takes KEY=value arguments, so every placeholder key is named once. hack/migration/port-pr.sh had the same rescanning loop and inserts commit subjects and author names from the core PR; it now uses the shared renderer too. fill-template-test.sh, part of workflows:check, checks that placeholder text in values stays literal (under a timeout, so a rescanning loop fails), that unknown placeholders fail, and that both real templates render completely. Signed-off-by: Roland Huß --- hack/automation/README.md | 2 + hack/automation/fill-template-test.sh | 96 +++++++++++++++++++++++++++ hack/automation/fill-template.awk | 30 +++++++++ hack/automation/fill-template.sh | 30 +++++++++ hack/automation/open-bump-pr.sh | 30 ++------- hack/migration/README.md | 2 +- hack/migration/port-pr.sh | 14 ++-- mise.toml | 3 +- 8 files changed, 172 insertions(+), 35 deletions(-) create mode 100755 hack/automation/fill-template-test.sh create mode 100644 hack/automation/fill-template.awk create mode 100755 hack/automation/fill-template.sh diff --git a/hack/automation/README.md b/hack/automation/README.md index 969857c..cac2278 100644 --- a/hack/automation/README.md +++ b/hack/automation/README.md @@ -9,6 +9,8 @@ Workflows run them with a token of the `ai-openshell-sdk-go` GitHub App (`ai-ope | `core-tags.sh` | `core:tags` | List ai-openshell/openshell release tags newer than the pin (`buf.gen.yaml`, `inputs[0].tag`), semver-sorted with pre-releases below their stable version. | | `open-bump-pr.sh [--dry-run]` | `core:bump` | Open the update proposal for one core tag: branch `core/`, pin change, regenerated bindings, proto diff in the body, labels `core-bump` plus `stable` or `prerelease`. Closes older pre-release proposals. | | `bump-pr-body.md` | | PR body template for `open-bump-pr.sh`. | +| `fill-template.sh