diff --git a/apps/base/iuclabs-runners/job-started.sh b/apps/base/iuclabs-runners/job-started.sh index aadc0cc..925b04d 100755 --- a/apps/base/iuclabs-runners/job-started.sh +++ b/apps/base/iuclabs-runners/job-started.sh @@ -33,13 +33,9 @@ esac case "${event}" in push | workflow_dispatch | schedule | merge_group | release) ;; pull_request) - trusted=$(jq -r ' - .pull_request.head.repo.full_name as $head - | if $head == null then false - elif $head == .repository.full_name then true - else (.pull_request.author_association | IN("OWNER", "MEMBER", "COLLABORATOR")) - end' "${GITHUB_EVENT_PATH}") || refuse "event payload unreadable" - [ "${trusted}" = true ] || refuse "pull request from untrusted fork" + same=$(jq -r '.pull_request.head.repo.full_name != null + and .pull_request.head.repo.full_name == .repository.full_name' "${GITHUB_EVENT_PATH}") || refuse "event payload unreadable" + [ "${same}" = true ] || refuse "pull request from a fork" ;; *) refuse "event not allowed on self-hosted runners" ;; esac diff --git a/ci/test-runner-hooks.sh b/ci/test-runner-hooks.sh index 69b3a8a..31d3b5d 100755 --- a/ci/test-runner-hooks.sh +++ b/ci/test-runner-hooks.sh @@ -29,7 +29,7 @@ done for e in push workflow_dispatch schedule merge_group release; do check 0 default "$e" push.json done -check 0 default pull_request pr-member.json +check 1 default pull_request pr-member.json check 0 default pull_request pr-same-repo.json check 1 default pull_request pr-fork-none.json check 1 default pull_request pr-fork-spoofed.json @@ -62,6 +62,7 @@ for r in terraform-git terraform-vault terraform-artifactapi terraform-authentik check 0 infra push push.json "IUCLabs/$r" check 0 infra pull_request pr-same-repo.json "IUCLabs/$r" check 1 infra pull_request pr-fork-none.json "IUCLabs/$r" + check 1 infra pull_request pr-member.json "IUCLabs/$r" check 1 infra issue_comment issue-comment.json "IUCLabs/$r" done for r in IUCLabs/app IUCLabs/terraform-netbox iuclabs/terraform-git evil/terraform-git IUCLabs/terraform-git-x "IUCLabs/terraform-git "; do