dpnishant / appmon

Documentation:
http://dpnishant.github.io/appmon
Apache License 2.0
1.56k stars 276 forks source link

GET /api/fetch 500 error #61

Closed madushan1000 closed 6 years ago

madushan1000 commented 6 years ago

I tried to get my appmon(from master branch) working on with apps running on my OnePlus 3 (Android 7.1.1/aarch64) with arm64 frida-server (10.6.21) and frida(10.6.21) from PiPy with python2.7. But whenever I access the webapp and select the app I want to monitor, it silently fails with a HTTP 500 error. (I can see it in the dev tools). Here are the logs from the appmon stdout.

127.0.0.1 - - [07/Nov/2017 23:11:33] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Nov/2017 23:11:33] "GET /static/img/logo.png HTTP/1.1" 304 -
127.0.0.1 - - [07/Nov/2017 23:11:39] "GET /monitor?app=com.twitter.android HTTP/1.1" 301 -
127.0.0.1 - - [07/Nov/2017 23:11:39] "GET /monitor/?app=com.twitter.android HTTP/1.1" 200 -
127.0.0.1 - - [07/Nov/2017 23:11:39] "GET /static/img/logo.png HTTP/1.1" 304 -
127.0.0.1 - - [07/Nov/2017 23:11:40] "GET /static/img/to-bottom.png HTTP/1.1" 304 -
127.0.0.1 - - [07/Nov/2017 23:11:40] "GET /static/img/to-top.png HTTP/1.1" 304 -
127.0.0.1 - - [07/Nov/2017 23:11:40] "GET /api/fetch?id=0&app=com.twitter.android&_=1510076499873 HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 2000, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1991, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1567, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/madushan/Dev/my/android/appmon/appmon.py", line 64, in serve_json
    response = db.read_from_database(db_name, index)
  File "/Users/madushan/Dev/my/android/appmon/database/__init__.py", line 67, in read_from_database
    artifact_value = artifact_value.replace("<", "&lt;").replace(">", "&gt;")
AttributeError: 'int' object has no attribute 'replace'

Appreciate if anyone could give me a hand in resolving this, am I doing something wrong?

madushan1000 commented 6 years ago

As a temporary measure, I have added the following code in database/__init__.py

if type(artifact_value) == str:
          artifact_value = artifact_value.replace("<", "&lt;").replace(">", "&gt;")

I'm not sure it's the correct approach but the app is working now. If it is, I can send you a PR.

dpnishant commented 6 years ago

Merged the PR. Thanks