Skip to content

Commit

Permalink
Merge pull request #123 from Netflix-Skunkworks/fix-mac-address-parsing
Browse files Browse the repository at this point in the history
Fix mac address parsing
  • Loading branch information
jkriss authored Apr 8, 2019
2 parents 96a1c57 + 2e96c6f commit 33a3523
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ stevedore==1.27.0
treq==17.8.0
Twisted==17.9.0
txretry==1.0.1
git+https://github.com/wrapp/txwebretry.git@df5014019cf3a5d501bc755b9ce46509c1b31351#egg=txwebretry
git+https://github.com/wrapp/txwebretry.git#egg=txwebretry
uritemplate==3.0.0
urllib3==1.22
validate-email==1.3
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ replace = version='{new_version}'
universal = 1

[flake8]
ignore = E111,E114,E121,E125,E128
ignore = E111,E114,E121,E125,E128,W504
exclude = .git,__pycache__,*.pyc,*.pyo,.tox,.eggs,*.egg-info,.ropeproject,scratch
max-line-length = 100
doctests = True
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def parse_file(filename, encoding='utf-8'):
install_requires=install_requires,
dependency_links=[
'git+https://github.com/duosecurity/duo_client_python.git@1cc71f80927b02e75773094c9dd77af1fc8e4064.zip#egg=duo_client-3.0', # noqa
'git+https://github.com/wrapp/txwebretry.git@df5014019cf3a5d501bc755b9ce46509c1b31351#egg=txwebretry-0.1.1', # noqa
'git+https://github.com/wrapp/txwebretry.git#egg=txwebretry', # noqa
],
entry_points={
'console_scripts': [
Expand Down
2 changes: 1 addition & 1 deletion stethoscope/csrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

def generate_token():
salt = str(urandom.randrange(0, _MAX_CSRF_KEY)).encode('utf-8')
return hashlib.sha1(salt).hexdigest()
return hashlib.sha256(salt).hexdigest()


def _same_origin(url1, url2):
Expand Down
2 changes: 1 addition & 1 deletion stethoscope/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

logger = logbook.Logger(__name__)

MACADDR_PATTERN = re.compile(r'^' + r'\:?'.join([r'([0-9A-F]{1,2})'] * 6) + r'$', re.IGNORECASE)
MACADDR_PATTERN = re.compile(r'^([0-9A-F]{2}[:-]?){5,7}([0-9A-F]{2})$', re.IGNORECASE)


def _is_valid_macaddr(addr):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ def test_valid_macaddr(self):
self.assertEqual(request.code, 200)
self.assertEqual(request.getWrittenData(), six.b(json.dumps("00:00:DE:CA:FB:AD")))

def test_valid_long_macaddr(self):
request = requestMock(b"/api/00:00:DE:CA:FB:AD:AB:CD")
deferred = _render(KleinResource(self.app), request)

self.assertEqual(self.successResultOf(deferred), None)
self.assertEqual(request.code, 200)
self.assertEqual(request.getWrittenData(), six.b(json.dumps("00:00:DE:CA:FB:AD:AB:CD")))


class ValidateEmailTestCase(HTMLEscapeMixin, ValidationBase):

Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ envlist =

[travis]
python =
2.7: py27, lint, bandit, flake8, docs
2.7: py27, lint, bandit, flake8
3.4: py34
3.5: py35
3.6: py36

[testenv]
install_command = pip install --process-dependency-links {opts} {packages}
install_command = pip install {opts} {packages}
deps =
-rrequirements.txt
setenv =
Expand Down

0 comments on commit 33a3523

Please sign in to comment.