fix: use pull_request_target to enable E2E tests for Dependabot PRs#156
fix: use pull_request_target to enable E2E tests for Dependabot PRs#156Copilot wants to merge 4 commits into
Conversation
Agent-Logs-Url: https://github.com/Azure/AKSFlexNode/sessions/a69a3c91-5ece-41a0-8102-b1689fb66122 Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
bcho
left a comment
There was a problem hiding this comment.
we do want dependabot's PRs to run with e2e tests
…secrets Agent-Logs-Url: https://github.com/Azure/AKSFlexNode/sessions/3e091818-6e1c-44d4-b0ab-5fd531d60ed0 Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Addressed in commit |
Add an `if` condition on the e2e job so that when triggered by pull_request_target only PRs from the same repository or from dependabot[bot] run with repository secrets. External fork PRs are skipped, preventing arbitrary users from exfiltrating credentials. Agent-Logs-Url: https://github.com/Azure/AKSFlexNode/sessions/15f8caea-8942-44c2-93e8-f3b77db9ae9c Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Yes — that was a real risk with the original Fixed in if: |
github.event_name != 'pull_request_target' ||
github.event.pull_request.head.repo.full_name == github.repository ||
github.actor == 'dependabot[bot]'This means:
|
Dependabot PRs run with Dependabot-scoped secrets only and cannot access regular repository secrets under the
pull_requestevent, causing the E2E job to always fail withE2E_RESOURCE_GROUP: Set E2E_RESOURCE_GROUP in environment or .env.Change
Switch the E2E workflow trigger from
pull_requesttopull_request_target, which runs in the base-branch context and has full access to repository secrets even for Dependabot PRs. The checkout step is explicitly pinned togithub.event.pull_request.head.shaso the actual PR code is tested rather than the base-branch code:A job-level
ifguard is added to prevent the knownpull_request_targetsecurity risk where arbitrary fork PRs could execute untrusted code with repository secrets. Only PRs from within the same repository or fromdependabot[bot]are allowed to run:This allows Dependabot PRs and internal team PRs to run E2E tests with the required Azure credentials, while external fork PRs are skipped and never receive repository secrets.