How to store/create/access global pre-receive hooks? #7484

Closed
opened 2025-11-02 07:27:01 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @Chewibub on GitHub (Jun 19, 2021).

Tried adding a hooks folder in the gitea-repositories folder (separate to the one within repos), and using:
git config --global core.hooksPath <path/to/hooks>
but that didn't work. Tested adding server side hooks to the hook folder within the repo and those work, but I'm looking for a solution to have the hook be present in all repo within the gitea server.

Also, is there an easy way to push hooks to the gitea server from within a local repo? Have the server hosted within kubernetes, making it pretty difficult.

Thanks!

Originally created by @Chewibub on GitHub (Jun 19, 2021). Tried adding a hooks folder in the gitea-repositories folder (separate to the one within repos), and using: `git config --global core.hooksPath <path/to/hooks>` but that didn't work. Tested adding server side hooks to the hook folder within the repo and those work, but I'm looking for a solution to have the hook be present in all repo within the gitea server. Also, is there an easy way to push hooks to the gitea server from within a local repo? Have the server hosted within kubernetes, making it pretty difficult. Thanks!
GiteaMirror added the type/question label 2025-11-02 07:27:01 -06:00
Author
Owner

@zeripath commented on GitHub (Jun 21, 2021):

You can set the DISABLE_GIT_HOOKS option to false and then the admin will get a nice UI to add hooks.

Regarding core.hooksPath we want to use that in future to take complete control of hooks within gitea, so you would likely have found that breaking at some point.

edit by @techknowlogick reminder re: enabling git Hooks: "WARNING: Custom git hooks can be used to perform arbitrary code execution on the host operating system. This enables the users to access and modify this config file and the Gitea database and interrupt the Gitea service. By modifying the Gitea database, users can gain Gitea administrator privileges. It also enables them to access other resources available to the user on the operating system that is running the Gitea instance and perform arbitrary actions in the name of the Gitea OS user. This maybe harmful to you website or your operating system."

@zeripath commented on GitHub (Jun 21, 2021): You can set the DISABLE_GIT_HOOKS option to false and then the admin will get a nice UI to add hooks. Regarding core.hooksPath we want to use that in future to take complete control of hooks within gitea, so you would likely have found that breaking at some point. edit by @techknowlogick reminder re: enabling git Hooks: "WARNING: Custom git hooks can be used to perform arbitrary code execution on the host operating system. This enables the users to access and modify this config file and the Gitea database and interrupt the Gitea service. By modifying the Gitea database, users can gain Gitea administrator privileges. It also enables them to access other resources available to the user on the operating system that is running the Gitea instance and perform arbitrary actions in the name of the Gitea OS user. This maybe harmful to you website or your operating system."
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7484