تخطَّ إلى المحتوى

pull_request_target checks out the pull request (ARCH10032)

هذا المحتوى غير متوفر بلغتك بعد.

Key config.ci.pull-request-target-checkout · Severity error · Category security · CWE CWE-829

A pull_request_target workflow runs in the base repository’s context, with its secrets and a write token. Checking out the pull request’s head there and building or testing it runs code anyone can propose with those rights.

on: pull_request_target
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: npm ci && npm test
on: pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm test

Use pull_request for anything that builds or runs the change; keep a pull_request_target job away from the change’s code (labels, comments).

  • actions/checkout without a ref in a pull_request_target workflow: it checks out the base branch.