Refuse all fork pull requests on IUCLabs runners #593
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user