MobSF / Mobile-Security-Framework-MobSF

Mobile Security Framework (MobSF) is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing, malware analysis and security assessment framework capable of performing static and dynamic analysis.
https://opensecurity.in
GNU General Public License v3.0
17.29k stars 3.22k forks source link

[FEATURE] Native Postgres Support for docker image #2430

Open AdrienHutinel opened 1 week ago

AdrienHutinel commented 1 week ago

As a mobsf user I want to run the latest version of mobsf with the least support needed on my side to always be up to date. I also want to have it use postgres without having to clone and build image. In addition to that it could be extended to add other database support like Mysql...

Solution 1

make 2 tags on publish 1 for sqlite support and 1 for postgres (so each version would have two image on docker hub) for example in docker latest workflow:

-
            name: Build and push AMD64, ARM64 images
            id: docker_build
            uses: docker/build-push-action@v5
            with:
                push: true
                context: .
                build-args: |
                   POSTGRES = True # Add this
                platforms: linux/amd64,linux/arm64
                tags: opensecurity/mobile-security-framework-mobsf:postgres-latest

Solution 2

make it dynamic at runtime by checking what environement variables are defined in settings.py:

if 'POSTGRES_HOST' in os.environ: # Could use a POSTGRES True/False variable too
    logger.info('Using Postgres as backend DB')
    default = {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'mobsf',
        'USER': os.environ['POSTGRES_USER'],
        'PASSWORD': os.environ['POSTGRES_PASSWORD'],
        'HOST': os.environ['POSTGRES_HOST'],
        'PORT': 5432,
    }
else:
    logger.info('Using Default Sqlite3 as backend DB')
    default = {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': DB_DIR,
    },

DATABASES = {
    'default': default
}

this means getting rid of postgres_support.sh and add psycopg2-binary by default: image

github-actions[bot] commented 1 week ago

👋 @AdrienHutinel Issues is only for reporting a bug/feature request. For limited support, questions, and discussions, please join MobSF Slack channel Please include all the requested and relevant information when opening a bug report. Improper reports will be closed without any response.

ajinabraham commented 1 week ago

Interesting, I will take a look at this and get back.