Skip to content

Commit def86e5

Browse files
committed
Add flake8, coverage, and prepare for release
1 parent ecd73a4 commit def86e5

7 files changed

Lines changed: 42 additions & 12 deletions

File tree

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ env:
3535
- TOXENV=py36-1.10
3636
- TOXENV=py36-1.11
3737
- TOXENV=py36-2.0
38+
- TOXENV=flake8
39+
- TOXENV=coverage
3840

3941
install:
4042
- pip install tox

AUTHORS

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ The primary development of this project is sponsored by Caktus Consulting Group.
22
Thank you to the contributors below which have given time and effort to develop
33
and maintain this project.
44

5-
Johannes Kirschner
6-
Mark Lavin
7-
Tobias McNulty
8-
Alvin Chow
9-
Vinod Kurup
10-
Gavin Wahl
5+
Johannes Kirschner (@jkirschner42)
6+
Mark Lavin (@mlavin)
7+
Tobias McNulty (@tobiasmcnulty)
8+
Alvin Chow (@alvinchow86)
9+
Vinod Kurup (@vkurup)
10+
Gavin Wahl (@gavinwahl)
1111
Arne de Laat (@153957)
1212
Jaap Roes (@jaap3)
13+
Tony S Yu (@tonysyu)
14+
Dan Poirier (@dpoirier)

bandit/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ def get_version():
2222
vers.append('%(releaselevel)s' % __version_info__)
2323
return ''.join(vers)
2424

25+
2526
__version__ = get_version()

bandit/backends/base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import logging
44

55
from email.utils import parseaddr
6-
from functools import reduce
76

87
from django.conf import settings
98
from django.template.loader import render_to_string
@@ -13,8 +12,11 @@
1312

1413
class HijackBackendMixin(object):
1514
"""
16-
This backend mixin intercepts outgoing messages drops them to a single
17-
email address.
15+
This backend mixin intercepts outgoing messages, redirecting them to addresses in the
16+
BANDIT_EMAIL setting.
17+
18+
Addresses which are not in ADMINS, SERVER_EMAIL, BANDIT_EMAIL or BANDIT_WHITELIST are
19+
intercepted.
1820
"""
1921

2022
def __init__(self, *args, **kwargs):
@@ -49,7 +51,7 @@ def is_approved(email):
4951
'previous_recipients': message.to,
5052
'previous_cc': message.cc,
5153
'previous_bcc': message.bcc
52-
} # included for backwards compatibility
54+
} # previous_* values included for backwards compatibility
5355
log_message = render_to_string("bandit/hijacked-email-log-message.txt", context)
5456
logger.log(self.log_level, log_message)
5557
if not self.log_only:

bandit/backends/smtp.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77

88
class HijackSMTPBackend(HijackBackendMixin, SMTPBackend):
99
"""
10-
This backend intercepts outgoing messages drops them to a single email
11-
address.
10+
This backend intercepts outgoing messages and logs them, allowing
11+
only messages destined for ADMINS, BANDIT_EMAIL, SERVER_EMAIL, or
12+
BANDIT_WHITELIST to be sent via SMTP.
13+
14+
It also sends intercepted messages to BANDIT_EMAIL.
1215
"""
1316
pass
1417

@@ -18,5 +21,7 @@ class LogOnlySMTPBackend(LogOnlyBackendMixin, SMTPBackend):
1821
This backend intercepts outgoing messages and logs them, allowing
1922
only messages destined for ADMINS, BANDIT_EMAIL, SERVER_EMAIL, or
2023
BANDIT_WHITELIST to be sent via SMTP.
24+
25+
It does not forward intercepted messages.
2126
"""
2227
pass

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 130

tox.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[tox]
22
envlist = {py27,py35,py36}-{1.8,1.10,1.11},
33
{py35,py36}-{2.0},
4+
flake8,
5+
coverage,
46
docs
57

68
[testenv]
@@ -15,6 +17,20 @@ deps =
1517
1.11: Django>=1.11,<2.0
1618
2.0: Django>=2.0,<2.1
1719

20+
[testenv:flake8]
21+
basepython = python3.6
22+
deps = flake8>=3.5,<3.6
23+
commands = flake8 bandit
24+
25+
[testenv:coverage]
26+
basepython = python3.6
27+
commands =
28+
coverage run runtests.py
29+
coverage report -m --fail-under 85
30+
deps =
31+
Django>=2.0,<2.1
32+
coverage>=4.4,<4.5
33+
1834
[testenv:docs]
1935
basepython = python3.6
2036
deps =

0 commit comments

Comments
 (0)