From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Dmytro Lymarenko <dmytro.lymarenko@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [RFC] Optional per-repository consent before running local hooks
Date: Tue, 29 Sep 2026 21:32:28 +0000 [thread overview]
Message-ID: <arwubFmKkRcbbto3@fruit.crustytoothpaste.net> (raw)
In-Reply-To: <CAF1QGTmK=WY_AODsfETOtzOSuwpZ_4KV5SiNPoRv0SAYeJ7T5A@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1954 bytes --]
On 2026-09-29 at 04:23:43, Dmytro Lymarenko wrote:
> I’d like to propose an optional safety setting for Git hooks. When
> enabled, Git would check for an active hook before running it in a
> repository that the user has not approved. It would show the hook’s
> path and ask whether to run it once, trust the current hooks for this
> repository, or decline.
In addition to what Junio said, we need to consider what happens if Git
operates noninteractively. For instance, a CI system or a Docker
container.
> This would help when a tool or setup step installs hooks from files
> supplied by a project. The check should happen immediately before
> execution, so it also covers hooks installed after a repository was
> cloned. For scripts inside the working tree, Git should ask again if
> the approved script changes.
I agree this is undesirable behaviour from a project and I typically
consider installing hooks or other external software from the repository
without the user's consent to be malicious. Installing hooks from
things like Git LFS I consider less of a problem because I have
installed that software and configured it on my system, so I presumably
want that behaviour.
The problem also becomes where to store this information because Git
doesn't have any sort of data store to store per-user information other
than the config file and as Junio mentioned, if the repository can
install hooks, it can also set config.
What may be kind of equivalent is to set `core.hooksPath` to `/dev/null`
in the global config and then choose to set it to `hooks` or
`.git/hooks` in the local config if you want that. Or you can do the
reverse and use `core.hooksPath=/dev/null` in the local config for
poorly behaved repositories. Of course, the repo can override that, but
if it does that, then I'd just report it as malicious to its hosting
provider.
--
brian m. carlson (they/them)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 325 bytes --]
prev parent reply other threads:[~2026-09-29 21:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 4:23 [RFC] Optional per-repository consent before running local hooks Dmytro Lymarenko
2026-09-29 18:27 ` Junio C Hamano
2026-09-29 21:32 ` brian m. carlson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=arwubFmKkRcbbto3@fruit.crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=dmytro.lymarenko@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox