Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion .github/workflows/dev-lead-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,43 @@
with:
token: ${{ secrets.GH_PAT_DON_PETRY || secrets.GH_PAT_WORKFLOWS || github.token }}

- name: Validate dev-lead ref input
shell: bash
env:
AGENT_REF: ${{ inputs.agent_ref }}
run: |
ref="$AGENT_REF"
if [ -z "$ref" ]; then
ref="main"
fi

# Block untrusted PR refs and unsafe ref formats.
if [[ "$ref" =~ ^refs/pull/ ]]; then
echo "::error::inputs.agent_ref must not be a pull-request ref: $ref"
exit 1
fi
if [[ "$ref" =~ ^[0-9a-fA-F]{40}$ ]]; then
echo "::error::inputs.agent_ref must not be a raw commit SHA: $ref"
exit 1
fi
if [[ "$ref" == *".."* || "$ref" == *":"* || "$ref" =~ [[:space:]] ]]; then
echo "::error::inputs.agent_ref contains unsafe characters: $ref"
exit 1
fi
if [[ ! "$ref" =~ ^[A-Za-z0-9._/-]+$ ]]; then
echo "::error::inputs.agent_ref contains invalid characters: $ref"
exit 1
fi

echo "SAFE_AGENT_REF=$ref" >> "$GITHUB_ENV"
Comment on lines +254 to +278

- name: Checkout dev-lead scripts
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: petry-projects/.github-private
# Pinned channel (e.g. dev-lead/stable) when a trigger stub passes it;
# defaults to "main" → unchanged behaviour (#535/#506).
ref: ${{ inputs.agent_ref }}
ref: ${{ env.SAFE_AGENT_REF }}
path: .dev-lead
# Cross-repo callers: github.token cannot read a private org repo — ensure
# GH_PAT_WORKFLOWS is set as an org or repo secret in the calling repo.
Expand Down
Loading