]> source.dussan.org Git - gitblit.git/commitdiff
Add `clone.bundle` as known command, but reject it as not implemented. 1323/head
authorFlorian Zschocke <florian.zschocke@devolo.de>
Sun, 10 Nov 2019 23:33:02 +0000 (00:33 +0100)
committerFlorian Zschocke <florian.zschocke@devolo.de>
Sun, 10 Nov 2019 23:33:02 +0000 (00:33 +0100)
src/main/java/com/gitblit/servlet/AccessRestrictionFilter.java
src/main/java/com/gitblit/servlet/GitFilter.java
src/test/java/com/gitblit/tests/GitServletTest.java

index f83f160842e671a964259de54e5f202915d61402..61c5eb1cf4b30c3291e574ca786beaaea89b8b63 100644 (file)
@@ -188,6 +188,15 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
                        return;\r
                }\r
 \r
+               // TODO: Maybe checking for clone bundle should be done somewhere else? Like other stuff?\r
+               //       In any way, the access to the constant from here is messed up an needs some cleaning up.\r
+               if (GitFilter.CLONE_BUNDLE.equalsIgnoreCase(urlRequestType)) {\r
+                       logger.info(MessageFormat.format("ARF: Rejecting request for {0}, clone bundle is not implemented.", repository));\r
+                       httpResponse.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "The 'clone.bundle' command is currently not implemented. " +\r
+                                       "Please use a normal clone command.");\r
+                       return;\r
+               }\r
+\r
                UserModel user = getUser(httpRequest);\r
 \r
                // Load the repository model\r
index 4b32b4335ee83fff9d486658994c890bf6a46ac3..66933cbddfe40832417079468192646aea19fdc1 100644 (file)
@@ -49,11 +49,13 @@ public class GitFilter extends AccessRestrictionFilter {
        static final String GIT_RECEIVE_PACK = "/git-receive-pack";\r
 \r
        static final String GIT_UPLOAD_PACK = "/git-upload-pack";\r
+\r
+       static final String CLONE_BUNDLE = "/clone.bundle";\r
        \r
        static final String GIT_LFS = "/info/lfs";\r
        \r
        static final String[] SUFFIXES = {GIT_RECEIVE_PACK, GIT_UPLOAD_PACK, "/info/refs", "/HEAD",\r
-                       "/objects", GIT_LFS};\r
+                       "/objects", GIT_LFS, CLONE_BUNDLE};\r
 \r
        private IStoredSettings settings;\r
 \r
@@ -127,6 +129,8 @@ public class GitFilter extends AccessRestrictionFilter {
                                return GIT_UPLOAD_PACK;\r
                        } else if (suffix.startsWith(GIT_LFS)) {\r
                                return GIT_LFS;\r
+                       } else if (suffix.startsWith(CLONE_BUNDLE)) {\r
+                               return CLONE_BUNDLE;\r
                        } else {\r
                                return GIT_UPLOAD_PACK;\r
                        }\r
@@ -163,7 +167,11 @@ public class GitFilter extends AccessRestrictionFilter {
                if (GIT_LFS.equals(action)) {\r
                        return false;\r
                }\r
-               \r
+               // Action is not implemened.\r
+               if (CLONE_BUNDLE.equals(action)) {\r
+                       return false;\r
+               }\r
+\r
                return settings.getBoolean(Keys.git.allowCreateOnPush, true);\r
        }\r
 \r
index c433ab18dcff80f0614a8f39d3b7379b26d01a10..a816143da1552708df26a8ab1c606b85742fae26 100644 (file)
@@ -978,8 +978,20 @@ public class GitServletTest extends GitblitUnitTest {
                HttpGet request = new HttpGet(testURL);\r
 \r
                HttpResponse response = client.execute(request);\r
-\r
                assertEquals(400, response.getStatusLine().getStatusCode());\r
        }\r
 \r
+       @Test\r
+       public void testInvalidURLCloneBundle() throws IOException {\r
+               final String testURL = GitBlitSuite.gitServletUrl + "/helloworld.git/clone.bundle";\r
+\r
+               HttpClient client = HttpClientBuilder.create().build();\r
+               HttpGet request = new HttpGet(testURL);\r
+\r
+               HttpResponse response = client.execute(request);\r
+               assertEquals(501, response.getStatusLine().getStatusCode());\r
+               String content = IOUtils.toString(response.getEntity().getContent(), "UTF-8");\r
+               assertNotNull(content);\r
+       }\r
+\r
 }\r