From abff1959767a05ac7ec6149824f7171720f676a0 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:27:33 -0800 Subject: [PATCH 1/3] ci: refuse internal names in a pull request's public text A check on the lines a pull request adds, its commit messages, its title and its description: internal seat names and internal file-share paths are refused, each hit printed with file and line. Runs beside the spec trace check from the base branch; no pull request code is run. Co-Authored-By: Claude Fable 5.2 --- .../.github/scripts/public-text-check-test.sh | 32 +++++++++++++++ .../.github/scripts/public-text-check.sh | 41 +++++++++++++++++++ .../.github/workflows/spec-trace.yml | 6 +++ 3 files changed, 79 insertions(+) create mode 100755 seaweed-block/.github/scripts/public-text-check-test.sh create mode 100755 seaweed-block/.github/scripts/public-text-check.sh diff --git a/seaweed-block/.github/scripts/public-text-check-test.sh b/seaweed-block/.github/scripts/public-text-check-test.sh new file mode 100755 index 0000000000..a05d393a8f --- /dev/null +++ b/seaweed-block/.github/scripts/public-text-check-test.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Self-test of public-text-check.sh in a throwaway repository. +set -euo pipefail +here=$(cd "$(dirname "$0")" && pwd) +t=$(mktemp -d); trap 'rm -rf "$t"' EXIT +cd "$t"; git init -q .; git config user.email t@example.invalid; git config user.name t +echo base > a.txt; git add a.txt; git commit -q -m "base" +mb=$(git rev-parse HEAD) +: > title; : > body +run() { bash "$here/public-text-check.sh" "$@" >out 2>&1; } +expect() { # expect RC NAME + local want=$1 name=$2 rc=0 + shift 2 + run "$@" || rc=$? + [ "$rc" = "$want" ] || { echo "public-text-check-test: $name: exit $rc, want $want"; cat out; exit 1; } +} +echo "plain line" >> a.txt; git commit -q -am "add a plain line" +expect 0 "clean change" "$mb" HEAD title body +seat="clau""de06"; path="V:/sha""re/x"; nas="share/rd""ma/y" +echo "// asked by $seat" >> a.txt; git commit -q -am "comment" +expect 1 "seat name in an added line" "$mb" HEAD title body +grep -q "a.txt:3" out || { echo "public-text-check-test: hit does not name file and line"; cat out; exit 1; } +git reset -q --hard HEAD~1 +echo "ok" >> a.txt; git commit -q -am "review by $seat" +expect 1 "seat name in a commit subject" "$mb" HEAD title body +git reset -q --hard HEAD~1 +echo "see $path" > title; expect 1 "share path in the title" "$mb" HEAD title body; : > title +echo "results under $nas" > body; expect 1 "share path in the description" "$mb" HEAD title body; : > body +echo "an old line with $seat" >> a.txt; git commit -q -am "old"; mb2=$(git rev-parse HEAD) +echo "new clean line" >> a.txt; git commit -q -am "new" +expect 0 "an existing line is not this change's" "$mb2" HEAD title body +echo "public-text-check-test: ok" diff --git a/seaweed-block/.github/scripts/public-text-check.sh b/seaweed-block/.github/scripts/public-text-check.sh new file mode 100755 index 0000000000..9400c384f4 --- /dev/null +++ b/seaweed-block/.github/scripts/public-text-check.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# Refuses internal names in what a pull request makes public: the lines it +# adds, its commit messages, its title and its description. This repository is +# public; internal seat names and internal file-share paths do not belong in it. +# +# Usage: public-text-check.sh MERGE_BASE HEAD TITLE_FILE BODY_FILE +# Exit 0: clean. Exit 1: at least one hit (each printed). Exit 2: usage. +# +# The patterns live only here and in this check's own test; both files are +# excluded from the scan of added lines. +set -euo pipefail +[ "$#" -eq 4 ] || { echo "usage: public-text-check.sh MERGE_BASE HEAD TITLE_FILE BODY_FILE" >&2; exit 2; } +mb=$1; head=$2; title=$3; body=$4 +pat='(claude|codex)0[0-9]|share/rdma|V:[/\]share|diskstation' +out=$(mktemp); trap 'rm -f "$out"' EXIT +report() { # report WHERE < matching lines + local where=$1 line + while IFS= read -r line; do + printf 'public-text: %s: %s +' "$where" "${line:0:160}" >>"$out" + done +} +# Added lines of the diff, with file and line number. +git diff --no-color --no-renames -U0 "$mb" "$head" -- . \ + ':(exclude).github/scripts/public-text-check.sh' ':(exclude).github/scripts/public-text-check-test.sh' | + awk ' + /^\+\+\+ / { f = substr($0, 7); next } + /^@@ / { split($3, a, ","); n = substr(a[1], 2) + 0; next } + /^\+/ { print f ":" n ": " substr($0, 2); n++ } + ' | { grep -E -i -- "$pat" || true; } | report "added line" +# Commit messages (subjects and bodies) of the pull request. +git log --format='%h %s%n%b' "$mb..$head" | { grep -E -i -- "$pat" || true; } | report "commit message" +{ grep -E -i -- "$pat" "$title" || true; } | report "title" +{ grep -E -i -- "$pat" "$body" || true; } | report "description" +hits=$(wc -l <"$out" | tr -d ' ') +if [ "$hits" -gt 0 ]; then + cat "$out" + echo "public-text: $hits hit(s). Say what the code or test does instead of who asked for it; keep internal paths out." >&2 + exit 1 +fi +echo "public-text: clean" diff --git a/seaweed-block/.github/workflows/spec-trace.yml b/seaweed-block/.github/workflows/spec-trace.yml index 2e09b1c3cb..7bd9bdaa40 100644 --- a/seaweed-block/.github/workflows/spec-trace.yml +++ b/seaweed-block/.github/workflows/spec-trace.yml @@ -43,6 +43,7 @@ jobs: HEAD: ${{ github.event.pull_request.head.sha }} PR: ${{ github.event.pull_request.number }} BODY: ${{ github.event.pull_request.body }} + TITLE: ${{ github.event.pull_request.title }} run: | set -euo pipefail bash .github/scripts/spec-trace-check-test.sh @@ -60,3 +61,8 @@ jobs: done mkdir -p blobs bash .github/scripts/spec-trace-check.sh body.txt blobs title.txt + bash .github/scripts/public-text-check.sh "$mb" "$HEAD" title.txt body.txt From eba1949fb182a9a8b33be45f2c1ec4d3aaa49a88 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:32:48 -0800 Subject: [PATCH 2/3] ci: public-text check: header-like added lines, backslash paths, unreadable inputs An added line that begins with '++ ' is an added line, not a diff header; the share path is matched with either slash; a missing title or description file, an unknown commit or a failing grep is an error (exit 2), never 'clean'. Controls for each in the self-test; each fails on the previous script. Co-Authored-By: Claude Fable 5.2 --- .../.github/scripts/public-text-check-test.sh | 12 ++++++++++ .../.github/scripts/public-text-check.sh | 24 ++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/seaweed-block/.github/scripts/public-text-check-test.sh b/seaweed-block/.github/scripts/public-text-check-test.sh index a05d393a8f..964c440636 100755 --- a/seaweed-block/.github/scripts/public-text-check-test.sh +++ b/seaweed-block/.github/scripts/public-text-check-test.sh @@ -29,4 +29,16 @@ echo "results under $nas" > body; expect 1 "share path in the description" "$mb" echo "an old line with $seat" >> a.txt; git commit -q -am "old"; mb2=$(git rev-parse HEAD) echo "new clean line" >> a.txt; git commit -q -am "new" expect 0 "an existing line is not this change's" "$mb2" HEAD title body +# A file line that begins with "++ " shows in the diff as "+++ ...": an added line, not a header. +printf '%s +' "++ $seat" >> a.txt; git commit -q -am "plus line" +expect 1 "an added line that looks like a diff header" "$mb2" HEAD title body +git reset -q --hard HEAD~1 +bs=$(printf '\') +printf '%s +' "${bs}${bs}nas${bs}sha""re${bs}rd""ma${bs}z" > title +expect 1 "backslash form of the share path in the title" "$mb2" HEAD title body; : > title +expect 2 "a missing title file is an error, not clean" "$mb2" HEAD no-such-title body +expect 2 "a missing description file is an error, not clean" "$mb2" HEAD title no-such-body +expect 2 "an unknown commit is an error, not clean" 0000000000000000000000000000000000000000 HEAD title body echo "public-text-check-test: ok" diff --git a/seaweed-block/.github/scripts/public-text-check.sh b/seaweed-block/.github/scripts/public-text-check.sh index 9400c384f4..3146d095c5 100755 --- a/seaweed-block/.github/scripts/public-text-check.sh +++ b/seaweed-block/.github/scripts/public-text-check.sh @@ -11,7 +11,14 @@ set -euo pipefail [ "$#" -eq 4 ] || { echo "usage: public-text-check.sh MERGE_BASE HEAD TITLE_FILE BODY_FILE" >&2; exit 2; } mb=$1; head=$2; title=$3; body=$4 -pat='(claude|codex)0[0-9]|share/rdma|V:[/\]share|diskstation' +for f in "$title" "$body"; do + [ -f "$f" ] && [ -r "$f" ] || { echo "public-text: cannot read $f" >&2; exit 2; } +done +git rev-parse -q --verify "$mb^{commit}" >/dev/null && git rev-parse -q --verify "$head^{commit}" >/dev/null || + { echo "public-text: unknown commit $mb or $head" >&2; exit 2; } +# match: a grep error fails the check instead of reading as "no hit". +match() { local rc=0; grep -E -i -- "$pat" "$@" || rc=$?; [ "$rc" -le 1 ] || { echo "public-text: grep failed ($rc)" >&2; exit 2; }; } +pat='(claude|codex)0[0-9]|share[/\]rdma|V:[/\]share|diskstation' out=$(mktemp); trap 'rm -f "$out"' EXIT report() { # report WHERE < matching lines local where=$1 line @@ -24,14 +31,15 @@ report() { # report WHERE < matching lines git diff --no-color --no-renames -U0 "$mb" "$head" -- . \ ':(exclude).github/scripts/public-text-check.sh' ':(exclude).github/scripts/public-text-check-test.sh' | awk ' - /^\+\+\+ / { f = substr($0, 7); next } - /^@@ / { split($3, a, ","); n = substr(a[1], 2) + 0; next } - /^\+/ { print f ":" n ": " substr($0, 2); n++ } - ' | { grep -E -i -- "$pat" || true; } | report "added line" + /^diff --git / { hdr = 1; next } + hdr && /^\+\+\+ / { f = substr($0, 7); next } + /^@@ / { hdr = 0; split($3, a, ","); n = substr(a[1], 2) + 0; next } + !hdr && /^\+/ { print f ":" n ": " substr($0, 2); n++ } + ' | match | report "added line" # Commit messages (subjects and bodies) of the pull request. -git log --format='%h %s%n%b' "$mb..$head" | { grep -E -i -- "$pat" || true; } | report "commit message" -{ grep -E -i -- "$pat" "$title" || true; } | report "title" -{ grep -E -i -- "$pat" "$body" || true; } | report "description" +git log --format='%h %s%n%b' "$mb..$head" | match | report "commit message" +match "$title" | report "title" +match "$body" | report "description" hits=$(wc -l <"$out" | tr -d ' ') if [ "$hits" -gt 0 ]; then cat "$out" From 2cf83f5922f8d843a3e92f694100c772b4d86930 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:53:20 -0800 Subject: [PATCH 3/3] ci: public-text check self-test: a failing grep refuses Co-Authored-By: Claude Fable 5.2 --- seaweed-block/.github/scripts/public-text-check-test.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/seaweed-block/.github/scripts/public-text-check-test.sh b/seaweed-block/.github/scripts/public-text-check-test.sh index 964c440636..a59dc7e096 100755 --- a/seaweed-block/.github/scripts/public-text-check-test.sh +++ b/seaweed-block/.github/scripts/public-text-check-test.sh @@ -41,4 +41,11 @@ expect 1 "backslash form of the share path in the title" "$mb2" HEAD title body; expect 2 "a missing title file is an error, not clean" "$mb2" HEAD no-such-title body expect 2 "a missing description file is an error, not clean" "$mb2" HEAD title no-such-body expect 2 "an unknown commit is an error, not clean" 0000000000000000000000000000000000000000 HEAD title body +# A grep that fails (exit 2) is an error: the check must refuse and never print "clean". +mkdir -p fakebin; printf '#!/bin/sh +exit 2 +' > fakebin/grep; chmod +x fakebin/grep +rc=0; PATH="$PWD/fakebin:$PATH" bash "$here/public-text-check.sh" "$mb2" HEAD title body >out 2>&1 || rc=$? +[ "$rc" = 2 ] || { echo "public-text-check-test: failing grep: exit $rc, want 2"; cat out; exit 1; } +if PATH=/usr/bin:/bin grep -q "clean" out; then echo "public-text-check-test: failing grep printed clean"; cat out; exit 1; fi echo "public-text-check-test: ok"