Bug 491489 - Disable pushing to Git with refs/for/master for CDT
Summary: Disable pushing to Git with refs/for/master for CDT
Status: RESOLVED FIXED
Alias: None
Product: Community
Classification: Eclipse Foundation
Component: Git (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Eclipse Webmaster CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-12 03:25 EDT by Jonah Graham CLA
Modified: 2018-09-25 00:33 EDT (History)
6 users (show)

See Also:


Attachments
First page of the push wizard (39.70 KB, image/png)
2016-04-21 19:34 EDT, Sergey Prigogin CLA
no flags Details
Second page of the push wizard (53.85 KB, image/png)
2016-04-21 19:35 EDT, Sergey Prigogin CLA
no flags Details
Third page of the push wizard (42.76 KB, image/png)
2016-04-21 19:35 EDT, Sergey Prigogin CLA
no flags Details
Error message (19.72 KB, image/png)
2016-04-21 19:37 EDT, Sergey Prigogin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonah Graham CLA 2016-04-12 03:25:44 EDT
On CDT we (again?) had an accidental push to refs/for/master in git instead of gerrit.

Would it be possible to add a server side hook, perhaps as Matthias has suggested in Bug 491464 (which covers the client side of the change)?

(In reply to Matthias Sohn from Bug 491464 comment #1)
> I think this should be prevented on server side by installing a pre-receive
> hook,
> this way also pushes from other git implementations to this magic ref will
> be rejected
> 
> Contact webmaster@eclipse.org if you want this for a git repository hosted
> at Eclipse
> 
> the hook may look like (completely untested):
> 
> #! /bin/sh
> # reject push to Gerrit magic refs "refs/for/<branch name>" which is not
> # understood by plain git
> while read old new longref; do
>     case $longref in
>     refs/for/*)
>         echo "push to $longref rejected
>         You pushed to a plain bare git repository using a Gerrit magic ref
>         which isn't supported by plain git
>         Push to https://git.eclipse.org/r if you want to use Gerrit Code
> Review at Eclipse"
>         exit 1
>     esac
> done
> 
> for details about pre-receive hooks see section "pre-receive" in [1]
> 
> [1] https://git-scm.com/docs/githooks
Comment 1 Denis Roy CLA 2016-04-12 09:14:19 EDT
Let's just change the file permissions to prevent direct SSH access and use Gerrit for everyting. This does not mean code review for everything -- push to refs/heads/master goes into HEAD directly, push to refs/for/master triggers review.
Comment 2 Jonah Graham CLA 2016-04-12 09:27:57 EDT
(In reply to Denis Roy from comment #1)
> Let's just change the file permissions to prevent direct SSH access and use
> Gerrit for everyting. This does not mean code review for everything -- push
> to refs/heads/master goes into HEAD directly, push to refs/for/master
> triggers review.

From me there is no objection to that, there was a longish conversation on cdt-dev (that led to this bug report) [1]. I don't know enough about Eclipse processes on making such decisions, so I leave that in your hands.

Thanks Denis!

[1] https://dev.eclipse.org/mhonarc/lists/cdt-dev/msg30546.html
Comment 3 Denis Roy CLA 2016-04-12 10:12:18 EDT
cc'ing the project leads for +1 on the permissions change:

(In reply to Denis Roy from comment #1)
> Let's just change the file permissions to prevent direct SSH access and use
> Gerrit for everyting. This does not mean code review for everything -- push
> to refs/heads/master goes into HEAD directly, push to refs/for/master
> triggers review.
Comment 4 Marc Khouzam CLA 2016-04-12 12:44:40 EDT
(In reply to Denis Roy from comment #3)
> cc'ing the project leads for +1 on the permissions change:

This is ok for me but I'll let Doug make the final call as he may like the flexibility of having that option.
Comment 5 Doug Schaefer CLA 2016-04-12 13:30:53 EDT
(In reply to Marc Khouzam from comment #4)
> (In reply to Denis Roy from comment #3)
> > cc'ing the project leads for +1 on the permissions change:
> 
> This is ok for me but I'll let Doug make the final call as he may like the
> flexibility of having that option.

I fear not having it but I'll vote 0 since not having it probably doesn't matter that much. I haven't used it in a long time.
Comment 6 Marc Khouzam CLA 2016-04-12 13:37:46 EDT
(In reply to Doug Schaefer from comment #5)
> (In reply to Marc Khouzam from comment #4)
> > (In reply to Denis Roy from comment #3)
> > > cc'ing the project leads for +1 on the permissions change:
> > 
> > This is ok for me but I'll let Doug make the final call as he may like the
> > flexibility of having that option.
> 
> I fear not having it but I'll vote 0 since not having it probably doesn't
> matter that much. I haven't used it in a long time.

Ok, so let's try it.
I will warn our committers that this will be happening.  It will be their final warning to move to the Gerrit URL.
Comment 7 Marc Khouzam CLA 2016-04-12 13:40:44 EDT
I've renamed the bug to match what will be done.

As a note, Jonah had brought up the fact that the server hook could be done for all projects and therefore protect all projects.

Are there many projects that have direct access and therefore have the risk of pushing real refs/for/* branches? or is it fine to just focus on CDT for this bug?
Comment 8 Denis Roy CLA 2016-04-12 14:07:46 EDT
Which repo is this for?  Or shall we just do it on all repos?
Comment 9 Doug Schaefer CLA 2016-04-12 14:14:47 EDT
(In reply to Denis Roy from comment #8)
> Which repo is this for?  Or shall we just do it on all repos?

Yes, please. Do all of them under gitroot/cdt.

BTW, if I want to make a new repo, how do we do it and get the permissions correct? With our gerrit instance at BlackBerry, I can issue a create-project command over the 29418 port to do it. But I'm not sure how much Gerrit magic gets involved with that.
Comment 10 Denis Roy CLA 2016-04-12 15:31:03 EDT
Gerrit repos are still created manually / webmaster stuff. I have plans for addressing that, but getting to it is challenging.

For Gerrit we create a "permissions" project for each Eclipse project, then set that project as the parent of all your repos.

ssh -p 29418 gerrit gerrit set-project-parent --parent permissions/cdt-dev cdt/org.eclipse.cdt.master


All the CDT repos are under Gerrit control and all of them allow direct push to refs/heads/master.  Please use the Gerrit URLs for all Git operations. Here is a list of the CDT projects -- clone URLs are within.

https://git.eclipse.org/r/#/admin/projects/?filter=cdt




(In reply to Jonah Graham from comment #0)
> On CDT we (again?) had an accidental push to refs/for/master in git instead
> of gerrit.

Has the bad ref been cleared?
Comment 11 Marc Khouzam CLA 2016-04-12 15:45:57 EDT
(In reply to Denis Roy from comment #10)

> All the CDT repos are under Gerrit control and all of them allow direct push
> to refs/heads/master.  Please use the Gerrit URLs for all Git operations.

I've notified committers via the mailing list that they must use the Gerrit URL.

> (In reply to Jonah Graham from comment #0)
> > On CDT we (again?) had an accidental push to refs/for/master in git instead
> > of gerrit.
> 
> Has the bad ref been cleared?

Yes, that was fixed.  Thanks for asking.
Comment 12 Denis Roy CLA 2016-04-12 15:55:40 EDT
Great, I think we're done here.
Comment 13 Marc Khouzam CLA 2016-04-12 16:15:40 EDT
Thanks Denis!
Comment 14 Sergey Prigogin CLA 2016-04-13 19:50:16 EDT
I'm no longer able to push using ssh://sprigogin@git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git with refs/heads/master. Wasn't the intention to disable push to refs/for/master only?
Comment 15 Doug Schaefer CLA 2016-04-13 20:07:02 EDT
(In reply to Sergey Prigogin from comment #14)
> I'm no longer able to push using
> ssh://sprigogin@git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git with
> refs/heads/master. Wasn't the intention to disable push to refs/for/master
> only?

Nope, that's not what was decided.

But you should be able to push directly to refs/heads/master at ssh://sprigogin@git.eclipse.org:29418/cdt/org.eclipse.cdt.git without creating a change request.
Comment 16 Sergey Prigogin CLA 2016-04-13 20:15:35 EDT
Direct push to refs/heads/master at ssh://sprigogin@git.eclipse.org:29418/cdt/org.eclipse.cdt.git does work but in EGit it doesn't update local state and I have to pull explicitly to get rid of the outgoing change.
Comment 17 Sergey Prigogin CLA 2016-04-20 14:20:46 EDT
Please revert the change since it had unintended consequences described in comment #14 and comment #16.
Comment 18 Doug Schaefer CLA 2016-04-20 21:50:53 EDT
(In reply to Sergey Prigogin from comment #17)
> Please revert the change since it had unintended consequences described in
> comment #14 and comment #16.

What version of Egit are you using? I do regular direct pushes and don't see that problem. And 14 is negated by 15 :).

I've been using Gerrit both at Eclipse and at QNX in this mode without issue for years.
Comment 19 Doug Schaefer CLA 2016-04-20 21:52:45 EDT
(In reply to Doug Schaefer from comment #18)
> (In reply to Sergey Prigogin from comment #17)
> > Please revert the change since it had unintended consequences described in
> > comment #14 and comment #16.
> 
> What version of Egit are you using? I do regular direct pushes and don't see
> that problem. And 14 is negated by 15 :).
> 
> I've been using Gerrit both at Eclipse and at QNX in this mode without issue
> for years.

I'll take that back a bit. I used to see the issue you were having but that was with EGit in Luna.
Comment 20 Doug Schaefer CLA 2016-04-20 21:58:49 EDT
(In reply to Doug Schaefer from comment #19)
> (In reply to Doug Schaefer from comment #18)
> > (In reply to Sergey Prigogin from comment #17)
> > > Please revert the change since it had unintended consequences described in
> > > comment #14 and comment #16.
> > 
> > What version of Egit are you using? I do regular direct pushes and don't see
> > that problem. And 14 is negated by 15 :).
> > 
> > I've been using Gerrit both at Eclipse and at QNX in this mode without issue
> > for years.
> 
> I'll take that back a bit. I used to see the issue you were having but that
> was with EGit in Luna.

Also, just to make sure we're talking about the same thing. I push directly by selecting the branch and doing a "Push Branch".

And the most recent EGit cleans up some of the UX around the "Commit and Push" button in the Staging view so you can us it with more confidence that you're actually pushing to refs/for or refs/draft and not direct.
Comment 21 Sergey Prigogin CLA 2016-04-20 22:28:36 EDT
(In reply to Doug Schaefer from comment #20)

I'm using latest EGit nightly and pushing by clicking on Remote > Push... from the context menu of the git repository clone.

The magic trick suggested by Matthias Sohn in http://eclip.se/491464#c1 promised "reject push to Gerrit magic refs "refs/for/<branch name>" which is not understood by plain git", but instead push to ssh://<username>@git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git was disabled completely.
Comment 22 Denis Roy CLA 2016-04-21 08:23:31 EDT
> What version of Egit are you using? I do regular direct pushes and don't see
> that problem.

Agreed ... Could you take some screenshots of the push refs?
Comment 23 Doug Schaefer CLA 2016-04-21 12:00:13 EDT
BTW, the plan as I understood it was to make this change anyway so we only have one way of managing git access to the repos, and to do it for all projects. Having the golden repo sitting on the file system open to everyone is quite scary.

But at the end of the day, doesn't matter to me. I'm was working 100% against the Gerrit repo, including direct pushes, anyway so this change didn't affect me.
Comment 24 Sergey Prigogin CLA 2016-04-21 14:14:32 EDT
(In reply to Doug Schaefer from comment #23)

Doug, what is you origin points to, Gerrit or Git? Mine points to Git because it was used for original cloning as recommended in https://wiki.eclipse.org/Getting_started_with_CDT_development
Comment 25 Sergey Prigogin CLA 2016-04-21 19:34:56 EDT
Created attachment 261165 [details]
First page of the push wizard
Comment 26 Sergey Prigogin CLA 2016-04-21 19:35:19 EDT
Created attachment 261166 [details]
Second page of the push wizard
Comment 27 Sergey Prigogin CLA 2016-04-21 19:35:37 EDT
Created attachment 261167 [details]
Third page of the push wizard
Comment 28 Sergey Prigogin CLA 2016-04-21 19:37:28 EDT
Created attachment 261168 [details]
Error message

This and previous attachments illustrate that push to refs/heads/master using git URL doesn't work.
Comment 29 Marc Khouzam CLA 2016-04-22 09:19:01 EDT
(In reply to Sergey Prigogin from comment #24)
> (In reply to Doug Schaefer from comment #23)
> 
> Doug, what is you origin points to, Gerrit or Git? Mine points to Git
> because it was used for original cloning as recommended in
> https://wiki.eclipse.org/Getting_started_with_CDT_development

You can modify your 'origin' entry to replace the URL with the Gerrit URL. Then everything will work.  You can make the change using EGit or command-line.  I can provide pointers if needed.

You don't need to have the direct fit URL at all anymore.
Comment 30 Denis Roy CLA 2016-04-22 09:52:24 EDT
> You can modify your 'origin' entry to replace the URL with the Gerrit URL.
> Then everything will work.  You can make the change using EGit or
> command-line.  I can provide pointers if needed.
> 
> You don't need to have the direct fit URL at all anymore.

+1

/gitroot URIs are obsolete.


(In reply to Doug Schaefer from comment #23)
> BTW, the plan as I understood it was to make this change anyway so we only
> have one way of managing git access to the repos, and to do it for all
> projects. Having the golden repo sitting on the file system open to everyone
> is quite scary.

This is correct. At some point SSH access through the system SSh will be disabled, and all Git SSH access will be done through jSch.
Comment 31 Sergey Prigogin CLA 2016-04-22 13:11:43 EDT
https://wiki.eclipse.org/Getting_started_with_CDT_development has to be updated to reflect the new reality.
Comment 32 Doug Schaefer CLA 2016-04-22 13:33:59 EDT
(In reply to Sergey Prigogin from comment #24)
> (In reply to Doug Schaefer from comment #23)
> 
> Doug, what is you origin points to, Gerrit or Git? Mine points to Git
> because it was used for original cloning as recommended in
> https://wiki.eclipse.org/Getting_started_with_CDT_development

I made a new remote pointing at Gerrit and deleted the old one and the set up the branch properties to pull from the new remote.
Comment 33 Doug Schaefer CLA 2016-04-22 13:34:48 EDT
Never mind. What Marc, said. (Sorry, was replying to them in order).
Comment 34 Eclipse Genie CLA 2018-09-24 17:20:29 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 35 Jonah Graham CLA 2018-09-25 00:33:21 EDT
I think this is fully done.