-
Notifications
You must be signed in to change notification settings - Fork 0
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
Improve default configuration and reporting of Bandit email hijacking #20
Open
jmurty
wants to merge
5
commits into
master
Choose a base branch
from
email-hijacking-config-improvements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+30
−5
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
55da623
Print name to real Bandit settings module
jmurty f3c7594
Raise exception if BANDIT_EMAIL is unset or empty
jmurty 8f3f7fe
Print emails automatically whitelisted by Bandit
jmurty 0f7d0ff
Avoid potentially risky import of django.conf.settings
jmurty a22cb40
Drop use of locals()
jmurty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmurty is this necessary, or wise, considering that this file is itself part of the settings?
If the
ADMINS
andSERVER_EMAIL
settings are already defined in our base settings file, we can just access it immediately. But since we only need these settings to print them as help text, it might be better to put those print statements (and importdjango.conf.settings
) in https://github.com/ixc/ixc-django-docker/blob/master/ixc_django_docker/bandit.py instead?In that module, the settings will be finalised and any other subsequent adjustments to those settings (e.g. in
develop.py
or project settings which haven't been imported yet) will be available.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable, I'll move them @mrmachine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, except it doesn't look like the
ixc_django_docker.bandit
module is loaded at application start-up. It may be lazy-loaded and not actually called unless/until a site tries to actually send an email, which is far too late to be applying the sanity-checksThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrmachine Since moving the print and exception lines to
ixc_django_docker
leaves them unrun until too late, I have pushed a change to load settings fromlocals()
instead of doing the risky import ofdjango.conf.settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmurty I think we don't need to use
locals()
. Those two variables are always set inixc_django_docker/settings/base.py
. I don't think we need to support attempts to use individual optional split settings modules without also using the base split settings modules.It's probably ok 99% of the time where it is, but there is still a possibility for the actual value used by email-bandit to differ from the value we report in the settings module, if local settings or some other settings module alters those values afterwards. We could add
ixc_django_docker
as anINSTALLED_APP
and create aAppConfig.setup()
method to report any settings sanity check data at startup?Or just leave it where it is as it is an edge case, but we can drop the
locals()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrmachine I have dropped the use of
locals()
. I'm not sure why you're opposed to them (?) but it should be fine either way.I don't think it is worth adding a whole new
ixc_django_docker
app just to review, report on, and sanity-check settings. That's more complication than it's worth IMOThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmurty I am not against using
locals()
. You just mentioned in your commit message that this usage was a hack, and I was pointing out that either way it's unnecessary (as is theNameError
check) because we can assume that theemail_bandit.py
split settings module will only ever be applied on top of thebase.py
split settings module, which will always defines both of these two variables (SERVER_EMAIL
andADMINS
). ThePOST_OFFICE
variable would still need to uselocals()
orNameError
check, though.