matamorphosis / Scrummage

A Holistic OSINT and Threat Hunting Platform
GNU General Public License v3.0
506 stars 81 forks source link

Index error #3

Closed vinithius2 closed 5 years ago

vinithius2 commented 5 years ago

Hello!

I found index error in dashboard view, normally when my database is new and without record.

@app.route('/dashboard')
def dashboard():
.
.
.

return render_template('dashboard.html', username=session.get('user'), max=17000, open_set=zip(open_values, labels, colors), closed_set=zip(closed_values, labels, colors), mixed_set=zip(mixed_values, labels, colors), bar_labels=most_common_tasks_labels, bar_max=most_common_tasks_values[0], bar_values=most_common_tasks_values)

most_common_tasks_values ​​[0] get like empty list ...

matamorphosis commented 5 years ago

Hi vinithius2,

I looked into this not too long ago as it was preventing the dashboard from loading if there were no tasks in the database; however, now no graph should get generated for most common tasks on the dashboard, but the dashboard should still load.

Can you please clarify what the issue is that you are facing. Is the dashboard returning an error when loading?

vinithius2 commented 5 years ago

image

WARNING:main:Successful login from marcos.
INFO:werkzeug:127.0.0.1 - - [17/Sep/2019 10:23:38] "POST /login HTTP/1.1" 302 -
ERROR:main:list index out of range
ERROR:main:Exception on /dashboard [GET]
Traceback (most recent call last):
  File "/home/other/.virtualenvs/scrummage/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/other/.virtualenvs/scrummage/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
    return self.finalize_request(rv)
  File "/home/other/.virtualenvs/scrummage/lib/python3.6/site-packages/flask/app.py", line 1967, in finalize_request
    response = self.make_response(rv)
  File "/home/other/.virtualenvs/scrummage/lib/python3.6/site-packages/flask/app.py", line 2097, in make_response
    "The view function did not return a valid response. The"
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
INFO:werkzeug:127.0.0.1 - - [17/Sep/2019 10:23:39] "GET /dashboard HTTP/1.1" 500 -
INFO:werkzeug:127.0.0.1 - - [17/Sep/2019 10:23:39] "GET /favicon.ico HTTP/1.1" 404 -

This is the feedback from my terminal.

matamorphosis commented 5 years ago

Thanks for that, despite what I said earlier the changes i made weren't in the main.py file and they must have been missed. If you could try updating your /lib/main.py and /lib/templates/dashboard.html files and try again.

vinithius2 commented 5 years ago

It's work! Very nice, one more question, i had install more two package with pip install, psycopg2 and defectdojo_api, i believe updating the file "python_requirements.txt" solve this problem, no more, thank you.

matamorphosis commented 5 years ago

Thank you for that. I've added defectdojo_api to the requirements, again thought that was in there already. Will do another end-to-end test soon and just check everything is working as it should. As for psycopg2, python recommends installing it as a binary and not a library. (apt install python3-psycopg2) which can be seen on line 11 of installation/dependencies.sh, and that's why it's excluded from requirements.txt. I know this is supported on Ubuntu, Debian, and SUSE distributions. Which distribution did you set it up on?

vinithius2 commented 5 years ago

My distribution is Ubuntu, i used pip install psycopg2 this project. I Have other projetc with:

psycopg2-binary==version psycopg2==version

Maybe it works

matamorphosis commented 5 years ago

Okay no worries, if others experience a similar issue I will consider adding it to the requirements file.