diff options
author | Shawn Pearce <spearce@spearce.org> | 2016-07-04 18:04:43 -0700 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2017-02-11 00:20:36 +0100 |
commit | 0bff481d45db74db81a3b1b86f7401443a60d970 (patch) | |
tree | 47d11f395de3748b262c63e8d7d2e9f17d85f5e0 /org.eclipse.jgit.test/tst/org | |
parent | 67da5635a47ad7680b3c60358a1fec080eef7d1e (diff) | |
download | jgit-0bff481d45db74db81a3b1b86f7401443a60d970.tar.gz jgit-0bff481d45db74db81a3b1b86f7401443a60d970.zip |
Limit receive commands
Place a configurable upper bound on the amount of command data
received from clients during `git push`. The limit is applied to the
encoded wire protocol format, not the JGit in-memory representation.
This allows clients to flexibly use the limit; shorter reference names
allow for more commands, longer reference names permit fewer commands
per batch.
Based on data gathered from many repositories at $DAY_JOB, the average
reference name is well under 200 bytes when encoded in UTF-8 (the wire
encoding). The new 3 MiB default receive.maxCommandBytes allows about
11,155 references in a single `git push` invocation. A Gerrit Code
Review system with six-digit change numbers could still encode 29,399
references in the 3 MiB maxCommandBytes limit.
Change-Id: I84317d396d25ab1b46820e43ae2b73943646032c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java index 33a910505f..4aebc1d32c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java @@ -173,4 +173,27 @@ public class PushConnectionTest { } } } + + @Test + public void limitCommandBytes() throws IOException { + Map<String, RemoteRefUpdate> updates = new HashMap<>(); + for (int i = 0; i < 4; i++) { + RemoteRefUpdate rru = new RemoteRefUpdate( + null, null, obj2, "refs/test/T" + i, + false, null, ObjectId.zeroId()); + updates.put(rru.getRemoteName(), rru); + } + + server.getConfig().setInt("receive", null, "maxCommandBytes", 170); + try (Transport tn = testProtocol.open(uri, client, "server"); + PushConnection connection = tn.openPush()) { + try { + connection.push(NullProgressMonitor.INSTANCE, updates); + fail("server did not abort"); + } catch (TransportException e) { + String msg = e.getMessage(); + assertEquals("remote: Too many commands", msg); + } + } + } } |