fkie-cad / FACT_core

Firmware Analysis and Comparison Tool
https://fkie-cad.github.io/FACT_core
GNU General Public License v3.0
1.23k stars 224 forks source link

ImportError: cannot import name 'uia_username_mapper' from 'flask_security' #1044

Open hugooda12 opened 1 year ago

hugooda12 commented 1 year ago

FACT version

7b0c4ebd0c998a620f1e96d81e15486d3f56c7c9

Environment

Ubuntu 22.04.2 LTS

Steps to reproduce

run ./start_all_installed_fact_components after doing Install (python3 install.py)

Expeced Behavior

access to http://localhost:5000/

Installation logs

[2023-05-18 08:48:36][install][INFO]: FACT Installer 1.2 [2023-05-18 08:48:36][common][INFO]: Updating system [2023-05-18 08:48:39][install][INFO]: Installing apt-transport-https autoconf automake build-essential git libtool python3 python3-dev unzip libfuzzy-dev libmagic-dev [2023-05-18 08:48:44][common][INFO]: Installing python3 pip [2023-05-18 08:49:48][install][INFO]: Installing nodejs papirus-icon-theme [2023-05-18 08:51:19][install][WARNING]: Pip package flask-login==0.6.2 is already installed with distutils. This may Cause problems: Collecting flask-login==0.6.2 Downloading Flask_Login-0.6.2-py3-none-any.whl (17 kB) Collecting Flask>=1.0.4 (from flask-login==0.6.2) Downloading Flask-2.3.2-py3-none-any.whl (96 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.9/96.9 kB 2.3 MB/s eta 0:00:00 Requirement already satisfied: Werkzeug>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from flask-login==0.6.2) (2.3.4) Collecting Jinja2>=3.1.2 (from Flask>=1.0.4->flask-login==0.6.2) Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB 6.0 MB/s eta 0:00:00 Collecting itsdangerous>=2.1.2 (from Flask>=1.0.4->flask-login==0.6.2) Downloading itsdangerous-2.1.2-py3-none-any.whl (15 kB) Collecting click>=8.1.3 (from Flask>=1.0.4->flask-login==0.6.2) Downloading click-8.1.3-py3-none-any.whl (96 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.6/96.6 kB 4.6 MB/s eta 0:00:00 Collecting blinker>=1.6.2 (from Flask>=1.0.4->flask-login==0.6.2) Downloading blinker-1.6.2-py3-none-any.whl (13 kB) Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/lib/python3.10/dist-packages (from Werkzeug>=1.0.1->flask-login==0.6.2) (2.1.2) Installing collected packages: Jinja2, itsdangerous, click, blinker, Flask, flask-login Attempting uninstall: click Found existing installation: click 8.0.3 Uninstalling click-8.0.3: Successfully uninstalled click-8.0.3 Attempting uninstall: blinker Found existing installation: blinker 1.4 ERROR: Cannot uninstall 'blinker'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

[2023-05-18 08:51:20][install][WARNING]: Pip package flask-paginate==2022.1.8 is already installed with distutils. This may Cause problems: Collecting flask-paginate==2022.1.8 Downloading flask_paginate-2022.1.8-py2.py3-none-any.whl (7.2 kB) Collecting Flask (from flask-paginate==2022.1.8) Using cached Flask-2.3.2-py3-none-any.whl (96 kB) Requirement already satisfied: Werkzeug>=2.3.3 in /usr/local/lib/python3.10/dist-packages (from Flask->flask-paginate==2022.1.8) (2.3.4) Requirement already satisfied: Jinja2>=3.1.2 in /usr/local/lib/python3.10/dist-packages (from Flask->flask-paginate==2022.1.8) (3.1.2) Requirement already satisfied: itsdangerous>=2.1.2 in /usr/local/lib/python3.10/dist-packages (from Flask->flask-paginate==2022.1.8) (2.1.2) Requirement already satisfied: click>=8.1.3 in /usr/local/lib/python3.10/dist-packages (from Flask->flask-paginate==2022.1.8) (8.1.3) Collecting blinker>=1.6.2 (from Flask->flask-paginate==2022.1.8) Using cached blinker-1.6.2-py3-none-any.whl (13 kB) Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from Jinja2>=3.1.2->Flask->flask-paginate==2022.1.8) (2.1.2) Installing collected packages: blinker, Flask, flask-paginate Attempting uninstall: blinker Found existing installation: blinker 1.4 ERROR: Cannot uninstall 'blinker'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

[2023-05-18 08:51:22][install][WARNING]: Pip package flask-security-too==5.2.0 is already installed with distutils. This may Cause problems: Collecting flask-security-too==5.2.0 Downloading Flask_Security_Too-5.2.0-py2.py3-none-any.whl (369 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 369.9/369.9 kB 3.8 MB/s eta 0:00:00 Collecting Flask>=2.3.0 (from flask-security-too==5.2.0) Using cached Flask-2.3.2-py3-none-any.whl (96 kB) Collecting Flask-Login>=0.6.2 (from flask-security-too==5.2.0) Using cached Flask_Login-0.6.2-py3-none-any.whl (17 kB) Collecting Flask-Principal>=0.4.0 (from flask-security-too==5.2.0) Downloading Flask-Principal-0.4.0.tar.gz (5.5 kB) Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Collecting Flask-WTF>=1.1.1 (from flask-security-too==5.2.0) Downloading Flask_WTF-1.1.1-py3-none-any.whl (12 kB) Requirement already satisfied: email-validator>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from flask-security-too==5.2.0) (1.3.0) Collecting passlib>=1.7.4 (from flask-security-too==5.2.0) Downloading passlib-1.7.4-py2.py3-none-any.whl (525 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 525.6/525.6 kB 7.7 MB/s eta 0:00:00 Collecting wtforms>=3.0.0 (from flask-security-too==5.2.0) Downloading WTForms-3.0.1-py3-none-any.whl (136 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 136.5/136.5 kB 23.7 MB/s eta 0:00:00 Collecting importlib-resources>=5.10.0 (from flask-security-too==5.2.0) Downloading importlib_resources-5.12.0-py3-none-any.whl (36 kB) Requirement already satisfied: dnspython>=1.15.0 in /usr/local/lib/python3.10/dist-packages (from email-validator>=1.1.1->flask-security-too==5.2.0) (2.3.0) Requirement already satisfied: idna>=2.0.0 in /usr/lib/python3/dist-packages (from email-validator>=1.1.1->flask-security-too==5.2.0) (3.3) Requirement already satisfied: Werkzeug>=2.3.3 in /usr/local/lib/python3.10/dist-packages (from Flask>=2.3.0->flask-security-too==5.2.0) (2.3.4) Requirement already satisfied: Jinja2>=3.1.2 in /usr/local/lib/python3.10/dist-packages (from Flask>=2.3.0->flask-security-too==5.2.0) (3.1.2) Requirement already satisfied: itsdangerous>=2.1.2 in /usr/local/lib/python3.10/dist-packages (from Flask>=2.3.0->flask-security-too==5.2.0) (2.1.2) Requirement already satisfied: click>=8.1.3 in /usr/local/lib/python3.10/dist-packages (from Flask>=2.3.0->flask-security-too==5.2.0) (8.1.3) Collecting blinker>=1.6.2 (from Flask>=2.3.0->flask-security-too==5.2.0) Using cached blinker-1.6.2-py3-none-any.whl (13 kB) Requirement already satisfied: MarkupSafe in /usr/local/lib/python3.10/dist-packages (from wtforms>=3.0.0->flask-security-too==5.2.0) (2.1.2) Building wheels for collected packages: Flask-Principal Building wheel for Flask-Principal (setup.py): started Building wheel for Flask-Principal (setup.py): finished with status 'done' Created wheel for Flask-Principal: filename=Flask_Principal-0.4.0-py3-none-any.whl size=5576 sha256=5deef2a17c307b6a16b8bfbfa85585172e23efea641ae0b1bfebbd00de951a3b Stored in directory: /root/.cache/pip/wheels/fc/2f/54/bf43622f54da73e3032e0309ff0d4d9ec0dd64ad4fd7dcf780 Successfully built Flask-Principal Installing collected packages: passlib, wtforms, importlib-resources, blinker, Flask, Flask-WTF, Flask-Principal, Flask-Login, flask-security-too Attempting uninstall: blinker Found existing installation: blinker 1.4 ERROR: Cannot uninstall 'blinker'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

[2023-05-18 08:51:24][install][WARNING]: Pip package flask-wtf==1.1.1 is already installed with distutils. This may Cause problems: Collecting flask-wtf==1.1.1 Using cached Flask_WTF-1.1.1-py3-none-any.whl (12 kB) Collecting Flask (from flask-wtf==1.1.1) Using cached Flask-2.3.2-py3-none-any.whl (96 kB) Requirement already satisfied: WTForms in /usr/local/lib/python3.10/dist-packages (from flask-wtf==1.1.1) (3.0.1) Requirement already satisfied: itsdangerous in /usr/local/lib/python3.10/dist-packages (from flask-wtf==1.1.1) (2.1.2) Requirement already satisfied: Werkzeug>=2.3.3 in /usr/local/lib/python3.10/dist-packages (from Flask->flask-wtf==1.1.1) (2.3.4) Requirement already satisfied: Jinja2>=3.1.2 in /usr/local/lib/python3.10/dist-packages (from Flask->flask-wtf==1.1.1) (3.1.2) Requirement already satisfied: click>=8.1.3 in /usr/local/lib/python3.10/dist-packages (from Flask->flask-wtf==1.1.1) (8.1.3) Collecting blinker>=1.6.2 (from Flask->flask-wtf==1.1.1) Using cached blinker-1.6.2-py3-none-any.whl (13 kB) Requirement already satisfied: MarkupSafe in /usr/local/lib/python3.10/dist-packages (from WTForms->flask-wtf==1.1.1) (2.1.2) Installing collected packages: blinker, Flask, flask-wtf Attempting uninstall: blinker Found existing installation: blinker 1.4 ERROR: Cannot uninstall 'blinker'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

[2023-05-18 08:51:25][install][WARNING]: Pip package flask==2.3.2 is already installed with distutils. This may Cause problems: Collecting flask==2.3.2 Using cached Flask-2.3.2-py3-none-any.whl (96 kB) Requirement already satisfied: Werkzeug>=2.3.3 in /usr/local/lib/python3.10/dist-packages (from flask==2.3.2) (2.3.4) Requirement already satisfied: Jinja2>=3.1.2 in /usr/local/lib/python3.10/dist-packages (from flask==2.3.2) (3.1.2) Requirement already satisfied: itsdangerous>=2.1.2 in /usr/local/lib/python3.10/dist-packages (from flask==2.3.2) (2.1.2) Requirement already satisfied: click>=8.1.3 in /usr/local/lib/python3.10/dist-packages (from flask==2.3.2) (8.1.3) Collecting blinker>=1.6.2 (from flask==2.3.2) Using cached blinker-1.6.2-py3-none-any.whl (13 kB) Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from Jinja2>=3.1.2->flask==2.3.2) (2.1.2) Installing collected packages: blinker, flask Attempting uninstall: blinker Found existing installation: blinker 1.4 ERROR: Cannot uninstall 'blinker'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

[2023-05-18 08:51:28][install][WARNING]: Pip package flask_restx==1.1.0 is already installed with distutils. This may Cause problems: Collecting flask_restx==1.1.0 Downloading flask_restx-1.1.0-py2.py3-none-any.whl (2.8 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.8/2.8 MB 7.2 MB/s eta 0:00:00 Collecting aniso8601>=0.82 (from flask_restx==1.1.0) Downloading aniso8601-9.0.1-py2.py3-none-any.whl (52 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 52.8/52.8 kB 2.9 MB/s eta 0:00:00 Collecting jsonschema (from flask_restx==1.1.0) Downloading jsonschema-4.17.3-py3-none-any.whl (90 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 90.4/90.4 kB 9.7 MB/s eta 0:00:00 Collecting Flask!=2.0.0,>=0.8 (from flask_restx==1.1.0) Using cached Flask-2.3.2-py3-none-any.whl (96 kB) Requirement already satisfied: werkzeug!=2.0.0 in /usr/local/lib/python3.10/dist-packages (from flask_restx==1.1.0) (2.3.4) Requirement already satisfied: pytz in /usr/lib/python3/dist-packages (from flask_restx==1.1.0) (2022.1) Requirement already satisfied: Jinja2>=3.1.2 in /usr/local/lib/python3.10/dist-packages (from Flask!=2.0.0,>=0.8->flask_restx==1.1.0) (3.1.2) Requirement already satisfied: itsdangerous>=2.1.2 in /usr/local/lib/python3.10/dist-packages (from Flask!=2.0.0,>=0.8->flask_restx==1.1.0) (2.1.2) Requirement already satisfied: click>=8.1.3 in /usr/local/lib/python3.10/dist-packages (from Flask!=2.0.0,>=0.8->flask_restx==1.1.0) (8.1.3) Collecting blinker>=1.6.2 (from Flask!=2.0.0,>=0.8->flask_restx==1.1.0) Using cached blinker-1.6.2-py3-none-any.whl (13 kB) Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/lib/python3.10/dist-packages (from werkzeug!=2.0.0->flask_restx==1.1.0) (2.1.2) Requirement already satisfied: attrs>=17.4.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema->flask_restx==1.1.0) (23.1.0) Collecting pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 (from jsonschema->flask_restx==1.1.0) Downloading pyrsistent-0.19.3-py3-none-any.whl (57 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.5/57.5 kB 5.5 MB/s eta 0:00:00 Installing collected packages: aniso8601, pyrsistent, blinker, jsonschema, Flask, flask_restx Attempting uninstall: blinker Found existing installation: blinker 1.4 ERROR: Cannot uninstall 'blinker'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

[2023-05-18 08:51:30][install][WARNING]: Pip package flask_sqlalchemy==3.0.2 is already installed with distutils. This may Cause problems: Collecting flask_sqlalchemy==3.0.2 Downloading Flask_SQLAlchemy-3.0.2-py3-none-any.whl (24 kB) Collecting Flask>=2.2 (from flask_sqlalchemy==3.0.2) Using cached Flask-2.3.2-py3-none-any.whl (96 kB) Requirement already satisfied: SQLAlchemy>=1.4.18 in /usr/local/lib/python3.10/dist-packages (from flask_sqlalchemy==3.0.2) (1.4.43) Requirement already satisfied: Werkzeug>=2.3.3 in /usr/local/lib/python3.10/dist-packages (from Flask>=2.2->flask_sqlalchemy==3.0.2) (2.3.4) Requirement already satisfied: Jinja2>=3.1.2 in /usr/local/lib/python3.10/dist-packages (from Flask>=2.2->flask_sqlalchemy==3.0.2) (3.1.2) Requirement already satisfied: itsdangerous>=2.1.2 in /usr/local/lib/python3.10/dist-packages (from Flask>=2.2->flask_sqlalchemy==3.0.2) (2.1.2) Requirement already satisfied: click>=8.1.3 in /usr/local/lib/python3.10/dist-packages (from Flask>=2.2->flask_sqlalchemy==3.0.2) (8.1.3) Collecting blinker>=1.6.2 (from Flask>=2.2->flask_sqlalchemy==3.0.2) Using cached blinker-1.6.2-py3-none-any.whl (13 kB) Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy>=1.4.18->flask_sqlalchemy==3.0.2) (2.0.2) Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from Jinja2>=3.1.2->Flask>=2.2->flask_sqlalchemy==3.0.2) (2.1.2) Installing collected packages: blinker, Flask, flask_sqlalchemy Attempting uninstall: blinker Found existing installation: blinker 1.4 ERROR: Cannot uninstall 'blinker'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

[2023-05-18 08:52:25][frontend][INFO]: Creating directory for authentication [2023-05-18 08:52:25][frontend][INFO]: Initializing docker container for radare [2023-05-18 08:52:33][frontend][INFO]: Pulling pdf report container [2023-05-18 08:54:20][db][INFO]: Setting up PostgreSQL database [2023-05-18 08:54:55][db][INFO]: Initializing PostgreSQL database [2023-05-18 08:54:57][install][INFO]: Installing libjpeg-dev libssl-dev redis binutils file openssl bison flex pkg-config [2023-05-18 08:55:19][install][WARNING]: Pip package flask==2.3.2 is already installed with distutils. This may Cause problems: Collecting flask==2.3.2 Using cached Flask-2.3.2-py3-none-any.whl (96 kB) Requirement already satisfied: Werkzeug>=2.3.3 in /usr/local/lib/python3.10/dist-packages (from flask==2.3.2) (2.3.4) Requirement already satisfied: Jinja2>=3.1.2 in /usr/local/lib/python3.10/dist-packages (from flask==2.3.2) (3.1.2) Requirement already satisfied: itsdangerous>=2.1.2 in /usr/local/lib/python3.10/dist-packages (from flask==2.3.2) (2.1.2) Requirement already satisfied: click>=8.1.3 in /usr/local/lib/python3.10/dist-packages (from flask==2.3.2) (8.1.3) Collecting blinker>=1.6.2 (from flask==2.3.2) Using cached blinker-1.6.2-py3-none-any.whl (13 kB) Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from Jinja2>=3.1.2->flask==2.3.2) (2.1.1) Installing collected packages: blinker, flask Attempting uninstall: blinker Found existing installation: blinker 1.4 ERROR: Cannot uninstall 'blinker'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

[2023-05-18 08:55:23][backend][INFO]: Installing yara v4.2.3 [2023-05-18 08:55:54][backend][INFO]: Installing checksec.sh [2023-05-18 08:55:54][backend][INFO]: Pulling fact extraction container [2023-05-18 08:57:46][backend][INFO]: Installing qemu_exec plugin. [2023-05-18 08:58:03][backend][INFO]: Finished installing qemu_exec plugin.

[2023-05-18 08:58:03][backend][INFO]: Installing software_components plugin. [2023-05-18 08:59:24][backend][INFO]: Finished installing software_components plugin.

[2023-05-18 08:59:24][backend][INFO]: Installing users_and_passwords plugin. [2023-05-18 08:59:34][backend][INFO]: Finished installing users_and_passwords plugin.

[2023-05-18 08:59:34][backend][INFO]: Installing binwalk plugin. [2023-05-18 08:59:48][backend][INFO]: Finished installing binwalk plugin.

[2023-05-18 08:59:48][backend][INFO]: Installing architecture_detection plugin. [2023-05-18 09:00:07][backend][INFO]: Finished installing architecture_detection plugin.

[2023-05-18 09:00:07][backend][INFO]: Installing device_tree plugin. [2023-05-18 09:00:12][backend][INFO]: Finished installing device_tree plugin.

[2023-05-18 09:00:12][backend][INFO]: Installing ip_and_uri_finder plugin. [2023-05-18 09:00:24][backend][INFO]: Finished installing ip_and_uri_finder plugin.

[2023-05-18 09:00:24][backend][INFO]: Installing known_vulnerabilities plugin. [2023-05-18 09:00:26][backend][INFO]: Finished installing known_vulnerabilities plugin.

[2023-05-18 09:00:26][backend][INFO]: Installing linter plugin. [2023-05-18 09:01:00][backend][INFO]: Finished installing linter plugin.

[2023-05-18 09:01:00][backend][INFO]: Installing file_system_metadata plugin. [2023-05-18 09:01:02][backend][INFO]: Finished installing file_system_metadata plugin.

[2023-05-18 09:01:02][backend][INFO]: Installing cve_lookup plugin. [2023-05-18 09:02:31][install][ERROR]: Failed to run python3 setup_repository.py:

Backend logs

fact_main_backend.log ``` PASTE HERE ```

Frontend logs

fact_main_frontend.log ``` PASTE HERE ```

Other information

Operational MODE: preforking+threaded Traceback (most recent call last): File "flask_app_wrapper.py", line 26, in from web_interface.frontend_main import WebFrontEnd File "/home/ubuntu/FACT_core/src/./web_interface/frontend_main.py", line 7, in from web_interface.app import create_app File "/home/ubuntu/FACT_core/src/./web_interface/app.py", line 4, in from flask_security import uia_username_mapper ImportError: cannot import name 'uia_username_mapper' from 'flask_security' (unknown location) unable to load app 0 (mountpoint='') (callable not found or import error) no app loaded. going in full dynamic mode

cmajane commented 1 year ago

I'm facing this same issue.

hugooda12 commented 1 year ago

I did the install with Debian 11 and no issue. must be Ubuntu 22.04 specific. Unfortunetly FACT_Core doesn't work with ARM Binaries but that is fine

jstucke commented 1 year ago

It's a conflict between the python packages installed through apt and the ones FACT tries to install through pip (Flask-Security-Too depends on blinker). We can't simply uninstall the system package because other packages depend on it. The easiest solution is installing FACT in a virtual environment. To do this, create a virtual env, activate it and install FACT as usual. Of course you also need to activate it each time before starting FACT. For more info see https://docs.python.org/3/library/venv.html.

You may need to install the python3-venv package under Ubuntu/Debian to be able to create a venv.