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

Re: [RFC PATCH 0/2] MVP implementation of remote-suggested hooks

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Jun 21, 2021, 18:58 UTC
Message-ID
<20210621185858.1169385-1-jonathantanmy@google.com>
In-Reply-To
<87fsxc47le.fsf@evledraar.gmail.com>
Show 13 quoted lines
> On Wed, Jun 16 2021, Jonathan Tan wrote:
> 
> > This is a continuation of the work from [1]. That work described the
> > reasons, possible features, and possible workflows, but not the
> > implementation in detail. This patch set has an MVP implementation, and
> > my hope is that having a concrete implementation to look at makes it
> > easier to discuss matters of implementation.
> 
> My C on this RFC is:
> 
> 1) A request that someone reply (there or here would do) to my comments
>    on the last iteration of this at:
>    https://lore.kernel.org/git/874kghk906.fsf@evledraar.gmail.com/
OK - I'll take a look at that.
> 2) I think you'd get better feedback if you CC'd the people who've been
>   actively discussing this in previous rounds.
Good point.
Show 21 quoted lines
> > Design choices:
> >
> >  1. Where should the suggested hooks be in the remote repo? A branch,
> >     a non-branch ref, a config? I think that a branch is best - it is
> >     relatively well-understood and any hooks there can be
> >     version-controlled (and its history is independent of the other
> >     branches).
> 
> First, unlike brian I don't (I hope I'm fairly summarizing his view
> here) disagree mostly or entirely with the existence of such a feature
> at all. I mean, I get the viewpoint that git shouldn't bless what
> amounts to an active RCE from the remote.
> 
> I just think that we could probably do a better job of it than what
> people are doing in practice, and I've seen people do stuff like have
> build systems setup permanent symlinks to git-hooks/<some-name> in the
> tracked dir. We could at least envision a git-native implementation
> asking the user "do you want this hook update? <shows diff>".
> 
> I just find this design approach completely bizarre as noted (probably
> in less blunt words) in the linked E-Mail.

That's fair. You suggest an alternative below (and maybe more in the linked e-mail) - let's look at your suggestion...

Show 10 quoted lines
> We have Emily's series to convert hooks to be config driven that we hope
> to land in some form, at that point they won't be any more of a special
> snowflake than any other config.
> 
> And then, instead of doing what I'd think would be the natural result of
> that: Simply supporting an in-repo top-level ".gitconfig" file. We're
> still going to seemingly forever have them be an even more special
> snowflake with this facility, and the reason seems to be mostly/entirely
> to do with working around some aspect or restriction of Google's
> internal infrastructure.

I don't think that this is "natural". In particular, I still don't think that hooks should be tied to code revision. E.g. if we make commits based on an old revision and push them, we still want them to follow the latest requirements.

Show 6 quoted lines
> I think it's just un-git-y to have a meta-branch that in some way drives
> not only all other branches, but all other revisions of all branches,
> ever.
> 
> It breaks expectations around git in lots of different ways, you can't
> fetch a single branch and get its hooks,

Are you saying that each branch should have its own hooks? That might be reasonable in certain projects, but I don't see how that is a Git expectation.

> you can't locally alter, commit
> and update your hooks while e.g. renaming a "t/" directory to "test/";
> your hooks and code can't be atomically changed).

I still think that hooks should work independent of code versions, so I wouldn't think that atomicity here is important.

Show 10 quoted lines
> I think I get why you want to do it that way, I just don't get why, as
> mostly noted in those earlier rounds why it wouldn't be a better
> approach / more straightforward / more git-y to:
> 
> 1. Work on getting hooks driven by config <this is happening with
>    Emily's series / my split-out "base" topic>
> 2. Have a facility to read an in-repo '.gitconfig'; have lots of safety
>    valves etc. around this, I suggested starting with a whitelist of the
>    N least dangerous config options, e.g. some diff viewing options, or
>    a suggested sendemail.to or whatever.
I've replied to this above.
Show 17 quoted lines
> 3. Work our way up to trusting that for more dangerous stuff, eventually
>    hooks. Most of the legitimate concerns from others with this is
>    having some UX where our users won't be trained to just blindly say
>    "yes" to an alias/hook config that "rm -rf's /" or whatever.
> 
>    If we start experimenting with that with aliases or hooks that can
>    run arbitrary code it's like handing a toddlder a shotgun, let's at
>    least start with a sharp fork or something (less dangerous config) :)
> 
> 4. People who want this "I want my hooks to apply to all revisions ever"
>    could probably get 99% or 100% of what they want if their hook is
>    just a stub that does the equivalent of:
> 
>        sh `curl https://git.google.com/$reponame/hooks/$hookname`
> 
>    You'd then simply forbid on your servers any changes to a .gitconfig
>    that did anything with the hook.* namespace.

This would work if set in .git/config (not version controlled), but not .gitconfig (version controlled).

Show 5 quoted lines
> With such an implementation you don't need a magic
> "refs/remotes/origin/suggested-hooks" refs, just some state machine (I
> suggested e.g. GPG signing chains as an eventual end-state, but "show a
> diff every time" would also do) that keeps track of what config (and
> hooks are just one such case) has been OK'd, and which has not.
This sounds complicated.
> I'd think it would even work better in the Googleplex, you could clone a
> co-worker's branch and execute their hooks, since they're the same as
> what you've pre-approved,
In the presence of .gitconfig, how would you know?
Show 5 quoted lines
> you could even clone some random person's fork
> of a "blessed" project, because the hooks would be the same `sh $(curl
> <url I already trust>)`. That validation could even be a system-level
> in-config hook on your laptop, thus bringing the whole thing full
> circle...
Same here.

In summary, I think your point of using hook configs + remote-suggested configs instead of remote-suggested hooks is a reasonable one, but I disagree with your reasons (or, at least, your reasons as I understand them).

Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 15 of 36 in “MVP implementation of remote-suggested hooks”
  1. 0/2 MVP implementation of remote-suggested hooksJonathan Tan, Jun 16, 2021
  2. 1/2 hook: move list of hooksJonathan Tan, Jun 16, 2021
  3. Emily ShafferJun 18, 2021
  4. Jonathan TanJun 18, 2021
  5. 2/2 clone,fetch: remote-suggested auto-updating hooksJonathan Tan, Jun 16, 2021
  6. Emily ShafferJun 18, 2021
  7. Junio C HamanoJun 17, 2021
  8. Jonathan TanJun 18, 2021
  9. Emily ShafferJun 18, 2021
  10. Jonathan TanJun 18, 2021
  11. Randall S. BeckerJun 18, 2021
  12. Matt RogersJun 19, 2021
  13. Jonathan TanJun 21, 2021
  14. Ævar Arnfjörð BjarmasonJun 20, 2021
  15. Jonathan TanJun 21, 2021
  16. Ævar Arnfjörð BjarmasonJun 21, 2021
  17. Jonathan TanJun 22, 2021
  18. brian m. carlsonJun 22, 2021
  19. Jonathan TanJun 23, 2021
  20. brian m. carlsonJun 24, 2021
  21. Junio C HamanoJun 28, 2021
  22. 0/2 MVP implementation of remote-suggested hooksJonathan Tan, Jul 16, 2021
  23. 1/2 hook: move list of hooksJonathan Tan, Jul 16, 2021
  24. 2/2 hook: remote-suggested hooksJonathan Tan, Jul 16, 2021
  25. Junio C HamanoJul 19, 2021
  26. Jonathan TanJul 20, 2021
  27. Phil HordJul 20, 2021
  28. Jonathan TanJul 20, 2021
  29. Ævar Arnfjörð BjarmasonJul 20, 2021
  30. Jonathan TanJul 20, 2021
  31. Emily ShafferJul 27, 2021
  32. Junio C HamanoJul 27, 2021
  33. Jonathan TanJul 27, 2021
  34. Junio C HamanoJul 27, 2021
  35. Junio C HamanoJul 19, 2021
  36. Jonathan TanJul 20, 2021

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.