git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git Hooks

From
SDSatyakiran Duggina <satya0521@gmail.com>
Date
Dec 15, 2017, 20:48 UTC
Message-ID
<CAMZug26A0e=AunMOjZNC_xH2E5uqHe46mt6=jawWe7ozF=Jn0Q@mail.gmail.com>
In-Reply-To
<CAGyf7-F8cCprvK-e2S0kO0Wo+6n4m_gigpSQjCjSj-dhozMsMw@mail.gmail.com>
Thanks, Bryan.

To give the code pullers a chance to review, can we not have a `trusted-hooks: default` and `trusted-SHA: <some sha>` field in .git/. I'm assuming githooks/ are source tracked here.

When developer tries to execute `git commit`, git can ask developer to change `trusted-hooks` field to true or false. Let's say developer sets it to true, git can record the SHA. If any latest pull has the hooks changed, git can revert the `trusted-hook` to default.

This way there is not much hassle for developers to manually copy hooks all the time. And at the same time, they are not running scripts that they haven't reviewed.

Will this work?
On Fri, Dec 15, 2017 at 11:23 AM, Bryan Turner <bturner@atlassian.com> wrote:
Show 30 quoted lines
> On Fri, Dec 15, 2017 at 11:12 AM, Satyakiran Duggina
> <satya0521@gmail.com> wrote:
>> I see that `git init` creates a .git directory and hooks are to be
>> placed in that directory and these hooks are not tracked by version
>> control. To achieve tracked hooks, either each developer has to copy
>> the hooks or use tools like overcommit, pre-commit, husky etc.
>>
>> I'm wondering why hooks are not made external like .gitignore. I guess
>> it would be better to have two git configuration directories in a
>> repo, one hosting all the metadata managed by git and the other with
>> user configured data (hooks, ignore/exclude, repo config etc).
>
> Hooks are not external because they're not trusted. It essentially
> amounts to allowing someone to download an arbitrary script or program
> onto your computer which you then execute. It's extremely unsafe, and
> is intentionally not possible. To get hooks in your instance, you have
> to _manually_ install them. This gives you a chance to _review_ them
> before they start executing on your system. Any other approach and the
> hooks become an attack vector.
>
>>
>> Kindly let me know why the current design choice is made and if the
>> proposed change would introduce unseen issues.
>>
>>
>> Thanks,
>> Satya
>
> Hope this helps!
> Bryan Turner
-- 
Regards & Thanks
Satya Kiran Duggina
Previous: Bryan TurnerNext: Jeff King
Message 3 of 5 in “Git Hooks”
  1. Satyakiran DugginaDec 15, 2017
  2. Bryan TurnerDec 15, 2017
  3. Satyakiran DugginaDec 15, 2017
  4. Jeff KingDec 16, 2017
  5. Allowing remote git repos to set config & hook configurationÆvar Arnfjörð Bjarmason, Dec 19, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.