fix(ci): close the bypasses of the bot pull request diff guard

A change git treats as binary (NUL byte, UTF-16, a -diff attribute) or one with
no removed or no added line now fails, and the line diff runs with --text
--no-ext-diff --no-textconv. Tags are limited to [A-Za-z0-9._-]; the digest must
be present on both sides of an ubuntu job container line and of a FROM line;
matrix version lines must stay in place and rise; paths are taken literally
(--literal-pathspecs); an empty head ref on a pull_request fails closed
(EVENT_NAME). The lint workflow runs the guard from origin/main (the whole
scripts/ directory, since it imports check_image_versions) and falls back to
the pull request's copy with a notice while main has none.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-10-26 06:41:20 +00:00
1 parent a57714342b
commit 8e9a8c5df0
3 files changed
+189 -13

No files matched your search

+16 -2
View File
@@ -87,15 +87,29 @@ jobs:
# A pull request from a renovate/ branch may only move version, tag, digest and pin
# lines (scripts/check_bot_pr_diff.py), so the bot's automerge cannot change workflow
# logic or reach the org secrets. The branch name is attacker-controlled: this only
# constrains the bot's own pull requests. The refs go through env:, never into run:.
# constrains the bot's own pull requests. The guard runs from origin/main, never from the
# pull request's own copy (a PR could weaken it); the whole scripts/ directory comes from
# the base because the guard imports check_image_versions. Not -I: that drops the
# script's directory from sys.path and the import would fail; -E -s ignore the
# environment and user site. Until origin/main has the script (the PR that introduces it)
# the PR copy runs, with a notice. The refs go through env:, never into run:.
- name: Check a bot pull request only moves pins
if: github.event_name == 'pull_request'
env:
HEAD_REF: ${{ github.head_ref }}
BASE_REF: origin/main
EVENT_NAME: ${{ github.event_name }}
run: |
export PATH="/opt/venv/bin:$PATH"
python3 scripts/check_bot_pr_diff.py "$HEAD_REF" "$BASE_REF"
guard=scripts/check_bot_pr_diff.py
if git cat-file -e "$BASE_REF:scripts/check_bot_pr_diff.py" 2>/dev/null; then
base_dir="$(mktemp -d "${RUNNER_TEMP:-/tmp}/base.XXXXXX")"
git archive "$BASE_REF" scripts | tar -x -C "$base_dir"
guard="$base_dir/scripts/check_bot_pr_diff.py"
else
echo "::notice::$BASE_REF has no scripts/check_bot_pr_diff.py yet; running the pull request's copy"
fi
python3 -E -s "$guard" "$HEAD_REF" "$BASE_REF"
- name: Test the repository scripts
run: |