appium / mitmproxy-java

A bridge between Python's mitmproxy and Java programs. Built on top of mitmproxy-node
Apache License 2.0
64 stars 20 forks source link

Added fix for proxy to run properly in mac environment #18

Closed himanshunikhare25 closed 1 year ago

himanshunikhare25 commented 1 year ago

Fix contains 5 major changes for proxy to run perfectly on mac. This is my first PR, please correct/guide me if there is any issues with the PR.

1. Removed JCenter

Builds will no longer be able to resolve artifacts from JCenter after February 1st, 2022 

2. Used hasProperty instead of directly accessing property in authentication

Build was failing because no property was set for ossrhUsername and ossrhPassword

A problem occurred evaluating root project 'mitmproxy-java'.
> Could not get unknown property 'ossrhUsername' for object of type org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer.

3. Moved sign configurations.archives inside setRequired block

Signing is only required if the artifacts are to be published.

Execution failed for task ':signArchives'.
> Cannot perform signing task ':signArchives' because it has no configured signatory

4. Replaced http.HTTPResponse.make with http.Response.make as The mitmproxy API seems to have changed and the syntax is now http.Response.make()

[Thread-14] INFO io.appium.mitmproxy.MitmproxyJava - [11:32:53.624] Addon error: Traceback (most recent call last):
[Thread-14] INFO io.appium.mitmproxy.MitmproxyJava -   File "/private/var/folders/q3/vj5bmx6171b_wxhtdtq3th2c0000gn/T/mitmproxy-python-plugin3410838807867045242.py", line 201, in response
[Thread-14] INFO io.appium.mitmproxy.MitmproxyJava -     flow.response = http.HTTPResponse.make(
[Thread-14] INFO io.appium.mitmproxy.MitmproxyJava - AttributeError: module 'mitmproxy.http' has no attribute 'HTTPResponse'
[Thread-14] INFO io.appium.mitmproxy.MitmproxyJava - 127.0.0.1:50785: GET http://appium.io/
[Thread-14] INFO io.appium.mitmproxy.MitmproxyJava -               << 200 OK 4.5k

5. Updated MITMDUMP_PATH for mac

[Test worker] INFO io.appium.mitmproxy.MitmproxyJava - Starting mitmproxy on port 8080
[WebSocketSelector-22] INFO org.java_websocket.server.WebSocketServer - websocket server started successfully
[Test worker] ERROR org.zeroturnaround.exec.ProcessExecutor - Could not start process:
java.io.IOException: Cannot run program "/usr/local/bin/mitmdump": error=2, No such file or directory

Post all fixed all tests are passing perfectly in mac machine

11:42:38 AM: Executing 'build'...

Starting Gradle Daemon...
Gradle Daemon started in 461 ms
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :jar UP-TO-DATE
> Task :javadoc UP-TO-DATE
> Task :javadocJar UP-TO-DATE
> Task :sourcesJar UP-TO-DATE
> Task :assemble UP-TO-DATE
> Task :compileTestJava UP-TO-DATE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test
> Task :check
> Task :build

BUILD SUCCESSFUL in 7s
8 actionable tasks: 1 executed, 7 up-to-date
11:42:45 AM: Execution finished 'build'.
linux-foundation-easycla[bot] commented 1 year ago

CLA Signed

The committers listed above are authorized under a signed CLA.

Jonahss commented 1 year ago

Awesome! What version of mitm-proxy is it working with? The readme specifies v4, so if this now works with a later version, can you update the readme as well?

himanshunikhare25 commented 1 year ago

@Jonahss below are the details for mitm-proxy version used by me during the development for above PR.

Mitmproxy: 9.0.1
Python:    3.10.9
OpenSSL:   OpenSSL 3.0.7 1 Nov 2022
Platform:  macOS-13.2.1-arm64-arm-64bit

Updated the same to README.md

Jonahss commented 1 year ago

Super! Now I understand why people have been reporting problems. Everyone will be happy to update :D