Skip to content

Commit 45cf589

Browse files
Copilotkolaente
andcommitted
docs: enhance security comments in pr-docker workflow
Add detailed security rationale for using pull_request_target to address CodeQL alert and make the safety of this pattern explicit for reviewers. Co-authored-by: kolaente <13721712+kolaente@users.noreply.github.com>
1 parent 6068faf commit 45cf589

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

.github/workflows/pr-docker.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ name: PR Docker Build
22

33
on:
44
# Use pull_request_target instead of pull_request to get write access to GHCR
5-
# even for PRs from forks. This is safe because we explicitly checkout the PR's
6-
# code and only build a Docker image (no arbitrary code execution in the workflow).
5+
# even for PRs from forks. This is safe because:
6+
# 1. We explicitly checkout the PR's head commit (no base branch code execution)
7+
# 2. We ONLY build a Docker image (isolated container, no workflow scripts from PR)
8+
# 3. No actions that execute PR code in the workflow context (no github-script, etc)
9+
# 4. Build happens in isolated Docker container with well-defined Dockerfile
10+
# This is the recommended pattern for building/publishing PR images from forks.
711
pull_request_target:
812

913
jobs:
@@ -16,7 +20,9 @@ jobs:
1620
- name: Checkout
1721
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
1822
with:
19-
# Checkout the PR's head commit for accurate builds
23+
# SECURITY: Explicitly checkout PR's head commit, not base branch.
24+
# This is safe because no PR code is executed in workflow context.
25+
# Only Docker build uses the PR code (isolated in container).
2026
ref: ${{ github.event.pull_request.head.sha }}
2127
- name: Git describe
2228
id: ghd

0 commit comments

Comments
 (0)