Emit warning for pull_request_target trigger usage (#410)

* Emit warning when used with pull_request_target trigger
This commit is contained in:
Stefan Zweifel
2026-06-27 14:33:12 +02:00
committed by GitHub
parent d28176c21f
commit c365a749b4
4 changed files with 76 additions and 1 deletions
+12
View File
@@ -35,6 +35,8 @@ _main() {
_check_if_repository_is_in_detached_state
_check_for_pull_request_target_trigger
if "$INPUT_CREATE_GIT_TAG_ONLY"; then
_log "debug" "Create git tag only";
_set_github_output "create_git_tag_only" "true"
@@ -107,6 +109,16 @@ _check_if_is_git_repository() {
fi
}
_check_for_pull_request_target_trigger() {
if "$INPUT_DISABLE_PULL_REQUEST_TARGET_TRIGGER_WARNING"; then
return
fi
if [ "${GITHUB_EVENT_NAME:-}" = "pull_request_target" ]; then
_log "warning" "git-auto-commit is running on a 'pull_request_target' event. This trigger can be a security risk: a malicious pull request could potentially exfiltrate your repository secrets. See https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target and the 'pull_request_target' section in the git-auto-commit README (https://github.com/stefanzweifel/git-auto-commit-action#using-the-action-in-a-pull_request_target-workflow) for safer usage. Set 'disable_pull_request_target_trigger_warning: true' to suppress this warning.";
fi
}
_check_if_repository_is_in_detached_state() {
if [ -z "$(git symbolic-ref HEAD)" ]
then