browserup / browserup-proxy

BrowserUp Proxy is a free utility to watch, test, and manipulate web application network traffic and performance.
https://browserup.com
Apache License 2.0
164 stars 41 forks source link

NumberFormatException when specifying upstream proxy #228

Closed evgkirov closed 3 years ago

evgkirov commented 4 years ago

Describe the bug browserup-proxy throws me 500 Server Error when I specify an upstream proxy. I'm switching away from browsermob-proxy which worked with upstream proxies just fine, but hasn't updated for a while and lacks brotli support.

To Reproduce Steps to reproduce the behavior:

$ docker run -p 28700:8080 autifyhq/browserup-proxy:2.0.1
$ curl -X "POST" "http://127.0.0.1:28700/proxy?httpProxy=ip:port&proxyUsername=username&proxyPassword=password"
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 Server Error</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /proxy. Reason:
<pre>    Server Error</pre></p><h3>Caused by:</h3><pre>java.lang.ExceptionInInitializerError
        at org.mvel2.PropertyAccessor.set(PropertyAccessor.java:249)
        at org.mvel2.PropertyAccessor.set(PropertyAccessor.java:135)
        at org.mvel2.MVEL.setProperty(MVEL.java:1088)
        at com.google.sitebricks.MvelEvaluator.write(MvelEvaluator.java:64)
        at com.google.sitebricks.binding.MvelRequestBinder.bind(MvelRequestBinder.java:79)
        at com.google.sitebricks.routing.WidgetRoutingDispatcher.bindAndReply(WidgetRoutingDispatcher.java:97)
        at com.google.sitebricks.routing.WidgetRoutingDispatcher.dispatch(WidgetRoutingDispatcher.java:88)
        at com.google.sitebricks.DebugModeRoutingDispatcher.dispatch(DebugModeRoutingDispatcher.java:56)
        at com.google.sitebricks.SitebricksFilter.doFilter(SitebricksFilter.java:62)
        at com.google.sitebricks.HiddenMethodFilter.doFilter(HiddenMethodFilter.java:70)
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121)
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1591)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:542)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
        at org.eclipse.jetty.server.Server.handle(Server.java:494)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918)
        at java.base/java.lang.Thread.run(Thread.java:830)
Caused by: java.lang.NumberFormatException: For input string: &quot;14-&quot;
        at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
        at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
        at java.base/java.lang.Double.parseDouble(Double.java:549)
        at org.mvel2.util.ParseTools.&lt;clinit&gt;(ParseTools.java:62)
        ... 34 more
</pre>
<h3>Caused by:</h3><pre>java.lang.NumberFormatException: For input string: &quot;14-&quot;
        at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
        at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
        at java.base/java.lang.Double.parseDouble(Double.java:549)
        at org.mvel2.util.ParseTools.&lt;clinit&gt;(ParseTools.java:62)
        at org.mvel2.PropertyAccessor.set(PropertyAccessor.java:249)
        at org.mvel2.PropertyAccessor.set(PropertyAccessor.java:135)
        at org.mvel2.MVEL.setProperty(MVEL.java:1088)
        at com.google.sitebricks.MvelEvaluator.write(MvelEvaluator.java:64)
        at com.google.sitebricks.binding.MvelRequestBinder.bind(MvelRequestBinder.java:79)
        at com.google.sitebricks.routing.WidgetRoutingDispatcher.bindAndReply(WidgetRoutingDispatcher.java:97)
        at com.google.sitebricks.routing.WidgetRoutingDispatcher.dispatch(WidgetRoutingDispatcher.java:88)
        at com.google.sitebricks.DebugModeRoutingDispatcher.dispatch(DebugModeRoutingDispatcher.java:56)
        at com.google.sitebricks.SitebricksFilter.doFilter(SitebricksFilter.java:62)
        at com.google.sitebricks.HiddenMethodFilter.doFilter(HiddenMethodFilter.java:70)
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121)
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1591)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:542)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
        at org.eclipse.jetty.server.Server.handle(Server.java:494)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918)
        at java.base/java.lang.Thread.run(Thread.java:830)
</pre>
<hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.20.v20190813</a><hr/>

</body>
</html>

Expected behavior It should work just as fine as it does without an upstream proxy:

$ curl -X "POST" "http://127.0.0.1:28700/proxy"                                                                           
{"port":8081}%

Full server log

$ docker run -p 28700:8080 autifyhq/browserup-proxy:2.0.1 
Running BrowserUp Proxy, powered by LittleProxy.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/browserup-proxy-2.0.1/lib/guice-4.2.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO  2020-02-19T14:39:56,360 com.browserup.bup.proxy.Main] (main) Starting BrowserUp Proxy version ${project.version} 
[INFO  2020-02-19T14:39:56,417 org.eclipse.jetty.util.log] (main) Logging initialized @1108ms to org.eclipse.jetty.util.log.Slf4jLog 
[INFO  2020-02-19T14:39:56,491 org.eclipse.jetty.server.Server] (main) jetty-9.4.20.v20190813; built: 2019-08-13T21:28:18.144Z; git: 84700530e645e812b336747464d6fbbf370c9a20; jvm 14-ea+15 
[INFO  2020-02-19T14:39:56,526 org.eclipse.jetty.server.session] (main) DefaultSessionIdManager workerName=node0 
[INFO  2020-02-19T14:39:56,526 org.eclipse.jetty.server.session] (main) No SessionScavenger set, using defaults 
[INFO  2020-02-19T14:39:56,529 org.eclipse.jetty.server.session] (main) node0 Scavenging every 600000ms 
Feb 19, 2020 2:39:57 PM org.glassfish.jersey.internal.inject.Providers checkProviderRuntime
WARNING: A provider io.swagger.v3.jaxrs2.integration.resources.OpenApiResource registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER runtime. Due to constraint configuration problems the provider io.swagger.v3.jaxrs2.integration.resources.OpenApiResource will be ignored. 
[INFO  2020-02-19T14:39:57,171 org.hibernate.validator.internal.util.Version] (main) HV000001: Hibernate Validator 6.0.17.Final 
[INFO  2020-02-19T14:39:57,351 org.eclipse.jetty.server.handler.ContextHandler] (main) Started o.e.j.s.ServletContextHandler@707ca986{/,null,AVAILABLE} 
[INFO  2020-02-19T14:39:57,369 org.eclipse.jetty.server.AbstractConnector] (main) Started ServerConnector@44afefd5{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} 
[INFO  2020-02-19T14:39:57,369 org.eclipse.jetty.server.Server] (main) Started @2061ms 
[WARN  2020-02-19T14:40:23,356 org.eclipse.jetty.server.HttpChannel] (qtp654740048-18) /proxy java.lang.ExceptionInInitializerError: null
        at org.mvel2.PropertyAccessor.set(PropertyAccessor.java:249) ~[mvel2-2.1.3.Final.jar:?]
        at org.mvel2.PropertyAccessor.set(PropertyAccessor.java:135) ~[mvel2-2.1.3.Final.jar:?]
        at org.mvel2.MVEL.setProperty(MVEL.java:1088) ~[mvel2-2.1.3.Final.jar:?]
        at com.google.sitebricks.MvelEvaluator.write(MvelEvaluator.java:64) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.binding.MvelRequestBinder.bind(MvelRequestBinder.java:79) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.routing.WidgetRoutingDispatcher.bindAndReply(WidgetRoutingDispatcher.java:97) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.routing.WidgetRoutingDispatcher.dispatch(WidgetRoutingDispatcher.java:88) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.DebugModeRoutingDispatcher.dispatch(DebugModeRoutingDispatcher.java:56) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.SitebricksFilter.doFilter(SitebricksFilter.java:62) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.sitebricks.HiddenMethodFilter.doFilter(HiddenMethodFilter.java:70) ~[sitebricks-0.8.11.jar:0.8.11]
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121) ~[guice-servlet-4.2.2.jar:?]
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133) ~[guice-servlet-4.2.2.jar:?]
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1591) ~[jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:542) ~[jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) ~[jetty-servlet-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.Server.handle(Server.java:494) ~[jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [jetty-server-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [jetty-io-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [jetty-io-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [jetty-io-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [jetty-util-9.4.20.v20190813.jar:9.4.20.v20190813]
        at java.lang.Thread.run(Thread.java:830) [?:?]
Caused by: java.lang.NumberFormatException: For input string: "14-"
        at jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054) ~[?:?]
        at jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110) ~[?:?]
        at java.lang.Double.parseDouble(Double.java:549) ~[?:?]
        at org.mvel2.util.ParseTools.<clinit>(ParseTools.java:62) ~[mvel2-2.1.3.Final.jar:?]
        ... 34 more

[INFO  2020-02-19T14:43:15,391 com.browserup.bup.proxy.bricks.ProxyResource] (qtp654740048-18) POST / 
[INFO  2020-02-19T14:43:15,391 com.browserup.bup.proxy.bricks.ProxyResource] (qtp654740048-18) {} 
[INFO  2020-02-19T14:43:15,992 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp654740048-18) Starting proxy at address: 0.0.0.0/0.0.0.0:8081 
[INFO  2020-02-19T14:43:16,042 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp654740048-18) Proxy listening with TCP transport 
[INFO  2020-02-19T14:43:16,093 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp654740048-18) Proxy started at address: /0.0.0.0:8081 

Please complete the following information:

erickubenka commented 4 years ago

I can reproduce the error of @kirov with his steps.

But I guess it is because data is handled different between browsermob and browserup.

May you should try it with passing a json on the curl with -d option

curl -d '{"httpProxy":"127.0.0.1:5555"}' -X "POST" "http://127.0.0.1:28700/proxy"

evgkirov commented 4 years ago

That worked, although it needed a slight modification of browserup-proxy-py

However I've encountered another bug (NullPointerException in PUT rewrite), I will report it separately.