Skip to content

Commit ac692e1

Browse files
authored
chore: fix permissions for called workflow (#1934)
## Summary Follow-up to open-component-model/ocm-integrationtest#90, which hardens the called integration test workflow by removing the OCMBOT token generation and switching to unprivileged checkouts. ## Changes - **Downgrade `contents: write` to `contents: read`**: The called workflow no longer requires write access (report upload and repo pushes were removed in the companion PR). - **Remove `secrets: inherit`**: The called workflow no longer declares any `workflow_call` secrets — OCMBOT tokens are not needed since both repos are public and only read access is required. - **Switch `pull_request_target` to `pull_request`**: The `pull_request_target` trigger was only needed because the called workflow required secrets to generate a token for checkout. Now that no secrets are needed, plain `pull_request` provides the same functionality without the security risk of running untrusted fork code with access to repo secrets. - **Remove job-level `permissions` block**: The old called workflow required `contents: write`, `id-token: write`, and `packages: write`, which had to be explicitly granted at the job level since the caller's top-level permissions didn't include them. After the companion PR, the called workflow only needs `contents: read`, which is already covered by the caller's top-level `permissions` block — no additional job-level escalation is needed. - **Pin called workflow to commit SHA**: The `@main` reference is now pinned to `8b914397e79353d1f0b441295d7b1d36676849c3` to address the `unpinned-uses` finding from zizmor. ## Dependencies This PR must be merged **after** open-component-model/ocm-integrationtest#90, which removes the secrets requirement and token generation from the called workflow. (Already merged.) --------- Signed-off-by: Frederic Wilhelm <frederic.wilhelm@sap.com>
1 parent 8fefc86 commit ac692e1

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

.github/workflows/integration-test.yaml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,18 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request_target:
7+
pull_request:
88
branches:
99
- main
1010
workflow_dispatch:
1111

1212
permissions:
13-
# Necessary to write the branch
14-
# TODO: Remove once https://github.com/open-component-model/ocm-integrationtest/blob/main/.github/workflows/integrationtest.yaml#L41 is not needed anymore
15-
contents: write
13+
contents: read
1614

1715
jobs:
1816
test:
1917
name: Run
20-
uses: open-component-model/ocm-integrationtest/.github/workflows/integrationtest.yaml@main
21-
permissions:
22-
contents: write
23-
id-token: write
24-
packages: write
25-
secrets: inherit
18+
uses: open-component-model/ocm-integrationtest/.github/workflows/integrationtest.yaml@8b914397e79353d1f0b441295d7b1d36676849c3 # main
2619
with:
27-
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.ref || github.ref }}
28-
repo: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name || github.repository }}
20+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }}
21+
repo: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}

0 commit comments

Comments
 (0)