Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Split settings.py #1697

Closed
nelenkov opened this issue Mar 12, 2021 · 8 comments
Closed

[FEATURE] Split settings.py #1697

nelenkov opened this issue Mar 12, 2021 · 8 comments
Assignees
Labels
enhancement MobSF enhancements and feature requests

Comments

@nelenkov
Copy link

If you're requesting a new feature/enhancement, explain why you'd like it to be added and it's importance.

Is your feature request related to a problem? Please describe.
settings.py hosts both required MobSF/Django config and local config.
Each time MobSF version is updated, need to merge local settings (e.g., USE_HOME, DB config, ALLOWED_HOSTS) into the updated settings.py

~/MobSF/config.py allows for customizing some values, but can't host Django settings.

Describe the solution you'd like
Split the file into settings.py and local_settings.py (ideally loaded from `~/.MobSF).

Describe alternatives you've considered
Manual merge

Additional context
Django wiki about splitting settings: https://code.djangoproject.com/wiki/SplitSettings

@nelenkov nelenkov added the enhancement MobSF enhancements and feature requests label Mar 12, 2021
@ajinabraham
Copy link
Member

You could install mobsf from pypi.

pip install mobsf The version from pypi defaults to user's home directory.

@ajinabraham
Copy link
Member

Also, you could use export DJANGO_SETTINGS_MODULE=mysite.settings env var to always use your custom settings file instead. You might have to sync it with the fields from master on MAJOR version change.

@nelenkov
Copy link
Author

Thanks, I guess DJANGO_SETTINGS_MODULE could work.
I guess this is mostly a problem for people following master where the settings. py changes with each minor update.

-VERSION = '3.3.4'
-MOBSF_VER = 'v3.3.4 Beta'
+VERSION = '3.3.5'
+MOBSF_VER = 'v3.3.5 Beta'

The point of this request was to try to avoid the need to manually merge added fields, but maybe one small improvement could be to move VERSION/MOBSF_VER out of settings.py?

@ajinabraham
Copy link
Member

The current update mechanism looks for version change in settings.py. I will see if I can move to a different file.

@ajinabraham
Copy link
Member

The version will be moved from v3.4 onwards and the default user configuration is loaded from ~/.MobSF/config.py

@nelenkov
Copy link
Author

Thanks! Seems to be working fine.

Not sure if this script about Postgres is correct though, it doesn't seem that ~/.MobSF/settings.py is being loaded?

https://github.com/MobSF/Mobile-Security-Framework-MobSF/blob/master/scripts/postgres_support.sh#L8-L10

(It does work for me by specifying smth like DJANGO_SETTINGS_MODULE=mobsf.MobSF.settings_local)

@ajinabraham
Copy link
Member

Django and MobSF settings are still loaded from MobSF/settings.py. Only user configuration is loaded from ~/.MobSF. Postgres related info is a django settings.

The postgtess.sh is for enabling postgres support inside docker container.

@nelenkov
Copy link
Author

Ah, that makes sense, thanks!

I was wondering why postgres_support.sh is in the same diff, but I see it's only a format change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement MobSF enhancements and feature requests
Projects
None yet
Development

No branches or pull requests

2 participants