From 06e4b142fd564ae3261a1882d8d93fb34966c6ab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Apr 2026 21:45:43 +0000 Subject: [PATCH 1/4] Initial plan From 870f297e2b0fd7589b32cbceb901285ef5cc7402 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Apr 2026 21:47:51 +0000 Subject: [PATCH 2/4] fix: skip E2E tests for dependabot PRs (no secrets access) Agent-Logs-Url: https://github.com/Azure/AKSFlexNode/sessions/a69a3c91-5ece-41a0-8102-b1689fb66122 Co-authored-by: bcho <1975118+bcho@users.noreply.github.com> --- .github/workflows/e2e-tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 70270243..d65ccdf7 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -35,6 +35,10 @@ env: jobs: e2e: name: E2E Tests (MSI + Token) + # Dependabot PRs only bump dependency versions and cannot access repository + # secrets (they run with Dependabot-scoped secrets only). Skip E2E tests + # for such PRs to avoid always-failing runs due to missing credentials. + if: github.actor != 'dependabot[bot]' runs-on: [self-hosted, e2e, azure] timeout-minutes: 45 environment: e2e-testing From 2e69fbd7b19457dc8824a90447e5a58361f0e51d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Apr 2026 21:54:35 +0000 Subject: [PATCH 3/4] fix: use pull_request_target so dependabot PRs can access repository 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> --- .github/workflows/e2e-tests.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index d65ccdf7..85551e62 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -18,7 +18,12 @@ on: tags: - "v*" - pull_request: + # pull_request_target runs in the context of the base branch, giving the + # workflow access to repository secrets even for Dependabot PRs (which only + # receive Dependabot-scoped secrets under the plain pull_request event). + # The checkout step below pins to the PR head SHA so the actual PR code is + # tested, not the base-branch code. + pull_request_target: branches: [main, dev] types: [opened, synchronize, reopened] @@ -35,10 +40,6 @@ env: jobs: e2e: name: E2E Tests (MSI + Token) - # Dependabot PRs only bump dependency versions and cannot access repository - # secrets (they run with Dependabot-scoped secrets only). Skip E2E tests - # for such PRs to avoid always-failing runs due to missing credentials. - if: github.actor != 'dependabot[bot]' runs-on: [self-hosted, e2e, azure] timeout-minutes: 45 environment: e2e-testing @@ -46,6 +47,10 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + # Explicitly check out the PR head commit; with pull_request_target + # the default checkout is the base branch, not the PR branch. + ref: ${{ github.event.pull_request.head.sha }} - name: Set up Go uses: actions/setup-go@v5 From c17cb79ea00ae239b8f5e675f1bbe32b57d30547 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Apr 2026 22:30:07 +0000 Subject: [PATCH 4/4] fix: guard pull_request_target job against external fork PRs 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> --- .github/workflows/e2e-tests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 85551e62..44e0e25b 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -43,6 +43,14 @@ jobs: runs-on: [self-hosted, e2e, azure] timeout-minutes: 45 environment: e2e-testing + # For pull_request_target, only run when the PR originates from the same + # repository (team members) or from dependabot[bot]. External fork PRs + # must NOT receive repository secrets, even though pull_request_target + # would otherwise grant them access. + if: | + github.event_name != 'pull_request_target' || + github.event.pull_request.head.repo.full_name == github.repository || + github.actor == 'dependabot[bot]' steps: - name: Checkout code