Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE on clone.bundle #1092

Closed
bviktor opened this issue Jun 24, 2016 · 6 comments
Closed

NPE on clone.bundle #1092

bviktor opened this issue Jun 24, 2016 · 6 comments

Comments

@bviktor
Copy link
Contributor

bviktor commented Jun 24, 2016

This is used by the repo tool. Upon bundle commands the server returns HTTP 500 and the log shows this error:

2016-06-24 12:54:19 [WARN ] /r/frameworks/foobar/clone.bundle
java.lang.NullPointerException
        at com.gitblit.servlet.GitFilter.isCreationAllowed(GitFilter.java:155)
        at com.gitblit.servlet.AccessRestrictionFilter.doFilter(AccessRestrictionFilter.java:189)
        at com.gitblit.servlet.EnforceAuthenticationFilter.doFilter(EnforceAuthenticationFilter.java:99)
        at com.gitblit.servlet.ProxyFilter$1.doFilter(ProxyFilter.java:89)
        at com.gitblit.servlet.ProxyFilter.doFilter(ProxyFilter.java:92)
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120)
        at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:133)
        at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:130)
        at com.google.inject.servlet.GuiceFilter$Context.call(GuiceFilter.java:203)
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:130)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.Server.handle(Server.java:499)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
        at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
        at java.lang.Thread.run(Thread.java:745)
@teverett
Copy link

I am having this same issue. with gitblit 1.80, adding an account using Tower git.

Oct 16, 2016 8:34:38 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.NullPointerException
    at com.gitblit.servlet.GitFilter.isCreationAllowed(GitFilter.java:155)
    at com.gitblit.servlet.AccessRestrictionFilter.doFilter(AccessRestrictionFilter.java:189)
    at com.gitblit.servlet.EnforceAuthenticationFilter.doFilter(EnforceAuthenticationFilter.java:99)
    at com.gitblit.servlet.ProxyFilter$1.doFilter(ProxyFilter.java:89)
    at com.gitblit.servlet.ProxyFilter.doFilter(ProxyFilter.java:92)
    at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120)
    at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:133)
    at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:130)
    at com.google.inject.servlet.GuiceFilter$Context.call(GuiceFilter.java:203)
    at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:130)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:612)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:503)
    at java.lang.Thread.run(Thread.java:745)

@rnveach
Copy link

rnveach commented Oct 28, 2016

I am having the same issue too. It happened after I pushed to a ticket to test things out.

Looks like the direct issue is action is null: https://github.com/gitblit/gitblit/blob/9b8049057430592206cfb242ec24bde4ab7cb438/src/main/java/com/gitblit/servlet/GitFilter.java#L155

Here are some debug lines I added in AccessRestrictionFilter.doFilter:

2016-10-28 08:55:46 [DEBUG] Full URL: ?service=git-upload-pack
2016-10-28 08:55:46 [DEBUG] Repository: ?service=git-upload-pack
2016-10-28 08:55:46 [DEBUG] Full Suffix:
2016-10-28 08:55:46 [DEBUG] URL Request Type: null
2016-10-28 08:55:46 [WARN ] /r/ssa/repository.git/info/refs

Seems the issue is the repository variable isn't getting the repository name, which is the main problem.

@rnveach
Copy link

rnveach commented Oct 28, 2016

I was able to get it working with this patch, but I have no clue on the validity of the change. It didn't cause any negative side effects that I could see or find yet.

diff --git a/src/main/java/com/gitblit/servlet/AuthenticationFilter.java b/src/main/java/com/gitblit/servlet/AuthenticationFilter.java
index b52b619..fefd654 100644
--- a/src/main/java/com/gitblit/servlet/AuthenticationFilter.java
+++ b/src/main/java/com/gitblit/servlet/AuthenticationFilter.java
@@ -101,11 +101,19 @@
     */
    protected String getFullUrl(HttpServletRequest httpRequest) {
        final String servletUrl = httpRequest.getContextPath() + httpRequest.getServletPath();
-       String url = httpRequest.getRequestURI().substring(servletUrl.length());
+       String url = servletUrl;
+
+       if (!servletUrl.equals(httpRequest.getRequestURI())) {
+           url = httpRequest.getRequestURI().substring(servletUrl.length());
+       }
+
        final String params = httpRequest.getQueryString();
        if ((url.length() > 0) && (url.charAt(0) == '/')) {
            url = url.substring(1);
        }
+       if (url.startsWith("r/")) {
+           url = url.substring(2);
+       }
        final String fullUrl = url + (StringUtils.isEmpty(params) ? "" : ("?" + params));
        return fullUrl;
    }
diff --git a/src/main/java/com/gitblit/servlet/GitFilter.java b/src/main/java/com/gitblit/servlet/GitFilter.java
index d543044..37330ae 100644
--- a/src/main/java/com/gitblit/servlet/GitFilter.java
+++ b/src/main/java/com/gitblit/servlet/GitFilter.java
@@ -149,7 +149,7 @@
    protected boolean isCreationAllowed(String action) {

        // Repository must already exist before large files can be deposited
-       if (action.equals(gitLfs)) {
+       if (gitLfs.equals(action)) {
            return false;
        }

@flaix
Copy link
Member

flaix commented Nov 10, 2019

The NPE is easy enough to fix. The question is, where does it come from, i.e. what is the URL that was used, what was the client, what was the intended target repository, operation, etc.

In the first case, I didn't trigged on "repo tool", or clone.bundle, so it took me (quite a while) to realise you used the Android Repo tool from Google as a client. That is correct, that will not work this way, not even when the NPE is fixed. GitBlit does currently not support the "git bundle" command.

When using Repo as a client against GitBlit, please use the --no-clone-bundle command line argument to repo. That will switch Repo to using a normal clone and it will work.

@flaix
Copy link
Member

flaix commented Nov 10, 2019

In the second case I cannot help much because I have no information what the URL was, that caused the misbehaviour. The client is Tower, but as that is a commercial tool and not available to me for testing, I cannot check what URL was generated. Was it also issuing a bundle command? In that case I don't know a work-around.

@flaix
Copy link
Member

flaix commented Nov 10, 2019

In the third case, I don't know what is going on. The URL reaching the server seems to be /r/ssa/repository.git/info/refs, which is a valid URL that is understood and correctly handled by GitBlit. I have no idea how that got transformed into the string that has no URL anymore.

I guess the only fix for now is to prevent the NPE and to complain about clone.bundle being a unsupported command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants