Revert "Revert "Allow to enable git protocol version 2 for upload pack""

Reason for revert: The original revert was done because of security
vulnerability in JGit. This vulnerability was fixed meantime.

Another argument for procrastination with Git v2 protocol support in
upcoming Gerrit release may be the fact that we do not have any
integration tests for execution of AdvertiseRefsHook hook.

However, this argument is not specific for git v2 protocol, as
mentioned in JGit 5.0 release: [1], but other Git protocol versions
were affected as well, and thus does not hold. In fact bidirectional
v0 HTTP protocol also has not executed AdvertiseRefsHook hook and
this was not discovered for 8 years and all released Gerrit versions
were affected.

Test Plan:

1. Install git version 2.18 or later
2. Activate git v2 protocol on the client side
3. Enable git v2 protocol support in gerrit, by setting this config:
   receive.enableProtocolV2 = true
3. Run $ GIT_TRACE_PACKET=1 git ls-remote
4. Confirm that git v2 protocol is used
5. Confirm that the method: DefaultRefFilter#filter is get called
6. Confirm that the call stack looks sane: [2]

This reverts commit f51a97d523.

[1] https://projects.eclipse.org/projects/technology.jgit/releases/5.0.0
[2] http://paste.openstack.org/show/742267

Change-Id: I5e2e5c7c69cc1433bc8539a8c36cb2ebd70804fc
This commit is contained in:
David Ostrovsky
2019-01-13 10:57:45 +01:00
committed by Luca Milanesio
parent 40d2be69db
commit fb64381f7c
5 changed files with 45 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ public class TransferConfig {
private final long maxObjectSizeLimit;
private final String maxObjectSizeLimitFormatted;
private final boolean inheritProjectMaxObjectSizeLimit;
private final boolean enableProtocolV2;
@Inject
TransferConfig(@GerritServerConfig Config cfg) {
@@ -45,6 +46,7 @@ public class TransferConfig {
maxObjectSizeLimitFormatted = cfg.getString("receive", null, "maxObjectSizeLimit");
inheritProjectMaxObjectSizeLimit =
cfg.getBoolean("receive", "inheritProjectMaxObjectSizeLimit", false);
enableProtocolV2 = cfg.getBoolean("receive", "enableProtocolV2", false);
packConfig = new PackConfig();
packConfig.setDeltaCompress(false);
@@ -72,4 +74,8 @@ public class TransferConfig {
public boolean inheritProjectMaxObjectSizeLimit() {
return inheritProjectMaxObjectSizeLimit;
}
public boolean enableProtocolV2() {
return enableProtocolV2;
}
}